mixed_gauge 1.2.0.beta2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: beab801efa14406f04a67cfcb1fc3cc998fb65c9394d7695cee2357e50607474
4
- data.tar.gz: 11cf9c5164b085f5d6b9d9255bc132d6229693d318ef420070defa5bcbb61cb8
3
+ metadata.gz: cbfd5f3319701d6e7d4dc4714425a8480e2c28059d8b06dcd2010d669376d328
4
+ data.tar.gz: e00c05059656f9fcc6f738e3fb33632a4afd4d3d713d1196dc4f37a0a3b0025a
5
5
  SHA512:
6
- metadata.gz: ffe6fab2ded554fc2a7e3e23d98933caaca074b9d781c7dc8fa06262827bf6516304599e8146e84475ce9490218da5668e163745771609b309e232848b41711f
7
- data.tar.gz: 81d08dec954e130890a5e4097cbb9fde6b51012e44161fb51ce7dc2e8a67d0aa9d378aab83886ecc32c3ec8375e892310dc5ec37461d8c4593de4dfb59d19ef5
6
+ metadata.gz: b1e37c8a3a85d36bddad3a842ce0f2b7a254d38d7d2023d04463ce49541e8bfd62b260fb8fe4ec273d1996056f0888e0a72cd28a262ac78c9a134b1e3e5d28ed
7
+ data.tar.gz: 2ffa2dccebdedc31d92fcf92baec252399683cbbff2a5755c2d24283366ef25bfdca58f16094c47aee1937b8474743b248ea6ffb3c13ddbd41295534aa47ccec
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ DisplayStyleGuide: true
4
+
5
+ Metrics/BlockLength: { Enabled: false } # With Ruby DSL, block length can grow
6
+ Metrics/LineLength: { Max: 120 }
7
+ Metrics/MethodLength: { Max: 20 }
8
+ Layout/IndentHeredoc: { Enabled: false } # Focusing texual appearance is wrong
9
+ Style/GuardClause: { Enabled: false } # crazy
10
+ Style/ParallelAssignment: { Enabled: false } # crazy
11
+ Style/StderrPuts: { Enabled: false } # WTF
@@ -12,7 +12,7 @@ gemfile:
12
12
  - gemfiles/ar_4.1.7.gemfile
13
13
  - gemfiles/ar_4.1.8.gemfile
14
14
  - gemfiles/ar_4.2.gemfile
15
- - gemfiles/ar_5.0.gemfile
15
+ - gemfiles/ar_5.gemfile
16
16
  - gemfiles/rails_edge.gemfile
17
17
  matrix:
18
18
  allow_failures:
@@ -22,4 +22,4 @@ matrix:
22
22
  - rvm: 2.1.9
23
23
  gemfile: gemfiles/rails_edge.gemfile
24
24
  - rvm: 2.1.9
25
- gemfile: gemfiles/ar_5.0.gemfile
25
+ gemfile: gemfiles/ar_5.gemfile
data/Appraisals CHANGED
@@ -14,8 +14,8 @@ appraise 'ar-4.2' do
14
14
  gem 'activerecord', '~> 4.2'
15
15
  end
16
16
 
17
- appraise 'ar-5.0' do
18
- gem 'activerecord', '5.0.0.rc1'
17
+ appraise 'ar-5' do
18
+ gem 'activerecord', '~> 5.0'
19
19
  end
20
20
 
21
21
  appraise 'rails-edge' do
@@ -1,4 +1,7 @@
1
1
  # CHANGELOG for mixed_gauge
2
+ ## 1.2.0
3
+ - Don't enqueue parallel executions, run them immediately #7
4
+
2
5
  ## 1.1.0
3
6
  - Replication support. #5
4
7
 
data/Rakefile CHANGED
@@ -3,14 +3,16 @@ require 'bundler/setup'
3
3
 
4
4
  require 'bundler/gem_tasks'
5
5
 
6
- begin
7
- require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new(:spec)
9
- rescue LoadError
10
- end
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ require 'rubocop/rake_task'
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
11
13
 
12
14
  task :performance_test do
13
15
  ruby 'spec/performance_test.rb'
14
16
  end
15
17
 
16
- task :default => [:spec, :performance_test]
18
+ task default: %i[spec rubocop performance_test]
@@ -1,14 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "mixed_gauge"
3
+ require 'bundler/setup'
4
+ require 'mixed_gauge'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
9
+ require 'pry'
10
+ Pry.start
data/bump CHANGED
@@ -11,8 +11,13 @@ version = File.read(path).scan(regexp)[0][0]
11
11
  version_strs = version.split('.')
12
12
 
13
13
  if version_strs.size > 3
14
- warn "Current version includes a prelease suffix, drop it: #{version}"
14
+ puts "Current version includes a prelease suffix, drop it: #{version}"
15
15
  version_strs = version_strs[0..2]
16
+ next_version = version_strs.join('.')
17
+ File.write(path, File.read(path).gsub(regexp, "VERSION = '#{next_version}'.freeze"))
18
+ system('git', 'add', path)
19
+ system('git', 'commit', '-m', "v#{next_version}")
20
+ exit
16
21
  end
17
22
 
18
23
  case level
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "4.1.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "4.1.7"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "4.1.8"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 4.2"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "5.0.0.rc1"
5
+ gem "activerecord", "~> 5.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", :github => "rails/rails"
6
- gem "arel", :github => "rails/arel"
5
+ gem "activerecord", github: "rails/rails"
6
+ gem "arel", github: "rails/arel"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -11,6 +11,7 @@ require 'mixed_gauge/replication_mapping'
11
11
  require 'mixed_gauge/all_shards_in_parallel'
12
12
  require 'mixed_gauge/model'
13
13
 
14
+ # MixedGauge
14
15
  module MixedGauge
15
16
  class << self
16
17
  # @return [MixedGauge::Config]
@@ -13,7 +13,7 @@ module MixedGauge
13
13
  # @return [Array] A result
14
14
  # @example
15
15
  # User.all_shards_in_parallel.map(&:count).reduce(&:+)
16
- def map(&block)
16
+ def map
17
17
  commands = @shards.map do |m|
18
18
  Expeditor::Command.new(service: @service) { m.connection_pool.with_connection { yield m } }
19
19
  end
@@ -34,7 +34,7 @@ module MixedGauge
34
34
  # @param [Integer] slot
35
35
  # @return [Symbol] registered connection name
36
36
  def fetch(slot)
37
- @connection_registry.find {|slot_range, name| slot_range.cover?(slot) }[1]
37
+ @connection_registry.find { |slot_range, _name| slot_range.cover?(slot) }[1]
38
38
  end
39
39
 
40
40
  # @return [Array<Symbol>] An array of connection name
@@ -42,6 +42,7 @@ module MixedGauge
42
42
  @connection_registry.values
43
43
  end
44
44
 
45
+ # Validator
45
46
  class Validator
46
47
  # @param [Integer] slot_size
47
48
  # @param [Hash{Range => Symbol}] connection_registry
@@ -64,9 +65,7 @@ module MixedGauge
64
65
 
65
66
  # @param [Integer] first_start_point
66
67
  def check_first_start_point(first_start_point)
67
- unless first_start_point == 0
68
- report_invalid_first_start_point(first_start_point)
69
- end
68
+ report_invalid_first_start_point(first_start_point) unless first_start_point.zero?
70
69
  end
71
70
 
72
71
  # @param [Array<Integer>] all_start_points
@@ -76,43 +75,44 @@ module MixedGauge
76
75
  break if all_end_points.size == i + 1
77
76
 
78
77
  next_start_point = all_start_points[i + 1]
79
- unless end_point.succ == next_start_point
80
- report_invalid_coverage(end_point, all_start_points[i + 1])
81
- end
78
+ report_invalid_coverage(end_point, all_start_points[i + 1]) unless end_point.succ == next_start_point
82
79
  end
83
80
  end
84
81
 
85
82
  # @param [Integer] last_end_point
86
83
  def check_last_end_point(last_end_point)
87
- unless last_end_point == @slot_size - 1
88
- report_invalid_last_end_point(last_end_point)
89
- end
84
+ report_invalid_last_end_point(last_end_point) unless last_end_point == @slot_size - 1
90
85
  end
91
86
 
92
87
  # @param [Integer] point
93
88
  def report_invalid_first_start_point(point)
94
- r = @connection_registry.keys.find {|range| range.min == point }
89
+ r = @connection_registry.keys.find { |range| range.min == point }
95
90
  connection = @connection_registry[r]
96
91
  raise "First start point must be `0` but given `#{point}`: invalid slot configuration for #{connection}"
97
92
  end
98
93
 
99
94
  # @param [Integer] end_point
100
95
  # @param [Integer] next_start_point
96
+ # rubocop:disable Metrics/LineLength
101
97
  def report_invalid_coverage(end_point, next_start_point)
102
- end_point_slot = @connection_registry.keys.find {|range| range.max == end_point }
98
+ end_point_slot = @connection_registry.keys.find { |range| range.max == end_point }
103
99
  end_point_connection = @connection_registry[end_point_slot]
104
- start_point_slot = @connection_registry.keys.
105
- find {|range| range.min == next_start_point && range.max != end_point }
100
+ start_point_slot = @connection_registry.keys
101
+ .find { |range| range.min == next_start_point && range.max != end_point }
106
102
  start_point_connection = @connection_registry[start_point_slot]
107
- raise %!End point `#{end_point}` of "#{end_point_connection}" or start point `#{next_start_point}` of "#{start_point_connection}" is invalid. Next start point must be "previous end point + 1".!
103
+
104
+ raise %(End point `#{end_point}` of "#{end_point_connection}" or start point `#{next_start_point}` of "#{start_point_connection}" is invalid. Next start point must be "previous end point + 1".)
108
105
  end
106
+ # rubocop:enable Metrics/LineLength
109
107
 
110
108
  # @param [Integer] point
109
+ # rubocop:disable Metrics/LineLength
111
110
  def report_invalid_last_end_point(point)
112
- r = @connection_registry.keys.find {|range| range.max == point }
111
+ r = @connection_registry.keys.find { |range| range.max == point }
113
112
  connection = @connection_registry[r]
114
113
  raise "Last end point must be `#{@slot_size - 1}` but given `#{point}`: invalid slot configuration for #{connection}"
115
114
  end
115
+ # rubocop:enable Metrics/LineLength
116
116
  end
117
117
  end
118
118
  end
@@ -1,8 +1,9 @@
1
1
  require 'zlib'
2
2
 
3
3
  module MixedGauge
4
+ # Holding global configuration
4
5
  class Config
5
- DEFAULT_HASH_FUNCTION = -> (key) { Zlib.crc32(key) }
6
+ DEFAULT_HASH_FUNCTION = ->(key) { Zlib.crc32(key) }
6
7
 
7
8
  attr_reader :hash_proc, :cluster_configs
8
9
 
@@ -34,7 +35,7 @@ module MixedGauge
34
35
  # See README.md for example.
35
36
  def register_hash_function(&block)
36
37
  raise ArgumentError if block.arity != 1
37
- raise ArgumentError unless block.call('test value').is_a? Integer
38
+ raise ArgumentError unless yield('test value').is_a? Integer
38
39
  @hash_proc = block
39
40
  end
40
41
  end
@@ -1,77 +1,79 @@
1
1
  module MixedGauge
2
+ # Offers database related Rake tasks
2
3
  module DatabaseTasks
3
- extend self
4
-
5
- # @return [Boolean]
6
- def ar5?
7
- ActiveRecord::VERSION::MAJOR == 5
8
- end
4
+ class << self
5
+ # @return [Boolean]
6
+ def ar5?
7
+ ActiveRecord::VERSION::MAJOR == 5
8
+ end
9
9
 
10
- # @return [Boolean]
11
- def ar4?
12
- ActiveRecord::VERSION::MAJOR == 4
13
- end
10
+ # @return [Boolean]
11
+ def ar4?
12
+ ActiveRecord::VERSION::MAJOR == 4
13
+ end
14
14
 
15
- # @return [Boolean]
16
- def ar42?
17
- ar4? && ActiveRecord::VERSION::MINOR == 2
18
- end
15
+ # @return [Boolean]
16
+ def ar42?
17
+ ar4? && ActiveRecord::VERSION::MINOR == 2
18
+ end
19
19
 
20
- # @return [Boolean]
21
- def ar41?
22
- ar4? && ActiveRecord::VERSION::MINOR == 1
23
- end
20
+ # @return [Boolean]
21
+ def ar41?
22
+ ar4? && ActiveRecord::VERSION::MINOR == 1
23
+ end
24
24
 
25
- # @return [Boolean]
26
- def ar417_above?
27
- ar41? && ActiveRecord::VERSION::TINY > 7
28
- end
25
+ # @return [Boolean]
26
+ def ar417_above?
27
+ ar41? && ActiveRecord::VERSION::TINY > 7
28
+ end
29
29
 
30
- # Show information of database sharding config.
31
- def info
32
- puts "All clusters registered to mixed_gauge"
33
- puts
34
- clusters.each do |cluster|
35
- puts "= Cluster: #{cluster.name} ="
36
- cluster.connections.each do |name|
37
- puts "- #{name}"
38
- end
30
+ # Show information of database sharding config.
31
+ def info
32
+ puts 'All clusters registered to mixed_gauge'
39
33
  puts
34
+ clusters.each do |cluster|
35
+ puts "= Cluster: #{cluster.name} ="
36
+ cluster.connections.each do |name|
37
+ puts "- #{name}"
38
+ end
39
+ puts
40
+ end
40
41
  end
41
- end
42
42
 
43
- # @private
44
- # @param [String] task_name
45
- # @return [Rake::Task]
46
- def to_rake_task(task_name)
47
- Rake::Task[task_name]
48
- end
43
+ # @private
44
+ # @param [String] task_name
45
+ # @return [Rake::Task]
46
+ def to_rake_task(task_name)
47
+ Rake::Task[task_name]
48
+ end
49
49
 
50
- # @private
51
- # @return [Array<Symbol>]
52
- def cluster_names
53
- MixedGauge.config.cluster_configs.keys
54
- end
50
+ # @private
51
+ # @return [Array<Symbol>]
52
+ def cluster_names
53
+ MixedGauge.config.cluster_configs.keys
54
+ end
55
55
 
56
- # @private
57
- # @return [Array<MixedGauge::ClusterConfig>]
58
- def clusters
59
- MixedGauge.config.cluster_configs.values
60
- end
56
+ # @private
57
+ # @return [Array<MixedGauge::ClusterConfig>]
58
+ def clusters
59
+ MixedGauge.config.cluster_configs.values
60
+ end
61
61
 
62
- # @private
63
- # @return [MixedGauge::ClusterConfig]
64
- # @raise [KeyError]
65
- def fetch_cluster_config(cluster_name)
66
- MixedGauge.config.fetch_cluster_config(cluster_name)
67
- end
62
+ # @private
63
+ # @return [MixedGauge::ClusterConfig]
64
+ # @raise [KeyError]
65
+ def fetch_cluster_config(cluster_name)
66
+ MixedGauge.config.fetch_cluster_config(cluster_name)
67
+ end
68
68
 
69
- # For mock-ablity
70
- # @private
71
- def exit_with_error
72
- exit 1
69
+ # For mock-ablity
70
+ # @private
71
+ def exit_with_error
72
+ exit 1
73
+ end
73
74
  end
74
75
 
76
+ # TasksForMultipleClusters
75
77
  module TasksForMultipleClusters
76
78
  # @param [String] task_name
77
79
  def invoke_task_for_all_clusters(task_name)
@@ -125,7 +127,7 @@ module MixedGauge
125
127
  # @param [Hash{Symbol => String}] args
126
128
  # @return [String]
127
129
  def cluster_name_or_error(name, args)
128
- unless cluster_name = args[:cluster_name]
130
+ unless (cluster_name = args[:cluster_name])
129
131
  $stderr.puts <<-MSG
130
132
  Missing cluster_name. Find cluster_name via `rake mixed_gauge:info` then call `rake "mixed_gauge:#{name}[$cluster_name]"`.
131
133
  MSG
@@ -139,7 +141,7 @@ Missing cluster_name. Find cluster_name via `rake mixed_gauge:info` then call `r
139
141
  def cluster_or_error(cluster_name)
140
142
  fetch_cluster_config(cluster_name.to_sym)
141
143
  rescue KeyError
142
- $stderr.puts %!cluster name "#{cluster_name}" not found.!
144
+ $stderr.puts %(cluster name "#{cluster_name}" not found.)
143
145
  exit_with_error
144
146
  end
145
147
  end
@@ -165,12 +167,11 @@ Missing cluster_name. Find cluster_name via `rake mixed_gauge:info` then call `r
165
167
  def load_schema(connection_name)
166
168
  configuration = ActiveRecord::Base.configurations[connection_name]
167
169
 
168
- case
169
- when ar5?
170
+ if ar5?
170
171
  ActiveRecord::Tasks::DatabaseTasks.load_schema(configuration, :ruby)
171
- when ar42? || ar417_above?
172
+ elsif ar42? || ar417_above?
172
173
  ActiveRecord::Tasks::DatabaseTasks.load_schema_for(configuration, :ruby)
173
- when ar41?
174
+ elsif ar41?
174
175
  ActiveRecord::Base.establish_connection(configuration)
175
176
  ActiveRecord::Tasks::DatabaseTasks.load_schema(:ruby)
176
177
  else
@@ -27,6 +27,7 @@ module MixedGauge
27
27
  class_attribute :service, instance_writer: false
28
28
  end
29
29
 
30
+ # ClassMethods
30
31
  module ClassMethods
31
32
  # The cluster config must be defined before `use_cluster`.
32
33
  # @param [Symbol] name A cluster name which is set by MixedGauge.configure
@@ -40,7 +41,7 @@ module MixedGauge
40
41
  min_threads: thread_size,
41
42
  max_threads: thread_size,
42
43
  max_queue: shard_repository.all.size,
43
- fallback_policy: :abort,
44
+ fallback_policy: :abort
44
45
  )
45
46
  )
46
47
  self.abstract_class = true
@@ -69,7 +70,7 @@ module MixedGauge
69
70
  raise '`distkey` is not defined. Use `def_distkey`.' unless distkey
70
71
  @before_put_callback.call(attributes) if @before_put_callback
71
72
 
72
- if key = attributes[distkey] || attributes[distkey.to_s]
73
+ if (key = attributes[distkey]) || attributes[distkey.to_s]
73
74
  shard_for(key).create!(attributes)
74
75
  else
75
76
  raise MixedGauge::MissingDistkeyAttribute
@@ -91,7 +92,7 @@ module MixedGauge
91
92
  # @return [ActiveRecord::Base] A shard model instance
92
93
  # @raise [MixedGauge::RecordNotFound]
93
94
  def get!(key)
94
- get(key) or raise MixedGauge::RecordNotFound
95
+ get(key) || raise(MixedGauge::RecordNotFound)
95
96
  end
96
97
 
97
98
  # Register hook to assign auto-generated distkey or something.
@@ -134,7 +135,7 @@ module MixedGauge
134
135
  def all_shards_in_parallel
135
136
  AllShardsInParallel.new(all_shards, service: service)
136
137
  end
137
- alias_method :parallel, :all_shards_in_parallel
138
+ alias parallel all_shards_in_parallel
138
139
 
139
140
  # See example definitions in `spec/models.rb`.
140
141
  # @param [Symbol] A role name of target cluster.
@@ -1,4 +1,5 @@
1
1
  module MixedGauge
2
+ # Manages mapping of each database connection
2
3
  class ReplicationMapping
3
4
  def initialize(mapping)
4
5
  @mapping = mapping
@@ -9,7 +10,7 @@ module MixedGauge
9
10
  # @param [Symbol] A role name of target cluster.
10
11
  # @return [Class, Object] if block given then yielded result else
11
12
  # target shard model.
12
- def switch(from, role_name, &block)
13
+ def switch(from, role_name)
13
14
  @lock.synchronize { constantize! unless constantized? }
14
15
 
15
16
  model = @mapping.fetch(role_name)
@@ -25,7 +26,7 @@ module MixedGauge
25
26
  private
26
27
 
27
28
  def constantize!
28
- @mapping = Hash[@mapping.map {|k, name| [k, name.to_s.constantize] }]
29
+ @mapping = Hash[@mapping.map { |k, name| [k, name.to_s.constantize] }]
29
30
  end
30
31
 
31
32
  def constantized?
@@ -1,6 +1,7 @@
1
1
  require 'digest/md5'
2
2
 
3
3
  module MixedGauge
4
+ # Routing from key to database connection
4
5
  class Routing
5
6
  # @param [ClusterConfig] cluster_config
6
7
  def initialize(cluster_config)
@@ -1,4 +1,5 @@
1
1
  module MixedGauge
2
+ # Manages generated AR models
2
3
  class ShardRepository
3
4
  attr_reader :base_class
4
5
 
@@ -22,7 +23,7 @@ module MixedGauge
22
23
  # @param [Range] slots
23
24
  # @return [Class, nil] A AR model class.
24
25
  def fetch_by_slots(assigned_slots)
25
- @shards.find {|_, model| model.assigned_slots == assigned_slots }[1]
26
+ @shards.find { |_, model| model.assigned_slots == assigned_slots }[1]
26
27
  end
27
28
 
28
29
  # @return [Array<Class>]
@@ -60,7 +61,7 @@ module MixedGauge
60
61
  # @param [Symbol] connection_name
61
62
  # @return [String]
62
63
  def generate_class_name(connection_name)
63
- "ShardFor#{connection_name.to_s.gsub('-', '_').classify}"
64
+ "ShardFor#{connection_name.to_s.tr('-', '_').classify}"
64
65
  end
65
66
  end
66
67
  end
@@ -1,3 +1,3 @@
1
1
  module MixedGauge
2
- VERSION = '1.2.0.beta2'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -1,40 +1,40 @@
1
1
  namespace :mixed_gauge do
2
2
  desc 'Show all defined clusters and their detail'
3
- task info: %i(environment) do
3
+ task info: %i[environment] do
4
4
  MixedGauge::DatabaseTasks.info
5
5
  end
6
6
 
7
7
  desc 'Setup all databases in all clusters'
8
- task setup: %i(create_all load_schema_all) do
8
+ task setup: %i[create_all load_schema_all] do
9
9
  end
10
10
 
11
11
  desc 'Create all databases in all clusters'
12
- task :create_all => :environment do
12
+ task create_all: :environment do
13
13
  MixedGauge::DatabaseTasks.invoke_task_for_all_clusters('create')
14
14
  end
15
15
 
16
16
  desc 'Drop all databases in all clusters'
17
- task :drop_all => :environment do
17
+ task drop_all: :environment do
18
18
  MixedGauge::DatabaseTasks.invoke_task_for_all_clusters('drop')
19
19
  end
20
20
 
21
21
  desc 'Load schema to all databases in all clusters'
22
- task :load_schema_all => :environment do
22
+ task load_schema_all: :environment do
23
23
  MixedGauge::DatabaseTasks.invoke_task_for_all_clusters('load_schema')
24
24
  end
25
25
 
26
26
  desc 'Create all databases in specific cluster'
27
- task :create, %i(cluster_name) => %i(environment) do |_, args|
27
+ task :create, %i[cluster_name] => %i[environment] do |_, args|
28
28
  MixedGauge::DatabaseTasks.create_all_databases(args)
29
29
  end
30
30
 
31
31
  desc 'Drop all databases in specific cluster'
32
- task :drop, %i(cluster_name) => %i(environment) do |_, args|
32
+ task :drop, %i[cluster_name] => %i[environment] do |_, args|
33
33
  MixedGauge::DatabaseTasks.drop_all_databases(args)
34
34
  end
35
35
 
36
36
  desc 'Load schema to all databases in specific cluster'
37
- task :load_schema, %i(cluster_name) => %i(environment) do |_, args|
37
+ task :load_schema, %i[cluster_name] => %i[environment] do |_, args|
38
38
  MixedGauge::DatabaseTasks.load_schema_all_databases(args)
39
39
  end
40
40
  end
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # rubocop:disable Metrics/LineLength
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'mixed_gauge/version'
@@ -9,8 +10,8 @@ Gem::Specification.new do |spec|
9
10
  spec.authors = ['Taiki Ono']
10
11
  spec.email = ['taiks.4559@gmail.com']
11
12
 
12
- spec.summary = %{A simple and robust ActiveRecord extension for database sharding.}
13
- spec.description = %{#{spec.summary} Supports shards management with hash slots, re-sharding support, efficient KVS queries, limited RDB queries.}
13
+ spec.summary = %(A simple and robust ActiveRecord extension for database sharding.)
14
+ spec.description = %(#{spec.summary} Supports shards management with hash slots, re-sharding support, efficient KVS queries, limited RDB queries.)
14
15
  spec.homepage = 'https://github.com/taiki45/mixed_gauge'
15
16
  spec.license = 'MIT'
16
17
 
@@ -28,6 +29,9 @@ Gem::Specification.new do |spec|
28
29
  spec.add_development_dependency 'pry-stack_explorer'
29
30
  spec.add_development_dependency 'rake'
30
31
  spec.add_development_dependency 'rspec', '~> 3'
32
+ spec.add_development_dependency 'rubocop'
31
33
  spec.add_development_dependency 'simplecov'
32
34
  spec.add_development_dependency 'sqlite3'
33
35
  end
36
+
37
+ # rubocop:enable Metrics/LineLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixed_gauge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.beta2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiki Ono
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-15 00:00:00.000000000 Z
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: simplecov
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +190,7 @@ files:
176
190
  - ".coveralls.yml"
177
191
  - ".gitignore"
178
192
  - ".rspec"
193
+ - ".rubocop.yml"
179
194
  - ".travis.yml"
180
195
  - Appraisals
181
196
  - CHANGELOG.md
@@ -190,7 +205,7 @@ files:
190
205
  - gemfiles/ar_4.1.7.gemfile
191
206
  - gemfiles/ar_4.1.8.gemfile
192
207
  - gemfiles/ar_4.2.gemfile
193
- - gemfiles/ar_5.0.gemfile
208
+ - gemfiles/ar_5.gemfile
194
209
  - gemfiles/rails_edge.gemfile
195
210
  - lib/mixed_gauge.rb
196
211
  - lib/mixed_gauge/all_shards_in_parallel.rb
@@ -221,9 +236,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
236
  version: '0'
222
237
  required_rubygems_version: !ruby/object:Gem::Requirement
223
238
  requirements:
224
- - - ">"
239
+ - - ">="
225
240
  - !ruby/object:Gem::Version
226
- version: 1.3.1
241
+ version: '0'
227
242
  requirements: []
228
243
  rubyforge_project:
229
244
  rubygems_version: 2.7.3