masamune 0.17.12 → 0.17.13

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -21,7 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  describe Masamune::Commands::HadoopFilesystem do
24
- let(:configuration) { {options: options} }
24
+ let(:configuration) { { options: options } }
25
25
  let(:options) { [] }
26
26
  let(:attrs) { {} }
27
27
 
@@ -33,14 +33,14 @@ describe Masamune::Commands::HadoopFilesystem do
33
33
  end
34
34
 
35
35
  describe '#command_args' do
36
- let(:attrs) { {extra: ['-ls', '/']} }
36
+ let(:attrs) { { extra: ['-ls', '/'] } }
37
37
 
38
38
  subject { instance.command_args }
39
39
 
40
40
  it { is_expected.to eq(['hadoop', 'fs', '-ls', '/']) }
41
41
 
42
42
  context 'with options' do
43
- let(:options) { [{'--conf' => 'hadoop.conf'}] }
43
+ let(:options) { [{ '--conf' => 'hadoop.conf' }] }
44
44
 
45
45
  it { is_expected.to eq(['hadoop', 'fs', '--conf', 'hadoop.conf', '-ls', '/']) }
46
46
  end
@@ -23,10 +23,10 @@
23
23
  describe Masamune::Commands::HadoopStreaming do
24
24
  let(:filesystem) { Masamune::MockFilesystem.new }
25
25
 
26
- let(:configuration) { {options: options, input: input_option, output: 'output_dir', mapper: 'mapper.rb', reducer: 'reducer.rb', extra: extra} }
26
+ let(:configuration) { { options: options, input: input_option, output: 'output_dir', mapper: 'mapper.rb', reducer: 'reducer.rb', extra: extra } }
27
27
  let(:options) { [] }
28
28
  let(:input_option) { 'input.txt' }
29
- let(:extra) { ['-D', %q(map.output.key.field.separator='\t')] }
29
+ let(:extra) { ['-D', 'map.output.key.field.separator=\'\t\''] }
30
30
  let(:attrs) { {} }
31
31
 
32
32
  let(:delegate) { double }
@@ -87,13 +87,13 @@ describe Masamune::Commands::HadoopStreaming do
87
87
  it { is_expected.to eq(pre_command_args + extra + post_command_args) }
88
88
 
89
89
  context 'with options' do
90
- let(:options) { [{'-cacheFile' => 'cache.rb'}] }
90
+ let(:options) { [{ '-cacheFile' => 'cache.rb' }] }
91
91
 
92
92
  it { is_expected.to eq(pre_command_args + extra + options.map(&:to_a).flatten + post_command_args) }
93
93
  end
94
94
 
95
95
  context 'with quote' do
96
- let(:attrs) { {quote: true} }
96
+ let(:attrs) { { quote: true } }
97
97
  let(:quoted_extra) { ['-D', %q(map.output.key.field.separator='"'\\\\t'"')] }
98
98
 
99
99
  subject { instance.command_args }
@@ -22,7 +22,7 @@
22
22
 
23
23
  describe Masamune::Commands::Hive do
24
24
  let(:filesystem) { Masamune::MockFilesystem.new }
25
- let(:configuration) { {:options => options} }
25
+ let(:configuration) { { options: options } }
26
26
  let(:options) { [] }
27
27
  let(:attrs) { {} }
28
28
 
@@ -55,17 +55,17 @@ describe Masamune::Commands::Hive do
55
55
  it { is_expected.to eq(default_command) }
56
56
 
57
57
  context 'with command attrs' do
58
- let(:options) { [{'-d' => 'DATABASE=development'}] }
58
+ let(:options) { [{ '-d' => 'DATABASE=development' }] }
59
59
  it { is_expected.to eq([*default_command, '-d', 'DATABASE=development']) }
60
60
  end
61
61
 
62
62
  context 'with file' do
63
- let(:attrs) { {file: local_file} }
63
+ let(:attrs) { { file: local_file } }
64
64
  it { is_expected.to eq([*default_command, '-f', remote_file]) }
65
65
  end
66
66
 
67
67
  context 'with file and debug' do
68
- let(:attrs) { {file: local_file, debug: true} }
68
+ let(:attrs) { { file: local_file, debug: true } }
69
69
  before do
70
70
  expect(File).to receive(:read).with(local_file).and_return('SHOW TABLES;')
71
71
  expect(instance.logger).to receive(:debug).with("#{local_file}:\nSHOW TABLES;")
@@ -74,7 +74,7 @@ describe Masamune::Commands::Hive do
74
74
  end
75
75
 
76
76
  context 'with exec' do
77
- let(:attrs) { {exec: 'SELECT * FROM table;'} }
77
+ let(:attrs) { { exec: 'SELECT * FROM table;' } }
78
78
  before do
79
79
  expect(instance).to receive(:exec_file).and_return(remote_file)
80
80
  end
@@ -82,12 +82,12 @@ describe Masamune::Commands::Hive do
82
82
  end
83
83
 
84
84
  context 'with file and exec' do
85
- let(:attrs) { {file: local_file, exec: 'SELECT * FROM table;'} }
85
+ let(:attrs) { { file: local_file, exec: 'SELECT * FROM table;' } }
86
86
  it { expect { instance }.to raise_error ArgumentError, 'Cannot specify both file and exec' }
87
87
  end
88
88
 
89
89
  context 'with variables' do
90
- let(:attrs) { {file: local_file, variables: {R: 'R2DO', C: 'C3PO'}} }
90
+ let(:attrs) { { file: local_file, variables: { R: 'R2DO', C: 'C3PO' } } }
91
91
  it { is_expected.to eq([*default_command, '-f', remote_file, '-d', 'R=R2DO', '-d', 'C=C3PO']) }
92
92
  end
93
93
 
@@ -96,12 +96,12 @@ describe Masamune::Commands::Hive do
96
96
  filesystem.touch!('setup_a.hql', 'setup_b.hql')
97
97
  end
98
98
 
99
- let(:attrs) { {setup_files: ['setup_a.hql', 'setup_b.hql']} }
99
+ let(:attrs) { { setup_files: ['setup_a.hql', 'setup_b.hql'] } }
100
100
  it { is_expected.to eq([*default_command, '-i', 'setup_a.hql', '-i', 'setup_b.hql']) }
101
101
  end
102
102
 
103
103
  context 'with template file' do
104
- let(:attrs) { {file: 'zomg.hql.erb'} }
104
+ let(:attrs) { { file: 'zomg.hql.erb' } }
105
105
  before do
106
106
  expect(Masamune::Template).to receive(:render_to_file).with('zomg.hql.erb', {}).and_return('zomg.hql')
107
107
  expect_any_instance_of(Masamune::MockFilesystem).to receive(:copy_file_to_file)
@@ -110,7 +110,7 @@ describe Masamune::Commands::Hive do
110
110
  end
111
111
 
112
112
  context 'with template file and debug' do
113
- let(:attrs) { {file: 'zomg.hql.erb', debug: true} }
113
+ let(:attrs) { { file: 'zomg.hql.erb', debug: true } }
114
114
  before do
115
115
  expect(Masamune::Template).to receive(:render_to_file).with('zomg.hql.erb', {}).and_return('zomg.hql')
116
116
  expect(File).to receive(:read).with('zomg.hql').and_return('SHOW TABLES;')
@@ -124,7 +124,7 @@ describe Masamune::Commands::Hive do
124
124
  describe '#handle_stdout' do
125
125
  let(:buffer) { StringIO.new }
126
126
  let(:delimiter) { "\t" }
127
- let(:attrs) { {buffer: buffer, delimiter: delimiter, csv: true} }
127
+ let(:attrs) { { buffer: buffer, delimiter: delimiter, csv: true } }
128
128
 
129
129
  context 'encode NULL' do
130
130
  let(:input_row) { ['A', 'NULL', 'B', 'C', '', 'E'].join(delimiter) }
@@ -21,7 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  describe Masamune::Commands::PostgresAdmin do
24
- let(:configuration) { {:create_db_path => 'createdb', :drop_db_path => 'dropdb', :hostname => 'localhost', :username => 'postgres'} }
24
+ let(:configuration) { { create_db_path: 'createdb', drop_db_path: 'dropdb', hostname: 'localhost', username: 'postgres' } }
25
25
  let(:attrs) { {} }
26
26
 
27
27
  let(:delegate) { double }
@@ -38,42 +38,42 @@ describe Masamune::Commands::PostgresAdmin do
38
38
  end
39
39
 
40
40
  context 'action :create with database' do
41
- let(:attrs) { {action: :create, database: 'zombo'} }
41
+ let(:attrs) { { action: :create, database: 'zombo' } }
42
42
  it { is_expected.to eq(['createdb', '--host=localhost', '--username=postgres', '--no-password', 'zombo']) }
43
43
  end
44
44
 
45
45
  context 'action :create without database' do
46
- let(:attrs) { {action: :create} }
46
+ let(:attrs) { { action: :create } }
47
47
  it { expect { subject }.to raise_error ArgumentError, ':database must be given' }
48
48
  end
49
49
 
50
50
  context 'action :drop with database' do
51
- let(:attrs) { {action: :drop, database: 'zombo'} }
51
+ let(:attrs) { { action: :drop, database: 'zombo' } }
52
52
  it { is_expected.to eq(['dropdb', '--if-exists', '--host=localhost', '--username=postgres', '--no-password', 'zombo']) }
53
53
  end
54
54
 
55
55
  context 'action :drop with database and :output' do
56
- let(:attrs) { {action: :drop, database: 'zombo', output: 'zombo.csv'} }
56
+ let(:attrs) { { action: :drop, database: 'zombo', output: 'zombo.csv' } }
57
57
  it { is_expected.to eq(['dropdb', '--if-exists', '--host=localhost', '--username=postgres', '--no-password', 'zombo']) }
58
58
  end
59
59
 
60
60
  context 'action :dump with database' do
61
- let(:attrs) { {action: :dump, database: 'zombo'} }
61
+ let(:attrs) { { action: :dump, database: 'zombo' } }
62
62
  it { is_expected.to eq(['pg_dump', '--no-owner', '--no-privileges', '--oids', '--schema=public', '--host=localhost', '--username=postgres', '--no-password', '--dbname=zombo']) }
63
63
  end
64
64
 
65
65
  context 'action :dump with database and :output' do
66
- let(:attrs) { {action: :dump, database: 'zombo', output: 'zombo.csv'} }
66
+ let(:attrs) { { action: :dump, database: 'zombo', output: 'zombo.csv' } }
67
67
  it { is_expected.to eq(['pg_dump', '--no-owner', '--no-privileges', '--oids', '--schema=public', '--host=localhost', '--username=postgres', '--no-password', '--dbname=zombo', '--file=zombo.csv']) }
68
68
  end
69
69
 
70
70
  context 'action :drop without database' do
71
- let(:attrs) { {action: :drop} }
71
+ let(:attrs) { { action: :drop } }
72
72
  it { expect { subject }.to raise_error ArgumentError, ':database must be given' }
73
73
  end
74
74
 
75
75
  context 'action unfuddle with database' do
76
- let(:attrs) { {action: :unfuddle, database: 'zombo'} }
76
+ let(:attrs) { { action: :unfuddle, database: 'zombo' } }
77
77
  it { expect { subject }.to raise_error ArgumentError, ':action must be :create, :drop, or :dump' }
78
78
  end
79
79
  end
@@ -21,7 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  describe Masamune::Commands::Postgres do
24
- let(:configuration) { {:path => 'psql', :database => 'postgres', :options => options} }
24
+ let(:configuration) { { path: 'psql', database: 'postgres', options: options } }
25
25
  let(:options) { [] }
26
26
  let(:attrs) { {} }
27
27
 
@@ -36,14 +36,14 @@ describe Masamune::Commands::Postgres do
36
36
 
37
37
  describe '#stdin' do
38
38
  context 'with input' do
39
- let(:attrs) { {input: %q(SELECT * FROM table;)} }
39
+ let(:attrs) { { input: 'SELECT * FROM table;' } }
40
40
  subject(:stdin) { instance.stdin }
41
41
 
42
42
  it { is_expected.to be_a(StringIO) }
43
43
 
44
44
  describe '#string' do
45
45
  subject { stdin.string }
46
- it { is_expected.to eq(%q(SELECT * FROM table;)) }
46
+ it { is_expected.to eq('SELECT * FROM table;') }
47
47
  end
48
48
  end
49
49
  end
@@ -59,12 +59,12 @@ describe Masamune::Commands::Postgres do
59
59
  it { is_expected.to eq(default_command) }
60
60
 
61
61
  context 'with options' do
62
- let(:options) { [{'-A' => nil}] }
62
+ let(:options) { [{ '-A' => nil }] }
63
63
  it { is_expected.to eq([*default_command, '-A']) }
64
64
  end
65
65
 
66
66
  context 'with exec' do
67
- let(:attrs) { {exec: 'SELECT * FROM table;'} }
67
+ let(:attrs) { { exec: 'SELECT * FROM table;' } }
68
68
  before do
69
69
  expect(instance).to receive(:exec_file).and_return('zomg.psql')
70
70
  end
@@ -72,12 +72,12 @@ describe Masamune::Commands::Postgres do
72
72
  end
73
73
 
74
74
  context 'with file' do
75
- let(:attrs) { {file: 'zomg.psql'} }
75
+ let(:attrs) { { file: 'zomg.psql' } }
76
76
  it { is_expected.to eq([*default_command, '--file=zomg.psql']) }
77
77
  end
78
78
 
79
79
  context 'with file and debug' do
80
- let(:attrs) { {file: 'zomg.psql', debug: true} }
80
+ let(:attrs) { { file: 'zomg.psql', debug: true } }
81
81
  before do
82
82
  expect(File).to receive(:read).with('zomg.psql').and_return('SHOW TABLES;')
83
83
  expect(instance.logger).to receive(:debug).with("zomg.psql:\nSHOW TABLES;")
@@ -86,12 +86,12 @@ describe Masamune::Commands::Postgres do
86
86
  end
87
87
 
88
88
  context 'with file and exec' do
89
- let(:attrs) { {file: 'zomg.psql', exec: 'SELECT * FROM table;'} }
89
+ let(:attrs) { { file: 'zomg.psql', exec: 'SELECT * FROM table;' } }
90
90
  it { expect { subject }.to raise_error(/Cannot specify both file and exec/) }
91
91
  end
92
92
 
93
93
  context 'with template file' do
94
- let(:attrs) { {file: 'zomg.psql.erb'} }
94
+ let(:attrs) { { file: 'zomg.psql.erb' } }
95
95
  before do
96
96
  expect(Masamune::Template).to receive(:render_to_file).with('zomg.psql.erb', {}).and_return('zomg.psql')
97
97
  end
@@ -99,7 +99,7 @@ describe Masamune::Commands::Postgres do
99
99
  end
100
100
 
101
101
  context 'with template file and debug' do
102
- let(:attrs) { {file: 'zomg.psql.erb', debug: true} }
102
+ let(:attrs) { { file: 'zomg.psql.erb', debug: true } }
103
103
  before do
104
104
  expect(Masamune::Template).to receive(:render_to_file).with('zomg.psql.erb', {}).and_return('zomg.psql')
105
105
  expect(File).to receive(:read).with('zomg.psql').and_return('SHOW TABLES;')
@@ -109,22 +109,22 @@ describe Masamune::Commands::Postgres do
109
109
  end
110
110
 
111
111
  context 'with variables and no file' do
112
- let(:attrs) { {variables: {R: 'R2D2', C: 'C3PO'}} }
112
+ let(:attrs) { { variables: { R: 'R2D2', C: 'C3PO' } } }
113
113
  it { is_expected.to eq(default_command) }
114
114
  end
115
115
 
116
116
  context 'with variables and file' do
117
- let(:attrs) { {file: 'zomg.psql', variables: {R: 'R2D2', C: 'C3PO'}} }
118
- it { is_expected.to eq([*default_command, '--file=zomg.psql', %q(--set=R='R2D2'), %q(--set=C='C3PO')]) }
117
+ let(:attrs) { { file: 'zomg.psql', variables: { R: 'R2D2', C: 'C3PO' } } }
118
+ it { is_expected.to eq([*default_command, '--file=zomg.psql', "--set=R='R2D2'", "--set=C='C3PO'"]) }
119
119
  end
120
120
 
121
121
  context 'with csv' do
122
- let(:attrs) { {csv: true} }
122
+ let(:attrs) { { csv: true } }
123
123
  it { is_expected.to eq([*default_command, '--no-align', '--field-separator=,', '--pset=footer']) }
124
124
  end
125
125
 
126
126
  context 'with tuple_output' do
127
- let(:attrs) { {tuple_output: true} }
127
+ let(:attrs) { { tuple_output: true } }
128
128
  it { is_expected.to eq([*default_command, '--pset=tuples_only']) }
129
129
  end
130
130
  end
@@ -21,7 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  describe Masamune::Commands::RetryWithBackoff do
24
- let(:options) { {retries: retries, backoff: 0} }
24
+ let(:options) { { retries: retries, backoff: 0 } }
25
25
  let(:delegate) { double }
26
26
  let(:instance) { described_class.new(delegate, options) }
27
27
 
@@ -45,14 +45,15 @@ describe Masamune::Commands::RetryWithBackoff do
45
45
  instance.around_execute do
46
46
  @retry_count += 1
47
47
  if @retry_count < retries
48
- OpenStruct.new(:success? => false, :exitstatus => 42)
48
+ OpenStruct.new(success?: false, exitstatus: 42)
49
49
  else
50
- OpenStruct.new(:success? => true)
50
+ OpenStruct.new(success?: true)
51
51
  end
52
52
  end
53
53
  end
54
54
 
55
- it 'logs useful debug and error messages' do; end
55
+ it 'logs useful debug and error messages' do
56
+ end
56
57
  it 'attempts to retry the specified number of times' do
57
58
  expect(@retry_count).to eq(retries)
58
59
  end
@@ -73,11 +74,12 @@ describe Masamune::Commands::RetryWithBackoff do
73
74
  instance.around_execute do
74
75
  @retry_count += 1
75
76
  raise 'wtf' if @retry_count < retries
76
- OpenStruct.new(:success? => true)
77
+ OpenStruct.new(success?: true)
77
78
  end
78
79
  end
79
80
 
80
- it 'logs useful debug and error messages' do; end
81
+ it 'logs useful debug and error messages' do
82
+ end
81
83
  it 'attempts to retry the specified number of times' do
82
84
  expect(@retry_count).to eq(retries)
83
85
  end
@@ -102,7 +104,8 @@ describe Masamune::Commands::RetryWithBackoff do
102
104
  end
103
105
  end
104
106
 
105
- it 'logs useful debug and error messages' do; end
107
+ it 'logs useful debug and error messages' do
108
+ end
106
109
  it 'attempts to retry the specified number of times' do
107
110
  expect(@retry_count).to eq(retries + 1)
108
111
  end
@@ -21,7 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  describe Masamune::Commands::S3Cmd do
24
- let(:configuration) { {:options => options} }
24
+ let(:configuration) { { options: options } }
25
25
  let(:options) { [] }
26
26
  let(:attrs) { {} }
27
27
 
@@ -33,14 +33,14 @@ describe Masamune::Commands::S3Cmd do
33
33
  end
34
34
 
35
35
  describe '#command_args' do
36
- let(:attrs) { {extra: ['ls', 's3://fake']} }
36
+ let(:attrs) { { extra: ['ls', 's3://fake'] } }
37
37
 
38
38
  subject { instance.command_args }
39
39
 
40
40
  it { is_expected.to eq(['s3cmd', 'ls', 's3://fake']) }
41
41
 
42
42
  context 'with options' do
43
- let(:options) { [{'--config' => '/opt/etc/etl/s3cfg'}] }
43
+ let(:options) { [{ '--config' => '/opt/etc/etl/s3cfg' }] }
44
44
 
45
45
  it { is_expected.to eq(['s3cmd', '--config', '/opt/etc/etl/s3cfg', 'ls', 's3://fake']) }
46
46
  end
@@ -22,7 +22,7 @@
22
22
 
23
23
  describe Masamune::Commands::Shell do
24
24
  let(:input) { nil }
25
- let(:options) { {fail_fast: false} }
25
+ let(:options) { { fail_fast: false } }
26
26
  let(:delegate) { double }
27
27
  let(:instance) { described_class.new(delegate, options) }
28
28
 
@@ -34,7 +34,7 @@ describe Masamune::Commands::Shell do
34
34
  end
35
35
 
36
36
  context 'with simple command that succeeds' do
37
- let(:command) { %Q{bash -c "echo 'stdout 1'; echo 'stderr 1' 1>&2; echo 'stdout 2'; echo 'stderr 2' 1>&2"} }
37
+ let(:command) { %(bash -c "echo 'stdout 1'; echo 'stderr 1' 1>&2; echo 'stdout 2'; echo 'stderr 2' 1>&2") }
38
38
 
39
39
  before do
40
40
  expect(instance.logger).to receive(:debug).with(/\Aexecute: TZ=UTC bash -c .*\z/)
@@ -48,10 +48,10 @@ describe Masamune::Commands::Shell do
48
48
  end
49
49
 
50
50
  context 'with simple command that fails' do
51
- let(:command) { %Q{bash -c 'exit 1'} }
51
+ let(:command) { %(bash -c 'exit 1') }
52
52
 
53
53
  before do
54
- expect(instance.logger).to receive(:debug).with(%q(execute: TZ=UTC bash -c 'exit 1'))
54
+ expect(instance.logger).to receive(:debug).with("execute: TZ=UTC bash -c 'exit 1'")
55
55
  expect(instance.logger).to receive(:debug).with(/\Astatus: .* exit 1\z/)
56
56
  subject
57
57
  end
@@ -62,11 +62,11 @@ describe Masamune::Commands::Shell do
62
62
  end
63
63
 
64
64
  context 'with fail_fast and simple command that fails' do
65
- let(:command) { %Q{bash -c 'exit 1'} }
66
- let(:options) { {fail_fast: true} }
65
+ let(:command) { %(bash -c 'exit 1') }
66
+ let(:options) { { fail_fast: true } }
67
67
 
68
68
  before do
69
- expect(instance.logger).to receive(:debug).with(%q(execute: TZ=UTC bash -c 'exit 1'))
69
+ expect(instance.logger).to receive(:debug).with("execute: TZ=UTC bash -c 'exit 1'")
70
70
  expect(instance.logger).to receive(:debug).with(/\Astatus: .* exit 1\z/)
71
71
  end
72
72
 
@@ -74,12 +74,12 @@ describe Masamune::Commands::Shell do
74
74
  end
75
75
 
76
76
  context 'with fail_fast and simple command that fails and delegate.failure_message' do
77
- let(:command) { %Q{bash -c 'exit 1'} }
78
- let(:options) { {fail_fast: true} }
77
+ let(:command) { %(bash -c 'exit 1') }
78
+ let(:options) { { fail_fast: true } }
79
79
 
80
80
  before do
81
81
  allow(delegate).to receive(:failure_message).and_return('Wha happen')
82
- expect(instance.logger).to receive(:debug).with(%q(execute: TZ=UTC bash -c 'exit 1'))
82
+ expect(instance.logger).to receive(:debug).with("execute: TZ=UTC bash -c 'exit 1'")
83
83
  expect(instance.logger).to receive(:debug).with(/\Astatus: .* exit 1\z/)
84
84
  end
85
85
 
@@ -87,7 +87,7 @@ describe Masamune::Commands::Shell do
87
87
  end
88
88
 
89
89
  context 'when command is interrupted' do
90
- let(:command) { %Q{bash -c "echo 'test'"} }
90
+ let(:command) { %(bash -c "echo 'test'") }
91
91
 
92
92
  before do
93
93
  expect(instance.logger).to receive(:debug).with(%q(execute: TZ=UTC bash -c "echo 'test'"))
@@ -116,7 +116,7 @@ describe Masamune::Commands::Shell do
116
116
  end
117
117
 
118
118
  it { expect(delegate.status).to eq(0) }
119
- it { expect(delegate.stdout).to eq(['ping', 'pong']) }
119
+ it { expect(delegate.stdout).to eq(%w(ping pong)) }
120
120
  it { expect(delegate.stderr).to eq([]) }
121
121
  end
122
122
 
@@ -147,7 +147,7 @@ describe Masamune::Commands::Shell do
147
147
 
148
148
  context 'when delegate implements command_args' do
149
149
  before do
150
- allow(delegate).to receive(:command_args).and_return(command_args)
150
+ allow(delegate).to receive(:command_args).and_return(command_args)
151
151
  end
152
152
 
153
153
  context 'with nil command_args' do
@@ -172,17 +172,17 @@ describe Masamune::Commands::Shell do
172
172
 
173
173
  context 'with command_args containing nil' do
174
174
  let(:command_args) { ['echo', nil, 'foo'] }
175
- it { is_expected.to eq(['echo', 'foo']) }
175
+ it { is_expected.to eq(%w(echo foo)) }
176
176
  end
177
177
 
178
178
  context 'with command_args containing an integer' do
179
179
  let(:command_args) { ['echo', nil, 5] }
180
- it { is_expected.to eq(['echo', '5']) }
180
+ it { is_expected.to eq(%w(echo 5)) }
181
181
  end
182
182
 
183
183
  context 'with nested command_args' do
184
184
  let(:command_args) { [['echo'], ['foo']] }
185
- it { is_expected.to eq(['echo', 'foo']) }
185
+ it { is_expected.to eq(%w(echo foo)) }
186
186
  end
187
187
  end
188
188
  end