en16931 0.2.0 → 0.2.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.
@@ -166,6 +166,9 @@ module EN16931
166
166
 
167
167
  # A supported locale as a symbol; anything unknown falls back to German.
168
168
  def self.locale(value) = LABELS.key?(value&.to_sym) ? value.to_sym : :de
169
+
170
+ # Country names per locale from CLDR, see `rake countries`.
171
+ def self.countries = @countries ||= YAML.load_file(File.join(ROOT, "data", "countries.yml"))
169
172
  end
170
173
  end
171
174
  end
@@ -255,10 +255,7 @@ module EN16931
255
255
  def date(d) = d.strftime(FORMATS.fetch(locale)[2])
256
256
  def unit(code) = LABELS.fetch(locale)[:units].fetch(code, code)
257
257
 
258
- def country_name(code)
259
- { "DE" => "Deutschland", "AT" => "Österreich", "CH" => "Schweiz", "FR" => "Frankreich", "NL" => "Niederlande",
260
- "US" => "USA", "GB" => "Vereinigtes Königreich", "IE" => "Irland", "LU" => "Luxemburg" }.fetch(code, code)
261
- end
258
+ def country_name(code) = Renderer.countries.fetch(locale.to_s).fetch(code, code)
262
259
  end
263
260
  end
264
261
  end
data/lib/en16931/pdf.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "prawn"
4
4
  require "stringio"
5
+ require "yaml"
5
6
  require "prawn/table"
6
7
  require_relative "pdf/xmp"
7
8
  require_relative "pdf/giro_code"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EN16931
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: en16931
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schwed
@@ -93,6 +93,8 @@ files:
93
93
  - LICENSE.txt
94
94
  - README.md
95
95
  - Rakefile
96
+ - data/LICENSE-CLDR.txt
97
+ - data/countries.yml
96
98
  - fonts/DejaVuSans-Bold.ttf
97
99
  - fonts/DejaVuSans.ttf
98
100
  - fonts/LICENSE-DejaVu.txt