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
@@ -29,14 +29,14 @@ module Masamune::Commands
29
29
  include Masamune::Actions::Execute
30
30
 
31
31
  DEFAULT_ATTRIBUTES =
32
- {
33
- :path => 'aws',
34
- :extra => [],
35
- :config_file => nil,
36
- :action => nil,
37
- :cluster_id => nil,
38
- :interactive => false
39
- }
32
+ {
33
+ path: 'aws',
34
+ extra: [],
35
+ config_file: nil,
36
+ action: nil,
37
+ cluster_id: nil,
38
+ interactive: false
39
+ }.freeze
40
40
 
41
41
  def initialize(delegate, attrs = {})
42
42
  super delegate
@@ -104,10 +104,10 @@ module Masamune::Commands
104
104
  end
105
105
 
106
106
  def handle_stdout(line, line_no)
107
- if line_no == 0 && line =~ /\Assh/
108
- @delegate.handle_stderr(line, line_no) if @delegate.respond_to?(:handle_stderr)
109
- else
110
- @delegate.handle_stdout(line, line_no) if @delegate.respond_to?(:handle_stdout)
107
+ if line_no == 0 && line.start_with?('ssh') && @delegate.respond_to?(:handle_stderr)
108
+ @delegate.handle_stderr(line, line_no)
109
+ elsif @delegate.respond_to?(:handle_stdout)
110
+ @delegate.handle_stdout(line, line_no)
111
111
  end
112
112
  end
113
113
 
@@ -25,13 +25,13 @@ require 'delegate'
25
25
  module Masamune::Commands
26
26
  class HadoopFilesystem < SimpleDelegator
27
27
  DEFAULT_ATTRIBUTES =
28
- {
29
- :path => 'hadoop',
30
- :options => [],
31
- :extra => [],
32
- :block => nil,
33
- :print => false
34
- }
28
+ {
29
+ path: 'hadoop',
30
+ options: [],
31
+ extra: [],
32
+ block: nil,
33
+ print: false
34
+ }.freeze
35
35
 
36
36
  def initialize(delegate, attrs = {})
37
37
  super delegate
@@ -49,7 +49,7 @@ module Masamune::Commands
49
49
  args.flatten
50
50
  end
51
51
 
52
- def handle_stdout(line, line_no)
52
+ def handle_stdout(line, _line_no)
53
53
  @block.call(line) if @block
54
54
  console(line) if @print
55
55
  end
@@ -39,17 +39,17 @@ module Masamune::Commands
39
39
 
40
40
  DEFAULT_ATTRIBUTES =
41
41
  {
42
- :path => 'hadoop',
43
- :options => [],
44
- :jar => default_hadoop_streaming_jar,
45
- :input => [],
46
- :output => nil,
47
- :mapper => nil,
48
- :reducer => nil,
49
- :extra => [],
50
- :upload => true,
51
- :quote => false
52
- }
42
+ path: 'hadoop',
43
+ options: [],
44
+ jar: default_hadoop_streaming_jar,
45
+ input: [],
46
+ output: nil,
47
+ mapper: nil,
48
+ reducer: nil,
49
+ extra: [],
50
+ upload: true,
51
+ quote: false
52
+ }.freeze
53
53
 
54
54
  attr_reader :input
55
55
 
@@ -61,7 +61,7 @@ module Masamune::Commands
61
61
  @input = Array.wrap(@input)
62
62
  end
63
63
 
64
- # TODO ensure jar/ mapper/reduce exists, warn or remove if output exists
64
+ # TODO: ensure jar/ mapper/reduce exists, warn or remove if output exists
65
65
  def command_args
66
66
  args = []
67
67
  args << @path
@@ -95,10 +95,10 @@ module Masamune::Commands
95
95
  path + '/*'
96
96
  end
97
97
  end
98
- console("hadoop_streaming %s -> %s (%s/%s)" % [@input.join(' '), @output, @mapper, @reducer])
98
+ console(format('hadoop_streaming %s -> %s (%s/%s)', @input.join(' '), @output, @mapper, @reducer))
99
99
  end
100
100
 
101
- def around_execute(&block)
101
+ def around_execute
102
102
  Dir.chdir(filesystem.path(:run_dir)) do
103
103
  yield
104
104
  end
@@ -106,10 +106,10 @@ module Masamune::Commands
106
106
 
107
107
  private
108
108
 
109
- # FIXME shell quoting is a separate concern
109
+ # FIXME: shell quoting is a separate concern
110
110
  def quote_arg(arg)
111
111
  out = arg.dup
112
- out.gsub!(%q('\t'), %q('"'\\\\\\\\t'"'))
112
+ out.gsub!('\'\t\'', %q('"'\\\\\\\\t'"'))
113
113
  out
114
114
  end
115
115
  end
@@ -30,27 +30,27 @@ module Masamune::Commands
30
30
  class Hive < SimpleDelegator
31
31
  include Masamune::StringFormat
32
32
 
33
- PROMPT = 'hive>'
33
+ PROMPT = 'hive>'.freeze
34
34
 
35
35
  DEFAULT_ATTRIBUTES =
36
- {
37
- :path => 'hive',
38
- :options => [],
39
- :database => 'default',
40
- :setup_files => [],
41
- :schema_files => [],
42
- :file => nil,
43
- :exec => nil,
44
- :output => nil,
45
- :print => false,
46
- :block => nil,
47
- :variables => {},
48
- :buffer => nil,
49
- :service => false,
50
- :delimiter => "\001",
51
- :csv => false,
52
- :debug => false
53
- }
36
+ {
37
+ path: 'hive',
38
+ options: [],
39
+ database: 'default',
40
+ setup_files: [],
41
+ schema_files: [],
42
+ file: nil,
43
+ exec: nil,
44
+ output: nil,
45
+ print: false,
46
+ block: nil,
47
+ variables: {},
48
+ buffer: nil,
49
+ service: false,
50
+ delimiter: "\001",
51
+ csv: false,
52
+ debug: false
53
+ }.freeze
54
54
 
55
55
  def initialize(delegate, attrs = {})
56
56
  super delegate
@@ -83,11 +83,9 @@ module Masamune::Commands
83
83
  end
84
84
 
85
85
  def before_execute
86
- if @file
87
- console("hive with file #{@file}")
88
- end
86
+ console("hive with file #{@file}") if @file
89
87
 
90
- if @debug and output = rendered_template || @file
88
+ if @debug && (output = rendered_template || @file)
91
89
  logger.debug("#{output}:\n" + File.read(output))
92
90
  end
93
91
 
@@ -96,12 +94,10 @@ module Masamune::Commands
96
94
  @file = exec_file
97
95
  end
98
96
 
99
- if @output
100
- @buffer = Tempfile.create('masamune_hive_output')
101
- end
97
+ @buffer = Tempfile.create('masamune_hive_output') if @output
102
98
  end
103
99
 
104
- def around_execute(&block)
100
+ def around_execute
105
101
  Dir.chdir(filesystem.path(:run_dir)) do
106
102
  yield
107
103
  end
@@ -115,21 +111,21 @@ module Masamune::Commands
115
111
 
116
112
  filesystem.move_file_to_file(@buffer.path, @output)
117
113
  ensure
118
- File.delete(@buffer.path) if @buffer && @buffer.path && File.exists?(@buffer.path)
114
+ File.delete(@buffer.path) if @buffer && @buffer.path && File.exist?(@buffer.path)
119
115
  end
120
116
 
121
- def handle_stdout(line, line_no)
117
+ def handle_stdout(line, _line_no)
122
118
  if line =~ /\A#{PROMPT}/
123
119
  logger.debug(line)
124
- elsif line =~ /\AQuery returned non-zero code:/
120
+ elsif line.start_with?('Query returned non-zero code:')
125
121
  raise SystemExit, line
126
122
  else
127
123
  @block.call(line) if @block
128
124
 
129
125
  if @buffer
130
126
  @buffer.puts(@csv ? line.split(@delimiter).map { |row| encode_row(row) }.to_csv : line)
131
- else
132
- console(line) if print?
127
+ elsif print?
128
+ console(line)
133
129
  end
134
130
  end
135
131
  end
@@ -142,7 +138,7 @@ module Masamune::Commands
142
138
  files = @setup_files.map do |path|
143
139
  filesystem.glob_sort(path, order: :basename)
144
140
  end
145
- files.flatten.compact.map { |file| {'-i' => file} }
141
+ files.flatten.compact.map { |file| { '-i' => file } }
146
142
  end
147
143
 
148
144
  def command_args_for_file
@@ -153,7 +149,7 @@ module Masamune::Commands
153
149
  filesystem.copy_file_to_file(@file, remote_file)
154
150
  ['-f', remote_file].tap do |args|
155
151
  @variables.each do |key, val|
156
- args << ['-d', "#{key.to_s}=#{val.to_s}"]
152
+ args << ['-d', "#{key}=#{val}"]
157
153
  end
158
154
  end
159
155
  end
@@ -170,7 +166,7 @@ module Masamune::Commands
170
166
  end
171
167
 
172
168
  def remote_file
173
- @remote_file ||= File.join(filesystem.mktempdir!(:tmp_dir), filesystem.basename(@file)).gsub(/.erb\z/,'')
169
+ @remote_file ||= File.join(filesystem.mktempdir!(:tmp_dir), filesystem.basename(@file)).gsub(/.erb\z/, '')
174
170
  end
175
171
 
176
172
  def exec_file
@@ -31,24 +31,24 @@ module Masamune::Commands
31
31
  include Masamune::Commands::PostgresCommon
32
32
 
33
33
  DEFAULT_ATTRIBUTES =
34
- {
35
- :path => 'psql',
36
- :options => [],
37
- :hostname => 'localhost',
38
- :database => 'postgres',
39
- :username => 'postgres',
40
- :pgpass_file => nil,
41
- :file => nil,
42
- :exec => nil,
43
- :input => nil,
44
- :output => nil,
45
- :print => false,
46
- :block => nil,
47
- :csv => false,
48
- :variables => {},
49
- :tuple_output => false,
50
- :debug => false
51
- }
34
+ {
35
+ path: 'psql',
36
+ options: [],
37
+ hostname: 'localhost',
38
+ database: 'postgres',
39
+ username: 'postgres',
40
+ pgpass_file: nil,
41
+ file: nil,
42
+ exec: nil,
43
+ input: nil,
44
+ output: nil,
45
+ print: false,
46
+ block: nil,
47
+ csv: false,
48
+ variables: {},
49
+ tuple_output: false,
50
+ debug: false
51
+ }.freeze
52
52
 
53
53
  def initialize(delegate, attrs = {})
54
54
  super delegate
@@ -60,9 +60,7 @@ module Masamune::Commands
60
60
  end
61
61
 
62
62
  def stdin
63
- if @input
64
- @stdin ||= StringIO.new(strip_sql(@input))
65
- end
63
+ @stdin ||= StringIO.new(strip_sql(@input)) if @input
66
64
  end
67
65
 
68
66
  def interactive?
@@ -76,14 +74,14 @@ module Masamune::Commands
76
74
  def command_args
77
75
  args = []
78
76
  args << @path
79
- args << '--host=%s' % @hostname if @hostname
80
- args << '--dbname=%s' % @database
81
- args << '--username=%s' % @username if @username
77
+ args << "--host=#{@hostname}" if @hostname
78
+ args << "--dbname=#{@database}"
79
+ args << "--username=#{@username}" if @username
82
80
  args << '--no-password'
83
81
  args << '--set=ON_ERROR_STOP=1'
84
82
  args << @options.map(&:to_a)
85
83
  args << command_args_for_file if @file
86
- args << '--output=%s' % @output if @output
84
+ args << "--output=#{@output}" if @output
87
85
  args << '--no-align' << '--field-separator=,' << '--pset=footer' if @csv
88
86
  args << '--pset=tuples_only' if @tuple_output
89
87
  args.flatten.compact
@@ -91,7 +89,7 @@ module Masamune::Commands
91
89
 
92
90
  def before_execute
93
91
  console("psql with file #{@file}") if @file
94
- if @debug and output = rendered_template || @file
92
+ if @debug && (output = rendered_template || @file)
95
93
  logger.debug("#{output}:\n" + File.read(output))
96
94
  end
97
95
 
@@ -101,7 +99,7 @@ module Masamune::Commands
101
99
  end
102
100
  end
103
101
 
104
- def handle_stdout(line, line_no)
102
+ def handle_stdout(line, _line_no)
105
103
  if line =~ /\A#{prompt}/
106
104
  logger.debug(line)
107
105
  else
@@ -110,12 +108,12 @@ module Masamune::Commands
110
108
  end
111
109
  end
112
110
 
113
- def handle_stderr(line, line_no)
111
+ def handle_stderr(line, _line_no)
114
112
  @error = line.split(/ERROR:\s*/).last if line =~ /ERROR:/
115
113
  logger.debug(line)
116
114
  end
117
115
 
118
- def failure_message(status)
116
+ def failure_message(_status)
119
117
  @error || 'psql failed without error'
120
118
  end
121
119
 
@@ -134,15 +132,15 @@ module Masamune::Commands
134
132
  end
135
133
 
136
134
  def command_args_for_simple_file
137
- ['--file=%s' % @file].tap do |args|
135
+ ["--file=#{@file}"].tap do |args|
138
136
  @variables.each do |key, val|
139
- args << '--set=%s' % "#{key.to_s}='#{val.to_s}'"
137
+ args << "--set=#{key}='#{val}'"
140
138
  end
141
139
  end
142
140
  end
143
141
 
144
142
  def command_args_for_template
145
- ['--file=%s' % rendered_template]
143
+ ["--file=#{rendered_template}"]
146
144
  end
147
145
 
148
146
  def exec_file
@@ -29,18 +29,18 @@ module Masamune::Commands
29
29
  include Masamune::Commands::PostgresCommon
30
30
 
31
31
  DEFAULT_ATTRIBUTES =
32
- {
33
- :create_db_path => 'createdb',
34
- :drop_db_path => 'dropdb',
35
- :pg_dump_path => 'pg_dump',
36
- :options => [],
37
- :hostname => 'localhost',
38
- :username => 'postgres',
39
- :pgpass_file => nil,
40
- :action => nil,
41
- :database => nil,
42
- :output => nil
43
- }
32
+ {
33
+ create_db_path: 'createdb',
34
+ drop_db_path: 'dropdb',
35
+ pg_dump_path: 'pg_dump',
36
+ options: [],
37
+ hostname: 'localhost',
38
+ username: 'postgres',
39
+ pgpass_file: nil,
40
+ action: nil,
41
+ database: nil,
42
+ output: nil
43
+ }.freeze
44
44
 
45
45
  def initialize(delegate, attrs = {})
46
46
  super delegate
@@ -53,8 +53,8 @@ module Masamune::Commands
53
53
  raise ArgumentError, ':database must be given' unless @database
54
54
  args = []
55
55
  args << command_path
56
- args << '--host=%s' % @hostname if @hostname
57
- args << '--username=%s' % @username if @username
56
+ args << "--host=#{@hostname}" if @hostname
57
+ args << "--username=#{@username}" if @username
58
58
  args << '--no-password'
59
59
  args << database
60
60
  args << @options
@@ -79,12 +79,13 @@ module Masamune::Commands
79
79
 
80
80
  def database
81
81
  return @database unless @action == :dump
82
- '--dbname=%s' % @database
82
+ "--dbname=#{@database}"
83
83
  end
84
84
 
85
85
  def output
86
86
  return unless @action == :dump
87
- '--file=%s' % @output if @output
87
+ return unless @output
88
+ "--file=#{@output}"
88
89
  end
89
90
  end
90
91
  end
@@ -23,7 +23,7 @@
23
23
  module Masamune::Commands
24
24
  module PostgresCommon
25
25
  def command_env
26
- { 'PGOPTIONS'=> '--client-min-messages=warning' }.tap do |env|
26
+ { 'PGOPTIONS' => '--client-min-messages=warning' }.tap do |env|
27
27
  if @pgpass_file && File.readable?(@pgpass_file)
28
28
  env['PGPASSFILE'] = @pgpass_file
29
29
  end
@@ -35,25 +35,25 @@ module Masamune::Commands
35
35
  end
36
36
 
37
37
  def around_execute(&block)
38
- begin
39
- status = if @delegate.respond_to?(:around_execute)
40
- @delegate.around_execute(&block)
41
- else
42
- block.call
43
- end
44
- raise "exited with code: #{status.exitstatus}" unless status.success?
45
- status
46
- rescue => e
47
- logger.error(e.to_s)
48
- sleep @backoff
49
- @retry_count += 1
50
- unless @retry_count > @retries
51
- logger.debug("retrying (#{@retry_count}/#{@retries})")
52
- retry
53
- else
54
- logger.debug("max retries (#{@retries}) attempted, bailing")
55
- OpenStruct.new(:success? => false, :exitstatus => MAX_RETRY_EXIT_STATUS)
56
- end
38
+ status =
39
+ if @delegate.respond_to?(:around_execute)
40
+ @delegate.around_execute(&block)
41
+ else
42
+ yield
43
+ end
44
+
45
+ raise "exited with code: #{status.exitstatus}" unless status.success?
46
+ status
47
+ rescue => e
48
+ logger.error(e.to_s)
49
+ sleep @backoff
50
+ @retry_count += 1
51
+ if @retry_count > @retries
52
+ logger.debug("max retries (#{@retries}) attempted, bailing")
53
+ OpenStruct.new(success?: false, exitstatus: MAX_RETRY_EXIT_STATUS)
54
+ else
55
+ logger.debug("retrying (#{@retry_count}/#{@retries})")
56
+ retry
57
57
  end
58
58
  end
59
59
  end