ar_serialized_array 0.1.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/.gitignore +3 -0
  2. data/CHANGELOG +2 -0
  3. data/README.markdown +57 -0
  4. data/Rakefile +68 -5
  5. data/VERSION +1 -1
  6. data/cache/file_data_provider/countries-AF.txt +246 -0
  7. data/cache/file_data_provider/countries-AM.txt +246 -0
  8. data/cache/file_data_provider/countries-AR.txt +246 -0
  9. data/cache/file_data_provider/countries-AZ.txt +246 -0
  10. data/cache/file_data_provider/countries-BE.txt +246 -0
  11. data/cache/file_data_provider/countries-BG.txt +246 -0
  12. data/cache/file_data_provider/countries-BN.txt +246 -0
  13. data/cache/file_data_provider/countries-BR.txt +246 -0
  14. data/cache/file_data_provider/countries-BS.txt +246 -0
  15. data/cache/file_data_provider/countries-CA.txt +246 -0
  16. data/cache/file_data_provider/countries-CS.txt +246 -0
  17. data/cache/file_data_provider/countries-CY.txt +246 -0
  18. data/cache/file_data_provider/countries-DA.txt +246 -0
  19. data/cache/file_data_provider/countries-DE.txt +246 -0
  20. data/cache/file_data_provider/countries-DZ.txt +246 -0
  21. data/cache/file_data_provider/countries-EL.txt +246 -0
  22. data/cache/file_data_provider/countries-EN.txt +246 -0
  23. data/cache/file_data_provider/countries-EO.txt +246 -0
  24. data/cache/file_data_provider/countries-ES.txt +246 -0
  25. data/cache/file_data_provider/countries-ET.txt +246 -0
  26. data/cache/file_data_provider/countries-EU.txt +246 -0
  27. data/cache/file_data_provider/countries-FA.txt +246 -0
  28. data/cache/file_data_provider/countries-FI.txt +246 -0
  29. data/cache/file_data_provider/countries-FO.txt +246 -0
  30. data/cache/file_data_provider/countries-FR.txt +246 -0
  31. data/cache/file_data_provider/countries-GA.txt +246 -0
  32. data/cache/file_data_provider/countries-GL.txt +246 -0
  33. data/cache/file_data_provider/countries-GU.txt +246 -0
  34. data/cache/file_data_provider/countries-HE.txt +246 -0
  35. data/cache/file_data_provider/countries-HI.txt +246 -0
  36. data/cache/file_data_provider/countries-HR.txt +246 -0
  37. data/cache/file_data_provider/countries-HU.txt +246 -0
  38. data/cache/file_data_provider/countries-HY.txt +246 -0
  39. data/cache/file_data_provider/countries-ID.txt +246 -0
  40. data/cache/file_data_provider/countries-IS.txt +246 -0
  41. data/cache/file_data_provider/countries-IT.txt +246 -0
  42. data/cache/file_data_provider/countries-JA.txt +246 -0
  43. data/cache/file_data_provider/countries-KA.txt +246 -0
  44. data/cache/file_data_provider/countries-KK.txt +246 -0
  45. data/cache/file_data_provider/countries-KM.txt +246 -0
  46. data/cache/file_data_provider/countries-KN.txt +246 -0
  47. data/cache/file_data_provider/countries-KO.txt +246 -0
  48. data/cache/file_data_provider/countries-KU.txt +246 -0
  49. data/cache/file_data_provider/countries-LT.txt +246 -0
  50. data/cache/file_data_provider/countries-LV.txt +246 -0
  51. data/cache/file_data_provider/countries-MI.txt +246 -0
  52. data/cache/file_data_provider/countries-MK.txt +246 -0
  53. data/cache/file_data_provider/countries-ML.txt +246 -0
  54. data/cache/file_data_provider/countries-MN.txt +246 -0
  55. data/cache/file_data_provider/countries-MR.txt +246 -0
  56. data/cache/file_data_provider/countries-MS.txt +246 -0
  57. data/cache/file_data_provider/countries-MT.txt +246 -0
  58. data/cache/file_data_provider/countries-NB.txt +246 -0
  59. data/cache/file_data_provider/countries-NE.txt +246 -0
  60. data/cache/file_data_provider/countries-NL.txt +246 -0
  61. data/cache/file_data_provider/countries-NN.txt +246 -0
  62. data/cache/file_data_provider/countries-OC.txt +246 -0
  63. data/cache/file_data_provider/countries-PA.txt +246 -0
  64. data/cache/file_data_provider/countries-PL.txt +246 -0
  65. data/cache/file_data_provider/countries-PS.txt +246 -0
  66. data/cache/file_data_provider/countries-PT.txt +246 -0
  67. data/cache/file_data_provider/countries-RO.txt +246 -0
  68. data/cache/file_data_provider/countries-RU.txt +246 -0
  69. data/cache/file_data_provider/countries-RW.txt +246 -0
  70. data/cache/file_data_provider/countries-SK.txt +246 -0
  71. data/cache/file_data_provider/countries-SL.txt +246 -0
  72. data/cache/file_data_provider/countries-SO.txt +246 -0
  73. data/cache/file_data_provider/countries-SQ.txt +246 -0
  74. data/cache/file_data_provider/countries-SR.txt +246 -0
  75. data/cache/file_data_provider/countries-SV.txt +246 -0
  76. data/cache/file_data_provider/countries-SW.txt +246 -0
  77. data/cache/file_data_provider/countries-TA.txt +246 -0
  78. data/cache/file_data_provider/countries-TH.txt +246 -0
  79. data/cache/file_data_provider/countries-TI.txt +246 -0
  80. data/cache/file_data_provider/countries-TK.txt +246 -0
  81. data/cache/file_data_provider/countries-TL.txt +246 -0
  82. data/cache/file_data_provider/countries-TR.txt +246 -0
  83. data/cache/file_data_provider/countries-TT.txt +246 -0
  84. data/cache/file_data_provider/countries-UK.txt +246 -0
  85. data/cache/file_data_provider/countries-VE.txt +246 -0
  86. data/cache/file_data_provider/countries-VI.txt +246 -0
  87. data/cache/file_data_provider/countries-WA.txt +246 -0
  88. data/cache/file_data_provider/countries-WO.txt +246 -0
  89. data/cache/file_data_provider/countries-XH.txt +246 -0
  90. data/cache/file_data_provider/countries-ZU.txt +246 -0
  91. data/cache/file_data_provider/languages-AF.txt +185 -0
  92. data/cache/file_data_provider/languages-AM.txt +185 -0
  93. data/cache/file_data_provider/languages-AR.txt +185 -0
  94. data/cache/file_data_provider/languages-AZ.txt +185 -0
  95. data/cache/file_data_provider/languages-BE.txt +185 -0
  96. data/cache/file_data_provider/languages-BG.txt +185 -0
  97. data/cache/file_data_provider/languages-BR.txt +185 -0
  98. data/cache/file_data_provider/languages-BS.txt +185 -0
  99. data/cache/file_data_provider/languages-CA.txt +185 -0
  100. data/cache/file_data_provider/languages-CS.txt +185 -0
  101. data/cache/file_data_provider/languages-CY.txt +185 -0
  102. data/cache/file_data_provider/languages-DA.txt +185 -0
  103. data/cache/file_data_provider/languages-DE.txt +185 -0
  104. data/cache/file_data_provider/languages-EL.txt +185 -0
  105. data/cache/file_data_provider/languages-EN.txt +185 -0
  106. data/cache/file_data_provider/languages-EO.txt +185 -0
  107. data/cache/file_data_provider/languages-ES.txt +185 -0
  108. data/cache/file_data_provider/languages-ET.txt +185 -0
  109. data/cache/file_data_provider/languages-EU.txt +185 -0
  110. data/cache/file_data_provider/languages-FA.txt +185 -0
  111. data/cache/file_data_provider/languages-FI.txt +185 -0
  112. data/cache/file_data_provider/languages-FR.txt +185 -0
  113. data/cache/file_data_provider/languages-GA.txt +185 -0
  114. data/cache/file_data_provider/languages-GL.txt +185 -0
  115. data/cache/file_data_provider/languages-HE.txt +185 -0
  116. data/cache/file_data_provider/languages-HI.txt +185 -0
  117. data/cache/file_data_provider/languages-HR.txt +185 -0
  118. data/cache/file_data_provider/languages-HU.txt +185 -0
  119. data/cache/file_data_provider/languages-ID.txt +185 -0
  120. data/cache/file_data_provider/languages-IS.txt +185 -0
  121. data/cache/file_data_provider/languages-IT.txt +185 -0
  122. data/cache/file_data_provider/languages-JA.txt +185 -0
  123. data/cache/file_data_provider/languages-KO.txt +185 -0
  124. data/cache/file_data_provider/languages-LT.txt +185 -0
  125. data/cache/file_data_provider/languages-LV.txt +185 -0
  126. data/cache/file_data_provider/languages-MI.txt +185 -0
  127. data/cache/file_data_provider/languages-MK.txt +185 -0
  128. data/cache/file_data_provider/languages-MN.txt +185 -0
  129. data/cache/file_data_provider/languages-MR.txt +185 -0
  130. data/cache/file_data_provider/languages-MS.txt +185 -0
  131. data/cache/file_data_provider/languages-MT.txt +185 -0
  132. data/cache/file_data_provider/languages-NB.txt +185 -0
  133. data/cache/file_data_provider/languages-NL.txt +185 -0
  134. data/cache/file_data_provider/languages-NN.txt +185 -0
  135. data/cache/file_data_provider/languages-OC.txt +185 -0
  136. data/cache/file_data_provider/languages-PL.txt +185 -0
  137. data/cache/file_data_provider/languages-PS.txt +185 -0
  138. data/cache/file_data_provider/languages-PT.txt +185 -0
  139. data/cache/file_data_provider/languages-RO.txt +185 -0
  140. data/cache/file_data_provider/languages-RU.txt +185 -0
  141. data/cache/file_data_provider/languages-RW.txt +185 -0
  142. data/cache/file_data_provider/languages-SK.txt +185 -0
  143. data/cache/file_data_provider/languages-SL.txt +185 -0
  144. data/cache/file_data_provider/languages-SR.txt +185 -0
  145. data/cache/file_data_provider/languages-SV.txt +185 -0
  146. data/cache/file_data_provider/languages-TA.txt +185 -0
  147. data/cache/file_data_provider/languages-TH.txt +185 -0
  148. data/cache/file_data_provider/languages-TI.txt +185 -0
  149. data/cache/file_data_provider/languages-TR.txt +185 -0
  150. data/cache/file_data_provider/languages-TT.txt +185 -0
  151. data/cache/file_data_provider/languages-UK.txt +185 -0
  152. data/cache/file_data_provider/languages-VE.txt +185 -0
  153. data/cache/file_data_provider/languages-VI.txt +185 -0
  154. data/cache/file_data_provider/languages-WA.txt +185 -0
  155. data/cache/file_data_provider/languages-XH.txt +185 -0
  156. data/cache/file_data_provider/languages-ZU.txt +185 -0
  157. data/example_output/all_names_for_DE.txt +85 -0
  158. data/example_output/all_names_for_FR.txt +85 -0
  159. data/example_output/all_names_for_GB.txt +85 -0
  160. data/example_output/all_names_for_US.txt +85 -0
  161. data/i18n_data.gemspec +31 -0
  162. data/lib/i18n_data/file_data_provider.rb +56 -0
  163. data/lib/i18n_data/live_data_provider.rb +97 -0
  164. data/lib/i18n_data.rb +34 -0
  165. data/spec/i18n_data/file_data_provider_spec.rb +23 -0
  166. data/spec/i18n_data/live_data_provider_spec.rb +44 -0
  167. data/spec/i18n_data_spec.rb +101 -0
  168. data/spec/spec_helper.rb +2 -4
  169. metadata +183 -39
  170. data/Readme.md +0 -50
  171. data/ar_serialized_array.gemspec +0 -47
  172. data/init.rb +0 -1
  173. data/lib/ar_serialized_array.rb +0 -37
  174. data/spec/ar_serialized_array_spec.rb +0 -84
  175. data/spec/setup_test_model.rb +0 -28
@@ -0,0 +1,97 @@
1
+ require 'open-uri'
2
+ require 'rexml/document'
3
+ gem 'activesupport', '> 2.2'
4
+ require 'activesupport'
5
+
6
+ module I18nData
7
+ # fetches data online from debian svn
8
+ module LiveDataProvider
9
+ extend ActiveSupport::Memoizable
10
+ extend self
11
+
12
+ XML_CODES = {
13
+ :countries => 'http://svn.debian.org/viewsvn/*checkout*/pkg-isocodes/trunk/iso-codes/iso_3166/iso_3166.xml',
14
+ :languages => 'http://svn.debian.org/viewsvn/*checkout*/pkg-isocodes/trunk/iso-codes/iso_639/iso_639.xml'
15
+ }
16
+ TRANSLATIONS = {
17
+ :languages => 'http://svn.debian.org/viewsvn/*checkout*/pkg-isocodes/trunk/iso-codes/iso_639/',
18
+ :countries => 'http://svn.debian.org/viewsvn/*checkout*/pkg-isocodes/trunk/iso-codes/iso_3166/'
19
+ }
20
+
21
+ def codes(type,language_code)
22
+ language_code = language_code.upcase
23
+ if language_code == 'EN'
24
+ send("english_#{type}")
25
+ else
26
+ translated(type,language_code)
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def translate(type,language,to_language_code)
33
+ translated = translations(type,to_language_code)[language]
34
+ translated.to_s.empty? ? nil : translated
35
+ end
36
+
37
+ def translated(type,language_code)
38
+ translations = {}
39
+ send("english_#{type}").each do |code,name|
40
+ translation = translate(type,name,language_code)
41
+ translations[code] = translation ? translation : name
42
+ end
43
+ translations
44
+ end
45
+ memoize :translated
46
+
47
+ def translations(type,language_code)
48
+ begin
49
+ data = open(TRANSLATIONS[type]+"#{language_code.downcase}.po").readlines
50
+ rescue
51
+ raise NoTranslationAvailable.new("for #{type} and language code = #{language_code}")
52
+ end
53
+
54
+ po_to_hash(data)
55
+ end
56
+ memoize :translations
57
+
58
+ def english_languages
59
+ codes = {}
60
+ xml(:languages).elements.each('*/iso_639_entry') do |entry|
61
+ name = entry.attributes['name'].to_s.gsub("'","\\'")
62
+ code = entry.attributes['iso_639_1_code'].to_s.upcase
63
+ next if code.empty? or name.empty?
64
+ codes[code]=name
65
+ end
66
+ codes
67
+ end
68
+ memoize :english_languages
69
+
70
+ def english_countries
71
+ codes = {}
72
+ xml(:countries).elements.each('*/iso_3166_entry') do |entry|
73
+ name = entry.attributes['name'].to_s.gsub("'","\\'")
74
+ code = entry.attributes['alpha_2_code'].to_s.upcase
75
+ codes[code]=name
76
+ end
77
+ codes
78
+ end
79
+ memoize :english_countries
80
+
81
+ def po_to_hash(data)
82
+ names = data.select{|l| l =~ /^msgid/}.map{|line| line.match(/^msgid "(.*?)"/)[1]}
83
+ translations = data.select{|l| l =~ /^msgstr/}.map{|line| line.match(/^msgstr "(.*?)"/)[1]}
84
+
85
+ translated = {}
86
+ names.each_with_index do |name,index|
87
+ translated[name]=translations[index]
88
+ end
89
+ translated
90
+ end
91
+
92
+ def xml(type)
93
+ xml = open(XML_CODES[type]).read
94
+ REXML::Document.new(xml)
95
+ end
96
+ end
97
+ end
data/lib/i18n_data.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'activesupport'
2
+
3
+ module I18nData
4
+ VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
5
+
6
+ extend self
7
+
8
+ def languages(language_code='EN')
9
+ data_provider.codes(:languages,language_code.to_s.upcase)
10
+ end
11
+
12
+ def countries(language_code='EN')
13
+ data_provider.codes(:countries,language_code.to_s.upcase)
14
+ end
15
+
16
+ def data_provider
17
+ if @data_provider
18
+ @data_provider
19
+ else
20
+ require 'i18n_data/file_data_provider'
21
+ FileDataProvider
22
+ end
23
+ end
24
+
25
+ def data_provider=(provider)
26
+ @data_provider = provider
27
+ end
28
+
29
+ class NoTranslationAvailable < Exception
30
+ def to_s
31
+ "NoTranslationAvailable -- #{super}"
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__),'..',"spec_helper")
2
+ require 'i18n_data/file_data_provider'
3
+
4
+ describe I18nData::FileDataProvider do
5
+ before do
6
+ `rm -f #{I18nData::FileDataProvider.send(:cache_for,"XX","YY")}`
7
+ end
8
+
9
+ def read(x,y)
10
+ I18nData::FileDataProvider.codes(x,y)
11
+ end
12
+
13
+ it "preserves data when writing and then reading" do
14
+ data = {"x"=>"y","z"=>"w"}
15
+ I18nData::FileDataProvider.send(:write_to_file,data,"XX","YY")
16
+ read("XX","YY").should == data
17
+ end
18
+
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
22
+ end
23
+ end
@@ -0,0 +1,44 @@
1
+ require File.join(File.dirname(__FILE__),'..',"spec_helper")
2
+ require 'i18n_data/live_data_provider'
3
+
4
+ describe I18nData::LiveDataProvider do
5
+ describe :po_to_hash do
6
+ def po_to_hash(text)
7
+ I18nData::LiveDataProvider.send(:po_to_hash,text)
8
+ end
9
+
10
+ it "parses po file into translations" do
11
+ text = <<EOF
12
+ # come comment msgstr
13
+ msgid "one"
14
+ msgstr "1"
15
+ EOF
16
+ po_to_hash(text).should == {"one"=>"1"}
17
+ end
18
+
19
+ it "keeps order of translations" do
20
+ text = <<EOF
21
+ msgid "one"
22
+ msgstr "1"
23
+ msgid "two"
24
+ msgstr ""
25
+ msgid "three"
26
+ msgstr "3"
27
+ EOF
28
+ po_to_hash(text).should == {"one"=>"1","two"=>"","three"=>"3"}
29
+ end
30
+
31
+ it "finds x-line long translations" do
32
+ pending
33
+ text = <<EOF
34
+ #. name for chu, cu
35
+ msgid ""
36
+ "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church "
37
+ "Slavonic"
38
+ msgstr "Kirchenslavisch"
39
+ EOF
40
+ long_name = "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic"
41
+ po_to_hash(text)[long_name].should == "Kirchenslavisch"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,101 @@
1
+ require File.expand_path("spec_helper", File.dirname(__FILE__))
2
+
3
+ NUM_2_LETTER_LANGUAGES = 185
4
+ NUM_COUNTRIES = 246
5
+
6
+ describe I18nData do
7
+ require "i18n_data/live_data_provider"
8
+ require "i18n_data/file_data_provider"
9
+
10
+ [I18nData::LiveDataProvider,I18nData::FileDataProvider].each do |provider|
11
+ describe "using #{provider}" do
12
+ before :all do
13
+ I18nData.data_provider = provider
14
+ end
15
+
16
+ describe :languages do
17
+ it "raises NoTranslationAvailable for unavailable languages" do
18
+ lambda{I18nData.languages('XX')}.should raise_error(I18nData::NoTranslationAvailable)
19
+ end
20
+
21
+ describe :english do
22
+ it "does not contain blanks" do
23
+ I18nData.languages.detect {|k,v| k.blank? or v.blank?}.should == nil
24
+ end
25
+
26
+ it "has english as default" do
27
+ I18nData.languages['DE'].should == 'German'
28
+ end
29
+
30
+ it "contains all languages" do
31
+ I18nData.languages.size.should == NUM_2_LETTER_LANGUAGES
32
+ end
33
+ end
34
+
35
+ describe :translated do
36
+ it "is translated" do
37
+ I18nData.languages('DE')['DE'].should == 'Deutsch'
38
+ end
39
+
40
+ it "contains all languages" do
41
+ I18nData.languages('DE').size.should == NUM_2_LETTER_LANGUAGES
42
+ end
43
+
44
+ it "has english names for not-translateable languages" do
45
+ I18nData.languages('IS')['HA'].should == I18nData.languages['HA']
46
+ end
47
+
48
+ it "does not contain blanks" do
49
+ I18nData.languages('GL').detect {|k,v| k.blank? or v.blank?}.should == nil
50
+ end
51
+
52
+ it "is written in unicode" do
53
+ I18nData.languages('DE')['DA'].should == 'Dänisch'
54
+ end
55
+ end
56
+ end
57
+
58
+ describe :countries do
59
+ describe :english do
60
+ it "has english as default" do
61
+ I18nData.countries['DE'].should == 'Germany'
62
+ end
63
+
64
+ it "does not contain blanks" do
65
+ I18nData.countries.detect {|k,v| k.blank? or v.blank?}.should == nil
66
+ end
67
+
68
+ it "contains all countries" do
69
+ I18nData.countries.size.should == NUM_COUNTRIES
70
+ end
71
+ end
72
+
73
+ describe :translated do
74
+ it "is translated" do
75
+ I18nData.countries('DE')['DE'].should == 'Deutschland'
76
+ end
77
+
78
+ it "contains all countries" do
79
+ I18nData.countries('DE').size.should == NUM_COUNTRIES
80
+ end
81
+
82
+ it "has english names for not-translateable countries" do
83
+ I18nData.countries('IS')['PK'].should == I18nData.countries['PK']
84
+ end
85
+
86
+ it "does not contain blanks" do
87
+ I18nData.countries('GL').detect {|k,v| k.blank? or v.blank?}.should == nil
88
+ end
89
+
90
+ it "is written in unicode" do
91
+ I18nData.countries('DE')['DK'].should == 'Dänemark'
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ it "has a VERSION" do
99
+ I18nData::VERSION.should =~ /^\d+\.\d+\.\d+$/
100
+ end
101
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,2 @@
1
- require 'rubygems'
2
- $LOAD_PATH << "lib"
3
- require "init"
4
- require "spec/setup_test_model"
1
+ $LOAD_PATH << 'lib'
2
+ require 'i18n_data'
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_serialized_array
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
4
+ version: 0.2.4
11
5
  platform: ruby
12
6
  authors:
13
7
  - Michael Grosser
@@ -15,76 +9,226 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2011-01-17 00:00:00 +01:00
12
+ date: 2009-11-16 00:00:00 +01:00
19
13
  default_executable:
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
- name: activerecord
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
23
  version: "0"
33
- type: :runtime
34
- version_requirements: *id001
24
+ version:
35
25
  description:
36
26
  email: grosser.michael@gmail.com
37
27
  executables: []
38
28
 
39
29
  extensions: []
40
30
 
41
- extra_rdoc_files: []
42
-
31
+ extra_rdoc_files:
32
+ - README.markdown
43
33
  files:
34
+ - .gitignore
35
+ - CHANGELOG
36
+ - README.markdown
44
37
  - Rakefile
45
- - Readme.md
46
38
  - VERSION
47
- - ar_serialized_array.gemspec
48
- - init.rb
49
- - lib/ar_serialized_array.rb
50
- - spec/ar_serialized_array_spec.rb
51
- - spec/setup_test_model.rb
39
+ - cache/file_data_provider/countries-AF.txt
40
+ - cache/file_data_provider/countries-AM.txt
41
+ - cache/file_data_provider/countries-AR.txt
42
+ - cache/file_data_provider/countries-AZ.txt
43
+ - cache/file_data_provider/countries-BE.txt
44
+ - cache/file_data_provider/countries-BG.txt
45
+ - cache/file_data_provider/countries-BN.txt
46
+ - cache/file_data_provider/countries-BR.txt
47
+ - cache/file_data_provider/countries-BS.txt
48
+ - cache/file_data_provider/countries-CA.txt
49
+ - cache/file_data_provider/countries-CS.txt
50
+ - cache/file_data_provider/countries-CY.txt
51
+ - cache/file_data_provider/countries-DA.txt
52
+ - cache/file_data_provider/countries-DE.txt
53
+ - cache/file_data_provider/countries-DZ.txt
54
+ - cache/file_data_provider/countries-EL.txt
55
+ - cache/file_data_provider/countries-EN.txt
56
+ - cache/file_data_provider/countries-EO.txt
57
+ - cache/file_data_provider/countries-ES.txt
58
+ - cache/file_data_provider/countries-ET.txt
59
+ - cache/file_data_provider/countries-EU.txt
60
+ - cache/file_data_provider/countries-FA.txt
61
+ - cache/file_data_provider/countries-FI.txt
62
+ - cache/file_data_provider/countries-FO.txt
63
+ - cache/file_data_provider/countries-FR.txt
64
+ - cache/file_data_provider/countries-GA.txt
65
+ - cache/file_data_provider/countries-GL.txt
66
+ - cache/file_data_provider/countries-GU.txt
67
+ - cache/file_data_provider/countries-HE.txt
68
+ - cache/file_data_provider/countries-HI.txt
69
+ - cache/file_data_provider/countries-HR.txt
70
+ - cache/file_data_provider/countries-HU.txt
71
+ - cache/file_data_provider/countries-HY.txt
72
+ - cache/file_data_provider/countries-ID.txt
73
+ - cache/file_data_provider/countries-IS.txt
74
+ - cache/file_data_provider/countries-IT.txt
75
+ - cache/file_data_provider/countries-JA.txt
76
+ - cache/file_data_provider/countries-KA.txt
77
+ - cache/file_data_provider/countries-KK.txt
78
+ - cache/file_data_provider/countries-KM.txt
79
+ - cache/file_data_provider/countries-KN.txt
80
+ - cache/file_data_provider/countries-KO.txt
81
+ - cache/file_data_provider/countries-KU.txt
82
+ - cache/file_data_provider/countries-LT.txt
83
+ - cache/file_data_provider/countries-LV.txt
84
+ - cache/file_data_provider/countries-MI.txt
85
+ - cache/file_data_provider/countries-MK.txt
86
+ - cache/file_data_provider/countries-ML.txt
87
+ - cache/file_data_provider/countries-MN.txt
88
+ - cache/file_data_provider/countries-MR.txt
89
+ - cache/file_data_provider/countries-MS.txt
90
+ - cache/file_data_provider/countries-MT.txt
91
+ - cache/file_data_provider/countries-NB.txt
92
+ - cache/file_data_provider/countries-NE.txt
93
+ - cache/file_data_provider/countries-NL.txt
94
+ - cache/file_data_provider/countries-NN.txt
95
+ - cache/file_data_provider/countries-OC.txt
96
+ - cache/file_data_provider/countries-PA.txt
97
+ - cache/file_data_provider/countries-PL.txt
98
+ - cache/file_data_provider/countries-PS.txt
99
+ - cache/file_data_provider/countries-PT.txt
100
+ - cache/file_data_provider/countries-RO.txt
101
+ - cache/file_data_provider/countries-RU.txt
102
+ - cache/file_data_provider/countries-RW.txt
103
+ - cache/file_data_provider/countries-SK.txt
104
+ - cache/file_data_provider/countries-SL.txt
105
+ - cache/file_data_provider/countries-SO.txt
106
+ - cache/file_data_provider/countries-SQ.txt
107
+ - cache/file_data_provider/countries-SR.txt
108
+ - cache/file_data_provider/countries-SV.txt
109
+ - cache/file_data_provider/countries-SW.txt
110
+ - cache/file_data_provider/countries-TA.txt
111
+ - cache/file_data_provider/countries-TH.txt
112
+ - cache/file_data_provider/countries-TI.txt
113
+ - cache/file_data_provider/countries-TK.txt
114
+ - cache/file_data_provider/countries-TL.txt
115
+ - cache/file_data_provider/countries-TR.txt
116
+ - cache/file_data_provider/countries-TT.txt
117
+ - cache/file_data_provider/countries-UK.txt
118
+ - cache/file_data_provider/countries-VE.txt
119
+ - cache/file_data_provider/countries-VI.txt
120
+ - cache/file_data_provider/countries-WA.txt
121
+ - cache/file_data_provider/countries-WO.txt
122
+ - cache/file_data_provider/countries-XH.txt
123
+ - cache/file_data_provider/countries-ZU.txt
124
+ - cache/file_data_provider/languages-AF.txt
125
+ - cache/file_data_provider/languages-AM.txt
126
+ - cache/file_data_provider/languages-AR.txt
127
+ - cache/file_data_provider/languages-AZ.txt
128
+ - cache/file_data_provider/languages-BE.txt
129
+ - cache/file_data_provider/languages-BG.txt
130
+ - cache/file_data_provider/languages-BR.txt
131
+ - cache/file_data_provider/languages-BS.txt
132
+ - cache/file_data_provider/languages-CA.txt
133
+ - cache/file_data_provider/languages-CS.txt
134
+ - cache/file_data_provider/languages-CY.txt
135
+ - cache/file_data_provider/languages-DA.txt
136
+ - cache/file_data_provider/languages-DE.txt
137
+ - cache/file_data_provider/languages-EL.txt
138
+ - cache/file_data_provider/languages-EN.txt
139
+ - cache/file_data_provider/languages-EO.txt
140
+ - cache/file_data_provider/languages-ES.txt
141
+ - cache/file_data_provider/languages-ET.txt
142
+ - cache/file_data_provider/languages-EU.txt
143
+ - cache/file_data_provider/languages-FA.txt
144
+ - cache/file_data_provider/languages-FI.txt
145
+ - cache/file_data_provider/languages-FR.txt
146
+ - cache/file_data_provider/languages-GA.txt
147
+ - cache/file_data_provider/languages-GL.txt
148
+ - cache/file_data_provider/languages-HE.txt
149
+ - cache/file_data_provider/languages-HI.txt
150
+ - cache/file_data_provider/languages-HR.txt
151
+ - cache/file_data_provider/languages-HU.txt
152
+ - cache/file_data_provider/languages-ID.txt
153
+ - cache/file_data_provider/languages-IS.txt
154
+ - cache/file_data_provider/languages-IT.txt
155
+ - cache/file_data_provider/languages-JA.txt
156
+ - cache/file_data_provider/languages-KO.txt
157
+ - cache/file_data_provider/languages-LT.txt
158
+ - cache/file_data_provider/languages-LV.txt
159
+ - cache/file_data_provider/languages-MI.txt
160
+ - cache/file_data_provider/languages-MK.txt
161
+ - cache/file_data_provider/languages-MN.txt
162
+ - cache/file_data_provider/languages-MR.txt
163
+ - cache/file_data_provider/languages-MS.txt
164
+ - cache/file_data_provider/languages-MT.txt
165
+ - cache/file_data_provider/languages-NB.txt
166
+ - cache/file_data_provider/languages-NL.txt
167
+ - cache/file_data_provider/languages-NN.txt
168
+ - cache/file_data_provider/languages-OC.txt
169
+ - cache/file_data_provider/languages-PL.txt
170
+ - cache/file_data_provider/languages-PS.txt
171
+ - cache/file_data_provider/languages-PT.txt
172
+ - cache/file_data_provider/languages-RO.txt
173
+ - cache/file_data_provider/languages-RU.txt
174
+ - cache/file_data_provider/languages-RW.txt
175
+ - cache/file_data_provider/languages-SK.txt
176
+ - cache/file_data_provider/languages-SL.txt
177
+ - cache/file_data_provider/languages-SR.txt
178
+ - cache/file_data_provider/languages-SV.txt
179
+ - cache/file_data_provider/languages-TA.txt
180
+ - cache/file_data_provider/languages-TH.txt
181
+ - cache/file_data_provider/languages-TI.txt
182
+ - cache/file_data_provider/languages-TR.txt
183
+ - cache/file_data_provider/languages-TT.txt
184
+ - cache/file_data_provider/languages-UK.txt
185
+ - cache/file_data_provider/languages-VE.txt
186
+ - cache/file_data_provider/languages-VI.txt
187
+ - cache/file_data_provider/languages-WA.txt
188
+ - cache/file_data_provider/languages-XH.txt
189
+ - cache/file_data_provider/languages-ZU.txt
190
+ - example_output/all_names_for_DE.txt
191
+ - example_output/all_names_for_FR.txt
192
+ - example_output/all_names_for_GB.txt
193
+ - example_output/all_names_for_US.txt
194
+ - i18n_data.gemspec
195
+ - lib/i18n_data.rb
196
+ - lib/i18n_data/file_data_provider.rb
197
+ - lib/i18n_data/live_data_provider.rb
198
+ - spec/i18n_data/file_data_provider_spec.rb
199
+ - spec/i18n_data/live_data_provider_spec.rb
200
+ - spec/i18n_data_spec.rb
52
201
  - spec/spec_helper.rb
53
202
  has_rdoc: true
54
203
  homepage: http://github.com/grosser/ar_serialized_array
55
204
  licenses: []
56
205
 
57
206
  post_install_message:
58
- rdoc_options: []
59
-
207
+ rdoc_options:
208
+ - --charset=UTF-8
60
209
  require_paths:
61
210
  - lib
62
211
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
212
  requirements:
65
213
  - - ">="
66
214
  - !ruby/object:Gem::Version
67
- hash: 3
68
- segments:
69
- - 0
70
215
  version: "0"
216
+ version:
71
217
  required_rubygems_version: !ruby/object:Gem::Requirement
72
- none: false
73
218
  requirements:
74
219
  - - ">="
75
220
  - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
221
  version: "0"
222
+ version:
80
223
  requirements: []
81
224
 
82
225
  rubyforge_project:
83
- rubygems_version: 1.4.2
226
+ rubygems_version: 1.3.5
84
227
  signing_key:
85
228
  specification_version: 3
86
- summary: Serialize an array in a column, [] when no set, xx_as_text accessors and more.
229
+ summary: country/language names and 2-letter-code pairs, in 85 languages
87
230
  test_files:
88
- - spec/ar_serialized_array_spec.rb
89
- - spec/setup_test_model.rb
90
231
  - spec/spec_helper.rb
232
+ - spec/i18n_data/file_data_provider_spec.rb
233
+ - spec/i18n_data/live_data_provider_spec.rb
234
+ - spec/i18n_data_spec.rb
data/Readme.md DELETED
@@ -1,50 +0,0 @@
1
- Serialize an array in one column.
2
-
3
- - [] when not set
4
- - `xxx_as_text` / `xxx_as_text=` accessors to edit in forms
5
- - `:on_set` callback for cleanup
6
- - stores NULL when given array was empty (all empty -> `IS NULL`)
7
-
8
- Install
9
- =======
10
- - As Rails plugin: `rails plugin install git://github.com/grosser/ar_serialized_array.git `
11
- - As gem: ` sudo gem install ar_serialized_array `
12
-
13
-
14
- Usage
15
- =====
16
-
17
- # basic / forms
18
- class User < ActiveRecord::Base
19
- serialized_array :product_ids, :accessor => :product_ids_as_text
20
- end
21
-
22
- <%= form_for @user do |f| %>
23
- <%= f.text_field :product_ids_as_text %>
24
- <% end %>
25
-
26
- # set / get
27
- User.new.product_ids # []
28
-
29
- user.product_ids_as_text = "1, , 12323 , 23, 1"
30
- user.product_ids # [1, 12323, 23]
31
- user.product_ids_as_text # "1, 12323, 23"
32
-
33
- # find ...
34
- filled = User.all(:conditions => {:product_ids=>[1,3].to_yaml})
35
- empty = User.all(:conditions => {:product_ids=>nil})
36
-
37
- # with cleanup (unique integers)
38
- class User < ActiveRecord::Base
39
- serialized_array :product_ids, :on_set=>lambda{|x| x.map(&:to_i).uniq }
40
- end
41
-
42
- TODO
43
- ====
44
- - add support for `user.product_ids << 1`
45
-
46
- Author
47
- ======
48
- [Michael Grosser](http://grosser.it)
49
- michael@grosser.it
50
- Hereby placed under public domain, do what you want, just do not hold me accountable...
@@ -1,47 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{ar_serialized_array}
8
- s.version = "0.1.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-01-17}
13
- s.email = %q{grosser.michael@gmail.com}
14
- s.files = [
15
- "Rakefile",
16
- "Readme.md",
17
- "VERSION",
18
- "ar_serialized_array.gemspec",
19
- "init.rb",
20
- "lib/ar_serialized_array.rb",
21
- "spec/ar_serialized_array_spec.rb",
22
- "spec/setup_test_model.rb",
23
- "spec/spec_helper.rb"
24
- ]
25
- s.homepage = %q{http://github.com/grosser/ar_serialized_array}
26
- s.require_paths = ["lib"]
27
- s.rubygems_version = %q{1.4.2}
28
- s.summary = %q{Serialize an array in a column, [] when no set, xx_as_text accessors and more.}
29
- s.test_files = [
30
- "spec/ar_serialized_array_spec.rb",
31
- "spec/setup_test_model.rb",
32
- "spec/spec_helper.rb"
33
- ]
34
-
35
- if s.respond_to? :specification_version then
36
- s.specification_version = 3
37
-
38
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
- s.add_runtime_dependency(%q<activerecord>, [">= 0"])
40
- else
41
- s.add_dependency(%q<activerecord>, [">= 0"])
42
- end
43
- else
44
- s.add_dependency(%q<activerecord>, [">= 0"])
45
- end
46
- end
47
-
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'ar_serialized_array'