receipts 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +17 -3
- data/Rakefile +6 -3
- data/examples/invoice.pdf +0 -0
- data/examples/receipt.pdf +0 -0
- data/lib/receipts/invoice.rb +5 -3
- data/lib/receipts/receipt.rb +5 -3
- data/lib/receipts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d6ebae8a7ca039194ecf740410f4bf187553f02a31fc78e93b7a34b3b086afb
|
4
|
+
data.tar.gz: 6617c60cf1d35cf645dc174243f3e4af6aae57d921896bb8fbb772409de54e48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4793df5b3719104cc32c0fffb24abf28d5346ffbcc69ce91e8c8a7c91ea67be774801112002dd922b6f1647cd37389bc0901ab6f3d6cfc7a5c41102a33805a
|
7
|
+
data.tar.gz: 9ad1a70dcd8751166d6f125d477e874ec48355f40550b15d2ecde71f42383ace50680174a756a11f75609ea5394066c37e09bd652def125fafeb4a644db17687
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -66,7 +66,7 @@ class Charge < ActiveRecord::Base
|
|
66
66
|
name: "GoRails, LLC.",
|
67
67
|
address: "123 Fake Street\nNew York City, NY 10012",
|
68
68
|
email: "support@example.com",
|
69
|
-
logo: Rails.root.join("app/assets/images/
|
69
|
+
logo: Rails.root.join("app/assets/images/logo.png")
|
70
70
|
},
|
71
71
|
line_items: [
|
72
72
|
["Date", created_at.to_s],
|
@@ -105,11 +105,25 @@ Company consists of several required nested attributes.
|
|
105
105
|
* `name` - **Required**
|
106
106
|
* `address` - **Required**
|
107
107
|
* `email` - **Required**
|
108
|
+
* `line_items` - **Required**
|
109
|
+
|
110
|
+
You can set as many line items on the receipts as you want. Just pass in an array with each item containing a name and a value to display on the receipt.
|
111
|
+
|
108
112
|
* `logo` - *Optional*
|
109
113
|
|
110
|
-
|
114
|
+
The logo must be either a string path to a file or a file-like object.
|
111
115
|
|
112
|
-
|
116
|
+
```ruby
|
117
|
+
logo: Rails.root.join("app/assets/images/logo.png")
|
118
|
+
# or
|
119
|
+
logo: File.open("app/assets/images/logo.png", "rb")
|
120
|
+
```
|
121
|
+
|
122
|
+
To use an image from a URL, we recommend using `open-uri` to open the remote file as a StringIO object.
|
123
|
+
|
124
|
+
`require 'open-uri'`
|
125
|
+
|
126
|
+
`logo: URI.open("https://www.ruby-lang.org/images/header-ruby-logo@2x.png")`
|
113
127
|
|
114
128
|
* `font` - *Optional*
|
115
129
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "open-uri"
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new('spec')
|
5
6
|
|
@@ -22,7 +23,7 @@ task :receipt do
|
|
22
23
|
name: "GoRails, LLC",
|
23
24
|
address: "123 Fake Street\nNew York City, NY 10012",
|
24
25
|
email: "support@example.com",
|
25
|
-
logo:
|
26
|
+
logo: URI.open("https://www.ruby-lang.org/images/header-ruby-logo@2x.png")
|
26
27
|
},
|
27
28
|
line_items: [
|
28
29
|
["Date", Time.now.to_s],
|
@@ -54,7 +55,9 @@ task :invoice do
|
|
54
55
|
name: "GoRails, LLC",
|
55
56
|
address: "123 Fake Street\nNew York City, NY 10012",
|
56
57
|
email: "support@example.com",
|
57
|
-
logo:
|
58
|
+
#logo: Rails.root.join("app/assets/images/gorails.png")
|
59
|
+
#logo: File.expand_path("./examples/gorails.png")
|
60
|
+
logo: File.open("./examples/gorails.png")
|
58
61
|
},
|
59
62
|
line_items: [
|
60
63
|
["<b>Item</b>", "<b>Unit Cost</b>", "<b>Quantity</b>", "<b>Amount</b>"],
|
data/examples/invoice.pdf
CHANGED
Binary file
|
data/examples/receipt.pdf
CHANGED
Binary file
|
data/lib/receipts/invoice.rb
CHANGED
@@ -52,12 +52,14 @@ module Receipts
|
|
52
52
|
def header
|
53
53
|
move_down 60
|
54
54
|
|
55
|
-
|
55
|
+
logo = company[:logo]
|
56
56
|
|
57
|
-
if
|
57
|
+
if logo.nil?
|
58
58
|
move_down 32
|
59
|
-
|
59
|
+
elsif logo.is_a?(String)
|
60
60
|
image open(logo_path), height: 32
|
61
|
+
else
|
62
|
+
image logo, height: 32
|
61
63
|
end
|
62
64
|
|
63
65
|
move_down 8
|
data/lib/receipts/receipt.rb
CHANGED
@@ -48,12 +48,14 @@ module Receipts
|
|
48
48
|
def header
|
49
49
|
move_down 60
|
50
50
|
|
51
|
-
|
51
|
+
logo = company[:logo]
|
52
52
|
|
53
|
-
if
|
53
|
+
if logo.nil?
|
54
54
|
move_down 32
|
55
|
-
|
55
|
+
elsif logo.is_a?(String)
|
56
56
|
image open(logo_path), height: 32
|
57
|
+
else
|
58
|
+
image logo, height: 32
|
57
59
|
end
|
58
60
|
|
59
61
|
move_down 8
|
data/lib/receipts/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: receipts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|