wicoris-postman 0.11.1 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wicoris/postman/copier.rb +6 -0
- data/lib/wicoris/postman/fax_machine.rb +6 -0
- data/lib/wicoris/postman/job.rb +4 -0
- data/lib/wicoris/postman/version.rb +1 -1
- data/spec/wicoris/postman/copier_spec.rb +3 -0
- data/spec/wicoris/postman/fax_machine_spec.rb +7 -0
- data/spec/wicoris/postman/job_spec.rb +6 -0
- metadata +4 -4
@@ -4,6 +4,8 @@ require 'digest/md5'
|
|
4
4
|
module Wicoris
|
5
5
|
module Postman
|
6
6
|
class Copier
|
7
|
+
attr_reader :logger
|
8
|
+
|
7
9
|
def initialize(job, opts = {})
|
8
10
|
@job = job
|
9
11
|
@opts = opts
|
@@ -13,6 +15,10 @@ module Wicoris
|
|
13
15
|
# Copy letter to destination.
|
14
16
|
def run
|
15
17
|
FileUtils.cp(source, destination, :noop => (@opts[:noop] == true))
|
18
|
+
logger.debug :message => 'Letter copied',
|
19
|
+
:destination => destination,
|
20
|
+
:letter => @job.letter,
|
21
|
+
:job => @job
|
16
22
|
end
|
17
23
|
|
18
24
|
private
|
@@ -8,6 +8,8 @@ module Wicoris
|
|
8
8
|
\d{7,}$ # followed by at least 8 digits
|
9
9
|
}x
|
10
10
|
|
11
|
+
attr_reader :logger
|
12
|
+
|
11
13
|
def initialize(job, opts = {})
|
12
14
|
@job = job
|
13
15
|
@opts = opts
|
@@ -17,6 +19,10 @@ module Wicoris
|
|
17
19
|
# Actually fax the letter.
|
18
20
|
def run
|
19
21
|
system(command) unless @opts[:noop]
|
22
|
+
logger.debug :message => 'Letter faxed',
|
23
|
+
:phone => validated_phone,
|
24
|
+
:letter => @job.letter,
|
25
|
+
:job => @job
|
20
26
|
end
|
21
27
|
|
22
28
|
# @returns [String] Validated phone number.
|
data/lib/wicoris/postman/job.rb
CHANGED
@@ -4,12 +4,15 @@ module Wicoris::Postman
|
|
4
4
|
describe Copier do
|
5
5
|
let(:job) { double('job') }
|
6
6
|
let(:copier) { Copier.new(job, {}) }
|
7
|
+
let(:logger) { double('logger') }
|
7
8
|
|
8
9
|
describe '#run' do
|
9
10
|
|
10
11
|
before do
|
12
|
+
logger.stub(:debug)
|
11
13
|
job.stub(:letter).and_return('/tmp/foo.pdf')
|
12
14
|
copier.stub(:destination).and_return('/export')
|
15
|
+
copier.stub(:logger).and_return(logger)
|
13
16
|
end
|
14
17
|
|
15
18
|
context 'without noop' do
|
@@ -12,6 +12,13 @@ module Wicoris::Postman
|
|
12
12
|
describe '#run' do
|
13
13
|
let(:logger) { double('logger') }
|
14
14
|
|
15
|
+
before do
|
16
|
+
logger.stub(:debug)
|
17
|
+
fax.stub(:logger).and_return(logger)
|
18
|
+
fax.stub(:validated_phone)
|
19
|
+
job.stub(:letter)
|
20
|
+
end
|
21
|
+
|
15
22
|
it 'faxes the document' do
|
16
23
|
fax.stub(:command).and_return('chunky bacon')
|
17
24
|
fax.should_receive(:system).with('chunky bacon')
|
@@ -154,6 +154,12 @@ module Wicoris::Postman
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
+
describe '#to_s' do
|
158
|
+
it 'returns the JSON file path' do
|
159
|
+
expect(job.to_s).to eq 'example.json'
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
157
163
|
describe '#clear!' do
|
158
164
|
before do
|
159
165
|
job.stub(:json).and_return('')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wicoris-postman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 11
|
9
|
-
-
|
10
|
-
version: 0.11.
|
9
|
+
- 2
|
10
|
+
version: 0.11.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Bjo\xCC\x88rn Albers"
|
@@ -223,7 +223,7 @@ rubyforge_project:
|
|
223
223
|
rubygems_version: 1.6.2
|
224
224
|
signing_key:
|
225
225
|
specification_version: 3
|
226
|
-
summary: wicoris-postman-0.11.
|
226
|
+
summary: wicoris-postman-0.11.2
|
227
227
|
test_files:
|
228
228
|
- features/copy.feature
|
229
229
|
- features/fax.feature
|