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 +4 -4
- data/lib/qr-bills.rb +14 -14
- data/lib/qr-bills/qr-generator.rb +1 -1
- data/lib/qr-bills/qr-params.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a85d84e79fe4fa53efb5f4d4821e16c81b284a130c846080899832a96bd4411f
|
4
|
+
data.tar.gz: 1259e4936f1c13236e8db5f3a030e915c3cf4187cfe5cbae860932b1cc8862f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18740e8deb4d743597acdee385ee27e2f05b79ea912d64d4c57e83d6a4e9ab6b8681e2db92634fec366e9124fe4639a689ce334d6bddc2278b81b6ba2615193c
|
7
|
+
data.tar.gz: f6a0c34c01b2c61484dde00ca5965feb08c059eba293f7977a91ca9f0eca476205280453ff333b135f876e4edfd06b681593a584acea6544adf8d8f7d043eb34
|
data/lib/qr-bills.rb
CHANGED
@@ -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
|
|
data/lib/qr-bills/qr-params.rb
CHANGED
@@ -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,
|