masamune 0.17.3 → 0.17.4

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: 308f642fba45cf0882c10023bcd0ab3f30a9a611
4
- data.tar.gz: eb32061afd7d7e656bc0384eb1aeb694edebca90
3
+ metadata.gz: 61f6f61c4cd5df082a7f5a63cee2f4f7716ff7ca
4
+ data.tar.gz: 9a47bb9bbdb0339904cf8159968fe9fc0a6dc6aa
5
5
  SHA512:
6
- metadata.gz: 657e6b91d3a6f09dc9d303d5c83e6fe0664ca92c5dfda40b828cf11d6bdfd2b6d870e70c010df328310d6afe46742df28df4dd84985eec1eb50e3f1ebbf16c7b
7
- data.tar.gz: bc8f2e98fc05e9bb96096480f5a5070a6a386bb7911b430cb0ff7bfab80c905a6740402fd960fb833731822f16d2a147f2fc50ca1e22b3ccf0ee055e8851beb1
6
+ metadata.gz: e7bd7a01c74b0779318dc2988c1741fed4122c866b913fe63457d4696a47794ffb540de0d363bb8d92b9f4836de3be1ed929dc741a90085c093b216728e8aaae
7
+ data.tar.gz: 5ec032b8c286a99d8873a03525ba6c02c2f090567e7a451711423b6e2fd2f6d87133deabafcd527dd149b502b1c5c07ff03bff6b24037bd202a44143ded3cd1d
@@ -144,7 +144,7 @@ module Masamune::Commands
144
144
  end
145
145
 
146
146
  def command_args_for_file
147
- @command_args_for_file ||= (@file =~ /\.erb\Z/ ? command_args_for_template : command_args_for_simple_file)
147
+ @command_args_for_file ||= (template_file? ? command_args_for_template : command_args_for_simple_file)
148
148
  end
149
149
 
150
150
  def command_args_for_simple_file
@@ -163,6 +163,10 @@ module Masamune::Commands
163
163
 
164
164
  private
165
165
 
166
+ def template_file?
167
+ @file =~ /\.erb\Z/
168
+ end
169
+
166
170
  def remote_file
167
171
  @remote_file ||= File.join(filesystem.mktempdir!(:tmp_dir), filesystem.basename(@file)).gsub(/.erb\z/,'')
168
172
  end
@@ -175,6 +179,7 @@ module Masamune::Commands
175
179
  end
176
180
 
177
181
  def rendered_template
182
+ return unless template_file?
178
183
  @rendered_template ||= Masamune::Template.render_to_file(@file, @variables)
179
184
  end
180
185
  end
@@ -115,8 +115,12 @@ module Masamune::Commands
115
115
 
116
116
  private
117
117
 
118
+ def template_file?
119
+ @file =~ /\.erb\Z/
120
+ end
121
+
118
122
  def command_args_for_file
119
- @file =~ /\.erb\Z/ ? command_args_for_template : command_args_for_simple_file
123
+ template_file? ? command_args_for_template : command_args_for_simple_file
120
124
  end
121
125
 
122
126
  def command_args_for_simple_file
@@ -139,6 +143,7 @@ module Masamune::Commands
139
143
  end
140
144
 
141
145
  def rendered_template
146
+ return unless template_file?
142
147
  @rendered_template ||= Masamune::Template.render_to_file(@file, @variables)
143
148
  end
144
149
  end
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Masamune
24
- VERSION = '0.17.3'
24
+ VERSION = '0.17.4'
25
25
  end
@@ -64,6 +64,15 @@ describe Masamune::Commands::Hive do
64
64
  it { is_expected.to eq([*default_command, '-f', remote_file]) }
65
65
  end
66
66
 
67
+ context 'with file and debug' do
68
+ let(:attrs) { {file: local_file, debug: true} }
69
+ before do
70
+ expect(File).to receive(:read).with(local_file).and_return('SHOW TABLES;')
71
+ expect(instance.logger).to receive(:debug).with("#{local_file}:\nSHOW TABLES;")
72
+ end
73
+ it { is_expected.to eq([*default_command, '-f', remote_file]) }
74
+ end
75
+
67
76
  context 'with exec' do
68
77
  let(:attrs) { {exec: 'SELECT * FROM table;'} }
69
78
  before do
@@ -76,6 +76,15 @@ describe Masamune::Commands::Postgres do
76
76
  it { is_expected.to eq([*default_command, '--file=zomg.psql']) }
77
77
  end
78
78
 
79
+ context 'with file and debug' do
80
+ let(:attrs) { {file: 'zomg.psql', debug: true} }
81
+ before do
82
+ expect(File).to receive(:read).with('zomg.psql').and_return('SHOW TABLES;')
83
+ expect(instance.logger).to receive(:debug).with("zomg.psql:\nSHOW TABLES;")
84
+ end
85
+ it { is_expected.to eq([*default_command, '--file=zomg.psql']) }
86
+ end
87
+
79
88
  context 'with file and exec' do
80
89
  let(:attrs) { {file: 'zomg.psql', exec: 'SELECT * FROM table;'} }
81
90
  it { expect { subject }.to raise_error(/Cannot specify both file and exec/) }
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.3
4
+ version: 0.17.4
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-02-04 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor