masamune 0.15.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7abad0d40705fd8c85b74398cf3ce198d6e1e0a3
4
- data.tar.gz: 049aeb65a25a01b8dca0a9db21d7e543e9eadae5
3
+ metadata.gz: 4dbe593ba3a215812769938a30319600a4d09dfd
4
+ data.tar.gz: ce90762802dc54af83d0f82fd17cf17d86d79fcf
5
5
  SHA512:
6
- metadata.gz: 5a8ef99944a527c5d0fde7b4875fc1d6541dd830060372fb47752a8a915f8d6bb7a3c359ad54c2592b2939c1bbc0ac1ea2c486f34c75fb31c7551524ef278963
7
- data.tar.gz: 3d44f7583a6048a70010c124b8f8c881163196b285ced0fbfe78cb0bc3858bcd3768bc3b3528f0bd8a8a9043060c8fb33f4a813bb472ffa3a751cd71bd0fbbbb
6
+ metadata.gz: b4ed08a3d39df015ad02fc4b7957f5d507f071a953d21d7e3431b2ba204f64c9d727890563ca81722570c45b904cc8d99e977f27fc95baf2bb6197cc49f714d3
7
+ data.tar.gz: f8105bc6cbdd055cbb897a7a4994d7c266dc4d258db006ae7f6fbe060fa0e0dfc45d83091a2b847c7159838fe474d682d43534938fef663cd93faa28a3f21929
@@ -41,7 +41,6 @@ module Masamune::Commands
41
41
  :schema_files => [],
42
42
  :file => nil,
43
43
  :exec => nil,
44
- :input => nil,
45
44
  :output => nil,
46
45
  :print => false,
47
46
  :block => nil,
@@ -60,12 +59,6 @@ module Masamune::Commands
60
59
  end
61
60
  end
62
61
 
63
- def stdin
64
- if @input || @exec
65
- @stdin ||= StringIO.new(strip_sql(@input || @exec))
66
- end
67
- end
68
-
69
62
  def interactive?
70
63
  !(@exec || @file)
71
64
  end
@@ -99,6 +92,7 @@ module Masamune::Commands
99
92
 
100
93
  if @exec
101
94
  console("hive exec '#{strip_sql(@exec)}' #{'into ' + @output if @output}")
95
+ @file = exec_file
102
96
  end
103
97
 
104
98
  if @output
@@ -174,5 +168,12 @@ module Masamune::Commands
174
168
  def remote_file
175
169
  @remote_file ||= File.join(filesystem.mktempdir!(:tmp_dir), filesystem.basename(@file)).gsub(/.erb\z/,'')
176
170
  end
171
+
172
+ def exec_file
173
+ Tempfile.new('masamune').tap do |tmp|
174
+ tmp.write(@exec)
175
+ tmp.flush
176
+ end.path
177
+ end
177
178
  end
178
179
  end
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Masamune
24
- VERSION = '0.15.0'
24
+ VERSION = '0.15.1'
25
25
  end
@@ -39,27 +39,15 @@ describe Masamune::Commands::Hive do
39
39
  allow(filesystem).to receive(:mktempdir!) { filesystem.path(:tmp_dir, mock_tmpdir) }
40
40
 
41
41
  allow(delegate).to receive(:filesystem) { filesystem }
42
+ allow(delegate).to receive(:console).and_return(double)
42
43
  allow(delegate).to receive_message_chain(:configuration, :hive).and_return(configuration)
43
44
  end
44
45
 
45
- describe '#stdin' do
46
- context 'with exec' do
47
- let(:attrs) { {exec: %q(SELECT * FROM table;)} }
48
- subject(:stdin) { instance.stdin }
49
-
50
- it { is_expected.to be_a(StringIO) }
51
-
52
- describe '#string' do
53
- subject { stdin.string }
54
- it { is_expected.to eq(%q(SELECT * FROM table;)) }
55
- end
56
- end
57
- end
58
-
59
46
  describe '#command_args' do
60
47
  let(:default_command) { ['hive', '--database', 'default'] }
61
48
 
62
49
  subject do
50
+ instance.before_execute
63
51
  instance.command_args
64
52
  end
65
53
 
@@ -75,6 +63,14 @@ describe Masamune::Commands::Hive do
75
63
  it { is_expected.to eq([*default_command, '-f', remote_file]) }
76
64
  end
77
65
 
66
+ context 'with exec' do
67
+ let(:attrs) { {exec: 'SELECT * FROM table;'} }
68
+ before do
69
+ expect_any_instance_of(Masamune::MockFilesystem).to receive(:basename).and_return(File.basename(local_file))
70
+ end
71
+ it { is_expected.to eq([*default_command, '-f', remote_file]) }
72
+ end
73
+
78
74
  context 'with variables' do
79
75
  let(:attrs) { {file: local_file, variables: {R: 'R2DO', C: 'C3PO'}} }
80
76
  it { is_expected.to eq([*default_command, '-f', remote_file, '-d', 'R=R2DO', '-d', 'C=C3PO']) }
@@ -128,12 +128,7 @@ module Masamune::SharedExampleGroup
128
128
 
129
129
  def execute_output_command(output, output_file)
130
130
  if output['hive'] && output['hive'].is_a?(String)
131
- # FIXME: Replace with exec once SBI-530 is fixed
132
- Tempfile.open('etl') do |tmp|
133
- tmp.write(output['hive'])
134
- tmp.flush
135
- hive(file: tmp.path, output: output_file)
136
- end
131
+ hive(exec: output['hive'], output: output_file)
137
132
  elsif output['table']
138
133
  table = eval "catalog.#{output['table']}"
139
134
  query = denormalize_table(table, output.slice('columns', 'order', 'except', 'include')).to_s
@@ -142,12 +137,7 @@ module Masamune::SharedExampleGroup
142
137
  when :postgres
143
138
  postgres(exec: query, csv: true, output: output_file)
144
139
  when :hive
145
- # FIXME: Replace with exec once SBI-530 is fixed
146
- Tempfile.open('etl') do |tmp|
147
- tmp.write(query)
148
- tmp.flush
149
- hive(file: tmp.path, output: output_file)
150
- end
140
+ hive(exec: query, output: output_file)
151
141
  else
152
142
  raise "'table' output not supported for #{output['table']}"
153
143
  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.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Andrews
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2015-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor