Skip to content

Commit

Permalink
Use 1.9 hash style notation
Browse files Browse the repository at this point in the history
  • Loading branch information
zbelzer committed Sep 10, 2019
1 parent 58d1e71 commit 84d9e6a
Show file tree
Hide file tree
Showing 28 changed files with 81 additions and 71 deletions.
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
AllCops:
TargetRubyVersion: 2.4
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true

# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: true
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ group :development do

# code metrics:
gem 'yard'
gem 'metric_fu', :require => false
gem 'jeweler' , :require => false
gem 'metric_fu', require: false
gem 'jeweler' , require: false


unless ENV["RM_INFO"]
Expand All @@ -39,9 +39,10 @@ end
group :development, :test do
gem "pry"
gem "pry-byebug"
gem "rubocop"
end

group :test do
gem 'simplecov' , :require => false
gem 'simplecov-rcov-text', :require => false
gem 'simplecov' , require: false
gem 'simplecov-rcov-text', require: false
end
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def add_index(table_name, column_name, options = {})
#
def index_exists?(table_name, column_name, options = {})
column_names = Array.wrap(column_name)
index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, :column => column_names)
index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, column: column_names)

# Always compare the index name
default_comparator = lambda { |index| index.name == index_name }
Expand Down Expand Up @@ -134,7 +134,7 @@ def index_name(table_name, options) #:nodoc:
raise ArgumentError, "You must specify the index name"
end
else
index_name(table_name, :column => options)
index_name(table_name, column: options)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::ExtensionMethods
# Default options for {#create_extension} method.
CREATE_EXTENSION_DEFAULTS = {
:if_not_exists => true,
:schema_name => nil,
:version => nil,
:old_version => nil
if_not_exists: true,
schema_name: nil,
version: nil,
old_version: nil
}

# Default options for {#drop_extension} method.
DROP_EXTENSION_DEFAULTS = {
:if_exists => true,
:mode => :restrict
if_exists: true,
mode: :restrict
}

# The modes which determine postgresql behavior on DROP EXTENSION operation.
#
# *:restrict* refuse to drop the extension if any objects depend on it
# *:cascade* automatically drop objects that depend on the extension
AVAILABLE_DROP_MODES = {
:restrict => 'RESTRICT',
:cascade => 'CASCADE'
restrict: 'RESTRICT',
cascade: 'CASCADE'
}

# @return [Boolean] if adapter supports postgresql extension manipulation
Expand Down Expand Up @@ -127,8 +127,8 @@ def pg_extensions
[
row['ext_name'],
{
:schema_name => row['schema_name'],
:version => row['ext_version']
schema_name: row['schema_name'],
version: row['ext_version']
}
]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pg_saurus/create_index_concurrently.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def enque(*arguments, &block)
module MigrationProxy
# :nodoc:
def self.included(klass)
klass.delegate :process_postponed_queries, :to => :migration
klass.delegate :process_postponed_queries, to: :migration
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/app/models/demography/country.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Demography::Country < ActiveRecord::Base
has_many :citizens, :class_name => 'Demography::Citizen'
has_many :citizens, class_name: 'Demography::Citizen'
end
2 changes: 1 addition & 1 deletion spec/dummy/app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class User < ActiveRecord::Base
has_one :citizen, :class_name => 'Demography::Citizen'
has_one :citizen, class_name: 'Demography::Citizen'
end
2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.

Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters :format => [:json]
wrap_parameters format: [:json]
end

# Disable root element in JSON by default.
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20120105112744_create_pets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def change
t.integer :citizen_id
t.integer :breed_id
t.integer :owner_id
t.boolean :active, :default => true
t.boolean :active, default: true
end

add_index(:pets, :color)
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/db/migrate/20120106163544_create_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def change
set_column_comment :users, :name, "User name"

set_column_comments :users,
:email => "Email address",
:phone_number => "Phone number"
email: "Email address",
phone_number: "Phone number"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def change
set_table_comment 'demography.countries', "Countries"

set_column_comments 'demography.countries',
:name => "Country name",
:continent => "Continent"
name: "Country name",
continent: "Continent"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def change
set_column_comment 'demography.citizens', :country_id, 'Country key'

set_column_comments 'demography.citizens',
:first_name => "First name",
:last_name => "Last name",
:birthday => "Birthday",
:bio => "Biography"
first_name: "First name",
last_name: "Last name",
birthday: "Birthday",
bio: "Biography"
end
end
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20120207150844_add_foreign_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def change
add_foreign_key 'demography.citizens', 'demography.countries' # This foreign key is removed in RemoveForeignKeys migration

# Add foreign key without an index
add_foreign_key 'demography.citizens', 'users', :exclude_index => true
add_foreign_key 'demography.citizens', 'users', exclude_index: true

end
end
4 changes: 2 additions & 2 deletions spec/dummy/db/migrate/20120207163652_remove_foreign_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ def up
remove_foreign_key 'demography.citizens', column: :country_id, remove_index: true
remove_foreign_key 'pets', 'demography.countries'
#remove_foreign_key 'pets', 'owners'
remove_foreign_key 'pets', :column => "owner_id", remove_index: true
remove_foreign_key 'pets', :column => "breed_id"
remove_foreign_key 'pets', column: "owner_id", remove_index: true
remove_foreign_key 'pets', column: "breed_id"
end

def down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def up

def down
set_column_comments 'demography.citizens',
:birthday => "Birthday",
:bio => "Biography"
birthday: "Birthday",
bio: "Biography"
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class AddDemographyCitizensActiveColumn < ActiveRecord::Migration[5.2]
def change
add_column 'demography.citizens', :active, :boolean, :null => false, :default => false
add_column 'demography.citizens', :active, :boolean, null: false, default: false

add_index 'demography.citizens', [:country_id, :user_id], :unique => true, :where => 'active'
add_index 'demography.citizens', [:country_id, :user_id], unique: true, where: 'active'
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class DemographyPopulationStatistics < ActiveRecord::Migration[5.2]
def change
create_table "population_statistics", :schema => "demography" do |t|
create_table "population_statistics", schema: "demography" do |t|
t.integer :year
t.integer :population
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class RemoveDemographyNationalities < ActiveRecord::Migration[5.2]
def change
drop_table 'nationalities', :schema => 'demography'
drop_table 'nationalities', schema: 'demography'
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddPartialFunctionalIndex < ActiveRecord::Migration[5.2]
def change
add_index :pets, ["upper(color)"], :where => 'name IS NULL'
add_index :pets, ["upper(color)"], where: 'name IS NULL'
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddConcurrentlyIndexToUsersOnEmail < ActiveRecord::Migration[5.2]
def change
add_index :users, :email, :concurrently => true
add_index :users, :email, concurrently: true
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddConcurrentlyIndexWithForeignKey < ActiveRecord::Migration[5.2]
def change
add_foreign_key :pets, :users, :exclude_index => true#, :concurrent_index => true
add_foreign_key :pets, :users, exclude_index: true#, :concurrent_index => true
end
end
8 changes: 4 additions & 4 deletions spec/dummy/db/migrate/20121009170904_create_extension.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
class CreateExtension < ActiveRecord::Migration[5.2]
def change
create_extension "fuzzystrmatch"
drop_extension "fuzzystrmatch", :mode => :cascade
drop_extension "fuzzystrmatch", mode: :cascade
create_extension "fuzzystrmatch"

# Test names with dashes are escaped correctly.
# https://github.com/TMXCredit/pg_power/pull/40
create_extension "uuid-ossp"
drop_extension "uuid-ossp"

create_extension "btree_gist", :schema_name => 'demography'
add_index :pets, :user_id, :using => :gist, :name => 'index_pets_on_user_id_gist'
add_index :pets, "to_tsvector('english', name)", :using => :gist, :name => 'index_pets_on_to_tsvector_name_gist'
create_extension "btree_gist", schema_name: 'demography'
add_index :pets, :user_id, using: :gist, name: 'index_pets_on_user_id_gist'
add_index :pets, "to_tsvector('english', name)", using: :gist, name: 'index_pets_on_to_tsvector_name_gist'
end
end
2 changes: 1 addition & 1 deletion spec/foreign_keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
it 'should not raise an exception if the index does not exist' do
expect {
connection = ActiveRecord::Base::connection
connection.add_foreign_key 'pets', 'demography.citizens', :exclude_index => true
connection.add_foreign_key 'pets', 'demography.citizens', exclude_index: true
connection.remove_foreign_key 'pets', 'demography.citizens'
}.not_to raise_error
end
Expand Down
Loading

0 comments on commit 84d9e6a

Please sign in to comment.