qr-bills 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e1fe21f94c47f9bf2a75366c84c57613da064450e93c9d1392ae29a0e4a1cb4
4
- data.tar.gz: 603a98f65633d442e67644113b531165fcc2cbff6160496ad15ff5ae8b075122
3
+ metadata.gz: a85d84e79fe4fa53efb5f4d4821e16c81b284a130c846080899832a96bd4411f
4
+ data.tar.gz: 1259e4936f1c13236e8db5f3a030e915c3cf4187cfe5cbae860932b1cc8862f3
5
5
  SHA512:
6
- metadata.gz: a29968031cea9c22e8e48e07e34b142e24045b75324a2708680af7ce1b95f3041432b3fb158a7a8a38233ca49da30225371ce3857f053cfba7331a0a16ff99b8
7
- data.tar.gz: 22dfd9f688aebf73e2aef1fc0f72f7a126ccfd7d08bff9c5495756bcedff293bd69c30e10a24bccaa843e05ac916e5609c302aa913c70ff2e7f2b60a09326020
6
+ metadata.gz: 18740e8deb4d743597acdee385ee27e2f05b79ea912d64d4c57e83d6a4e9ab6b8681e2db92634fec366e9124fe4639a689ce334d6bddc2278b81b6ba2615193c
7
+ data.tar.gz: f6a0c34c01b2c61484dde00ca5965feb08c059eba293f7977a91ca9f0eca476205280453ff333b135f876e4edfd06b681593a584acea6544adf8d8f7d043eb34
@@ -6,27 +6,15 @@ require 'qr-bills/qr-creditor-reference'
6
6
 
7
7
  class QRBills
8
8
  def self.generate(qr_params)
9
- # init translator sets
10
- I18n.load_path << "#{File.expand_path("#{File.dirname(__FILE__)}/../config/locales/it.yml")}"
11
- I18n.load_path << "#{File.expand_path("#{File.dirname(__FILE__)}/../config/locales/en.yml")}"
12
- I18n.load_path << "#{File.expand_path("#{File.dirname(__FILE__)}/../config/locales/de.yml")}"
13
- I18n.load_path << "#{File.expand_path("#{File.dirname(__FILE__)}/../config/locales/fr.yml")}"
14
- I18n.default_locale = :it
15
-
16
- bill = {
17
- params: qr_params,
18
- output: nil
19
- }
20
9
 
10
+ # params validation
21
11
  if qr_params.has_key?(:bill_type)
22
12
 
23
13
  if !QRParams.valid?(qr_params)
24
14
  raise QRExceptions::INVALID_PARAMETERS + ": params validation check failed"
25
15
  end
26
16
 
27
- if qr_params[:output_params][:format] == "html"
28
- bill[:output] = QRHTMLLayout.create(qr_params)
29
- else
17
+ if !qr_params[:output_params][:format] == "html"
30
18
  raise QRExceptions::NOT_SUPPORTED + ": html is the only output format supported so far"
31
19
  end
32
20
 
@@ -34,6 +22,18 @@ class QRBills
34
22
  raise QRExceptions::INVALID_PARAMETERS + ": bill type param not set"
35
23
  end
36
24
 
25
+ # init translator sets
26
+ I18n.load_path << File.join(qr_params[:locales][:path], "it.yml")
27
+ I18n.load_path << File.join(qr_params[:locales][:path], "en.yml")
28
+ I18n.load_path << File.join(qr_params[:locales][:path], "de.yml")
29
+ I18n.load_path << File.join(qr_params[:locales][:path], "fr.yml")
30
+ I18n.default_locale = :it
31
+
32
+ bill = {
33
+ params: qr_params,
34
+ output: QRHTMLLayout.create(qr_params)
35
+ }
36
+
37
37
  return bill
38
38
  end
39
39
 
@@ -1,5 +1,5 @@
1
1
  require 'rqrcode'
2
- require 'RMagick'
2
+ require 'rmagick'
3
3
  include Magick
4
4
 
5
5
  class QRGenerator
@@ -13,6 +13,9 @@ class QRParams
13
13
  ttf: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.ttf"),
14
14
  svg: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.svg")
15
15
  },
16
+ locales: {
17
+ path: File.expand_path("#{File.dirname(__FILE__)}/../../config/locales")
18
+ },
16
19
  bill_params: {
17
20
  language: "it",
18
21
  amount: 0.0,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qr-bills
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damiano Radice