payday 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,5 @@
1
1
  # This is Payday!
2
2
  module Payday
3
-
4
3
  # Current Version
5
- VERSION = "1.1.3"
4
+ VERSION = "1.1.4"
6
5
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
3
3
  require "payday/version"
4
4
 
5
5
  Gem::Specification.new do |s|
@@ -8,19 +8,24 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Alan Johnson"]
10
10
  s.email = ["alan@commondream.net"]
11
- s.homepage = ""
12
- s.summary = %q{git remote add origin git@github.com:commondream/payday.git}
13
- s.description = %q{Payday is a library for rendering invoices. At present it supports rendering invoices to pdfs, but we're planning on adding support for other formats in the near future.}
11
+ s.homepage = "https://github.com/commondream/payday"
12
+ s.summary = "A simple library for rendering invoices."
13
+ s.description = <<-EOF
14
+ Payday is a library for rendering invoices. At present it supports rendering
15
+ invoices to pdfs, but we're planning on adding support for other formats in
16
+ the near future.
17
+ EOF
14
18
 
15
19
  s.add_dependency("prawn", "~> 1.0.0")
16
- s.add_dependency("money", "~> 6.1")
20
+ s.add_dependency("money", "~> 6.5")
17
21
  s.add_dependency("prawn-svg", "~> 0.15.0.0")
18
- s.add_dependency("i18n", ">= 0.6.9")
22
+ s.add_dependency("i18n", "~> 0.7")
19
23
 
20
24
  s.add_development_dependency("rspec", "~> 3.1.0")
21
25
 
22
- s.files = `git ls-files`.split("\n")
23
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
+ s.files = `git ls-files`.split("\n")
27
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
28
+ s.executables =
29
+ `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
25
30
  s.require_paths = ["lib"]
26
31
  end
Binary file
@@ -1,15 +1,16 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Payday
4
4
  describe Invoice do
5
5
 
6
6
  it "should be able to be initalized with a hash of options" do
7
- i = Invoice.new(:invoice_number => 20, :bill_to => "Here", :ship_to => "There",
8
- :notes => "These are some notes.",
9
- :line_items => [LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")],
10
- :shipping_rate => 15.00, :shipping_description => "USPS Priority Mail:",
11
- :tax_rate => 0.125, :tax_description => "Local Sales Tax, 12.5%",
12
- :invoice_date => Date.civil(1993, 4, 12))
7
+ i = Invoice.new(invoice_number: 20, bill_to: "Here", ship_to: "There",
8
+ notes: "These are some notes.",
9
+ line_items:
10
+ [LineItem.new(price: 10, quantity: 3, description: "Shirts")],
11
+ shipping_rate: 15.00, shipping_description: "USPS Priority Mail:",
12
+ tax_rate: 0.125, tax_description: "Local Sales Tax, 12.5%",
13
+ invoice_date: Date.civil(1993, 4, 12))
13
14
 
14
15
  expect(i.invoice_number).to eq(20)
15
16
  expect(i.bill_to).to eq("Here")
@@ -27,58 +28,61 @@ module Payday
27
28
  i = Invoice.new
28
29
 
29
30
  # $100 in Pants
30
- i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
31
+ i.line_items << LineItem.new(price: 20, quantity: 5, description: "Pants")
31
32
 
32
33
  # $30 in Shirts
33
- i.line_items << LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")
34
+ i.line_items <<
35
+ LineItem.new(price: 10, quantity: 3, description: "Shirts")
34
36
 
35
37
  # $1000 in Hats
36
- i.line_items << LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
38
+ i.line_items << LineItem.new(price: 5, quantity: 200, description: "Hats")
37
39
 
38
40
  expect(i.subtotal).to eq(BigDecimal.new("1130"))
39
41
  end
40
42
 
41
- it "should calculate the correct tax amount, rounded to two decimal places" do
42
- i = Invoice.new(:tax_rate => 0.1)
43
- i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
43
+ it "should calculate the correct tax rounded to two decimal places" do
44
+ i = Invoice.new(tax_rate: 0.1)
45
+ i.line_items << LineItem.new(price: 20, quantity: 5, description: "Pants")
44
46
 
45
47
  expect(i.tax).to eq(BigDecimal.new("10"))
46
48
  end
47
49
 
48
- it "shouldn't apply taxes to invoices with a subtotal of 0 or a negative amount" do
49
- i = Invoice.new(:tax_rate => 0.1)
50
- i.line_items << LineItem.new(:price => -1, :quantity => 100, :description => "Negative Priced Pants")
50
+ it "shouldn't apply taxes to invoices with subtotal <= 0" do
51
+ i = Invoice.new(tax_rate: 0.1)
52
+ i.line_items << LineItem.new(price: -1, quantity: 100,
53
+ description: "Negative Priced Pants")
51
54
 
52
55
  expect(i.tax).to eq(BigDecimal.new("0"))
53
56
  end
54
57
 
55
58
  it "should calculate the total for an invoice correctly" do
56
- i = Invoice.new(:tax_rate => 0.1)
59
+ i = Invoice.new(tax_rate: 0.1)
57
60
 
58
61
  # $100 in Pants
59
- i.line_items << LineItem.new(:price => 20, :quantity => 5, :description => "Pants")
62
+ i.line_items << LineItem.new(price: 20, quantity: 5, description: "Pants")
60
63
 
61
64
  # $30 in Shirts
62
- i.line_items << LineItem.new(:price => 10, :quantity => 3, :description => "Shirts")
65
+ i.line_items <<
66
+ LineItem.new(price: 10, quantity: 3, description: "Shirts")
63
67
 
64
68
  # $1000 in Hats
65
- i.line_items << LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
69
+ i.line_items << LineItem.new(price: 5, quantity: 200, description: "Hats")
66
70
 
67
71
  expect(i.total).to eq(BigDecimal.new("1243"))
68
72
  end
69
73
 
70
74
  it "is overdue when it's past date and unpaid" do
71
- i = Invoice.new(:due_at => Date.today - 1)
75
+ i = Invoice.new(due_at: Date.today - 1)
72
76
  expect(i.overdue?).to eq(true)
73
77
  end
74
78
 
75
79
  it "isn't overdue when past due date and paid" do
76
- i = Invoice.new(:due_at => Date.today - 1, :paid_at => Date.today)
80
+ i = Invoice.new(due_at: Date.today - 1, paid_at: Date.today)
77
81
  expect(i.overdue?).not_to eq(true)
78
82
  end
79
83
 
80
84
  it "is overdue when due date is a time before the current date" do
81
- i = Invoice.new(:due_at => Time.parse("Jan 1 14:33:20 GMT 2011"))
85
+ i = Invoice.new(due_at: Time.parse("Jan 1 14:33:20 GMT 2011"))
82
86
  expect(i.overdue?).to eq(true)
83
87
  end
84
88
 
@@ -88,7 +92,7 @@ module Payday
88
92
  end
89
93
 
90
94
  it "should be refunded when marked as refunded" do
91
- i = Invoice.new(:refunded_at => Date.today)
95
+ i = Invoice.new(refunded_at: Date.today)
92
96
  expect(i.refunded?).to eq(true)
93
97
  end
94
98
 
@@ -98,37 +102,38 @@ module Payday
98
102
  end
99
103
 
100
104
  it "should be paid when marked as paid" do
101
- i = Invoice.new(:paid_at => Date.today)
105
+ i = Invoice.new(paid_at: Date.today)
102
106
  expect(i.paid?).to eq(true)
103
107
  end
104
108
 
105
109
  it "should be able to iterate over details" do
106
- i = Invoice.new(:invoice_details => [["Test", "Yes"], ["Awesome", "Absolutely"]])
110
+ i = Invoice.new(invoice_details: [%w(Test Yes), %w(Awesome Absolutely)])
107
111
  details = []
108
112
  i.each_detail do |key, value|
109
113
  details << [key, value]
110
114
  end
111
115
 
112
116
  expect(details.length).to eq(2)
113
- expect(details).to include(["Test", "Yes"])
114
- expect(details).to include(["Awesome", "Absolutely"])
117
+ expect(details).to include(%w(Test Yes))
118
+ expect(details).to include(%w(Awesome Absolutely))
115
119
  end
116
120
 
117
121
  it "should be able to iterate through invoice_details as a hash" do
118
- i = Invoice.new(:invoice_details => {"Test" => "Yes", "Awesome" => "Absolutely"})
122
+ i = Invoice.new(invoice_details:
123
+ { "Test" => "Yes", "Awesome" => "Absolutely" })
119
124
  details = []
120
125
  i.each_detail do |key, value|
121
126
  details << [key, value]
122
127
  end
123
128
 
124
129
  expect(details.length).to eq(2)
125
- expect(details).to include(["Test", "Yes"])
126
- expect(details).to include(["Awesome", "Absolutely"])
130
+ expect(details).to include(%w(Test Yes))
131
+ expect(details).to include(%w(Awesome Absolutely))
127
132
  end
128
133
 
129
134
  describe "rendering" do
130
135
  before do
131
- Dir.mkdir("tmp") unless File.exists?("tmp")
136
+ Dir.mkdir("tmp") unless File.exist?("tmp")
132
137
  Config.default.reset
133
138
  end
134
139
 
@@ -136,58 +141,69 @@ module Payday
136
141
  let(:invoice_params) { {} }
137
142
 
138
143
  it "should render to a file" do
139
- File.unlink("tmp/testing.pdf") if File.exists?("tmp/testing.pdf")
144
+ File.unlink("tmp/testing.pdf") if File.exist?("tmp/testing.pdf")
140
145
 
141
146
  invoice.render_pdf_to_file("tmp/testing.pdf")
142
147
 
143
- expect(File.exists?("tmp/testing.pdf")).to be true
148
+ expect(File.exist?("tmp/testing.pdf")).to be true
144
149
  end
145
150
 
146
- context 'with some invoice details' do
147
- let(:invoice_params) { {
148
- :invoice_details => { "Ordered By:" => "Alan Johnson", "Paid By:" => "Dude McDude" }
149
- } }
151
+ context "with some invoice details" do
152
+ let(:invoice_params) do
153
+ {
154
+ invoice_details: {
155
+ "Ordered By:" => "Alan Johnson",
156
+ "Paid By:" => "Dude McDude"
157
+ }
158
+ }
159
+ end
150
160
 
151
161
  it "should render an invoice correctly" do
152
- Payday::Config.default.company_details = "10 This Way\nManhattan, NY 10001\n800-111-2222\nawesome@awesomecorp.com"
162
+ Payday::Config.default.company_details = <<-EOF
163
+ 10 This Way
164
+ Manhattan, NY 10001
165
+ 800-111-2222
166
+ awesome@awesomecorp.com
167
+ EOF
153
168
 
154
169
  invoice.line_items += [
155
- LineItem.new(:price => 20, :quantity => 5, :description => "Pants"),
156
- LineItem.new(:price => 10, :quantity => 3, :description => "Shirts"),
157
- LineItem.new(:price => 5, :quantity => 200, :description => "Hats")
170
+ LineItem.new(price: 20, quantity: 5, description: "Pants"),
171
+ LineItem.new(price: 10, quantity: 3, description: "Shirts"),
172
+ LineItem.new(price: 5, quantity: 200, description: "Hats")
158
173
  ] * 30
159
174
 
160
- expect(invoice.render_pdf).to match_binary_asset 'testing.pdf'
175
+ expect(invoice.render_pdf).to match_binary_asset "testing.pdf"
161
176
  end
162
177
  end
163
178
 
164
- context 'paid, with an svg logo' do
179
+ context "paid, with an svg logo" do
165
180
  before do
166
- Payday::Config.default.invoice_logo = { :filename => "spec/assets/tiger.svg", :size => "100x100" }
181
+ logo = { filename: "spec/assets/tiger.svg", size: "100x100" }
182
+ Payday::Config.default.invoice_logo = logo
167
183
  end
168
184
 
169
- let(:invoice_params) { { :paid_at => Date.civil(2012, 2, 22) } }
185
+ let(:invoice_params) { { paid_at: Date.civil(2012, 2, 22) } }
170
186
 
171
- it 'should render an invoice correctly' do
187
+ it "should render an invoice correctly" do
172
188
  invoice.line_items += [
173
- LineItem.new(:price => 20, :quantity => 5, :description => "Pants"),
174
- LineItem.new(:price => 10, :quantity => 3, :description => "Shirts"),
175
- LineItem.new(:price => 5, :quantity => 200.0, :description => "Hats")
189
+ LineItem.new(price: 20, quantity: 5, description: "Pants"),
190
+ LineItem.new(price: 10, quantity: 3, description: "Shirts"),
191
+ LineItem.new(price: 5, quantity: 200.0, description: "Hats")
176
192
  ] * 3
177
193
 
178
- expect(invoice.render_pdf).to match_binary_asset 'svg.pdf'
194
+ expect(invoice.render_pdf).to match_binary_asset "svg.pdf"
179
195
  end
180
196
  end
181
197
 
182
198
  def new_invoice(params = {})
183
199
  default_params = {
184
- :tax_rate => 0.1,
185
- :notes => "These are some crazy awesome notes!",
186
- :invoice_number => 12,
187
- :invoice_date => Date.civil(2011, 1, 1),
188
- :due_at => Date.civil(2011, 1, 22),
189
- :bill_to => "Alan Johnson\n101 This Way\nSomewhere, SC 22222",
190
- :ship_to => "Frank Johnson\n101 That Way\nOther, SC 22229"
200
+ tax_rate: 0.1,
201
+ notes: "These are some crazy awesome notes!",
202
+ invoice_number: 12,
203
+ invoice_date: Date.civil(2011, 1, 1),
204
+ due_at: Date.civil(2011, 1, 22),
205
+ bill_to: "Alan Johnson\n101 This Way\nSomewhere, SC 22222",
206
+ ship_to: "Frank Johnson\n101 That Way\nOther, SC 22229"
191
207
  }
192
208
 
193
209
  Invoice.new(default_params.merge(params))
@@ -1,26 +1,25 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Payday
4
4
  describe LineItem do
5
5
  it "should be able to be initilized with a price" do
6
- li = LineItem.new(:price => BigDecimal.new("20"))
6
+ li = LineItem.new(price: BigDecimal.new("20"))
7
7
  expect(li.price).to eq(BigDecimal.new("20"))
8
8
  end
9
9
 
10
10
  it "should be able to be initialized with a quantity" do
11
- li = LineItem.new(:quantity => 30)
11
+ li = LineItem.new(quantity: 30)
12
12
  expect(li.quantity).to eq(BigDecimal.new("30"))
13
13
  end
14
14
 
15
15
  it "should be able to be initlialized with a description" do
16
- li = LineItem.new(:description => "12 Pairs of Pants")
16
+ li = LineItem.new(description: "12 Pairs of Pants")
17
17
  expect(li.description).to eq("12 Pairs of Pants")
18
18
  end
19
19
 
20
20
  it "should return the correct amount" do
21
- li = LineItem.new(:price => 10, :quantity => 12)
21
+ li = LineItem.new(price: 10, quantity: 12)
22
22
  expect(li.amount).to eq(BigDecimal.new("120"))
23
23
  end
24
24
  end
25
25
  end
26
-
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Payday
4
- describe PdfRenderer do
5
- describe ".number_to_currency" do
6
- it "formats numbers to currency currectly" do
7
- expect(PdfRenderer.number_to_currency(20, nil)).to eq("$20.00")
8
- end
9
- end
10
- end
4
+ describe PdfRenderer do
5
+ describe ".number_to_currency" do
6
+ it "formats numbers to currency currectly" do
7
+ expect(PdfRenderer.number_to_currency(20, nil)).to eq("$20.00")
8
+ end
9
+ end
10
+ end
11
11
  end
@@ -1,9 +1,9 @@
1
- require_relative '../lib/payday'
1
+ require_relative "../lib/payday"
2
2
 
3
3
  # Requires supporting ruby files with custom matchers and macros, etc, in
4
4
  # spec/support/ and its subdirectories.
5
5
  Dir["spec/support/**/*.rb"].each { |f| require f[5..-1] }
6
6
 
7
- RSpec.configure do |config|
7
+ RSpec.configure do |_config|
8
8
  # some (optional) config here
9
9
  end
@@ -1,14 +1,14 @@
1
- require 'fileutils'
1
+ require "fileutils"
2
2
 
3
3
  # Usage: expect(renderer.render).to match_binary_asset('pdf/test.pdf')
4
4
  RSpec::Matchers.define(:match_binary_asset) do |file_name|
5
5
  match do |actual_output|
6
- expected_path = File.join('spec/assets', file_name)
6
+ expected_path = File.join("spec/assets", file_name)
7
7
  expected_output = File.binread(expected_path)
8
8
 
9
9
  (actual_output == expected_output).tap do |result|
10
10
  unless result
11
- output_path = File.join('tmp/rendered_output', file_name)
11
+ output_path = File.join("tmp/rendered_output", file_name)
12
12
 
13
13
  FileUtils.mkdir_p(File.dirname(output_path))
14
14
  File.open(output_path, "wb") { |f| f.write actual_output }
@@ -16,10 +16,11 @@ RSpec::Matchers.define(:match_binary_asset) do |file_name|
16
16
  end
17
17
  end
18
18
 
19
- failure_message do |actual_output|
20
- expected_output_path = File.join('spec/assets', file_name)
21
- actual_output_path = File.join('tmp/rendered_output', file_name)
19
+ failure_message do |_actual_output|
20
+ expected_output_path = File.join("spec/assets", file_name)
21
+ actual_output_path = File.join("tmp/rendered_output", file_name)
22
22
 
23
- "expected output to match '#{expected_output_path}' (see #{actual_output_path})"
23
+ "expected output to match '#{expected_output_path}' "\
24
+ "(see #{actual_output_path})"
24
25
  end
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-02 00:00:00.000000000 Z
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '6.1'
33
+ version: '6.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '6.1'
40
+ version: '6.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: prawn-svg
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: i18n
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.6.9
61
+ version: '0.7'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.6.9
68
+ version: '0.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,9 +80,10 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 3.1.0
83
- description: Payday is a library for rendering invoices. At present it supports rendering
84
- invoices to pdfs, but we're planning on adding support for other formats in the
85
- near future.
83
+ description: |2
84
+ Payday is a library for rendering invoices. At present it supports rendering
85
+ invoices to pdfs, but we're planning on adding support for other formats in
86
+ the near future.
86
87
  email:
87
88
  - alan@commondream.net
88
89
  executables: []
@@ -91,6 +92,7 @@ extra_rdoc_files: []
91
92
  files:
92
93
  - ".gitattributes"
93
94
  - ".gitignore"
95
+ - ".rubocop.yml"
94
96
  - ".ruby-version"
95
97
  - CHANGELOG.md
96
98
  - Gemfile
@@ -126,7 +128,7 @@ files:
126
128
  - spec/pdf_renderer_spec.rb
127
129
  - spec/spec_helper.rb
128
130
  - spec/support/asset_matchers.rb
129
- homepage: ''
131
+ homepage: https://github.com/commondream/payday
130
132
  licenses: []
131
133
  metadata: {}
132
134
  post_install_message:
@@ -148,7 +150,7 @@ rubyforge_project:
148
150
  rubygems_version: 2.2.2
149
151
  signing_key:
150
152
  specification_version: 4
151
- summary: git remote add origin git@github.com:commondream/payday.git
153
+ summary: A simple library for rendering invoices.
152
154
  test_files:
153
155
  - spec/assets/default_logo.png
154
156
  - spec/assets/svg.pdf
@@ -159,4 +161,3 @@ test_files:
159
161
  - spec/pdf_renderer_spec.rb
160
162
  - spec/spec_helper.rb
161
163
  - spec/support/asset_matchers.rb
162
- has_rdoc: