countries 2.1.0 → 2.1.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
  SHA1:
3
- metadata.gz: e8fc719a6c875b10fcb6e46302add80010155e19
4
- data.tar.gz: f020ded0676f664d3dbfb587844ff37321d66606
3
+ metadata.gz: 735b197a9e7e8fda800a39ab7e2558da8ee59b80
4
+ data.tar.gz: 7af8cbb88f8301bf72f8831fffffa2d556f38a81
5
5
  SHA512:
6
- metadata.gz: 149f9e07816af0d46bdf9ae28fd3c4199dccd0f44d914756402addfe1186f7d2e4bf877d6b42c75a0f02cb88c7aab71e5b7f07c430c00ea792ed5d877b103947
7
- data.tar.gz: 7a372638737464c1bd72d1fdc1c036fe8b75d05d4aa47cace4d253ce997ff2599cd5c21e10b7aa63a6599daef01065a45e875fa37a4af1bf79497e8917dd3424
6
+ metadata.gz: 5d3b4230c7a1500f5eab70351d027b1ede91811817cac14e8e602a222d7fdc68b61bb8af5ef5b8150e5ae888e9e9ce01cc003dd85e6b27c33c8e822e9ddcf127
7
+ data.tar.gz: 8e9d46e88acad56b12dbead0157f0895a4c80b10bc850e3bf26fe15a10a950241d5ee54763719d39cf332a236eb16e62c99d5488bfad7a6e891997bad2af19b3
@@ -2,6 +2,7 @@ module ISO3166
2
2
  ##
3
3
  # Handles building the in memory store of countries data
4
4
  class Data
5
+ @@cache_dir = [File.dirname(__FILE__), 'cache']
5
6
  @@cache = {}
6
7
  @@registered_data = {}
7
8
 
@@ -14,6 +15,14 @@ module ISO3166
14
15
  end
15
16
 
16
17
  class << self
18
+ def cache_dir
19
+ @@cache_dir
20
+ end
21
+
22
+ def cache_dir=(value)
23
+ @@cache_dir = value
24
+ end
25
+
17
26
  def register(data)
18
27
  alpha2 = data[:alpha2].upcase
19
28
  @@registered_data[alpha2] = \
@@ -52,7 +61,7 @@ module ISO3166
52
61
 
53
62
  def load_data!
54
63
  return @@cache unless load_required?
55
- @@cache = load_cache %w(cache countries.json)
64
+ @@cache = load_cache %w(countries.json)
56
65
  @@_country_codes = @@cache.keys
57
66
  @@cache = @@cache.merge(@@registered_data)
58
67
  @@cache
@@ -106,7 +115,7 @@ module ISO3166
106
115
  end
107
116
 
108
117
  def load_translations(locale)
109
- locale_names = load_cache(['cache', 'locales', "#{locale}.json"])
118
+ locale_names = load_cache(['locales', "#{locale}.json"])
110
119
  internal_codes.each do |alpha2|
111
120
  @@cache[alpha2]['translations'] ||= Translations.new
112
121
  @@cache[alpha2]['translations'][locale] = locale_names[alpha2].freeze
@@ -129,7 +138,7 @@ module ISO3166
129
138
  end
130
139
 
131
140
  def datafile_path(file_array)
132
- File.join([File.dirname(__FILE__)] + file_array)
141
+ File.join([@@cache_dir] + file_array)
133
142
  end
134
143
  end
135
144
  end
@@ -1,6 +1,7 @@
1
1
  module ISO3166
2
2
  Subdivision = KwargStruct.new(
3
3
  :name,
4
+ :code,
4
5
  :unofficial_names,
5
6
  :geo,
6
7
  :translations,
@@ -1,3 +1,3 @@
1
1
  module Countries
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.1.1'.freeze
3
3
  end
@@ -81,12 +81,12 @@ describe ISO3166::Data do
81
81
 
82
82
  describe '#load_cache' do
83
83
  it 'will return an empty hash for an unsupported locale' do
84
- file_array = %w(cache locales unsupported.json)
84
+ file_array = %w(locales unsupported.json)
85
85
  expect(ISO3166::Data.send(:load_cache, file_array)).to eql({})
86
86
  end
87
87
 
88
88
  it 'will return json for a supported locale' do
89
- file_array = %w(cache locales en.json)
89
+ file_array = %w(locales en.json)
90
90
  expect(ISO3166::Data.send(:load_cache, file_array)).not_to be_empty
91
91
  end
92
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: countries
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Robinson