tobacco 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tobacco/exhaler.rb +1 -1
- data/lib/tobacco/smoker.rb +5 -1
- data/lib/tobacco/version.rb +1 -1
- data/lib/tobacco.rb +5 -3
- data/spec/tobacco/smoker_spec.rb +8 -8
- metadata +1 -1
data/lib/tobacco/exhaler.rb
CHANGED
data/lib/tobacco/smoker.rb
CHANGED
@@ -41,6 +41,10 @@ module Tobacco
|
|
41
41
|
callback(:on_success, modified_content)
|
42
42
|
|
43
43
|
rescue => e
|
44
|
+
Tobacco.log("ErrorWriting: #{filepath}")
|
45
|
+
|
46
|
+
# Remove the empty file
|
47
|
+
File.delete(filepath) if File.exists?(filepath)
|
44
48
|
|
45
49
|
error = error_object('Error Writing', modified_content, e)
|
46
50
|
callback(:on_write_error, error)
|
@@ -126,7 +130,7 @@ module Tobacco
|
|
126
130
|
def error_object(msg, modified_content, e)
|
127
131
|
Tobacco::Error.new(
|
128
132
|
msg: msg,
|
129
|
-
filepath: file_path_generator.
|
133
|
+
filepath: file_path_generator.output_filepath,
|
130
134
|
content: modified_content,
|
131
135
|
object: e
|
132
136
|
)
|
data/lib/tobacco/version.rb
CHANGED
data/lib/tobacco.rb
CHANGED
@@ -27,12 +27,14 @@ module Tobacco
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.log(msg)
|
30
|
-
|
30
|
+
log_msg = "\n*******************************************\n"
|
31
|
+
log_msg += "Tobacco::Log: #{msg}\n"
|
32
|
+
log_msg += "*******************************************\n"
|
31
33
|
|
32
34
|
if defined? Rails
|
33
|
-
Rails.logger.info(
|
35
|
+
Rails.logger.info(log_msg)
|
34
36
|
else
|
35
|
-
puts
|
37
|
+
puts log_msg
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
data/spec/tobacco/smoker_spec.rb
CHANGED
@@ -21,10 +21,10 @@ describe Tobacco::Smoker do
|
|
21
21
|
|
22
22
|
context 'when content is empty' do
|
23
23
|
let(:inhaler) { mock('inhaler', read: '') }
|
24
|
-
let(:filepath) { mock('roller', content_url: '/video',
|
24
|
+
let(:filepath) { mock('roller', content_url: '/video', output_filepath: '/user') }
|
25
25
|
|
26
26
|
before do
|
27
|
-
Tobacco::Inhaler.
|
27
|
+
Tobacco::Inhaler.stub(:new).and_return(inhaler)
|
28
28
|
subject.file_path_generator = filepath
|
29
29
|
end
|
30
30
|
|
@@ -39,10 +39,10 @@ describe Tobacco::Smoker do
|
|
39
39
|
context 'content' do
|
40
40
|
let(:content) { 'Directly set content' }
|
41
41
|
let(:exhaler) { mock('exhaler', write!: true) }
|
42
|
-
let(:filepath) { mock('roller', content_url: '/video',
|
42
|
+
let(:filepath) { mock('roller', content_url: '/video', output_filepath: '/desktop') }
|
43
43
|
|
44
44
|
before do
|
45
|
-
Tobacco::Exhaler.
|
45
|
+
Tobacco::Exhaler.stub(:new).and_return(exhaler)
|
46
46
|
subject.file_path_generator = filepath
|
47
47
|
end
|
48
48
|
|
@@ -121,7 +121,7 @@ describe Tobacco::Smoker do
|
|
121
121
|
let(:filepath) { mock('roller', content_url: '/video') }
|
122
122
|
|
123
123
|
before do
|
124
|
-
Tobacco::Inhaler.
|
124
|
+
Tobacco::Inhaler.stub(:new).and_return(inhaler)
|
125
125
|
subject.file_path_generator = filepath
|
126
126
|
end
|
127
127
|
|
@@ -152,7 +152,7 @@ describe Tobacco::Smoker do
|
|
152
152
|
let(:filepath) { mock('roller', content_url: '/video') }
|
153
153
|
|
154
154
|
before do
|
155
|
-
Tobacco::Inhaler.
|
155
|
+
Tobacco::Inhaler.stub(:new).and_return(inhaler)
|
156
156
|
subject.file_path_generator = filepath
|
157
157
|
end
|
158
158
|
|
@@ -176,11 +176,11 @@ describe Tobacco::Smoker do
|
|
176
176
|
|
177
177
|
describe '#on_read_error' do
|
178
178
|
let(:inhaler) { mock('inhaler', read: '') }
|
179
|
-
let(:filepath) { mock('roller', content_url: '/video',
|
179
|
+
let(:filepath) { mock('roller', content_url: '/video', output_filepath: '/file/path') }
|
180
180
|
let(:smoker) { Writer.new }
|
181
181
|
|
182
182
|
before do
|
183
|
-
Tobacco::Inhaler.
|
183
|
+
Tobacco::Inhaler.stub(:new).and_return(inhaler)
|
184
184
|
subject.file_path_generator = filepath
|
185
185
|
end
|
186
186
|
|