get_invoice 0.1.0 → 0.2.0

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.
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
+ gem "invoice_harvester"
5
6
  gem "blinksale"
6
7
 
7
8
  # Add dependencies to develop your gem here.
data/Gemfile.lock CHANGED
@@ -6,6 +6,9 @@ GEM
6
6
  rest-client
7
7
  diff-lcs (1.1.2)
8
8
  git (1.2.5)
9
+ invoice_harvester (0.1.0)
10
+ nokogiri
11
+ rest-client
9
12
  jeweler (1.6.2)
10
13
  bundler (~> 1.0)
11
14
  git (>= 1.2.5)
@@ -31,6 +34,7 @@ PLATFORMS
31
34
  DEPENDENCIES
32
35
  blinksale
33
36
  bundler (~> 1.0.0)
37
+ invoice_harvester
34
38
  jeweler (~> 1.6.2)
35
39
  rcov
36
40
  rspec (~> 2.3.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -4,8 +4,8 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{invoicer}
8
- s.version = "0.1.0"
7
+ s.name = %q{get_invoice}
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tomasz Werbicki"]
@@ -25,13 +25,17 @@ Gem::Specification.new do |s|
25
25
  "README.rdoc",
26
26
  "Rakefile",
27
27
  "VERSION",
28
- "invoicer.gemspec",
28
+ "get_invoice.gemspec",
29
29
  "lib/invoice.rb",
30
30
  "lib/invoicer.rb",
31
31
  "lib/services/blinksale.rb",
32
32
  "lib/services/blinksale/invoice.rb",
33
33
  "lib/services/blinksale/invoice_manager.rb",
34
+ "lib/services/harvest.rb",
35
+ "lib/services/harvest/invoice.rb",
36
+ "lib/services/harvest/invoice_manager.rb",
34
37
  "spec/services/blinksale_spec.rb",
38
+ "spec/services/harvest_spec.rb",
35
39
  "spec/spec_helper.rb"
36
40
  ]
37
41
  s.homepage = %q{http://github.com/neaf/invoicer}
@@ -45,12 +49,14 @@ Gem::Specification.new do |s|
45
49
  s.specification_version = 3
46
50
 
47
51
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<invoice_harvester>, [">= 0"])
48
53
  s.add_runtime_dependency(%q<blinksale>, [">= 0"])
49
54
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
50
55
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
56
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
52
57
  s.add_development_dependency(%q<rcov>, [">= 0"])
53
58
  else
59
+ s.add_dependency(%q<invoice_harvester>, [">= 0"])
54
60
  s.add_dependency(%q<blinksale>, [">= 0"])
55
61
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
56
62
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -58,6 +64,7 @@ Gem::Specification.new do |s|
58
64
  s.add_dependency(%q<rcov>, [">= 0"])
59
65
  end
60
66
  else
67
+ s.add_dependency(%q<invoice_harvester>, [">= 0"])
61
68
  s.add_dependency(%q<blinksale>, [">= 0"])
62
69
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
63
70
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
data/lib/invoicer.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  require "invoice"
2
2
  require "services/blinksale"
3
+ require "services/harvest"
@@ -0,0 +1,16 @@
1
+ module Invoicer
2
+ class HarvestInvoice
3
+ def self.from_harvest(harvest_invoice)
4
+ Invoice.new(
5
+ :id => harvest_invoice.id,
6
+ :number => harvest_invoice.number,
7
+ :total_amount => harvest_invoice.total_amount,
8
+ :due_amount => harvest_invoice.due_amount,
9
+ :issued_on => harvest_invoice.issued_on,
10
+ :due_on => harvest_invoice.due_on,
11
+ :currency => harvest_invoice.currency,
12
+ :service => :harvest
13
+ )
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ require "harvester"
2
+ require "services/harvest/invoice"
3
+
4
+ module Invoicer
5
+ class HarvestInvoiceManager
6
+ attr_reader :service
7
+
8
+ def initialize(service)
9
+ @service = service
10
+ end
11
+
12
+ def all(params = {})
13
+ service.harvester.all(params).map do |i|
14
+ Invoicer::HarvestInvoice.from_harvest(i)
15
+ end
16
+ end
17
+
18
+ def get(id)
19
+ Invoicer::HarvestInvoice.from_harvest(service.harvester.get(id))
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ require "services/harvest/invoice_manager"
2
+
3
+ module Invoicer
4
+ class Harvest
5
+ attr_reader :harvester
6
+ attr_reader :invoices
7
+
8
+ def initialize(*args)
9
+ @harvester = ::Harvester::Client.new(*args)
10
+ @invoices = Invoicer::HarvestInvoiceManager.new(self)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,109 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Invoicer::Harvest do
4
+ let(:service) { Invoicer::Harvest.new('test', 'test', 'test') }
5
+
6
+ describe "#invoices" do
7
+ it "returns invoice manager instance" do
8
+ service.invoices.should be_an_instance_of(Invoicer::HarvestInvoiceManager)
9
+ end
10
+ end
11
+ end
12
+
13
+ describe Invoicer::HarvestInvoiceManager do
14
+ let(:manager) { Invoicer::Harvest.new('test', 'test', 'test').invoices }
15
+
16
+ describe "#all" do
17
+ before(:each) do
18
+ invoices = [
19
+ mock('invoice',
20
+ :id => 1,
21
+ :number => "00001",
22
+ :total_amount => 20,
23
+ :due_amount => 10,
24
+ :issued_on => Date.today,
25
+ :due_on => Date.today + 30,
26
+ :currency => "USD"
27
+ ),
28
+ mock('invoice',
29
+ :id => 2,
30
+ :number => "00002",
31
+ :total_amount => 20,
32
+ :due_amount => 10,
33
+ :issued_on => Date.today,
34
+ :due_on => Date.today + 30,
35
+ :currency => "USD"
36
+ ),
37
+ mock('invoice',
38
+ :id => 3,
39
+ :number => "00003",
40
+ :total_amount => 20,
41
+ :due_amount => 10,
42
+ :issued_on => Date.today,
43
+ :due_on => Date.today + 30,
44
+ :currency => "USD"
45
+ )
46
+ ]
47
+
48
+ manager.service.harvester.stub!(:all).and_return(invoices)
49
+ end
50
+
51
+ it "passes params to Harvesb client" do
52
+ params = { :status => "draft" }
53
+ manager.service.harvester.should_receive(:all).with(params).once
54
+ manager.all(params)
55
+ end
56
+
57
+ it "returns collection of invoices" do
58
+ manager.all.should_not be_empty
59
+ end
60
+
61
+ describe "invoice" do
62
+ let(:invoice) { manager.all.first }
63
+
64
+ it "is an Invoicer::Invoice instance" do
65
+ invoice.should be_an_instance_of(Invoicer::Invoice)
66
+ end
67
+
68
+ it "has proper attributes set" do
69
+ invoice.number.should eql("00001")
70
+ invoice.currency.should eql("USD")
71
+ invoice.service.should eql(:harvest)
72
+ end
73
+ end
74
+ end
75
+
76
+ describe "#get" do
77
+ before(:each) do
78
+ invoice = mock('invoice',
79
+ :id => 1,
80
+ :number => "00001",
81
+ :total_amount => 20,
82
+ :due_amount => 10,
83
+ :issued_on => Date.today,
84
+ :due_on => Date.today + 30,
85
+ :currency => "USD"
86
+ )
87
+
88
+ manager.service.harvester.stub!(:get).and_return(invoice)
89
+ end
90
+
91
+ let(:invoice) { manager.get(1) }
92
+
93
+ it "returns invoice instance" do
94
+ invoice.should be_an_instance_of(Invoicer::Invoice)
95
+ end
96
+
97
+ describe "invoice" do
98
+ it "is an Invoicer::Invoice instance" do
99
+ invoice.should be_an_instance_of(Invoicer::Invoice)
100
+ end
101
+
102
+ it "has proper attributes set" do
103
+ invoice.number.should eql("00001")
104
+ invoice.currency.should eql("USD")
105
+ invoice.service.should eql(:harvest)
106
+ end
107
+ end
108
+ end
109
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tomasz Werbicki
@@ -18,7 +18,7 @@ date: 2011-06-27 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: blinksale
21
+ name: invoice_harvester
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
@@ -31,8 +31,21 @@ dependencies:
31
31
  prerelease: false
32
32
  version_requirements: *id001
33
33
  - !ruby/object:Gem::Dependency
34
- name: rspec
34
+ name: blinksale
35
35
  requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: &id003 !ruby/object:Gem::Requirement
36
49
  none: false
37
50
  requirements:
38
51
  - - ~>
@@ -44,10 +57,10 @@ dependencies:
44
57
  version: 2.3.0
45
58
  type: :development
46
59
  prerelease: false
47
- version_requirements: *id002
60
+ version_requirements: *id003
48
61
  - !ruby/object:Gem::Dependency
49
62
  name: bundler
50
- requirement: &id003 !ruby/object:Gem::Requirement
63
+ requirement: &id004 !ruby/object:Gem::Requirement
51
64
  none: false
52
65
  requirements:
53
66
  - - ~>
@@ -59,10 +72,10 @@ dependencies:
59
72
  version: 1.0.0
60
73
  type: :development
61
74
  prerelease: false
62
- version_requirements: *id003
75
+ version_requirements: *id004
63
76
  - !ruby/object:Gem::Dependency
64
77
  name: jeweler
65
- requirement: &id004 !ruby/object:Gem::Requirement
78
+ requirement: &id005 !ruby/object:Gem::Requirement
66
79
  none: false
67
80
  requirements:
68
81
  - - ~>
@@ -74,10 +87,10 @@ dependencies:
74
87
  version: 1.6.2
75
88
  type: :development
76
89
  prerelease: false
77
- version_requirements: *id004
90
+ version_requirements: *id005
78
91
  - !ruby/object:Gem::Dependency
79
92
  name: rcov
80
- requirement: &id005 !ruby/object:Gem::Requirement
93
+ requirement: &id006 !ruby/object:Gem::Requirement
81
94
  none: false
82
95
  requirements:
83
96
  - - ">="
@@ -87,7 +100,7 @@ dependencies:
87
100
  version: "0"
88
101
  type: :development
89
102
  prerelease: false
90
- version_requirements: *id005
103
+ version_requirements: *id006
91
104
  description: Common API for managing invoices from different online accounting services.
92
105
  email: tomasz@werbicki.net
93
106
  executables: []
@@ -106,13 +119,17 @@ files:
106
119
  - README.rdoc
107
120
  - Rakefile
108
121
  - VERSION
109
- - invoicer.gemspec
122
+ - get_invoice.gemspec
110
123
  - lib/invoice.rb
111
124
  - lib/invoicer.rb
112
125
  - lib/services/blinksale.rb
113
126
  - lib/services/blinksale/invoice.rb
114
127
  - lib/services/blinksale/invoice_manager.rb
128
+ - lib/services/harvest.rb
129
+ - lib/services/harvest/invoice.rb
130
+ - lib/services/harvest/invoice_manager.rb
115
131
  - spec/services/blinksale_spec.rb
132
+ - spec/services/harvest_spec.rb
116
133
  - spec/spec_helper.rb
117
134
  has_rdoc: true
118
135
  homepage: http://github.com/neaf/invoicer
@@ -128,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
145
  requirements:
129
146
  - - ">="
130
147
  - !ruby/object:Gem::Version
131
- hash: -2770695777343712863
148
+ hash: -4578703806334281031
132
149
  segments:
133
150
  - 0
134
151
  version: "0"