grosser-i18n_data 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -23,23 +23,23 @@ Usage
23
23
  sudo gem install grosser-i18n_data
24
24
  require 'i18n_data'
25
25
  ...
26
- I18NData.languages # {"DE"=>"German",...}
27
- I18NData.languages('DE') # {"DE"=>"Deutsch",...}
28
- I18NData.languages('FR') # {"DE"=>"Allemand",...}
26
+ I18nData.languages # {"DE"=>"German",...}
27
+ I18nData.languages('DE') # {"DE"=>"Deutsch",...}
28
+ I18nData.languages('FR') # {"DE"=>"Allemand",...}
29
29
  ...
30
30
 
31
- I18NData.countries # {"DE"=>"Germany",...}
32
- I18NData.countries('DE') # {"DE"=>"Deutschland",...}
31
+ I18nData.countries # {"DE"=>"Germany",...}
32
+ I18nData.countries('DE') # {"DE"=>"Deutschland",...}
33
33
  ...
34
34
 
35
35
  #Not yet implemented...
36
- I18NData.language_code('German') # DE
37
- I18NData.language_code('Deutsch') # DE
38
- I18NData.language_code('Allemand') # DE
36
+ I18nData.language_code('German') # DE
37
+ I18nData.language_code('Deutsch') # DE
38
+ I18nData.language_code('Allemand') # DE
39
39
  ..
40
40
 
41
- I18NData.country_code('Germany') # DE
42
- I18NData.country_code('Deutschland') # DE
41
+ I18nData.country_code('Germany') # DE
42
+ I18nData.country_code('Deutschland') # DE
43
43
  ..
44
44
 
45
45
  Data Providers
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  desc "write all languages to output"
13
13
  task :all_languages do
14
- I18NData.languages.keys.each do |lc|
14
+ I18nData.languages.keys.each do |lc|
15
15
  `rake languages LANGUAGE=#{lc}`
16
16
  end
17
17
  end
@@ -20,13 +20,13 @@ desc "write languages to output/languages_{language}"
20
20
  task :languages do
21
21
  raise unless language = ENV['LANGUAGE']
22
22
  `mkdir output -p`
23
- data = I18NData.languages(language.upcase)
23
+ data = I18nData.languages(language.upcase)
24
24
  File.open("output/languages_#{language.downcase}.yml",'w') {|f|f.puts data.to_yaml}
25
25
  end
26
26
 
27
27
  desc "write all countries to output"
28
28
  task :all_countries do
29
- I18NData.languages.keys.each do |lc|
29
+ I18nData.languages.keys.each do |lc|
30
30
  `rake countries LANGUAGE=#{lc}`
31
31
  end
32
32
  end
@@ -35,7 +35,7 @@ desc "write countries to output/countries_{language}"
35
35
  task :countries do
36
36
  raise unless language = ENV['LANGUAGE']
37
37
  `mkdir output -p`
38
- data = I18NData.countries(language.upcase)
38
+ data = I18nData.countries(language.upcase)
39
39
  File.open("output/countries_#{language.downcase}.yml",'w') {|f|f.puts data.to_yaml}
40
40
  end
41
41
 
@@ -45,10 +45,10 @@ task :example_output do
45
45
 
46
46
  #all names for germany, france, united kingdom and unites states
47
47
  ['DE','FR','GB','US'].each do |cc|
48
- names = I18NData.languages.keys.map do |lc|
48
+ names = I18nData.languages.keys.map do |lc|
49
49
  begin
50
- [I18NData.countries(lc)[cc], I18NData.languages[lc]]
51
- rescue I18NData::NoOnlineTranslationAvaiable
50
+ [I18nData.countries(lc)[cc], I18nData.languages[lc]]
51
+ rescue I18nData::NoOnlineTranslationAvaiable
52
52
  nil
53
53
  end
54
54
  end
@@ -58,22 +58,22 @@ task :example_output do
58
58
  end
59
59
  end
60
60
 
61
- desc "write cache for I18NData::FileDataProvider"
61
+ desc "write cache for I18nData::FileDataProvider"
62
62
  task :write_cache_for_file_data_provider do
63
63
  require 'i18n_data/file_data_provider'
64
64
  require 'i18n_data/live_data_provider'
65
- I18NData::FileDataProvider.write_cache(I18NData::LiveDataProvider)
65
+ I18nData::FileDataProvider.write_cache(I18nData::LiveDataProvider)
66
66
  end
67
67
 
68
68
  require 'echoe'
69
69
 
70
- Echoe.new('i18n_data', '0.1.2') do |p|
70
+ Echoe.new('i18n_data', '0.2.0') do |p|
71
71
  p.description = "country/language names and 2-letter-code pairs, in 85 languages, for country/language "
72
72
  p.url = "http://github.com/grosser/i18n_data"
73
73
  p.author = "Michael Grosser"
74
74
  p.email = "grosser.michael@gmail.com"
75
75
  p.ignore_pattern = ["tmp/*", "script/*", "nbproject/*", "nbproject/*/*", "output/*", "example_output/*"]
76
- p.dependencies = [] #requires activesupport, but crashes on require when activesupport is already loaded WTF!
76
+ p.dependencies = ['rexml','open-uri'] #requires activesupport, but crashes on require when activesupport is already loaded WTF!
77
77
  p.development_dependencies = ['echoe','spec','mocha','activesupport']
78
78
  end
79
79
 
data/i18n_data.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{i18n_data}
5
- s.version = "0.1.2"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Michael Grosser"]
9
- s.date = %q{2009-01-27}
9
+ s.date = %q{2009-02-02}
10
10
  s.description = %q{country/language names and 2-letter-code pairs, in 85 languages, for country/language}
11
11
  s.email = %q{grosser.michael@gmail.com}
12
12
  s.extra_rdoc_files = ["lib/i18n_data/file_data_provider.rb", "lib/i18n_data/live_data_provider.rb", "lib/i18n_data.rb", "README.markdown"]
@@ -24,17 +24,23 @@ Gem::Specification.new do |s|
24
24
  s.specification_version = 2
25
25
 
26
26
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<rexml>, [">= 0"])
28
+ s.add_runtime_dependency(%q<open-uri>, [">= 0"])
27
29
  s.add_development_dependency(%q<echoe>, [">= 0"])
28
30
  s.add_development_dependency(%q<spec>, [">= 0"])
29
31
  s.add_development_dependency(%q<mocha>, [">= 0"])
30
32
  s.add_development_dependency(%q<activesupport>, [">= 0"])
31
33
  else
34
+ s.add_dependency(%q<rexml>, [">= 0"])
35
+ s.add_dependency(%q<open-uri>, [">= 0"])
32
36
  s.add_dependency(%q<echoe>, [">= 0"])
33
37
  s.add_dependency(%q<spec>, [">= 0"])
34
38
  s.add_dependency(%q<mocha>, [">= 0"])
35
39
  s.add_dependency(%q<activesupport>, [">= 0"])
36
40
  end
37
41
  else
42
+ s.add_dependency(%q<rexml>, [">= 0"])
43
+ s.add_dependency(%q<open-uri>, [">= 0"])
38
44
  s.add_dependency(%q<echoe>, [">= 0"])
39
45
  s.add_dependency(%q<spec>, [">= 0"])
40
46
  s.add_dependency(%q<mocha>, [">= 0"])
@@ -1,4 +1,4 @@
1
- module I18NData
1
+ module I18nData
2
2
  module FileDataProvider
3
3
  DATA_SEPERATOR = ";;"
4
4
  extend self
@@ -3,7 +3,7 @@ require 'rexml/document'
3
3
  gem 'activesupport', '> 2.2'
4
4
  require 'activesupport'
5
5
 
6
- module I18NData
6
+ module I18nData
7
7
  # fetches data online from debian svn
8
8
  module LiveDataProvider
9
9
  extend ActiveSupport::Memoizable
data/lib/i18n_data.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'activesupport'
2
- module I18NData
2
+ module I18nData
3
3
  extend self
4
4
 
5
5
  def languages(language_code='EN')
@@ -1,23 +1,23 @@
1
1
  require File.join(File.dirname(__FILE__),'..',"spec_helper")
2
2
  require 'i18n_data/file_data_provider'
3
3
 
4
- describe I18NData::FileDataProvider do
4
+ describe I18nData::FileDataProvider do
5
5
  before do
6
- `rm -f #{I18NData::FileDataProvider.send(:cache_for,"XX","YY")}`
6
+ `rm -f #{I18nData::FileDataProvider.send(:cache_for,"XX","YY")}`
7
7
  end
8
8
 
9
9
  def read(x,y)
10
- I18NData::FileDataProvider.codes(x,y)
10
+ I18nData::FileDataProvider.codes(x,y)
11
11
  end
12
12
 
13
13
  it "preserves data when writing and then reading" do
14
14
  data = {"x"=>"y","z"=>"w"}
15
- I18NData::FileDataProvider.send(:write_to_file,data,"XX","YY")
15
+ I18nData::FileDataProvider.send(:write_to_file,data,"XX","YY")
16
16
  read("XX","YY").should == data
17
17
  end
18
18
 
19
19
  it "does not write empty data sets" do
20
- I18NData::FileDataProvider.send(:write_to_file,{},"XX","YY")
21
- lambda{read("XX","YY")}.should raise_error I18NData::NoTranslationAvailable
20
+ I18nData::FileDataProvider.send(:write_to_file,{},"XX","YY")
21
+ lambda{read("XX","YY")}.should raise_error I18nData::NoTranslationAvailable
22
22
  end
23
23
  end
@@ -1,10 +1,10 @@
1
1
  require File.join(File.dirname(__FILE__),'..',"spec_helper")
2
2
  require 'i18n_data/live_data_provider'
3
3
 
4
- describe I18NData::LiveDataProvider do
4
+ describe I18nData::LiveDataProvider do
5
5
  describe :po_to_hash do
6
6
  def po_to_hash(text)
7
- I18NData::LiveDataProvider.send(:po_to_hash,text)
7
+ I18nData::LiveDataProvider.send(:po_to_hash,text)
8
8
  end
9
9
  it "parses po file into translations" do
10
10
  text = <<EOF
@@ -3,74 +3,74 @@ require File.expand_path("spec_helper", File.dirname(__FILE__))
3
3
  NUM_2_LETTER_LANGUAGES = 185
4
4
  NUM_COUNTRIES = 246
5
5
 
6
- describe I18NData do
6
+ describe I18nData do
7
7
  require "i18n_data/live_data_provider"
8
8
  require "i18n_data/file_data_provider"
9
- [I18NData::LiveDataProvider,I18NData::FileDataProvider].each do |provider|
9
+ [I18nData::LiveDataProvider,I18nData::FileDataProvider].each do |provider|
10
10
  describe "using #{provider}" do
11
11
  before :all do
12
- I18NData.data_provider = provider
12
+ I18nData.data_provider = provider
13
13
  end
14
14
  describe :languages do
15
15
  it "raises NoTranslationAvailable for unavailable languages" do
16
- lambda{I18NData.languages('XX')}.should raise_error(I18NData::NoTranslationAvailable)
16
+ lambda{I18nData.languages('XX')}.should raise_error(I18nData::NoTranslationAvailable)
17
17
  end
18
18
  describe :english do
19
19
  it "does not contain blanks" do
20
- I18NData.languages.detect {|k,v| k.blank? or v.blank?}.should == nil
20
+ I18nData.languages.detect {|k,v| k.blank? or v.blank?}.should == nil
21
21
  end
22
22
  it "has english as default" do
23
- I18NData.languages['DE'].should == 'German'
23
+ I18nData.languages['DE'].should == 'German'
24
24
  end
25
25
  it "contains all languages" do
26
- I18NData.languages.size.should == NUM_2_LETTER_LANGUAGES
26
+ I18nData.languages.size.should == NUM_2_LETTER_LANGUAGES
27
27
  end
28
28
  end
29
29
  describe :translated do
30
30
  it "is translated" do
31
- I18NData.languages('DE')['DE'].should == 'Deutsch'
31
+ I18nData.languages('DE')['DE'].should == 'Deutsch'
32
32
  end
33
33
  it "contains all languages" do
34
- I18NData.languages('DE').size.should == NUM_2_LETTER_LANGUAGES
34
+ I18nData.languages('DE').size.should == NUM_2_LETTER_LANGUAGES
35
35
  end
36
36
  it "has english names for not-translateable languages" do
37
- I18NData.languages('IS')['HA'].should == I18NData.languages['HA']
37
+ I18nData.languages('IS')['HA'].should == I18nData.languages['HA']
38
38
  end
39
39
  it "does not contain blanks" do
40
- I18NData.languages('GL').detect {|k,v| k.blank? or v.blank?}.should == nil
40
+ I18nData.languages('GL').detect {|k,v| k.blank? or v.blank?}.should == nil
41
41
  end
42
42
  it "is written in unicode" do
43
- I18NData.languages('DE')['DA'].should == 'Dänisch'
43
+ I18nData.languages('DE')['DA'].should == 'Dänisch'
44
44
  end
45
45
  end
46
46
  end
47
47
  describe :countries do
48
48
  describe :english do
49
49
  it "has english as default" do
50
- I18NData.countries['DE'].should == 'Germany'
50
+ I18nData.countries['DE'].should == 'Germany'
51
51
  end
52
52
  it "does not contain blanks" do
53
- I18NData.countries.detect {|k,v| k.blank? or v.blank?}.should == nil
53
+ I18nData.countries.detect {|k,v| k.blank? or v.blank?}.should == nil
54
54
  end
55
55
  it "contains all countries" do
56
- I18NData.countries.size.should == NUM_COUNTRIES
56
+ I18nData.countries.size.should == NUM_COUNTRIES
57
57
  end
58
58
  end
59
59
  describe :translated do
60
60
  it "is translated" do
61
- I18NData.countries('DE')['DE'].should == 'Deutschland'
61
+ I18nData.countries('DE')['DE'].should == 'Deutschland'
62
62
  end
63
63
  it "contains all countries" do
64
- I18NData.countries('DE').size.should == NUM_COUNTRIES
64
+ I18nData.countries('DE').size.should == NUM_COUNTRIES
65
65
  end
66
66
  it "has english names for not-translateable countries" do
67
- I18NData.countries('IS')['PK'].should == I18NData.countries['PK']
67
+ I18nData.countries('IS')['PK'].should == I18nData.countries['PK']
68
68
  end
69
69
  it "does not contain blanks" do
70
- I18NData.countries('GL').detect {|k,v| k.blank? or v.blank?}.should == nil
70
+ I18nData.countries('GL').detect {|k,v| k.blank? or v.blank?}.should == nil
71
71
  end
72
72
  it "is written in unicode" do
73
- I18NData.countries('DE')['DK'].should == 'Dänemark'
73
+ I18nData.countries('DE')['DK'].should == 'Dänemark'
74
74
  end
75
75
  end
76
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grosser-i18n_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -9,9 +9,27 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-27 00:00:00 -08:00
12
+ date: 2009-02-02 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rexml
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: open-uri
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
15
33
  - !ruby/object:Gem::Dependency
16
34
  name: echoe
17
35
  version_requirement: