activeldap 1.2.1 → 1.2.2

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.
Files changed (186) hide show
  1. data/CHANGES +17 -0
  2. data/README +7 -1
  3. data/Rakefile +2 -1
  4. data/benchmark/bench-al.rb +3 -3
  5. data/examples/al-admin/app/helpers/users_helper.rb +1 -1
  6. data/examples/al-admin/config/environment.rb +4 -3
  7. data/examples/al-admin/config/initializers/gettext.rb +1 -0
  8. data/examples/al-admin/config/session_secret.txt +1 -1
  9. data/examples/al-admin/po/al-admin.pot +344 -0
  10. data/examples/al-admin/public/images/active-ldap.png +0 -0
  11. data/examples/al-admin/vendor/locale_rails/.gitignore +6 -0
  12. data/examples/al-admin/vendor/locale_rails/COPYING +56 -0
  13. data/examples/al-admin/vendor/locale_rails/ChangeLog +35 -0
  14. data/examples/al-admin/vendor/locale_rails/README.rdoc +62 -0
  15. data/examples/al-admin/vendor/locale_rails/Rakefile +73 -0
  16. data/examples/al-admin/vendor/locale_rails/lib/locale_rails.rb +18 -0
  17. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller.rb +15 -0
  18. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/base.rb +82 -0
  19. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/caching.rb +51 -0
  20. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_controller/test_process.rb +44 -0
  21. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/action_view.rb +53 -0
  22. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/i18n.rb +67 -0
  23. data/examples/al-admin/vendor/locale_rails/lib/locale_rails/version.rb +4 -0
  24. data/examples/al-admin/vendor/locale_rails/sample/README +22 -0
  25. data/examples/al-admin/vendor/locale_rails/sample/Rakefile +10 -0
  26. data/examples/al-admin/vendor/locale_rails/sample/app/controllers/application.rb +42 -0
  27. data/examples/al-admin/vendor/locale_rails/sample/app/controllers/samples_controller.rb +30 -0
  28. data/examples/al-admin/vendor/locale_rails/sample/app/helpers/application_helper.rb +3 -0
  29. data/examples/al-admin/vendor/locale_rails/sample/app/views/layouts/samples.html.erb +20 -0
  30. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part.html.erb +68 -0
  31. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/_part_nl.html.erb +2 -0
  32. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/cached_action.html.erb +6 -0
  33. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.html.erb +33 -0
  34. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index.pt.html.erb +16 -0
  35. data/examples/al-admin/vendor/locale_rails/sample/app/views/samples/index_uz_UZ.html.erb +16 -0
  36. data/examples/al-admin/vendor/locale_rails/sample/config/boot.rb +109 -0
  37. data/examples/al-admin/vendor/locale_rails/sample/config/environment.rb +25 -0
  38. data/examples/al-admin/vendor/locale_rails/sample/config/environments/development.rb +17 -0
  39. data/examples/al-admin/vendor/locale_rails/sample/config/environments/production.rb +24 -0
  40. data/examples/al-admin/vendor/locale_rails/sample/config/environments/test.rb +22 -0
  41. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/inflections.rb +10 -0
  42. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/mime_types.rb +5 -0
  43. data/examples/al-admin/vendor/locale_rails/sample/config/initializers/new_rails_defaults.rb +17 -0
  44. data/examples/al-admin/vendor/locale_rails/sample/config/locales/en.yml +2 -0
  45. data/examples/al-admin/vendor/locale_rails/sample/config/locales/ja.yml +2 -0
  46. data/examples/al-admin/vendor/locale_rails/sample/config/routes.rb +13 -0
  47. data/examples/al-admin/vendor/locale_rails/sample/db/schema.rb +10 -0
  48. data/examples/al-admin/vendor/locale_rails/sample/public/404.html +30 -0
  49. data/examples/al-admin/vendor/locale_rails/sample/public/422.html +30 -0
  50. data/examples/al-admin/vendor/locale_rails/sample/public/500.html +33 -0
  51. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.cgi +10 -0
  52. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.fcgi +24 -0
  53. data/examples/al-admin/vendor/locale_rails/sample/public/dispatch.rb +10 -0
  54. data/examples/al-admin/vendor/locale_rails/sample/public/favicon.ico +0 -0
  55. data/examples/al-admin/vendor/locale_rails/sample/public/images/rails.png +0 -0
  56. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/application.js +2 -0
  57. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/controls.js +963 -0
  58. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/dragdrop.js +972 -0
  59. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/effects.js +1120 -0
  60. data/examples/al-admin/vendor/locale_rails/sample/public/javascripts/prototype.js +4221 -0
  61. data/examples/al-admin/vendor/locale_rails/sample/public/robots.txt +5 -0
  62. data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/locale.css +81 -0
  63. data/examples/al-admin/vendor/locale_rails/sample/public/stylesheets/scaffold.css +74 -0
  64. data/examples/al-admin/vendor/locale_rails/sample/script/about +4 -0
  65. data/examples/al-admin/vendor/locale_rails/sample/script/console +3 -0
  66. data/examples/al-admin/vendor/locale_rails/sample/script/dbconsole +3 -0
  67. data/examples/al-admin/vendor/locale_rails/sample/script/destroy +3 -0
  68. data/examples/al-admin/vendor/locale_rails/sample/script/generate +3 -0
  69. data/examples/al-admin/vendor/locale_rails/sample/script/performance/benchmarker +3 -0
  70. data/examples/al-admin/vendor/locale_rails/sample/script/performance/profiler +3 -0
  71. data/examples/al-admin/vendor/locale_rails/sample/script/performance/request +3 -0
  72. data/examples/al-admin/vendor/locale_rails/sample/script/plugin +3 -0
  73. data/examples/al-admin/vendor/locale_rails/sample/script/process/inspector +3 -0
  74. data/examples/al-admin/vendor/locale_rails/sample/script/process/reaper +3 -0
  75. data/examples/al-admin/vendor/locale_rails/sample/script/process/spawner +3 -0
  76. data/examples/al-admin/vendor/locale_rails/sample/script/runner +3 -0
  77. data/examples/al-admin/vendor/locale_rails/sample/script/server +3 -0
  78. data/examples/al-admin/vendor/locale_rails/sample/test/performance/browsing_test.rb +9 -0
  79. data/examples/al-admin/vendor/locale_rails/sample/test/test_helper.rb +38 -0
  80. data/examples/al-admin/vendor/locale_rails/test/README +243 -0
  81. data/examples/al-admin/vendor/locale_rails/test/Rakefile +10 -0
  82. data/examples/al-admin/vendor/locale_rails/test/app/controllers/application_controller.rb +10 -0
  83. data/examples/al-admin/vendor/locale_rails/test/app/controllers/articles_controller.rb +17 -0
  84. data/examples/al-admin/vendor/locale_rails/test/app/helpers/application_helper.rb +3 -0
  85. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index.html.erb +1 -0
  86. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_de.html.erb +1 -0
  87. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_fr_FR.html.erb +1 -0
  88. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/index_ja.html.erb +1 -0
  89. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/list.html.erb +1 -0
  90. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.html.erb +0 -0
  91. data/examples/al-admin/vendor/locale_rails/test/app/views/articles/show.js.rjs +0 -0
  92. data/examples/al-admin/vendor/locale_rails/test/config/boot.rb +110 -0
  93. data/examples/al-admin/vendor/locale_rails/test/config/environment.rb +42 -0
  94. data/examples/al-admin/vendor/locale_rails/test/config/environments/development.rb +17 -0
  95. data/examples/al-admin/vendor/locale_rails/test/config/environments/production.rb +28 -0
  96. data/examples/al-admin/vendor/locale_rails/test/config/environments/test.rb +35 -0
  97. data/examples/al-admin/vendor/locale_rails/test/config/initializers/backtrace_silencers.rb +7 -0
  98. data/examples/al-admin/vendor/locale_rails/test/config/initializers/inflections.rb +10 -0
  99. data/examples/al-admin/vendor/locale_rails/test/config/initializers/mime_types.rb +5 -0
  100. data/examples/al-admin/vendor/locale_rails/test/config/initializers/new_rails_defaults.rb +19 -0
  101. data/examples/al-admin/vendor/locale_rails/test/config/initializers/session_store.rb +15 -0
  102. data/examples/al-admin/vendor/locale_rails/test/config/locales/en.yml +5 -0
  103. data/examples/al-admin/vendor/locale_rails/test/config/routes.rb +46 -0
  104. data/examples/al-admin/vendor/locale_rails/test/db/schema.rb +0 -0
  105. data/examples/al-admin/vendor/locale_rails/test/public/404.html +30 -0
  106. data/examples/al-admin/vendor/locale_rails/test/public/422.html +30 -0
  107. data/examples/al-admin/vendor/locale_rails/test/public/500.html +30 -0
  108. data/examples/al-admin/vendor/locale_rails/test/public/favicon.ico +0 -0
  109. data/examples/al-admin/vendor/locale_rails/test/public/images/rails.png +0 -0
  110. data/examples/al-admin/vendor/locale_rails/test/public/index.html +275 -0
  111. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/application.js +2 -0
  112. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/controls.js +963 -0
  113. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/dragdrop.js +973 -0
  114. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/effects.js +1128 -0
  115. data/examples/al-admin/vendor/locale_rails/test/public/javascripts/prototype.js +4320 -0
  116. data/examples/al-admin/vendor/locale_rails/test/public/robots.txt +5 -0
  117. data/examples/al-admin/vendor/locale_rails/test/script/about +4 -0
  118. data/examples/al-admin/vendor/locale_rails/test/script/console +3 -0
  119. data/examples/al-admin/vendor/locale_rails/test/script/dbconsole +3 -0
  120. data/examples/al-admin/vendor/locale_rails/test/script/destroy +3 -0
  121. data/examples/al-admin/vendor/locale_rails/test/script/generate +3 -0
  122. data/examples/al-admin/vendor/locale_rails/test/script/performance/benchmarker +3 -0
  123. data/examples/al-admin/vendor/locale_rails/test/script/performance/profiler +3 -0
  124. data/examples/al-admin/vendor/locale_rails/test/script/plugin +3 -0
  125. data/examples/al-admin/vendor/locale_rails/test/script/runner +3 -0
  126. data/examples/al-admin/vendor/locale_rails/test/script/server +3 -0
  127. data/examples/al-admin/vendor/locale_rails/test/test/functional/articles_controller_test.rb +161 -0
  128. data/examples/al-admin/vendor/locale_rails/test/test/performance/browsing_test.rb +9 -0
  129. data/examples/al-admin/vendor/locale_rails/test/test/test_helper.rb +38 -0
  130. data/lib/active_ldap.rb +9 -4
  131. data/lib/active_ldap/adapter/base.rb +3 -3
  132. data/lib/active_ldap/adapter/jndi.rb +1 -1
  133. data/lib/active_ldap/adapter/jndi_connection.rb +1 -3
  134. data/lib/active_ldap/adapter/ldap.rb +11 -11
  135. data/lib/active_ldap/adapter/ldap_ext.rb +25 -3
  136. data/lib/active_ldap/adapter/net_ldap.rb +9 -2
  137. data/lib/active_ldap/association/collection.rb +14 -2
  138. data/lib/active_ldap/base.rb +13 -5
  139. data/lib/active_ldap/configuration.rb +1 -0
  140. data/lib/active_ldap/ldap_error.rb +3 -3
  141. data/lib/active_ldap/ldif.rb +1 -1
  142. data/lib/active_ldap/operations.rb +2 -0
  143. data/lib/active_ldap/schema/syntaxes.rb +2 -2
  144. data/lib/active_ldap/validations.rb +37 -26
  145. data/lib/active_ldap/xml.rb +2 -0
  146. data/po/active-ldap.pot +38 -58
  147. data/test-unit/COPYING +56 -0
  148. data/test-unit/GPL +340 -0
  149. data/test-unit/History.txt +65 -3
  150. data/test-unit/Manifest.txt +5 -0
  151. data/test-unit/PSFL +271 -0
  152. data/test-unit/README.txt +6 -1
  153. data/test-unit/lib/test/unit.rb +6 -1
  154. data/test-unit/lib/test/unit/assertions.rb +129 -13
  155. data/test-unit/lib/test/unit/autorunner.rb +21 -16
  156. data/test-unit/lib/test/unit/collector.rb +1 -8
  157. data/test-unit/lib/test/unit/collector/dir.rb +1 -1
  158. data/test-unit/lib/test/unit/collector/load.rb +15 -7
  159. data/test-unit/lib/test/unit/color-scheme.rb +6 -2
  160. data/test-unit/lib/test/unit/diff.rb +17 -1
  161. data/test-unit/lib/test/unit/error.rb +4 -0
  162. data/test-unit/lib/test/unit/failure.rb +4 -0
  163. data/test-unit/lib/test/unit/notification.rb +8 -4
  164. data/test-unit/lib/test/unit/omission.rb +4 -0
  165. data/test-unit/lib/test/unit/pending.rb +4 -0
  166. data/test-unit/lib/test/unit/priority.rb +2 -3
  167. data/test-unit/lib/test/unit/testcase.rb +18 -7
  168. data/test-unit/lib/test/unit/ui/console/testrunner.rb +5 -3
  169. data/test-unit/lib/test/unit/util/backtracefilter.rb +1 -0
  170. data/test-unit/lib/test/unit/util/output.rb +31 -0
  171. data/test-unit/lib/test/unit/version.rb +1 -1
  172. data/test-unit/test/collector/test-descendant.rb +2 -4
  173. data/test-unit/test/collector/test-load.rb +121 -8
  174. data/test-unit/test/collector/test_objectspace.rb +7 -5
  175. data/test-unit/test/test-color-scheme.rb +4 -2
  176. data/test-unit/test/test-testcase.rb +48 -38
  177. data/test-unit/test/test_assertions.rb +87 -5
  178. data/test-unit/test/util/test-output.rb +11 -0
  179. data/test/al-test-utils.rb +6 -1
  180. data/test/fixtures/lower_case_object_class_schema.rb +802 -0
  181. data/test/test_associations.rb +20 -1
  182. data/test/test_base.rb +50 -3
  183. data/test/test_ldif.rb +10 -1
  184. data/test/test_syntax.rb +12 -0
  185. data/test/test_validation.rb +0 -2
  186. metadata +225 -56
@@ -0,0 +1,6 @@
1
+ *.sqlite3
2
+ pkg/*.gem
3
+ test/log
4
+ test/tmp
5
+ .idea
6
+
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the GPL
3
+ version 2 (see the file GPL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a) distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
@@ -0,0 +1,35 @@
1
+ = locale_rails-2.0.5 (2009-11-11)
2
+ * Update license information (explicit to use Ruby's or LGPL).
3
+ [Pointed out by Masateru Yoshikawa]
4
+ * Fixed to work expire_fragment/action.
5
+ [Reported by Sean Tan]
6
+ * Support Rails-2.3.2, 2.3.3 and 2.3.4.
7
+ Update the version information.
8
+
9
+ = locale_rails-2.0.4 (2009-05-22)
10
+ * Fixed that localized views are not working correctly. [Reported by Dan Coutu]
11
+ * Add tests
12
+
13
+ = locale_rails-2.0.3 (2009-05-09)
14
+ * Fixed a bug not to work with fragment cache. [Reported by Andy Lo-A-Foe]
15
+ * Fixed the dependencies. [Reported by Hans de Graaff]
16
+
17
+ = locale_rails-2.0.2 (2009-05-04)
18
+ * Remove I18n.candidates. Use Locale.candidates directly.
19
+ * Improve documentations.
20
+ * Override I18n.default_locale= to call Locale.default.
21
+
22
+ = locale_rails-2.0.1 (2009-04-17)
23
+ * Fixed to work localized view which was canceled.
24
+
25
+ = locale_rails-2.0.0 (2009-03-22)
26
+ * I18n.translate fallbacks to the localized message in the locale candidates.
27
+ * Support localized view both of gettext-1.93.0 style and rails-2.3.x style.
28
+
29
+ = locale_rails-0.1.0 (2008-12-04)
30
+ * Initial released.
31
+ * Auto-Detect the locales from the WWW browser
32
+ * Localized Routes
33
+ * Action/Fragment caching
34
+ * Separated Localized View template file
35
+
@@ -0,0 +1,62 @@
1
+ = Ruby-Locale for Ruby on Rails
2
+
3
+ This library provides some Rails localized functions.
4
+
5
+ This is useful with Rails i18n backends which doesn't have
6
+ auto-detection and some other features includes this library.
7
+
8
+ == Features for Ruby on Rails
9
+ * Auto-Detect the locales from the WWW browser
10
+ * Action/Fragment caching
11
+ * Separated Localized View template file
12
+ * Localized Routes
13
+ * I18n.t fallback to localized message candidates.
14
+
15
+ == Website
16
+ * http://www.yotabanana.com/hiki/ruby-locale-rails.html
17
+ * http://locale.rubyforge.org/
18
+
19
+ == Requirements
20
+ * Ruby-1.8.7 or later <http://www.ruby-lang.org/ja/>
21
+ * JRuby-1.1.4 or later <http://jruby.codehaus.org/>
22
+ * Ruby-Locale-0.9.0 or later <http://locale.rubyforge.org/>
23
+
24
+ == Install
25
+ * gem:
26
+ ($ su)
27
+ # gem install locale_rails
28
+
29
+ == Usage
30
+ ==== config/environment.rb
31
+ Rails::Initializer.run do |config|
32
+ :
33
+ :
34
+ config.gem 'locale'
35
+ config.gem 'locale_rails'
36
+ end
37
+
38
+ ==== config/initializer/locale.rb
39
+
40
+ # Tell the I18n library where to find your translations
41
+ I18n.supported_locales = ["ja", "en"]
42
+ I18n.default_locale = "ja"
43
+
44
+ == Support matrix
45
+ * locale_rails-2.0.6 - rails-2.3.2,2.3.3,2.3.4,2.3.5
46
+ * locale_rails-2.0.5 - rails-2.3.2,2.3.3,2.3.4
47
+ * locale_rails-2.0.4 - rails-2.3.2
48
+ * locale_rails-2.0.3 - rails-2.3.2
49
+ * locale_rails-2.0.2 - rails-2.3.2
50
+ * locale_rails-2.0.1 - rails-2.3.2
51
+ * locale_rails-2.0.0 - rails-2.3.2
52
+ * locale_rails-0.1.0 - rails-2.1.x
53
+
54
+ == Tested Ruby version:
55
+ * locale_rails-2.0.6 - 1.8.7-p249, 1.9.1-p378
56
+
57
+ == License
58
+ This program is licenced under the same licence as Ruby(See COPYING) or
59
+ LGPL(Lesser General Public License: http://www.gnu.org/licenses/lgpl-3.0.txt).
60
+
61
+ == Maintainer
62
+ Masao Mutoh <mutomasa at gmail.com>
@@ -0,0 +1,73 @@
1
+ $:.unshift "./lib"
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/packagetask'
7
+ require 'rake/gempackagetask'
8
+
9
+ require 'locale_rails/version'
10
+
11
+ #desc "Default Task"
12
+ #task :default => [ :test ]
13
+
14
+ PKG_NAME = "locale_rails"
15
+ PKG_VERSION = LocaleRails::VERSION
16
+
17
+ # Run the unit tests
18
+ task :test do
19
+ cd "test"
20
+ sh "rake test"
21
+ cd ".."
22
+ end
23
+
24
+ Rake::RDocTask.new { |rdoc|
25
+ begin
26
+ allison = `allison --path`.chop
27
+ rescue Exception
28
+ allison = ""
29
+ end
30
+ rdoc.rdoc_dir = 'doc'
31
+ rdoc.title = "Ruby-Locale for Ruby on Rails"
32
+ rdoc.options << '--line-numbers' << '--inline-source'
33
+ rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
34
+ rdoc.rdoc_files.include('lib/**/*.rb')
35
+ rdoc.template = allison if allison.size > 0
36
+ }
37
+
38
+ desc "Create gem and tar.gz"
39
+ spec = Gem::Specification.new do |s|
40
+ s.name = PKG_NAME
41
+ s.version = PKG_VERSION
42
+ s.summary = 'Ruby-Locale for Ruby on Rails is the pure ruby library which provides basic functions for localization based on Ruby-Locale.'
43
+ s.author = 'Masao Mutoh'
44
+ s.email = 'mutomasa at gmail.com'
45
+ s.homepage = 'http://locale.rubyforge.org/'
46
+ s.rubyforge_project = "locale"
47
+ s.files = FileList['**/*'].to_a.select{|v| v !~ /pkg|CVS|git/}
48
+ s.require_path = 'lib'
49
+ s.bindir = 'bin'
50
+ s.add_dependency('locale', '>= 2.0.6')
51
+ s.has_rdoc = true
52
+ s.description = <<-EOF
53
+ Ruby-Locale for Ruby on Rails is the pure ruby library which provides basic functions for localization.
54
+ EOF
55
+ end
56
+
57
+ Rake::GemPackageTask.new(spec) do |p|
58
+ p.gem_spec = spec
59
+ p.need_tar_gz = false
60
+ p.need_zip = false
61
+ end
62
+
63
+ desc "Publish the release files to RubyForge."
64
+ task :release => [ :package ] do
65
+ require 'rubyforge'
66
+
67
+ rubyforge = RubyForge.new
68
+ rubyforge.configure
69
+ rubyforge.login
70
+ rubyforge.add_release("locale", "locale_rails",
71
+ PKG_VERSION,
72
+ "pkg/#{PKG_NAME}-#{PKG_VERSION}.gem")
73
+ end
@@ -0,0 +1,18 @@
1
+ require 'locale'
2
+
3
+ Locale.init(:driver => :cgi)
4
+
5
+ ["i18n", "action_controller", "action_view", "version"].each do |lib|
6
+ require File.join(File.dirname(__FILE__), "locale_rails", lib)
7
+ end
8
+
9
+ begin
10
+ Rails::Info.property("Locale version") do
11
+ Locale::VERSION
12
+ end
13
+ Rails::Info.property("Locale for Rails version") do
14
+ Locale::LOCALE_RAILS_VERSION
15
+ end
16
+ rescue Exception
17
+ $stderr.puts "Locale's Rails::Info is not found." if $DEBUG
18
+ end
@@ -0,0 +1,15 @@
1
+ =begin
2
+ lib/locale_rails/action_controller.rb - Ruby/Locale for "Ruby on Rails"
3
+
4
+ Copyright (C) 2008-2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby or LGPL.
8
+
9
+ =end
10
+
11
+ require 'action_controller'
12
+ ["base", "caching", "test_process"].each do |lib|
13
+ require File.join(File.dirname(__FILE__), "action_controller", lib)
14
+ end
15
+
@@ -0,0 +1,82 @@
1
+ =begin
2
+ lib/locale_rails/action_controller/base.rb - Ruby/Locale for "Ruby on Rails"
3
+
4
+ Copyright (C) 2008-2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby or LGPL.
8
+ =end
9
+
10
+ require 'action_controller'
11
+
12
+ module ActionController #:nodoc:
13
+ class Base
14
+ prepend_before_filter :init_locale
15
+
16
+ def self.locale_filter_chain # :nodoc:
17
+ if chain = read_inheritable_attribute('locale_filter_chain')
18
+ return chain
19
+ else
20
+ write_inheritable_attribute('locale_filter_chain', FilterChain.new)
21
+ return locale_filter_chain
22
+ end
23
+ end
24
+
25
+ def init_locale # :nodoc:
26
+ cgi = nil
27
+ if defined? ::Rack
28
+ cgi = request
29
+ else
30
+ if defined? request.cgi
31
+ cgi = request.cgi
32
+ end
33
+ end
34
+
35
+ fchain = self.class.locale_filter_chain
36
+ run_before_filters(fchain.select(&:before?), 0, 0)
37
+
38
+ cgi.params["lang"] = [params["lang"]] if params["lang"].is_a?(String)
39
+ Locale.set_cgi(cgi)
40
+ if cgi.params["lang"]
41
+ I18n.locale = cgi.params["lang"][0]
42
+ else
43
+ I18n.locale = nil
44
+ end
45
+
46
+ run_after_filters(fchain.select(&:after?), 0)
47
+ end
48
+
49
+ # Append a block which is called before initializing locale on each WWW request.
50
+ #
51
+ # (e.g.)
52
+ # class ApplicationController < ActionController::Base
53
+ # def before_init_i18n
54
+ # if (cookies["lang"].nil? or cookies["lang"].empty?)
55
+ # params["lang"] = "ko_KR"
56
+ # end
57
+ # end
58
+ # before_init_locale :before_init_i18n
59
+ # # ...
60
+ # end
61
+ def self.before_init_locale(*filters, &block)
62
+ locale_filter_chain.append_filter_to_chain(filters, :before, &block)
63
+ end
64
+
65
+ # Append a block which is called after initializing locale on each WWW request.
66
+ #
67
+ # (e.g.)
68
+ # class ApplicationController < ActionController::Base
69
+ # def after_init_i18n
70
+ # L10nClass.new(Locale.candidates)
71
+ # end
72
+ # after_init_locale :after_init_i18n
73
+ # # ...
74
+ # end
75
+ def self.after_init_locale(*filters, &block)
76
+ locale_filter_chain.append_filter_to_chain(filters, :after, &block)
77
+ end
78
+ end
79
+
80
+ end
81
+
82
+
@@ -0,0 +1,51 @@
1
+ =begin
2
+ lib/locale_rails/action_controller.rb - Ruby/Locale for "Ruby on Rails"
3
+
4
+ Copyright (C) 2008-2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby or LGPL.
8
+ =end
9
+
10
+ require 'action_controller/caching'
11
+
12
+ module ActionController #:nodoc:
13
+
14
+ module Caching
15
+ module Fragments
16
+ @@fragmented_locales = []
17
+ def fragment_cache_key_with_locale(name)
18
+ ret = fragment_cache_key_without_locale(name)
19
+ if ret.is_a? String
20
+ unless @@fragmented_locales.include? I18n.locale
21
+ @@fragmented_locales << I18n.locale
22
+ end
23
+ ret.gsub(/:/, ".") << "_#{I18n.locale}"
24
+ else
25
+ ret
26
+ end
27
+ end
28
+ alias_method_chain :fragment_cache_key, :locale
29
+
30
+ def expire_fragment_with_locale(name, options = nil)
31
+ return unless perform_caching
32
+
33
+ fc_store = (respond_to? :cache_store) ? cache_store : fragment_cache_store
34
+ key = name.is_a?(Regexp) ? name : fragment_cache_key_without_locale(name)
35
+ if key.is_a?(Regexp)
36
+ self.class.benchmark "Expired fragments matching: #{key.source}" do
37
+ fc_store.delete_matched(key, options)
38
+ end
39
+ else
40
+ key = key.gsub(/:/, ".")
41
+ self.class.benchmark "Expired fragment: #{key}, lang = #{@@fragmented_locales}" do
42
+ @@fragmented_locales.each do |lang|
43
+ fc_store.delete("#{key}_#{lang}", options)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ alias_method_chain :expire_fragment, :locale
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,44 @@
1
+ =begin
2
+ lib/locale_rails/action_controller.rb - Ruby/Locale for "Ruby on Rails"
3
+
4
+ Copyright (C) 2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby or LGPL.
8
+
9
+ =end
10
+
11
+ require 'action_controller'
12
+ require 'action_controller/test_process'
13
+
14
+ module ActionController
15
+ if defined? AbstractRequest #:nodoc:
16
+ # for Rails-2.2.x or earlier.
17
+ class TestRequest < AbstractRequest #:nodoc:
18
+ class LocaleMockCGI < CGI #:nodoc:
19
+ attr_accessor :stdinput, :stdoutput, :env_table
20
+
21
+ def initialize(env, input=nil)
22
+ self.env_table = env
23
+ self.stdinput = StringIO.new(input || "")
24
+ self.stdoutput = StringIO.new
25
+
26
+ super()
27
+ end
28
+ end
29
+
30
+ @cgi = nil
31
+ def cgi
32
+ unless @cgi
33
+ @cgi = LocaleMockCGI.new("REQUEST_METHOD" => "GET",
34
+ "QUERY_STRING" => "",
35
+ "REQUEST_URI" => "/",
36
+ "HTTP_HOST" => "www.example.com",
37
+ "SERVER_PORT" => "80",
38
+ "HTTPS" => "off")
39
+ end
40
+ @cgi
41
+ end
42
+ end
43
+ end
44
+ end