flow-reference 0.2.85

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 24b36f5ba952da5c30801e95dad140e07f20dee9
4
+ data.tar.gz: acadd4dbbea167d0f82bf5413fb8421190e329c0
5
+ SHA512:
6
+ metadata.gz: 69b66c6c22ee90d7094c97d34db41f7a57f6c49ad572953e289ac950b430a9f757678a18478b045bea7f03a7b3fa7a291c92d5a658f5b64d65065afdef77664d
7
+ data.tar.gz: 22e8fd17ac0d7d57aeb171d44b88813886c4f6822b676df526b60074d15f53104aefabe844cd99e0c3a08b97d1d3f768a32553965f07e84292db658f932c3528
data/.apidoc ADDED
@@ -0,0 +1,7 @@
1
+ code:
2
+ flow:
3
+ reference:
4
+ version: latest
5
+ generators:
6
+ ruby_client: ./lib
7
+
@@ -0,0 +1,3 @@
1
+ .env
2
+ *.gem
3
+ tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rspec', require: false
4
+ gem 'pry', require: false
5
+ gem 'awesome_print', require: false
6
+
@@ -0,0 +1,36 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ awesome_print (1.7.0)
5
+ coderay (1.1.1)
6
+ diff-lcs (1.3)
7
+ method_source (0.8.2)
8
+ pry (0.10.4)
9
+ coderay (~> 1.1.0)
10
+ method_source (~> 0.8.1)
11
+ slop (~> 3.4)
12
+ rspec (3.5.0)
13
+ rspec-core (~> 3.5.0)
14
+ rspec-expectations (~> 3.5.0)
15
+ rspec-mocks (~> 3.5.0)
16
+ rspec-core (3.5.4)
17
+ rspec-support (~> 3.5.0)
18
+ rspec-expectations (3.5.0)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.5.0)
21
+ rspec-mocks (3.5.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.5.0)
24
+ rspec-support (3.5.0)
25
+ slop (3.6.0)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ awesome_print
32
+ pry
33
+ rspec
34
+
35
+ BUNDLED WITH
36
+ 1.14.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Flow Commerce
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # lib-reference-ruby
2
+
3
+ ## Usage
4
+
5
+ ```
6
+ require 'flow-reference'
7
+
8
+ usd = Flow::Reference::Currencies.find("usd")
9
+ # or
10
+ usd = Flow::Reference::Currencies::Data.Usd
11
+ usd.to_cents(10) # 1000
12
+
13
+ Flow::Reference::Currencies::Data.Jpy.to_cents(105) # 105
14
+ ```
15
+
16
+ ## Developer Installation
17
+
18
+ ```
19
+ bundler install # installs helper libs
20
+ bundler exec rspec # runs tests
21
+
22
+ bash ./bin/download.bash # gets json files
23
+ bash ./bin/generate.bash # auto-generates flow dep libs
24
+ ```
25
+
26
+ ### How it works?
27
+
28
+ * download fresh json with ./bin/download.bash
29
+ * generate libs with ./bin/generate.bash. Generated libs will be in ./lib/generated folder
30
+ * build and push gem
31
+ * gem build flow-reference.gemspec
32
+ * for local install and test
33
+ * gem install -l flow-reference-x-y-z.gem
34
+ * for the world
35
+ * gem push flow-reference-x-y-z.gem
36
+ * gem install 'flow-reference' # fresh install
37
+ * gem update 'flow-reference' # to get lates version
38
+
39
+ ## Examples Converting to cents
40
+
41
+ ```
42
+ Flow::Reference::Currencies::Data::Usd.to_cents("10.52") must equal(1052)
43
+ Flow::Reference::Currencies::Data::Usd.to_cents("10.524") must equal(1052)
44
+ Flow::Reference::Currencies::Data::Usd.to_cents("10.525") must equal(1053)
45
+ Flow::Reference::Currencies::Data::Usd.to_cents(100) must equal(10000)
46
+ Flow::Reference::Currencies::Data.Mro.to_cents("105") must equal(1050)
47
+ Flow::Reference::Currencies::Data.Mro.to_cents("105.55") must equal(1056)
48
+ Flow::Reference::Currencies::Data.Jpy.to_cents("105") must equal(105)
49
+ ```
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json'
4
+
5
+ CURRENCY_LIB_FILE = './lib/generated/currencies.rb'
6
+
7
+ currencies = JSON.load File.read './data/currencies.json'
8
+
9
+ lib_data = []
10
+
11
+ lib_data.push '# Generated by Flow code builder'
12
+ lib_data.push ''
13
+ lib_data.push 'module Flow'
14
+ lib_data.push ' module Reference'
15
+ lib_data.push ' class Currencies'
16
+ lib_data.push ' class Data'
17
+
18
+ currencies.each do |currency|
19
+ code = currency['iso_4217_3']
20
+ lib_data.push ' def Data.%s' % code.downcase.capitalize
21
+ lib_data.push ' ::Io::Flow::Reference::V0::Models::Currency.new(%s)' % currency.to_json
22
+ lib_data.push ' end'
23
+ lib_data.push ''
24
+ end
25
+
26
+ lib_data.push ' end'
27
+ lib_data.push ''
28
+ lib_data.push ' def Currencies._get_currency(code)'
29
+ lib_data.push ' case code'
30
+ currencies.each do |currency|
31
+ code = currency['iso_4217_3'].to_s.downcase.gsub(/[^\w]/,"")
32
+ lib_data.push ' when :%s' % code
33
+ lib_data.push ' return Data.%s' % code.capitalize
34
+ end
35
+ lib_data.push ' end'
36
+ lib_data.push ' nil'
37
+ lib_data.push ' end'
38
+ lib_data.push ' end'
39
+ lib_data.push ' end'
40
+ lib_data.push 'end'
41
+
42
+ #puts lib_data.join("\n")
43
+
44
+ File.open(CURRENCY_LIB_FILE, 'w') { |file| file.write(lib_data.join("\n")) }
45
+
46
+ puts 'Generated %s with currency %d entries' % [CURRENCY_LIB_FILE, currencies.length]
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ for json in continents countries currencies languages locales payment-methods regions
4
+ do
5
+ echo data/$json.json
6
+ curl -o "./data/$json.json" "https://raw.githubusercontent.com/flowcommerce/json-reference/master/data/final/$json.json"
7
+ done
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ruby ./bin/build-currency.rb
@@ -0,0 +1,259 @@
1
+ [
2
+ {
3
+ "name": "Africa",
4
+ "code": "AFR",
5
+ "countries": [
6
+ "BEN",
7
+ "BFA",
8
+ "BWA",
9
+ "CAF",
10
+ "CIV",
11
+ "CMR",
12
+ "COG",
13
+ "COM",
14
+ "CPV",
15
+ "DJI",
16
+ "DZA",
17
+ "EGY",
18
+ "ESH",
19
+ "ETH",
20
+ "GAB",
21
+ "GHA",
22
+ "GIN",
23
+ "GMB",
24
+ "GNB",
25
+ "GNQ",
26
+ "KEN",
27
+ "LBY",
28
+ "LSO",
29
+ "MAR",
30
+ "MLI",
31
+ "MRT",
32
+ "MUS",
33
+ "MWI",
34
+ "MYT",
35
+ "NAM",
36
+ "NER",
37
+ "NGA",
38
+ "REU",
39
+ "RWA",
40
+ "SEN",
41
+ "SHN",
42
+ "SLE",
43
+ "SOM",
44
+ "STP",
45
+ "SWZ",
46
+ "SYC",
47
+ "TCD",
48
+ "TGO",
49
+ "TUN",
50
+ "TZA",
51
+ "UGA",
52
+ "ZAF",
53
+ "ZMB"
54
+ ]
55
+ },
56
+ {
57
+ "name": "Antarctica",
58
+ "code": "ANT",
59
+ "countries": null
60
+ },
61
+ {
62
+ "name": "Asia",
63
+ "code": "ASI",
64
+ "countries": [
65
+ "ARE",
66
+ "ARM",
67
+ "AZE",
68
+ "BGD",
69
+ "BHR",
70
+ "BRN",
71
+ "BTN",
72
+ "CHN",
73
+ "GEO",
74
+ "HKG",
75
+ "IDN",
76
+ "IND",
77
+ "ISR",
78
+ "JOR",
79
+ "JPN",
80
+ "KAZ",
81
+ "KGZ",
82
+ "KHM",
83
+ "KOR",
84
+ "KWT",
85
+ "LAO",
86
+ "LBN",
87
+ "LKA",
88
+ "MAC",
89
+ "MDV",
90
+ "MNG",
91
+ "MYS",
92
+ "NPL",
93
+ "OMN",
94
+ "PAK",
95
+ "PHL",
96
+ "QAT",
97
+ "SAU",
98
+ "SGP",
99
+ "THA",
100
+ "TUR",
101
+ "TWN",
102
+ "UZB",
103
+ "VNM",
104
+ "YEM"
105
+ ]
106
+ },
107
+ {
108
+ "name": "Europe",
109
+ "code": "EUR",
110
+ "countries": [
111
+ "ALA",
112
+ "ALB",
113
+ "AND",
114
+ "AUT",
115
+ "BEL",
116
+ "BGR",
117
+ "BIH",
118
+ "CHE",
119
+ "CYP",
120
+ "CZE",
121
+ "DEU",
122
+ "DNK",
123
+ "ESP",
124
+ "EST",
125
+ "FIN",
126
+ "FRA",
127
+ "GBR",
128
+ "GGY",
129
+ "GIB",
130
+ "GRC",
131
+ "HRV",
132
+ "HUN",
133
+ "IMN",
134
+ "IRL",
135
+ "ISL",
136
+ "ITA",
137
+ "JEY",
138
+ "LIE",
139
+ "LTU",
140
+ "LUX",
141
+ "LVA",
142
+ "MCO",
143
+ "MDA",
144
+ "MLT",
145
+ "MNE",
146
+ "NLD",
147
+ "NOR",
148
+ "POL",
149
+ "PRT",
150
+ "ROU",
151
+ "RUS",
152
+ "SJM",
153
+ "SMR",
154
+ "SRB",
155
+ "SVK",
156
+ "SVN",
157
+ "SWE",
158
+ "UKR",
159
+ "VAT"
160
+ ]
161
+ },
162
+ {
163
+ "name": "North America",
164
+ "code": "NOA",
165
+ "countries": [
166
+ "ABW",
167
+ "AIA",
168
+ "ATG",
169
+ "BES",
170
+ "BHS",
171
+ "BLM",
172
+ "BLZ",
173
+ "BMU",
174
+ "BRB",
175
+ "CAN",
176
+ "CRI",
177
+ "CUW",
178
+ "CYM",
179
+ "DMA",
180
+ "DOM",
181
+ "GLP",
182
+ "GRD",
183
+ "GRL",
184
+ "GTM",
185
+ "HND",
186
+ "HTI",
187
+ "JAM",
188
+ "KNA",
189
+ "LCA",
190
+ "MAF",
191
+ "MEX",
192
+ "MSR",
193
+ "MTQ",
194
+ "NIC",
195
+ "PAN",
196
+ "PRI",
197
+ "SLV",
198
+ "SPM",
199
+ "SXM",
200
+ "TCA",
201
+ "TTO",
202
+ "USA",
203
+ "VCT",
204
+ "VGB",
205
+ "VIR"
206
+ ]
207
+ },
208
+ {
209
+ "name": "Oceania",
210
+ "code": "OCE",
211
+ "countries": [
212
+ "ASM",
213
+ "AUS",
214
+ "COK",
215
+ "FJI",
216
+ "FSM",
217
+ "GUM",
218
+ "KIR",
219
+ "MHL",
220
+ "MNP",
221
+ "NCL",
222
+ "NFK",
223
+ "NIU",
224
+ "NRU",
225
+ "NZL",
226
+ "PCN",
227
+ "PLW",
228
+ "PNG",
229
+ "PYF",
230
+ "SLB",
231
+ "TKL",
232
+ "TLS",
233
+ "TON",
234
+ "TUV",
235
+ "VUT",
236
+ "WLF",
237
+ "WSM"
238
+ ]
239
+ },
240
+ {
241
+ "name": "South America",
242
+ "code": "SOA",
243
+ "countries": [
244
+ "ARG",
245
+ "BOL",
246
+ "BRA",
247
+ "CHL",
248
+ "COL",
249
+ "ECU",
250
+ "FLK",
251
+ "GUF",
252
+ "GUY",
253
+ "PER",
254
+ "PRY",
255
+ "URY",
256
+ "VEN"
257
+ ]
258
+ }
259
+ ]