wicoris-postman 0.11.1 → 0.11.2

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.
@@ -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.
@@ -50,6 +50,10 @@ module Wicoris
50
50
  'Unknown'
51
51
  end
52
52
 
53
+ def to_s
54
+ @json_file
55
+ end
56
+
53
57
  private
54
58
 
55
59
  def deliver
@@ -1,5 +1,5 @@
1
1
  module Wicoris
2
2
  module Postman
3
- VERSION = '0.11.1'
3
+ VERSION = '0.11.2'
4
4
  end
5
5
  end
@@ -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: 49
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
- - 1
10
- version: 0.11.1
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.1
226
+ summary: wicoris-postman-0.11.2
227
227
  test_files:
228
228
  - features/copy.feature
229
229
  - features/fax.feature