masamune 0.17.12 → 0.17.13

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.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -3
  3. data/bin/masamune-aws-emr +1 -1
  4. data/bin/masamune-dump +1 -1
  5. data/bin/masamune-hive +1 -1
  6. data/bin/masamune-psql +1 -1
  7. data/bin/masamune-shell +1 -1
  8. data/lib/masamune.rb +1 -1
  9. data/lib/masamune/actions/aws_emr.rb +2 -2
  10. data/lib/masamune/actions/data_flow.rb +10 -10
  11. data/lib/masamune/actions/date_parse.rb +4 -6
  12. data/lib/masamune/actions/execute.rb +3 -3
  13. data/lib/masamune/actions/filesystem.rb +1 -1
  14. data/lib/masamune/actions/hadoop_filesystem.rb +2 -2
  15. data/lib/masamune/actions/hive.rb +5 -5
  16. data/lib/masamune/actions/invoke_parallel.rb +5 -5
  17. data/lib/masamune/actions/postgres.rb +6 -6
  18. data/lib/masamune/actions/postgres_admin.rb +1 -1
  19. data/lib/masamune/actions/s3cmd.rb +3 -3
  20. data/lib/masamune/actions/transform.rb +4 -4
  21. data/lib/masamune/after_initialize_callbacks.rb +4 -4
  22. data/lib/masamune/cached_filesystem.rb +7 -11
  23. data/lib/masamune/commands/aws_emr.rb +12 -12
  24. data/lib/masamune/commands/hadoop_filesystem.rb +8 -8
  25. data/lib/masamune/commands/hadoop_streaming.rb +16 -16
  26. data/lib/masamune/commands/hive.rb +31 -35
  27. data/lib/masamune/commands/postgres.rb +30 -32
  28. data/lib/masamune/commands/postgres_admin.rb +17 -16
  29. data/lib/masamune/commands/postgres_common.rb +1 -1
  30. data/lib/masamune/commands/retry_with_backoff.rb +19 -19
  31. data/lib/masamune/commands/s3cmd.rb +7 -7
  32. data/lib/masamune/commands/shell.rb +25 -38
  33. data/lib/masamune/configuration.rb +8 -9
  34. data/lib/masamune/data_plan/builder.rb +5 -5
  35. data/lib/masamune/data_plan/elem.rb +7 -7
  36. data/lib/masamune/data_plan/engine.rb +12 -15
  37. data/lib/masamune/data_plan/rule.rb +14 -12
  38. data/lib/masamune/data_plan/set.rb +13 -13
  39. data/lib/masamune/environment.rb +3 -3
  40. data/lib/masamune/filesystem.rb +29 -28
  41. data/lib/masamune/helpers/postgres.rb +8 -5
  42. data/lib/masamune/io.rb +2 -2
  43. data/lib/masamune/last_element.rb +3 -3
  44. data/lib/masamune/method_logger.rb +1 -1
  45. data/lib/masamune/schema/catalog.rb +9 -12
  46. data/lib/masamune/schema/column.rb +12 -10
  47. data/lib/masamune/schema/dimension.rb +5 -4
  48. data/lib/masamune/schema/fact.rb +2 -2
  49. data/lib/masamune/schema/map.rb +9 -13
  50. data/lib/masamune/schema/row.rb +3 -2
  51. data/lib/masamune/schema/store.rb +13 -14
  52. data/lib/masamune/schema/table.rb +24 -28
  53. data/lib/masamune/schema/table_reference.rb +7 -7
  54. data/lib/masamune/spec_helper.rb +1 -1
  55. data/lib/masamune/string_format.rb +1 -1
  56. data/lib/masamune/tasks/aws_emr_thor.rb +9 -9
  57. data/lib/masamune/tasks/dump_thor.rb +5 -5
  58. data/lib/masamune/tasks/hive_thor.rb +13 -13
  59. data/lib/masamune/tasks/postgres_thor.rb +8 -8
  60. data/lib/masamune/tasks/shell_thor.rb +3 -3
  61. data/lib/masamune/template.rb +4 -4
  62. data/lib/masamune/thor.rb +26 -25
  63. data/lib/masamune/transform/common/denormalize_table.rb +6 -6
  64. data/lib/masamune/transform/define_table.rb +1 -1
  65. data/lib/masamune/transform/hive/define_table.rb +0 -2
  66. data/lib/masamune/transform/insert_reference_values.rb +1 -1
  67. data/lib/masamune/transform/operator.rb +3 -2
  68. data/lib/masamune/transform/postgres/bulk_upsert.rb +0 -3
  69. data/lib/masamune/transform/postgres/deduplicate_dimension.rb +4 -6
  70. data/lib/masamune/transform/postgres/define_table.rb +2 -2
  71. data/lib/masamune/transform/postgres/insert_reference_values.rb +1 -4
  72. data/lib/masamune/transform/postgres/relabel_dimension.rb +1 -3
  73. data/lib/masamune/transform/postgres/rollup_fact.rb +3 -5
  74. data/lib/masamune/transform/postgres/snapshot_dimension.rb +1 -4
  75. data/lib/masamune/transform/postgres/stage_dimension.rb +8 -10
  76. data/lib/masamune/transform/postgres/stage_fact.rb +15 -14
  77. data/lib/masamune/version.rb +1 -1
  78. data/spec/masamune/actions/aws_emr_spec.rb +8 -8
  79. data/spec/masamune/actions/execute_spec.rb +6 -6
  80. data/spec/masamune/actions/hive_spec.rb +20 -15
  81. data/spec/masamune/actions/postgres_spec.rb +17 -10
  82. data/spec/masamune/after_initialization_callbacks_spec.rb +13 -7
  83. data/spec/masamune/commands/aws_emr_spec.rb +10 -10
  84. data/spec/masamune/commands/hadoop_filesystem_spec.rb +3 -3
  85. data/spec/masamune/commands/hadoop_streaming_spec.rb +4 -4
  86. data/spec/masamune/commands/hive_spec.rb +11 -11
  87. data/spec/masamune/commands/postgres_admin_spec.rb +9 -9
  88. data/spec/masamune/commands/postgres_spec.rb +15 -15
  89. data/spec/masamune/commands/retry_with_backoff_spec.rb +10 -7
  90. data/spec/masamune/commands/s3cmd_spec.rb +3 -3
  91. data/spec/masamune/commands/shell_spec.rb +16 -16
  92. data/spec/masamune/data_plan/builder_spec.rb +22 -19
  93. data/spec/masamune/data_plan/elem_spec.rb +20 -20
  94. data/spec/masamune/data_plan/engine_spec.rb +41 -33
  95. data/spec/masamune/data_plan/rule_spec.rb +19 -19
  96. data/spec/masamune/data_plan/set_spec.rb +8 -6
  97. data/spec/masamune/environment_spec.rb +5 -5
  98. data/spec/masamune/filesystem_spec.rb +87 -87
  99. data/spec/masamune/helpers/postgres_spec.rb +1 -1
  100. data/spec/masamune/rspec/job_fixture_spec.rb +0 -1
  101. data/spec/masamune/schema/catalog_spec.rb +16 -16
  102. data/spec/masamune/schema/column_spec.rb +19 -19
  103. data/spec/masamune/schema/dimension_spec.rb +2 -2
  104. data/spec/masamune/schema/fact_spec.rb +3 -3
  105. data/spec/masamune/schema/map_spec.rb +41 -41
  106. data/spec/masamune/schema/table_spec.rb +16 -16
  107. data/spec/masamune/string_format_spec.rb +7 -7
  108. data/spec/masamune/tasks/dump_thor_spec.rb +6 -6
  109. data/spec/masamune/tasks/hive_thor_spec.rb +2 -2
  110. data/spec/masamune/template_spec.rb +3 -2
  111. data/spec/masamune/thor_spec.rb +8 -8
  112. data/spec/masamune/transform/bulk_upsert.dimension_spec.rb +3 -3
  113. data/spec/masamune/transform/define_table.dimension_spec.rb +3 -3
  114. data/spec/masamune/transform/define_table.fact_spec.rb +5 -5
  115. data/spec/masamune/transform/define_table.table_spec.rb +6 -6
  116. data/spec/masamune/transform/denormalize_table_spec.rb +15 -15
  117. data/spec/masamune/transform/insert_reference_values.dimension_spec.rb +1 -1
  118. data/spec/masamune/transform/load_dimension_spec.rb +1 -1
  119. data/spec/masamune/transform/load_fact_spec.rb +1 -1
  120. data/spec/masamune/transform/rollup_fact_spec.rb +4 -4
  121. data/spec/masamune/transform/stage_dimension_spec.rb +3 -3
  122. data/spec/masamune/transform/stage_fact_spec.rb +4 -4
  123. data/spec/spec_helper.rb +1 -1
  124. data/spec/support/masamune/example_group.rb +2 -2
  125. data/spec/support/masamune/job_example_group.rb +3 -3
  126. data/spec/support/masamune/job_fixture.rb +4 -4
  127. data/spec/support/masamune/mock_command.rb +10 -10
  128. data/spec/support/masamune/mock_delegate.rb +2 -2
  129. data/spec/support/masamune/mock_filesystem.rb +3 -3
  130. data/spec/support/masamune/shared_example_group.rb +14 -16
  131. data/spec/support/masamune/step_example_group.rb +4 -4
  132. data/spec/support/masamune/step_fixture.rb +1 -1
  133. data/spec/support/masamune/task_example_group.rb +1 -1
  134. data/spec/support/masamune/thor_mute.rb +3 -2
  135. data/spec/support/rspec/example/action_example_group.rb +1 -1
  136. data/spec/support/rspec/example/task_example_group.rb +7 -4
  137. data/spec/support/rspec/example/transform_example_group.rb +1 -1
  138. data/spec/support/shared_examples/postgres_common_examples.rb +2 -2
  139. metadata +16 -2
@@ -22,7 +22,7 @@
22
22
 
23
23
  module Masamune::Schema
24
24
  class Fact < Table
25
- SUPPORTED_GRAINS = [:transaction, :hourly, :daily, :monthly]
25
+ SUPPORTED_GRAINS = [:transaction, :hourly, :daily, :monthly].freeze
26
26
 
27
27
  attr_accessor :grain
28
28
  attr_accessor :partition
@@ -96,7 +96,7 @@ module Masamune::Schema
96
96
  def partition_tables(start_date = nil, stop_date = nil)
97
97
  return unless partition
98
98
  return unless start_date && stop_date
99
- (start_date .. stop_date).each do |date|
99
+ (start_date..stop_date).each do |date|
100
100
  next unless date.day == 1
101
101
  yield partition_table(date)
102
102
  end
@@ -72,7 +72,7 @@ module Masamune::Schema
72
72
 
73
73
  def quote(buffer)
74
74
  return buffer if buffer =~ /\A".*"\z/
75
- %Q{"#{buffer.gsub('"', '""')}"}
75
+ %("#{buffer.gsub('"', '""')}")
76
76
  end
77
77
 
78
78
  def separator
@@ -101,10 +101,10 @@ module Masamune::Schema
101
101
  @csv = nil
102
102
  end
103
103
 
104
- def each(&block)
104
+ def each
105
105
  raise 'must call Buffer#bind first' unless @io
106
106
  CSV.parse(JSONEncoder.new(@io, @store), options.merge(headers: @store.headers || @table.columns.keys)) do |data|
107
- next if data.to_s =~ /\A#/
107
+ next if data.to_s.start_with?('#')
108
108
  row = safe_row(data)
109
109
  yield row.to_hash if row
110
110
  @line += 1
@@ -142,14 +142,12 @@ module Masamune::Schema
142
142
  end
143
143
  end
144
144
 
145
- def line
146
- @line
147
- end
145
+ attr_reader :line
148
146
 
149
147
  private
150
148
 
151
149
  def options
152
- {skip_blanks: true}.tap do | opts|
150
+ { skip_blanks: true }.tap do |opts|
153
151
  opts[:col_sep] = "\t" if @store.format == :tsv
154
152
  end
155
153
  end
@@ -178,7 +176,7 @@ module Masamune::Schema
178
176
  distinct: false,
179
177
  fail_fast: false,
180
178
  debug: false
181
- }
179
+ }.freeze
182
180
 
183
181
  DEFAULT_ATTRIBUTES.keys.each do |attr|
184
182
  attr_accessor attr
@@ -194,9 +192,7 @@ module Masamune::Schema
194
192
  @skipped = 0
195
193
  end
196
194
 
197
- def source=(source)
198
- @source = source
199
- end
195
+ attr_writer :source
200
196
 
201
197
  # FIXME: avoid implict conversions
202
198
  def target=(target)
@@ -229,7 +225,7 @@ module Masamune::Schema
229
225
  intermediate
230
226
  end
231
227
 
232
- def open_stream(file, mode, &block)
228
+ def open_stream(file, mode)
233
229
  case file
234
230
  when IO, StringIO
235
231
  file.flush
@@ -295,7 +291,7 @@ module Masamune::Schema
295
291
  output_buffer.flush
296
292
  end
297
293
 
298
- def safe_apply_function(input_buffer, input, &block)
294
+ def safe_apply_function(input_buffer, input)
299
295
  return unless input
300
296
  Array.wrap(function.call(input, input_buffer.line)).each do |output|
301
297
  yield output
@@ -30,7 +30,7 @@ module Masamune::Schema
30
30
  strict: true,
31
31
  parent: nil,
32
32
  debug: false
33
- }
33
+ }.freeze
34
34
 
35
35
  DEFAULT_ATTRIBUTES.keys.each do |attr|
36
36
  attr_accessor attr
@@ -128,7 +128,8 @@ module Masamune::Schema
128
128
  @columns = {}
129
129
  values.each do |key, value|
130
130
  next unless key
131
- if column = parent.dereference_column_name(key)
131
+ column = parent.dereference_column_name(key)
132
+ if column
132
133
  @columns[column.compact_name] = column
133
134
  result[column.compact_name] = column.ruby_value(value)
134
135
  elsif strict
@@ -28,7 +28,7 @@ module Masamune::Schema
28
28
  class Store
29
29
  include Masamune::HasEnvironment
30
30
 
31
- SUPPORTED_ATTRIBUTES = %(table dimension fact file)
31
+ SUPPORTED_ATTRIBUTES = %(table dimension fact file).freeze
32
32
 
33
33
  DEFAULT_ATTRIBUTES =
34
34
  {
@@ -37,7 +37,7 @@ module Masamune::Schema
37
37
  json_encoding: ->(store) { default_json_encoding(store) },
38
38
  headers: ->(store) { default_headers(store) },
39
39
  debug: false
40
- }
40
+ }.freeze
41
41
 
42
42
  DEFAULT_ATTRIBUTES.keys.each do |attr|
43
43
  attr_accessor attr
@@ -72,26 +72,25 @@ module Masamune::Schema
72
72
  @extra = []
73
73
  end
74
74
 
75
- def method_missing(method, *args, &block)
75
+ def method_missing(method, *_args)
76
76
  if type == :files
77
77
  files[method]
78
78
  else
79
79
  *attribute_name, attribute_type = method.to_s.split('_')
80
80
  raise ArgumentError, "unknown attribute type '#{attribute_type}'" unless SUPPORTED_ATTRIBUTES.include?(attribute_type)
81
- self.send(attribute_type.pluralize)[attribute_name.join('_')]
81
+ send(attribute_type.pluralize)[attribute_name.join('_')]
82
82
  end
83
83
  end
84
84
 
85
85
  def dereference_column(id, options = {})
86
86
  column_id, reference_id = id.to_s.split(/\./).reverse
87
87
  column_options = options.dup
88
- column_options.merge!(id: column_id)
88
+ column_options[:id] = column_id
89
89
 
90
- if reference = references[reference_id]
91
- column_options.merge!(reference: reference)
92
- else
93
- raise ArgumentError, "dimension #{reference_id} not defined"
94
- end if reference_id
90
+ if reference_id
91
+ raise ArgumentError, "dimension #{reference_id} not defined" unless references[reference_id]
92
+ column_options[:reference] = references[reference_id]
93
+ end
95
94
 
96
95
  Masamune::Schema::Column.new(column_options)
97
96
  end
@@ -105,16 +104,16 @@ module Masamune::Schema
105
104
  number = filename.split('_').first.to_i
106
105
  result << file if number <= 0 && order == :pre
107
106
  result << file if number > 0 && order == :post
108
- else
109
- result << file if order == :pre
107
+ elsif order == :pre
108
+ result << file
110
109
  end
111
110
  end
112
111
  result.to_a
113
112
  end
114
113
 
115
- private
116
-
117
114
  class << self
115
+ private
116
+
118
117
  def default_format(store)
119
118
  case store.type
120
119
  when :postgres then :csv
@@ -43,7 +43,7 @@ module Masamune::Schema
43
43
  inherit: false,
44
44
  debug: false,
45
45
  properties: {}
46
- }
46
+ }.freeze
47
47
 
48
48
  DEFAULT_ATTRIBUTES.keys.each do |attr|
49
49
  attr_accessor attr
@@ -76,8 +76,8 @@ module Masamune::Schema
76
76
  columns = (instance.is_a?(Hash) ? instance.values : instance).compact
77
77
  raise ArgumentError, "table #{name} contains reserved columns" if columns.any? { |column| reserved_column_ids.include?(column.id) }
78
78
 
79
- initialize_surrogate_key_column! unless columns.any? { |column| column.surrogate_key }
80
- initialize_reference_columns! unless columns.any? { |column| column.reference }
79
+ initialize_surrogate_key_column! unless columns.any?(&:surrogate_key)
80
+ initialize_reference_columns! unless columns.any?(&:reference)
81
81
  columns.each do |column|
82
82
  initialize_column!(column)
83
83
  end
@@ -104,7 +104,7 @@ module Masamune::Schema
104
104
  end
105
105
 
106
106
  def surrogate_key
107
- columns.values.detect { |column| column.surrogate_key }
107
+ columns.values.detect(&:surrogate_key)
108
108
  end
109
109
 
110
110
  def primary_keys
@@ -112,11 +112,11 @@ module Masamune::Schema
112
112
  end
113
113
 
114
114
  def natural_keys
115
- columns.values.select { |column| column.natural_key }
115
+ columns.values.select(&:natural_key)
116
116
  end
117
117
 
118
118
  def defined_columns
119
- columns.values.reject { |column| column.partition }
119
+ columns.values.reject(&:partition)
120
120
  end
121
121
  method_with_last_element :defined_columns
122
122
 
@@ -150,11 +150,11 @@ module Masamune::Schema
150
150
  end
151
151
 
152
152
  def reference_columns
153
- columns.values.select { | column| column.reference }
153
+ columns.values.select(&:reference)
154
154
  end
155
155
 
156
156
  def foreign_key_columns
157
- columns.values.select { | column| !column.degenerate? && column.reference && column.reference.foreign_key }
157
+ columns.values.select { |column| !column.degenerate? && column.reference && column.reference.foreign_key }
158
158
  end
159
159
 
160
160
  def partitions
@@ -166,7 +166,7 @@ module Masamune::Schema
166
166
  end
167
167
 
168
168
  def aliased_rows
169
- rows.select { |row| row.name }
169
+ rows.select(&:name)
170
170
  end
171
171
 
172
172
  def insert_references
@@ -225,7 +225,7 @@ module Masamune::Schema
225
225
  end
226
226
 
227
227
  def shared_columns(other)
228
- Hash.new { |h,k| h[k] = [] }.tap do |shared|
228
+ Hash.new { |h, k| h[k] = [] }.tap do |shared|
229
229
  columns.each do |_, column|
230
230
  other.columns.each do |_, other_column|
231
231
  shared[column] << other_column if column.references?(other_column)
@@ -235,13 +235,13 @@ module Masamune::Schema
235
235
  end
236
236
 
237
237
  def dereference_column_name(name)
238
- reference_name, column_name = Column::dereference_column_name(name)
239
- if reference = references[reference_name]
240
- if column = reference.columns[column_name]
241
- dereference_column(column.dup, reference)
242
- end
243
- elsif column = columns[column_name]
244
- column
238
+ reference_name, column_name = Column.dereference_column_name(name)
239
+ reference = references[reference_name]
240
+ if reference
241
+ column = reference.columns[column_name]
242
+ dereference_column(column.dup, reference) if column
243
+ elsif columns[column_name]
244
+ columns[column_name]
245
245
  end
246
246
  end
247
247
 
@@ -287,17 +287,13 @@ module Masamune::Schema
287
287
  column = dereference_column_name(name)
288
288
  next unless column
289
289
  next if inherit && parent.reserved_column_ids.include?(column.id)
290
- if column.parent == self
291
- next if column.surrogate_key
292
- result[name] = column
293
- else
294
- result[name] = column
295
- end
290
+ next if column.parent == self && column.surrogate_key
291
+ result[name] = column
296
292
  end
297
293
  end
298
294
  end
299
295
 
300
- def stage_table_references(parent, selected = [])
296
+ def stage_table_references(_parent, selected = [])
301
297
  selected = references.keys if selected.empty?
302
298
  {}.tap do |result|
303
299
  selected.each do |name|
@@ -325,7 +321,7 @@ module Masamune::Schema
325
321
  initialize_column! id: column.id, type: column.type, reference: reference, default: reference.default, null: reference.null, natural_key: reference.natural_key
326
322
  end
327
323
  elsif reference.foreign_key
328
- # FIXME column.reference should point to reference.surrogate_key, only allow column references to Columns
324
+ # FIXME: column.reference should point to reference.surrogate_key, only allow column references to Columns
329
325
  initialize_column! id: reference.foreign_key_name, type: reference.foreign_key_type, reference: reference, default: reference.default, null: reference.null, natural_key: reference.natural_key
330
326
  end
331
327
  end
@@ -342,7 +338,7 @@ module Masamune::Schema
342
338
 
343
339
  def index_column_map
344
340
  @index_column_map ||= begin
345
- map = Hash.new { |h,k| h[k] = [] }
341
+ map = Hash.new { |h, k| h[k] = [] }
346
342
  columns.each do |_, column|
347
343
  column.index.each do |index|
348
344
  map[index] << column.name
@@ -355,7 +351,7 @@ module Masamune::Schema
355
351
 
356
352
  def unique_constraints_map
357
353
  @unique_constraints_map ||= begin
358
- map = Hash.new { |h,k| h[k] = [] }
354
+ map = Hash.new { |h, k| h[k] = [] }
359
355
  columns.each do |_, column|
360
356
  next if column.auto_reference
361
357
  column.unique.each do |unique|
@@ -369,7 +365,7 @@ module Masamune::Schema
369
365
  end
370
366
 
371
367
  def reverse_unique_constraints_map
372
- @reverse_unique_constraints_map ||= Hash[unique_constraints_map.to_a.map { |k,v| [v.sort, k] }]
368
+ @reverse_unique_constraints_map ||= Hash[unique_constraints_map.to_a.map { |k, v| [v.sort, k] }]
373
369
  end
374
370
 
375
371
  def short_md5(*a)
@@ -34,7 +34,7 @@ module Masamune::Schema
34
34
  multiple: false,
35
35
  through: [],
36
36
  degenerate: false
37
- }
37
+ }.freeze
38
38
 
39
39
  DEFAULT_ATTRIBUTES.keys.each do |attr|
40
40
  attr_accessor attr
@@ -70,17 +70,17 @@ module Masamune::Schema
70
70
 
71
71
  def default(column = nil)
72
72
  return if @default == :null
73
- if default_row = @table.rows.detect { |row| @default ? row.id == @default : row.default }
74
- default_row.name(column)
75
- end
73
+ default_row = @table.rows.detect { |row| @default ? row.id == @default : row.default }
74
+ return unless default_row
75
+ default_row.name(column)
76
76
  end
77
77
 
78
78
  def unknown(column = nil)
79
79
  return unless @unknown
80
80
  return if @unknown == :null
81
- if unknown_row = @table.rows.detect { |row| row.id == @unknown }
82
- unknown_row.name(column)
83
- end
81
+ unknown_row = @table.rows.detect { |row| row.id == @unknown }
82
+ return unless unknown_row
83
+ unknown_row.name(column)
84
84
  end
85
85
 
86
86
  def through=(columns)
@@ -20,4 +20,4 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
- Dir["#{File.dirname(__FILE__)}/../../spec/support/masamune/**/*.rb"].each {|f| require f}
23
+ Dir["#{File.dirname(__FILE__)}/../../spec/support/masamune/**/*.rb"].each { |f| require f }
@@ -26,7 +26,7 @@ module Masamune
26
26
  out = sql.dup
27
27
  out.gsub!(/\A'|\A"|"\z|'\z/, '')
28
28
  out.gsub!(/\s\s+/, ' ')
29
- out.gsub!(/\s*;+\s*$/,'')
29
+ out.gsub!(/\s*;+\s*$/, '')
30
30
  out.strip!
31
31
  out + ';'
32
32
  end
@@ -28,36 +28,36 @@ module Masamune::Tasks
28
28
  include Masamune::Thor
29
29
  include Masamune::Actions::AwsEmr
30
30
 
31
- # FIXME need to add an unnecessary namespace until this issue is fixed:
31
+ # FIXME: need to add an unnecessary namespace until this issue is fixed:
32
32
  # https://github.com/wycats/thor/pull/247
33
33
  namespace :aws_emr
34
34
  skip_lock!
35
35
 
36
- REQUIRE_CLUSTER_ID_ACTIONS =
36
+ REQUIRE_CLUSTER_ID_ACTIONS =
37
37
  {
38
38
  'describe-cluster' => 'Describe an AWS EMR cluster',
39
39
  'list-instances' => 'List instances for an AWS EMR cluster',
40
40
  'add-instance-groups' => 'Add instances to an AWS EMR cluster',
41
41
  'ssh' => 'Launch an AWS EMR ssh session',
42
42
  'wait' => 'Wait for an AWS EMR cluster to start'
43
- }
43
+ }.freeze
44
44
 
45
45
  REQUIRE_CLUSTER_ID_ACTIONS.each do |action, description|
46
46
  desc action, description
47
- method_option :cluster_id, :desc => "AWS EMR cluster_id ID (Hint: `masamune-emr-aws list-clusters`)"
47
+ method_option :cluster_id, desc: 'AWS EMR cluster_id ID (Hint: `masamune-emr-aws list-clusters`)'
48
48
  define_method(action.underscore) do
49
49
  raise Thor::RequiredArgumentMissingError, "No value provided for required options '--cluster-id'" unless options[:cluster_id]
50
50
  aws_emr(aws_emr_options(action))
51
51
  end
52
52
  end
53
53
 
54
- NO_REQUIRE_CLUSTER_ID_ACTIONS =
54
+ NO_REQUIRE_CLUSTER_ID_ACTIONS =
55
55
  {
56
56
  'create-cluster' => 'Create an AWS EMR cluster',
57
57
  'list-clusters' => 'List existing AWS EMR clusters',
58
58
  'modify-instance-groups' => 'Modify instance groups for an AWS EMR cluster',
59
59
  'terminate-clusters' => 'Terminate one or more AWS EMR clusters'
60
- }
60
+ }.freeze
61
61
 
62
62
  NO_REQUIRE_CLUSTER_ID_ACTIONS.each do |action, description|
63
63
  desc action, description
@@ -69,9 +69,9 @@ module Masamune::Tasks
69
69
  no_tasks do
70
70
  def aws_emr_options(action)
71
71
  options.dup.with_indifferent_access.tap do |opts|
72
- opts.merge!(interactive: true)
73
- opts.merge!(action: action)
74
- opts.merge!(extra: self.extra)
72
+ opts[:interactive] = true
73
+ opts[:action] = action
74
+ opts.merge!(extra: extra)
75
75
  end
76
76
  end
77
77
  end
@@ -29,16 +29,16 @@ module Masamune::Tasks
29
29
  include Masamune::Actions::DateParse
30
30
  include Masamune::Transform::DefineSchema
31
31
 
32
- # FIXME need to add an unnecessary namespace until this issue is fixed:
32
+ # FIXME: need to add an unnecessary namespace until this issue is fixed:
33
33
  # https://github.com/wycats/thor/pull/247
34
34
  namespace :dump
35
35
  skip_lock!
36
36
 
37
37
  desc 'dump', 'Dump schema'
38
- method_option :type, :enum => ['psql', 'hql'], :desc => 'Schema type', :default => 'psql'
39
- method_option :section, :enum => ['pre', 'post', 'all'], :desc => 'Schema section', :default => 'all'
40
- method_option :exclude, :type => :array, :desc => 'Exclude tables matching globs', :default => []
41
- method_option :skip_indexes, :type => :boolean, :desc => 'Disable indexes', :default => false
38
+ method_option :type, enum: %w(psql hql), desc: 'Schema type', default: 'psql'
39
+ method_option :section, enum: %w(pre post all), desc: 'Schema section', default: 'all'
40
+ method_option :exclude, type: :array, desc: 'Exclude tables matching globs', default: []
41
+ method_option :skip_indexes, type: :boolean, desc: 'Disable indexes', default: false
42
42
  def dump_exec
43
43
  print_catalog
44
44
  exit