swiss_qr_bill 0.1.0 → 0.1.1

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: f994168de5ab5bb925c716de6341de11fb79c403641858e94552a7576ab20ab1
4
- data.tar.gz: 57e759c4076e09e3ec2ff556eb1d22c084d1788a1b5154ccf2d3eb390d0f2132
3
+ metadata.gz: de84a5080c04ece3528f8e0ac793f1517e5e01d16d94f6e80b87e84e0d5ee877
4
+ data.tar.gz: 6f5602368bc17d25dae9281cedc55d59c7e157101c2ac8b6bb039e187384cdb1
5
5
  SHA512:
6
- metadata.gz: 28c74f4a36ecc862d27305720b4183d8ee065f31858017ecf9831b079d8b6cb72d934ada97b23400626b0858188963452dc9b3a0017d1ff72615f50b957260ca
7
- data.tar.gz: d42289f1e25ed4d2166ae713af67b6fcea4290d9f22444d48ba64a25e1ed9ca6316df2bbad637bf2837d6e003e81bce5e5f0e8ed832cd83a2b0d4cfc50898d17
6
+ metadata.gz: a585399a6e03872554b1b1231a53dbaf05a3b66b0d42d7162097bb0f39d869d9a910f54591c5a8613fe123b781f49b81bb8681a65463fbee7085181ebc3098d3
7
+ data.tar.gz: 473c039954d34a22b72b7067e61c67a8f4e24de80d21b04c0315f1ae7b8b3b5d204858b6927b61bd31e65cc03aa5c856eb5a84063995e46592448000d3b938ce
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 4.0.0
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A Ruby Gem for reading and parsing Swiss QR-Bills from documents like PDFs and images.
4
4
 
5
- This gem is meant for reading and parsing Swiss QR-Bill codes out of documents, if you are looking to generate Swiss QR-Bills check out the [`qr-bills` gem](https://github.com/damoiser/qr-bills).
5
+ This gem is meant for reading and parsing Swiss QR-Bill codes out of documents, if you are looking to generate Swiss QR-Bills check out the [`qr-bills`](https://github.com/damoiser/qr-bills) and [`prawn-swiss_qr_bill`](https://github.com/mitosch/prawn-swiss_qr_bill) gems.
6
6
 
7
7
  ## Installation
8
8
 
@@ -24,8 +24,21 @@ Install the required NPM packages:
24
24
  yarn add @andreekeberg/imagedata pdf-to-png-converter jsqr
25
25
  ```
26
26
 
27
+ #### Note
28
+
29
+ This gem is built on top of the [`jsQR`](https://github.com/cozmo/jsQR) NPM package, which means you need to be running [Node.js](https://nodejs.org/en). We utilize the [`nodo`](https://github.com/mtgrosser/nodo) gem for calling out to Node.js.
30
+
31
+ TL;DR: as long as you have Node.js installed and the above listed NPM packages installed you shouldn't notice that it's calling out to Node.js.
32
+
33
+
27
34
  ## Usage
28
35
 
36
+ Given the following QR-Bill:
37
+
38
+ ![](https://github.com/marcoroth/swiss_qr_bill/blob/main/test/fixtures/muster-qr-zahlteile-en/Nr.%201%20englisch.jpg?raw=true)
39
+
40
+ You can read out it's information using:
41
+
29
42
  ```ruby
30
43
  require "swiss_qr_bill"
31
44
 
@@ -36,7 +49,7 @@ qr_bills.first
36
49
  # #<data SwissQRBill::QRBill
37
50
  # header=#<data SwissQRBill::QRBill::Header qr_type="SPC", version="0200", coding_type="1">,
38
51
  # creditor_information=#<data SwissQRBill::QRBill::CreditorInformation iban="CH6431961000004421557">,
39
- # creditor= #<data SwissQRBill::QRBill::StructuredAddress type="S", name="Health insurance fit&kicking", street="Am Wasser", building_number="1", postal_code="3000", town="Bern", country="CH">,
52
+ # creditor=#<data SwissQRBill::QRBill::StructuredAddress type="S", name="Health insurance fit&kicking", street="Am Wasser", building_number="1", postal_code="3000", town="Bern", country="CH">,
40
53
  # ulimate_creditor=#<data SwissQRBill::QRBill::StructuredAddress type="", name="", street="", building_number="", postal_code="", town="", country="">,
41
54
  # debtor=#<data SwissQRBill::QRBill::StructuredAddress type="S", name="Sarah Beispiel", street="Mustergasse", building_number="1", postal_code="3600", town="Thun", country="CH">,
42
55
  # payment_amount_information=#<data SwissQRBill::QRBill::PaymentAmountInformation amount=111.0, currency="CHF">,
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "qr_code_scanner"
4
+
3
5
  module SwissQRBill
4
6
  class QRBillParser
5
7
  def self.parse_file(path)
6
- detected_codes = QRCodeParser.parse_file(path)
8
+ detected_codes = QRCodeScanner.scan(path)
7
9
 
8
10
  return [] if detected_codes.empty?
9
11
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SwissQRBill
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/swiss_qr_bill.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "swiss_qr_bill/version"
4
- require_relative "swiss_qr_bill/qr_code_parser"
5
-
6
4
  require_relative "swiss_qr_bill/qr_bill"
7
5
  require_relative "swiss_qr_bill/qr_bill_parser"
8
6
 
data/yarn.lock CHANGED
@@ -12,9 +12,9 @@
12
12
  mime-kind "^3.0.0"
13
13
 
14
14
  "@babel/runtime@^7.7.2":
15
- version "7.26.0"
16
- resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1"
17
- integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==
15
+ version "7.26.10"
16
+ resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.10.tgz#a07b4d8fa27af131a633d7b3524db803eb4764c2"
17
+ integrity sha512-2WJMeRQPHKSPemqk/awGrAiuFfzBmOIPXKizAsVhWH9YJqLZ0H+HS4c8loHGgW6utJ3E/ejXQUsiGaQy2NZ9Fw==
18
18
  dependencies:
19
19
  regenerator-runtime "^0.14.0"
20
20
 
@@ -559,9 +559,9 @@ mime@^1.3.4:
559
559
  integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
560
560
 
561
561
  min-document@^2.19.0:
562
- version "2.19.0"
563
- resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685"
564
- integrity sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ==
562
+ version "2.19.2"
563
+ resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.2.tgz#f95db44639eaae3ac8ea85ae6809ae85ff7e3b81"
564
+ integrity sha512-8S5I8db/uZN8r9HSLFVWPdJCvYOejMcEC82VIzNUc6Zkklf/d1gg2psfE79/vyhWOj4+J8MtwmoOz3TmvaGu5A==
565
565
  dependencies:
566
566
  dom-walk "^0.1.0"
567
567
 
metadata CHANGED
@@ -1,29 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiss_qr_bill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Roth
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: nodo
13
+ name: qr_code_scanner
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - ">="
16
+ - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '0'
18
+ version: '0.1'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - ">="
23
+ - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '0'
25
+ version: '0.1'
27
26
  description: A Ruby Gem for reading and parsing Swiss QR-Bills from documents.
28
27
  email:
29
28
  - marco.roth@intergga.ch
@@ -33,6 +32,7 @@ extra_rdoc_files: []
33
32
  files:
34
33
  - ".node-version"
35
34
  - ".rubocop.yml"
35
+ - ".ruby-version"
36
36
  - ".yarnrc"
37
37
  - CHANGELOG.md
38
38
  - CODE_OF_CONDUCT.md
@@ -41,11 +41,9 @@ files:
41
41
  - lib/swiss_qr_bill.rb
42
42
  - lib/swiss_qr_bill/qr_bill.rb
43
43
  - lib/swiss_qr_bill/qr_bill_parser.rb
44
- - lib/swiss_qr_bill/qr_code_parser.rb
45
44
  - lib/swiss_qr_bill/version.rb
46
45
  - package.json
47
46
  - sig/swiss_qr_bill.rbs
48
- - swiss_qr_bill.gemspec
49
47
  - yarn.lock
50
48
  homepage: https://github.com/marcoroth/swiss_qr_bill
51
49
  licenses: []
@@ -54,7 +52,6 @@ metadata:
54
52
  rubygems_mfa_required: 'true'
55
53
  source_code_uri: https://github.com/marcoroth/swiss_qr_bill
56
54
  changelog_uri: https://github.com/marcoroth/swiss_qr_bill/blob/main/CHANGELOG.md
57
- post_install_message:
58
55
  rdoc_options: []
59
56
  require_paths:
60
57
  - lib
@@ -69,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
66
  - !ruby/object:Gem::Version
70
67
  version: '0'
71
68
  requirements: []
72
- rubygems_version: 3.5.5
73
- signing_key:
69
+ rubygems_version: 4.0.3
74
70
  specification_version: 4
75
71
  summary: A Ruby Gem for reading and parsing Swiss QR-Bills from documents.
76
72
  test_files: []
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "nodo"
4
-
5
- module SwissQRBill
6
- class QRCodeParser < Nodo::Core
7
- require fs: "node:fs"
8
- require path: "node:path"
9
-
10
- require jsQR: "jsqr"
11
- require pdfToPng: "pdf-to-png-converter"
12
- require imagedata: "@andreekeberg/imagedata"
13
-
14
- def self.parse_file(path)
15
- if path.end_with?(".pdf")
16
- new.parse_pdf(path)
17
- else
18
- [new.parse_image(path)]
19
- end
20
- end
21
-
22
- function :parse_image, <<~JS
23
- (imagePath) => {
24
- const { data, width, height } = imagedata.getSync(imagePath)
25
-
26
- return jsQR(data, width, height)?.data
27
- }
28
- JS
29
-
30
- function :parse_pdf, <<~JS
31
- async (pdfPath) => {
32
- const filename = path.basename(pdfPath)
33
-
34
- const pages = await pdfToPng.pdfToPng(pdfPath, { // The function accepts PDF file path or a Buffer
35
- disableFontFace: false, // When `false`, fonts will be rendered using a built-in font renderer that constructs the glyphs with primitive path commands. Default value is true.
36
- // useSystemFonts: false, // When `true`, fonts that aren't embedded in the PDF document will fallback to a system font. Default value is false.
37
- // enableXfa: false, // Render Xfa forms if any. Default value is false.
38
- viewportScale: 3.0, // The desired scale of PNG viewport. Default value is 1.0.
39
- outputFolder: 'tmp/swiss_qr_bill', // Folder to write output PNG files. If not specified, PNG output will be available only as a Buffer content, without saving to a file.
40
- outputFileMaskFunc: (page) => `${filename}_page_${page}.png`, // Function to generate custom output filenames. Example: (pageNum) => `page_${pageNum}.png`
41
- // pdfFilePassword: 'pa$$word', // Password for encrypted PDF.
42
- // pagesToProcess: [1, 3, 11], // Subset of pages to convert (first page = 1), other pages will be skipped if specified.
43
- // strictPagesToProcess: false, // When `true`, will throw an error if specified page number in pagesToProcess is invalid, otherwise will skip invalid page. Default value is false.
44
- // verbosityLevel: 0 // Verbosity level. ERRORS: 0, WARNINGS: 1, INFOS: 5. Default value is 0.
45
- })
46
-
47
- const result = pages.map(page => parse_image(page.path))
48
-
49
- pages.map(page => fs.unlinkSync(page.path)) // cleanup generated images
50
-
51
- return result.filter(result => result)
52
- }
53
- JS
54
- end
55
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/swiss_qr_bill/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "swiss_qr_bill"
7
- spec.version = SwissQRBill::VERSION
8
- spec.authors = ["Marco Roth"]
9
- spec.email = ["marco.roth@intergga.ch"]
10
-
11
- spec.summary = "A Ruby Gem for reading and parsing Swiss QR-Bills from documents."
12
- spec.description = spec.summary
13
- spec.homepage = "https://github.com/marcoroth/swiss_qr_bill"
14
- spec.required_ruby_version = ">= 3.2.0"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["rubygems_mfa_required"] = "true"
18
- spec.metadata["source_code_uri"] = "https://github.com/marcoroth/swiss_qr_bill"
19
- spec.metadata["changelog_uri"] = "https://github.com/marcoroth/swiss_qr_bill/blob/main/CHANGELOG.md"
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(__dir__) do
24
- `git ls-files -z`.split("\x0").reject do |f|
25
- (File.expand_path(f) == __FILE__) ||
26
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27
- end
28
- end
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
-
33
- spec.add_dependency "nodo"
34
- end