lolita-translation 0.3.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.gitignore +25 -0
  2. data/Gemfile +2 -18
  3. data/README.md +1 -2
  4. data/Rakefile +1 -49
  5. data/app/assets/javascripts/lolita/translation/application.js +4 -3
  6. data/app/assets/stylesheets/lolita/translation/application.css +7 -1
  7. data/app/views/components/lolita/translation/_assets.html.haml +4 -0
  8. data/app/views/components/lolita/translation/_language_wrap.html.haml +2 -0
  9. data/app/views/components/lolita/translation/_switch.html.haml +4 -0
  10. data/lib/lolita-translation.rb +40 -33
  11. data/lib/lolita-translation/builder/abstract_builder.rb +103 -0
  12. data/lib/lolita-translation/builder/active_record_builder.rb +106 -0
  13. data/lib/lolita-translation/builder/mongoid_builder.rb +0 -0
  14. data/lib/lolita-translation/configuration.rb +41 -166
  15. data/lib/lolita-translation/errors.rb +15 -0
  16. data/lib/lolita-translation/locale.rb +32 -0
  17. data/lib/lolita-translation/locales.rb +62 -0
  18. data/lib/lolita-translation/lolita/component_hooks.rb +49 -0
  19. data/lib/lolita-translation/lolita/tab_extension.rb +113 -0
  20. data/lib/lolita-translation/migrator.rb +56 -0
  21. data/lib/lolita-translation/migrators/active_record_migrator.rb +93 -0
  22. data/lib/lolita-translation/migrators/mongoid_migrator.rb +81 -0
  23. data/lib/lolita-translation/orm/mixin.rb +57 -0
  24. data/lib/lolita-translation/rails.rb +6 -31
  25. data/lib/lolita-translation/record.rb +220 -0
  26. data/lib/lolita-translation/translated_string.rb +11 -0
  27. data/lib/lolita-translation/translation_class_builder.rb +59 -0
  28. data/lib/lolita-translation/utils.rb +13 -0
  29. data/lib/lolita-translation/version.rb +32 -0
  30. data/lib/tasks/lolita_translation.rake +14 -0
  31. data/lolita-translation.gemspec +24 -71
  32. data/spec/ar_schema.rb +90 -0
  33. data/spec/header.rb +14 -0
  34. data/spec/integrations/active_record_integration_spec.rb +218 -0
  35. data/spec/lolita-translation/builder/abstract_builder_spec.rb +67 -0
  36. data/spec/lolita-translation/builder/active_record_builder_spec.rb +40 -0
  37. data/spec/lolita-translation/configuration_spec.rb +72 -0
  38. data/spec/lolita-translation/locale_spec.rb +25 -0
  39. data/spec/lolita-translation/locales_spec.rb +31 -0
  40. data/spec/lolita-translation/lolita/tab_extension_spec.rb +61 -0
  41. data/spec/lolita-translation/migrator_spec.rb +42 -0
  42. data/spec/lolita-translation/migrators/active_record_migrator_spec.rb +50 -0
  43. data/spec/lolita-translation/orm/mixin_spec.rb +52 -0
  44. data/spec/lolita-translation/record_spec.rb +112 -0
  45. data/spec/lolita-translation/translation_class_builder_spec.rb +62 -0
  46. data/spec/lolita_translation_spec.rb +16 -0
  47. data/spec/rails_helper.rb +6 -0
  48. data/spec/requests/record_language_switch_spec.rb +16 -0
  49. data/spec/requests/record_saving_spec.rb +63 -0
  50. data/spec/spec_helper.rb +38 -90
  51. data/spec/tasks/lolita_translation_spec.rb +32 -0
  52. data/spec/test_app/app/controllers/application_controller.rb +3 -0
  53. data/spec/test_app/app/models/category.rb +6 -0
  54. data/spec/test_app/app/models/post.rb +8 -0
  55. data/spec/test_app/config/application.rb +24 -0
  56. data/spec/test_app/config/boot.rb +11 -0
  57. data/spec/test_app/config/database.yml +3 -0
  58. data/spec/test_app/config/enviroment.rb +5 -0
  59. data/spec/test_app/config/enviroments/development.rb +44 -0
  60. data/spec/test_app/config/initializers/lolita_translation.rb +4 -0
  61. data/spec/test_app/config/initializers/token.rb +7 -0
  62. data/spec/test_app/config/routes.rb +4 -0
  63. data/spec/test_app/db/.gitkeep +0 -0
  64. data/spec/test_app/log/.gitkeep +0 -0
  65. metadata +193 -46
  66. data/.document +0 -5
  67. data/VERSION +0 -1
  68. data/app/views/components/lolita/translation/_assets.html.erb +0 -7
  69. data/app/views/components/lolita/translation/_language_wrap.html.erb +0 -4
  70. data/app/views/components/lolita/translation/_switch.html.erb +0 -8
  71. data/lib/generators/lolita_translation/USAGE +0 -8
  72. data/lib/generators/lolita_translation/has_translations_generator.rb +0 -8
  73. data/lib/lolita-translation/model.rb +0 -100
  74. data/lib/lolita-translation/modules.rb +0 -130
  75. data/lib/lolita-translation/string.rb +0 -19
  76. data/lib/tasks/has_translations_tasks.rake +0 -4
  77. data/spec/has_translations_spec.rb +0 -43
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+
3
+ end
@@ -0,0 +1,6 @@
1
+ class Category < ActiveRecord::Base
2
+ include Lolita::Configuration
3
+ include Lolita::Translation
4
+ translate :name
5
+ lolita
6
+ end
@@ -0,0 +1,8 @@
1
+ class Post < ActiveRecord::Base
2
+ include Lolita::Configuration
3
+ include Lolita::Translation
4
+
5
+ translate :title, :body
6
+
7
+ lolita
8
+ end
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+ require 'lolita'
3
+ if ENV["ORM"] == "active_record"
4
+ require 'rails/all'
5
+ elsif ENV["ORM"] == "mongoid"
6
+ require "action_controller/railtie"
7
+ require "action_mailer/railtie"
8
+ require "active_resource/railtie"
9
+ require "rails/test_unit/railtie"
10
+ require "sprockets/railtie"
11
+ end
12
+
13
+ Bundler.require(:default, :test, Rails.env) if defined?(Bundler)
14
+
15
+ module Test
16
+ class Application < Rails::Application
17
+ config.root = File.expand_path("#{File.dirname(__FILE__)}/..")
18
+ config.logger = Logger.new(File.join(config.root,"log","development.log"))
19
+ config.active_support.deprecation = :log
20
+ config.i18n.default_locale = I18n.default_locale
21
+ config.assets.enabled = true
22
+ #config.autoload_paths=File.expand_path("../#{File.dirname(__FILE__)}")
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+
3
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
4
+ begin
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ Bundler.setup(:default,:test)
7
+ rescue Bundler::GemNotFound => e
8
+ STDERR.puts e.message
9
+ STDERR.puts "Try running `bundle install`."
10
+ exit!
11
+ end if File.exist?(gemfile)
@@ -0,0 +1,3 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: "db/lolita-translation.db"
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Test::Application.initialize!
@@ -0,0 +1,44 @@
1
+ Test::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
33
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
34
+ # like if you have constraints or database-specific column types
35
+ # config.active_record.schema_format = :sql
36
+
37
+ # Print deprecation notices to the stderr
38
+ config.active_support.deprecation = :stderr
39
+ #config.log_level = :error
40
+
41
+ # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
42
+ config.assets.allow_debugging = true
43
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
44
+ end
@@ -0,0 +1,4 @@
1
+
2
+ Lolita.setup do |config|
3
+
4
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Test::Application.config.secret_token = '12870ac65ffa35be847226a38c8f2366234f4a6659e735b2d1aecf7e630ce3897cbf08fe01db26ce809b467cab674a57056ceed825acd217f56c8ef4ccace024'
@@ -0,0 +1,4 @@
1
+ Test::Application.routes.draw do
2
+ lolita_for :posts
3
+ lolita_for :categories
4
+ end
File without changes
File without changes
metadata CHANGED
@@ -1,74 +1,178 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolita-translation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - ITHouse
9
- - Gatis Tomsons
10
- - Arturs Meisters
8
+ - ITHouse (Latvia) and Arturs Meisters
11
9
  autorequire:
12
10
  bindir: bin
13
11
  cert_chain: []
14
- date: 2011-12-20 00:00:00.000000000Z
12
+ date: 2012-08-30 00:00:00.000000000 Z
15
13
  dependencies:
16
14
  - !ruby/object:Gem::Dependency
17
15
  name: lolita
18
- requirement: &88291940 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - ~>
22
20
  - !ruby/object:Gem::Version
23
- version: 3.2.0.rc.3
21
+ version: 3.2.0.rc.9
24
22
  type: :runtime
25
23
  prerelease: false
26
- version_requirements: *88291940
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0.rc.9
27
30
  - !ruby/object:Gem::Dependency
28
- name: shoulda
29
- requirement: &88291590 !ruby/object:Gem::Requirement
31
+ name: rails
32
+ requirement: !ruby/object:Gem::Requirement
30
33
  none: false
31
34
  requirements:
32
- - - ! '>='
35
+ - - ~>
33
36
  - !ruby/object:Gem::Version
34
- version: '0'
37
+ version: 3.2.3
35
38
  type: :development
36
39
  prerelease: false
37
- version_requirements: *88291590
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 3.2.3
38
46
  - !ruby/object:Gem::Dependency
39
- name: bundler
40
- requirement: &88219060 !ruby/object:Gem::Requirement
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
41
49
  none: false
42
50
  requirements:
43
51
  - - ~>
44
52
  - !ruby/object:Gem::Version
45
- version: 1.0.0
53
+ version: 2.9.0
46
54
  type: :development
47
55
  prerelease: false
48
- version_requirements: *88219060
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.9.0
49
62
  - !ruby/object:Gem::Dependency
50
- name: jeweler
51
- requirement: &88218580 !ruby/object:Gem::Requirement
63
+ name: rspec-rails
64
+ requirement: !ruby/object:Gem::Requirement
52
65
  none: false
53
66
  requirements:
54
67
  - - ~>
55
68
  - !ruby/object:Gem::Version
56
- version: 1.5.2
69
+ version: 2.9.0
57
70
  type: :development
58
71
  prerelease: false
59
- version_requirements: *88218580
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.9.0
60
78
  - !ruby/object:Gem::Dependency
61
- name: rcov
62
- requirement: &88217920 !ruby/object:Gem::Requirement
79
+ name: ffaker
80
+ requirement: !ruby/object:Gem::Requirement
63
81
  none: false
64
82
  requirements:
65
- - - ! '>='
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1'
94
+ - !ruby/object:Gem::Dependency
95
+ name: capybara
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.1.2
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.1.2
110
+ - !ruby/object:Gem::Dependency
111
+ name: capybara-webkit
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.11.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.11.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: cover_me
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 1.2.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 1.2.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: sqlite3
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 1.3.6
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 1.3.6
158
+ - !ruby/object:Gem::Dependency
159
+ name: debugger
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>'
66
164
  - !ruby/object:Gem::Version
67
165
  version: '0'
68
166
  type: :development
69
167
  prerelease: false
70
- version_requirements: *88217920
71
- description: Translates models in Lolita
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>'
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ description: Lolita extension that allow users to change language and translate DB
175
+ data.
72
176
  email: support@ithouse.lv
73
177
  executables: []
74
178
  extensions: []
@@ -76,35 +180,77 @@ extra_rdoc_files:
76
180
  - LICENSE.txt
77
181
  - README.md
78
182
  files:
79
- - .document
183
+ - .gitignore
80
184
  - .rspec
81
185
  - Gemfile
82
186
  - LICENSE.txt
83
187
  - README.md
84
188
  - Rakefile
85
- - VERSION
86
189
  - app/assets/.gitkeep
87
190
  - app/assets/javascripts/.gitkeep
88
191
  - app/assets/javascripts/lolita/translation/application.js
89
192
  - app/assets/stylesheets/lolita/translation/application.css
90
- - app/views/components/lolita/translation/_assets.html.erb
91
- - app/views/components/lolita/translation/_language_wrap.html.erb
92
- - app/views/components/lolita/translation/_switch.html.erb
193
+ - app/views/components/lolita/translation/_assets.html.haml
194
+ - app/views/components/lolita/translation/_language_wrap.html.haml
195
+ - app/views/components/lolita/translation/_switch.html.haml
93
196
  - config/locales/en.yml
94
197
  - config/locales/lv.yml
95
- - lib/generators/lolita_translation/USAGE
96
- - lib/generators/lolita_translation/has_translations_generator.rb
97
198
  - lib/lolita-translation.rb
199
+ - lib/lolita-translation/builder/abstract_builder.rb
200
+ - lib/lolita-translation/builder/active_record_builder.rb
201
+ - lib/lolita-translation/builder/mongoid_builder.rb
98
202
  - lib/lolita-translation/configuration.rb
99
- - lib/lolita-translation/model.rb
100
- - lib/lolita-translation/modules.rb
203
+ - lib/lolita-translation/errors.rb
204
+ - lib/lolita-translation/locale.rb
205
+ - lib/lolita-translation/locales.rb
206
+ - lib/lolita-translation/lolita/component_hooks.rb
207
+ - lib/lolita-translation/lolita/tab_extension.rb
208
+ - lib/lolita-translation/migrator.rb
209
+ - lib/lolita-translation/migrators/active_record_migrator.rb
210
+ - lib/lolita-translation/migrators/mongoid_migrator.rb
211
+ - lib/lolita-translation/orm/mixin.rb
101
212
  - lib/lolita-translation/rails.rb
102
- - lib/lolita-translation/string.rb
103
- - lib/tasks/has_translations_tasks.rake
213
+ - lib/lolita-translation/record.rb
214
+ - lib/lolita-translation/translated_string.rb
215
+ - lib/lolita-translation/translation_class_builder.rb
216
+ - lib/lolita-translation/utils.rb
217
+ - lib/lolita-translation/version.rb
218
+ - lib/tasks/lolita_translation.rake
104
219
  - lolita-translation.gemspec
105
- - spec/has_translations_spec.rb
220
+ - spec/ar_schema.rb
221
+ - spec/header.rb
222
+ - spec/integrations/active_record_integration_spec.rb
223
+ - spec/lolita-translation/builder/abstract_builder_spec.rb
224
+ - spec/lolita-translation/builder/active_record_builder_spec.rb
225
+ - spec/lolita-translation/configuration_spec.rb
226
+ - spec/lolita-translation/locale_spec.rb
227
+ - spec/lolita-translation/locales_spec.rb
228
+ - spec/lolita-translation/lolita/tab_extension_spec.rb
229
+ - spec/lolita-translation/migrator_spec.rb
230
+ - spec/lolita-translation/migrators/active_record_migrator_spec.rb
231
+ - spec/lolita-translation/orm/mixin_spec.rb
232
+ - spec/lolita-translation/record_spec.rb
233
+ - spec/lolita-translation/translation_class_builder_spec.rb
234
+ - spec/lolita_translation_spec.rb
235
+ - spec/rails_helper.rb
236
+ - spec/requests/record_language_switch_spec.rb
237
+ - spec/requests/record_saving_spec.rb
106
238
  - spec/spec_helper.rb
107
- homepage: http://github.com/ithouse/lolita-translations
239
+ - spec/tasks/lolita_translation_spec.rb
240
+ - spec/test_app/app/controllers/application_controller.rb
241
+ - spec/test_app/app/models/category.rb
242
+ - spec/test_app/app/models/post.rb
243
+ - spec/test_app/config/application.rb
244
+ - spec/test_app/config/boot.rb
245
+ - spec/test_app/config/database.yml
246
+ - spec/test_app/config/enviroment.rb
247
+ - spec/test_app/config/enviroments/development.rb
248
+ - spec/test_app/config/initializers/lolita_translation.rb
249
+ - spec/test_app/config/initializers/token.rb
250
+ - spec/test_app/config/routes.rb
251
+ - spec/test_app/db/.gitkeep
252
+ - spec/test_app/log/.gitkeep
253
+ homepage: http://github.com/ithouse/lolita-translation
108
254
  licenses:
109
255
  - MIT
110
256
  post_install_message:
@@ -119,19 +265,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
265
  version: '0'
120
266
  segments:
121
267
  - 0
122
- hash: 1059791219
268
+ hash: 635836627420984892
123
269
  required_rubygems_version: !ruby/object:Gem::Requirement
124
270
  none: false
125
271
  requirements:
126
272
  - - ! '>='
127
273
  - !ruby/object:Gem::Version
128
274
  version: '0'
275
+ segments:
276
+ - 0
277
+ hash: 635836627420984892
129
278
  requirements: []
130
279
  rubyforge_project:
131
- rubygems_version: 1.8.10
280
+ rubygems_version: 1.8.24
132
281
  signing_key:
133
282
  specification_version: 3
134
- summary: Lolita models translation plugin
135
- test_files:
136
- - spec/has_translations_spec.rb
137
- - spec/spec_helper.rb
283
+ summary: Lolita extension that add multilanguate support to Lolita.
284
+ test_files: []