masamune 0.17.15 → 0.18.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/masamune/actions/aws_emr.rb +5 -5
  3. data/lib/masamune/actions/hadoop_filesystem.rb +1 -1
  4. data/lib/masamune/actions/hadoop_streaming.rb +3 -3
  5. data/lib/masamune/actions/hive.rb +5 -5
  6. data/lib/masamune/actions/postgres.rb +5 -5
  7. data/lib/masamune/actions/s3cmd.rb +1 -1
  8. data/lib/masamune/cached_filesystem.rb +1 -1
  9. data/lib/masamune/commands/aws_emr.rb +11 -11
  10. data/lib/masamune/commands/hadoop_filesystem.rb +8 -8
  11. data/lib/masamune/commands/hadoop_streaming.rb +2 -2
  12. data/lib/masamune/commands/hive.rb +19 -19
  13. data/lib/masamune/commands/postgres.rb +19 -19
  14. data/lib/masamune/commands/postgres_admin.rb +13 -13
  15. data/lib/masamune/commands/s3cmd.rb +7 -7
  16. data/lib/masamune/configuration.rb +36 -52
  17. data/lib/masamune/environment.rb +4 -3
  18. data/lib/masamune/method_logger.rb +4 -0
  19. data/lib/masamune/schema/store.rb +17 -5
  20. data/lib/masamune/thor.rb +1 -3
  21. data/lib/masamune/version.rb +1 -1
  22. data/spec/masamune/actions/aws_emr_spec.rb +4 -4
  23. data/spec/masamune/actions/hadoop_filesystem_spec.rb +1 -1
  24. data/spec/masamune/actions/hadoop_streaming_spec.rb +5 -5
  25. data/spec/masamune/actions/hive_spec.rb +4 -4
  26. data/spec/masamune/actions/postgres_spec.rb +2 -2
  27. data/spec/masamune/actions/s3cmd_spec.rb +1 -1
  28. data/spec/masamune/commands/aws_emr_spec.rb +1 -1
  29. data/spec/masamune/commands/hadoop_filesystem_spec.rb +1 -1
  30. data/spec/masamune/commands/hadoop_streaming_spec.rb +1 -1
  31. data/spec/masamune/commands/hive_spec.rb +1 -1
  32. data/spec/masamune/commands/postgres_admin_spec.rb +15 -2
  33. data/spec/masamune/commands/postgres_spec.rb +1 -1
  34. data/spec/masamune/commands/s3cmd_spec.rb +1 -1
  35. data/spec/masamune/configuration_spec.rb +96 -1
  36. data/spec/masamune/environment_spec.rb +28 -1
  37. data/spec/masamune/schema/catalog_spec.rb +1 -1
  38. data/spec/masamune/tasks/aws_emr_thor_spec.rb +2 -2
  39. data/spec/masamune/tasks/hive_thor_spec.rb +7 -7
  40. data/spec/masamune/tasks/postgres_thor_spec.rb +4 -4
  41. data/spec/masamune/tasks/shell_thor_spec.rb +1 -1
  42. data/spec/masamune/thor_spec.rb +8 -13
  43. data/spec/support/masamune/example_group.rb +4 -3
  44. data/spec/support/masamune/job_example_group.rb +26 -27
  45. data/spec/support/masamune/mock_command.rb +3 -3
  46. data/spec/support/masamune/shared_example_group.rb +8 -10
  47. data/spec/support/masamune/step_example_group.rb +25 -28
  48. data/spec/support/masamune/task_example_group.rb +75 -28
  49. data/spec/support/masamune/thor_mute.rb +4 -2
  50. data/spec/support/rspec/example/action_example_group.rb +5 -3
  51. data/spec/support/rspec/example/task_example_group.rb +4 -67
  52. data/spec/support/rspec/example/transform_example_group.rb +7 -5
  53. metadata +16 -2
@@ -20,38 +20,85 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
+ require_relative 'shared_example_group'
24
+
23
25
  module Masamune::TaskExampleGroup
24
- module TaskFixtureContent
25
- shared_context 'task_fixture' do |context_options = {}|
26
- include_context 'job_fixture', context_options
27
- let!(:default_options) { configuration.as_options }
28
-
29
- let(:stdout) { @stdout }
30
- let(:stderr) { @stderr }
31
-
32
- let(:command) { nil }
33
- let(:options) { [] }
34
-
35
- subject(:execute_command) do
36
- n = context_options.fetch(:idempotent, false) ? 2 : 1
37
- n = 1 if ENV['MASAMUNE_FASTER_SPEC']
38
- capture(!default_options.include?('--debug')) do
39
- n.times do
40
- Array.wrap(command).each do |cmd|
41
- described_class.start([cmd, *(default_options + options)].compact)
42
- end
43
- end
44
- end
45
- end
26
+ extend ActiveSupport::Concern
27
+
28
+ include Masamune::ExampleGroup
29
+ include Masamune::SharedExampleGroup
30
+ include Masamune::Actions::Filesystem
31
+ include Masamune::Actions::Hive
32
+ include Masamune::Transform::DenormalizeTable
33
+
34
+ shared_examples 'general usage' do
35
+ it 'exits with status code 0 and prints general usage' do
36
+ expect { execute_command }.to raise_error { |e|
37
+ expect(e).to be_a(SystemExit)
38
+ expect(e.status).to eq(0)
39
+ }
40
+ expect(stdout.string).to match(/^Commands:/)
41
+ expect(stderr.string).to be_blank
46
42
  end
47
43
  end
48
44
 
49
- def self.included(base)
50
- base.send(:include, Masamune::ExampleGroup)
51
- base.send(:include, Masamune::Actions::Filesystem)
52
- base.send(:include, Masamune::Actions::Hive)
53
- base.send(:include, Masamune::Transform::DenormalizeTable)
54
- base.send(:include, TaskFixtureContent)
45
+ shared_examples 'command usage' do
46
+ it 'exits with status code 0 and prints command usage' do
47
+ expect { execute_command }.to raise_error { |e|
48
+ expect(e).to be_a(SystemExit)
49
+ expect(e.status).to eq(0)
50
+ }
51
+ expect(stdout.string).to match(/^Usage:/)
52
+ expect(stdout.string).to match(/^Options:/)
53
+ expect(stderr.string).to be_blank
54
+ end
55
+ end
56
+
57
+ shared_examples 'executes with success' do
58
+ it 'exits with status code 0' do
59
+ expect { execute_command }.to raise_error { |e|
60
+ expect(e).to be_a(SystemExit)
61
+ expect(e.status).to eq(0)
62
+ }
63
+ end
64
+ end
65
+
66
+ shared_examples 'raises Thor::MalformattedArgumentError' do |message|
67
+ it { expect { execute_command }.to raise_error Thor::MalformattedArgumentError, message }
68
+ end
69
+
70
+ shared_examples 'raises Thor::RequiredArgumentMissingError' do |message|
71
+ it { expect { execute_command }.to raise_error Thor::RequiredArgumentMissingError, message }
72
+ end
73
+
74
+ shared_context 'task_fixture' do |context_options = {}|
75
+ include_context 'job_fixture', context_options
76
+
77
+ let(:execute_command_times) { !ENV['MASAMUNE_FASTER_SPEC'] && context_options.fetch(:idempotent, false) ? 2 : 1 }
78
+ end
79
+
80
+ included do
81
+ let!(:default_options) { configuration.as_options }
82
+
83
+ let(:thor_class) { described_class }
84
+ let(:command) { nil }
85
+ let(:options) { [] }
86
+ let!(:stdout) { StringIO.new }
87
+ let!(:stderr) { StringIO.new }
88
+
89
+ let(:execute_command_times) { 1 }
90
+
91
+ before do
92
+ thor_class.send(:include, Masamune::ThorMute)
93
+ end
94
+
95
+ subject(:execute_command) do
96
+ capture(stdout: stdout, stderr: stderr, enable: !default_options.include?('--debug')) do
97
+ execute_command_times.times do
98
+ thor_class.start([command, *(default_options + options)].compact)
99
+ end
100
+ end
101
+ end
55
102
  end
56
103
  end
57
104
 
@@ -22,8 +22,10 @@
22
22
 
23
23
  # Silence noisy and uninformative create_command method
24
24
  module Masamune::ThorMute
25
- def self.included(base)
26
- base.instance_eval do
25
+ extend ActiveSupport::Concern
26
+
27
+ included do
28
+ instance_eval do
27
29
  def create_command(*a)
28
30
  tmp_stdout = $stdout
29
31
  $stdout = StringIO.new
@@ -21,9 +21,11 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module ActionExampleGroup
24
- def self.included(base)
25
- base.let(:run_dir) { Dir.mktmpdir('masamune') }
26
- base.before do
24
+ extend ActiveSupport::Concern
25
+
26
+ included do
27
+ let(:run_dir) { Dir.mktmpdir('masamune') }
28
+ before do
27
29
  instance.environment = Masamune::ExampleGroup
28
30
  Masamune::ExampleGroup.filesystem.add_path(:run_dir, run_dir)
29
31
  end
@@ -21,78 +21,15 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module TaskExampleGroup
24
- def capture(stdout, stderr)
25
- tmp_stdout = $stdout
26
- $stdout = stdout
27
- tmp_stderr = $stderr
28
- $stderr = stderr
29
- yield
30
- ensure
31
- $stdout = tmp_stdout
32
- $stderr = tmp_stderr
33
- end
34
-
35
- shared_examples 'general usage' do
36
- it 'exits with status code 0 and prints general usage' do
37
- expect { cli_invocation }.to raise_error { |e|
38
- expect(e).to be_a(SystemExit)
39
- expect(e.status).to eq(0)
40
- }
41
- expect(stdout.string).to match(/^Commands:/)
42
- expect(stderr.string).to be_blank
43
- end
44
- end
45
-
46
- shared_examples 'command usage' do
47
- it 'exits with status code 0 and prints command usage' do
48
- expect { cli_invocation }.to raise_error { |e|
49
- expect(e).to be_a(SystemExit)
50
- expect(e.status).to eq(0)
51
- }
52
- expect(stdout.string).to match(/^Usage:/)
53
- expect(stdout.string).to match(/^Options:/)
54
- expect(stderr.string).to be_blank
55
- end
56
- end
57
-
58
- shared_examples 'executes with success' do
59
- it 'exits with status code 0' do
60
- expect { cli_invocation }.to raise_error { |e|
61
- expect(e).to be_a(SystemExit)
62
- expect(e.status).to eq(0)
63
- }
64
- end
65
- end
24
+ extend ActiveSupport::Concern
66
25
 
67
- shared_examples 'raises Thor::MalformattedArgumentError' do |message|
68
- it { expect { cli_invocation }.to raise_error Thor::MalformattedArgumentError, message }
69
- end
26
+ include Masamune::TaskExampleGroup
70
27
 
71
- shared_examples 'raises Thor::RequiredArgumentMissingError' do |message|
72
- it { expect { cli_invocation }.to raise_error Thor::RequiredArgumentMissingError, message }
73
- end
74
-
75
- def self.included(base)
76
- base.before :all do
28
+ included do
29
+ before :all do
77
30
  ENV['THOR_DEBUG'] = '1'
78
31
  Masamune::Actions::DataFlow.reset_module!
79
32
  end
80
-
81
- base.let(:thor_class) { described_class }
82
- base.let(:command) { nil }
83
- base.let(:options) { {} }
84
- base.let!(:stdout) { StringIO.new }
85
- base.let!(:stderr) { StringIO.new }
86
-
87
- base.before do
88
- thor_class.send(:include, Masamune::ThorMute)
89
- end
90
-
91
- base.subject(:cli_invocation) do
92
- capture(stdout, stderr) do
93
- thor_class.start([command, *options].compact)
94
- end
95
- end
96
33
  end
97
34
  end
98
35
 
@@ -21,11 +21,13 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module TransformExampleGroup
24
- def self.included(base)
25
- base.let(:transform) { Object.new.extend(described_class) }
26
- base.let(:environment) { double }
27
- base.let(:catalog) { Masamune::Schema::Catalog.new(environment) }
28
- base.after do
24
+ extend ActiveSupport::Concern
25
+
26
+ included do
27
+ let(:transform) { Object.new.extend(described_class) }
28
+ let(:environment) { double }
29
+ let(:catalog) { Masamune::Schema::Catalog.new(environment) }
30
+ after do
29
31
  catalog.clear!
30
32
  end
31
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: masamune
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.15
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Andrews
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: hashie
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
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: rake
141
155
  requirement: !ruby/object:Gem::Requirement