receipts 1.0.1 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '065796e25d569a927cf67ebaa208b8d33c189a4ce3786196dc236c563191bb89'
4
- data.tar.gz: 4f59197b6b35a5cbd71f23586b69a3808655b79127c2c520dd13ee9d6c7efc3d
3
+ metadata.gz: 3d6ebae8a7ca039194ecf740410f4bf187553f02a31fc78e93b7a34b3b086afb
4
+ data.tar.gz: 6617c60cf1d35cf645dc174243f3e4af6aae57d921896bb8fbb772409de54e48
5
5
  SHA512:
6
- metadata.gz: d44d166eef2ea75f01ffe9c990b42e6a59ab932bc4e9a773ba00b7f11944448e1e4a16b426c6fc0649b472839825244f84e9825860bae0efb7d1d8c34209541b
7
- data.tar.gz: 6c2a3f9378751854d21daf34de2940a8a09f112a629fbaccbfb90f35c7e8bef56179cbae596d319749f165dd77e5413f712a8bdbb3d7b7e23f85cea9ecd6d321
6
+ metadata.gz: 7e4793df5b3719104cc32c0fffb24abf28d5346ffbcc69ce91e8c8a7c91ea67be774801112002dd922b6f1647cd37389bc0901ab6f3d6cfc7a5c41102a33805a
7
+ data.tar.gz: 9ad1a70dcd8751166d6f125d477e874ec48355f40550b15d2ecde71f42383ace50680174a756a11f75609ea5394066c37e09bd652def125fafeb4a644db17687
@@ -1,3 +1,7 @@
1
+ ### 1.0.2
2
+
3
+ * [NEW] Add ability to specify file-like objects for logo
4
+
1
5
  ### 1.0.1
2
6
 
3
7
  * [FIX] Make tables full width
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/one-month-dark.png")
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
- * `line_items` - **Required**
114
+ The logo must be either a string path to a file or a file-like object.
111
115
 
112
- 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.
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 'rspec/core/rake_task'
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: File.expand_path("./examples/gorails.png")
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: File.expand_path("./examples/gorails.png")
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>"],
Binary file
Binary file
@@ -52,12 +52,14 @@ module Receipts
52
52
  def header
53
53
  move_down 60
54
54
 
55
- logo_path = company.fetch(:logo, '')
55
+ logo = company[:logo]
56
56
 
57
- if logo_path.empty?
57
+ if logo.nil?
58
58
  move_down 32
59
- else
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
@@ -48,12 +48,14 @@ module Receipts
48
48
  def header
49
49
  move_down 60
50
50
 
51
- logo_path = company.fetch(:logo, '')
51
+ logo = company[:logo]
52
52
 
53
- if logo_path.empty?
53
+ if logo.nil?
54
54
  move_down 32
55
- else
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
@@ -1,3 +1,3 @@
1
1
  module Receipts
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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.1
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-06-27 00:00:00.000000000 Z
11
+ date: 2020-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler