awesome_translations 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/awesome_translations/groups.css.scss +4 -0
  3. data/app/views/awesome_translations/groups/show.html.haml +1 -2
  4. data/lib/awesome_translations.rb +1 -1
  5. data/lib/awesome_translations/erb_inspector/translation_inspector.rb +4 -0
  6. data/lib/awesome_translations/handlers/erb_handler.rb +1 -0
  7. data/lib/awesome_translations/handlers/global_handler.rb +1 -1
  8. data/lib/awesome_translations/handlers/model_handler.rb +5 -5
  9. data/lib/awesome_translations/model_inspector.rb +33 -63
  10. data/lib/awesome_translations/model_inspector/attribute.rb +4 -4
  11. data/lib/awesome_translations/version.rb +1 -1
  12. data/spec/dummy/config/locales/translations.yml +8 -0
  13. data/spec/dummy/log/development.log +1 -0
  14. data/spec/dummy/log/test.log +3282 -0
  15. data/spec/dummy/tmp/cache/assets/test/sass/79bc6a1530be4e47bb2bf0dda4943bc0e439789f/application.css.scssc +0 -0
  16. data/spec/dummy/tmp/cache/assets/test/sass/79bc6a1530be4e47bb2bf0dda4943bc0e439789f/groups.css.scssc +0 -0
  17. data/spec/dummy/tmp/cache/assets/test/sprockets/50b9bcf05a8718d9cb5b99276f154ea9 +0 -0
  18. data/spec/dummy/tmp/cache/assets/test/sprockets/6db8498274efddac6691248cc9afe855 +0 -0
  19. data/spec/dummy/tmp/cache/assets/test/sprockets/bd49bb0a6f5dfd284a750fb9cab40d85 +0 -0
  20. data/spec/dummy/tmp/cache/assets/test/sprockets/c39fce5fa19b758734af29527d4185ca +0 -0
  21. data/spec/dummy/tmp/cache/assets/test/sprockets/cb595904fcf7acdedf2b95571442fc59 +0 -0
  22. data/spec/lib/model_inspector/attribute_spec.rb +18 -0
  23. data/spec/lib/model_inspector_spec.rb +38 -0
  24. metadata +8 -26
  25. data/spec/dummy/config/locales/awesome_translations/app/views/users/da.yml +0 -5
  26. data/spec/dummy/config/locales/awesome_translations/app/views/users/de.yml +0 -5
  27. data/spec/dummy/config/locales/awesome_translations/app/views/users/en.yml +0 -5
  28. data/spec/dummy/config/locales/awesome_translations/da.yml +0 -4
  29. data/spec/dummy/config/locales/awesome_translations/de.yml +0 -4
  30. data/spec/dummy/config/locales/awesome_translations/en.yml +0 -4
  31. data/spec/dummy/config/locales/awesome_translations/models/role/da.yml +0 -6
  32. data/spec/dummy/config/locales/awesome_translations/models/role/de.yml +0 -6
  33. data/spec/dummy/config/locales/awesome_translations/models/role/en.yml +0 -6
  34. data/spec/dummy/config/locales/awesome_translations/models/user/da.yml +0 -12
  35. data/spec/dummy/config/locales/awesome_translations/models/user/de.yml +0 -12
  36. data/spec/dummy/config/locales/awesome_translations/models/user/en.yml +0 -12
@@ -0,0 +1,18 @@
1
+ require "spec_helper"
2
+
3
+ describe AwesomeTranslations::ModelInspector::Attribute do
4
+ let(:user_inspector) { AwesomeTranslations::ModelInspector.model_classes.select { |model_inspector| model_inspector.clazz == User }.first }
5
+ let(:email_attr) { user_inspector.attributes.select { |attribute| attribute.name == "email" }.first }
6
+
7
+ it "#i18n_key" do
8
+ email_attr.i18n_key.should eq "activerecord.attributes.user.email"
9
+ end
10
+
11
+ it "#name" do
12
+ email_attr.name.should eq "email"
13
+ end
14
+
15
+ it "#model_inspector" do
16
+ email_attr.model_inspector.clazz.should eq User
17
+ end
18
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ describe AwesomeTranslations::ModelInspector do
4
+ let(:user_inspector) { AwesomeTranslations::ModelInspector.model_classes.select { |model_inspector| model_inspector.clazz == User }.first }
5
+ let(:model_classes) { AwesomeTranslations::ModelInspector.model_classes.map(&:clazz) }
6
+
7
+ it "#model_classes" do
8
+ model_classes.to_a.sort { |class1, class2| class1.name <=> class2.name }.should eq [Role, User]
9
+ end
10
+
11
+ it "#engines" do
12
+ AwesomeTranslations::ModelInspector.engines.map(&:class).should eq [AwesomeTranslations::Engine, Jquery::Rails::Engine]
13
+ end
14
+
15
+ it "#class_key" do
16
+ user_inspector.class_key.should eq "activerecord.models.user"
17
+ end
18
+
19
+ it "#class_key_one" do
20
+ user_inspector.class_key_one.should eq "activerecord.models.user.one"
21
+ end
22
+
23
+ it "#class_key_other" do
24
+ user_inspector.class_key_other.should eq "activerecord.models.user.other"
25
+ end
26
+
27
+ it "#attribute_key" do
28
+ user_inspector.attribute_key("first_name").should eq "activerecord.attributes.user.first_name"
29
+ end
30
+
31
+ it "#snake_name" do
32
+ user_inspector.snake_name.should eq "user"
33
+ end
34
+
35
+ it "#attributes" do
36
+ user_inspector.attributes.map(&:name).to_a.should eq ["id", "email", "password", "age"]
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_translations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-03 00:00:00.000000000 Z
11
+ date: 2015-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -258,19 +258,8 @@ files:
258
258
  - spec/dummy/config/initializers/secret_token.rb
259
259
  - spec/dummy/config/initializers/session_store.rb
260
260
  - spec/dummy/config/initializers/wrap_parameters.rb
261
- - spec/dummy/config/locales/awesome_translations/app/views/users/da.yml
262
- - spec/dummy/config/locales/awesome_translations/app/views/users/de.yml
263
- - spec/dummy/config/locales/awesome_translations/app/views/users/en.yml
264
- - spec/dummy/config/locales/awesome_translations/da.yml
265
- - spec/dummy/config/locales/awesome_translations/de.yml
266
- - spec/dummy/config/locales/awesome_translations/en.yml
267
- - spec/dummy/config/locales/awesome_translations/models/role/da.yml
268
- - spec/dummy/config/locales/awesome_translations/models/role/de.yml
269
- - spec/dummy/config/locales/awesome_translations/models/role/en.yml
270
- - spec/dummy/config/locales/awesome_translations/models/user/da.yml
271
- - spec/dummy/config/locales/awesome_translations/models/user/de.yml
272
- - spec/dummy/config/locales/awesome_translations/models/user/en.yml
273
261
  - spec/dummy/config/locales/en.yml
262
+ - spec/dummy/config/locales/translations.yml
274
263
  - spec/dummy/config/routes.rb
275
264
  - spec/dummy/db/development.sqlite3
276
265
  - spec/dummy/db/migrate/20141018081559_create_users.rb
@@ -348,6 +337,8 @@ files:
348
337
  - spec/lib/erb_inspector/file_inspector_spec.rb
349
338
  - spec/lib/erb_inspector/translation_inspector_spec.rb
350
339
  - spec/lib/erb_inspector_spec.rb
340
+ - spec/lib/model_inspector/attribute_spec.rb
341
+ - spec/lib/model_inspector_spec.rb
351
342
  - spec/models/awesome_translations/handler_spec.rb
352
343
  - spec/models/awesome_translations/translated_value_spec.rb
353
344
  - spec/spec_helper.rb
@@ -375,6 +366,8 @@ signing_key:
375
366
  specification_version: 4
376
367
  summary: Semi-automatic maintenance of most translations in a Rails app.
377
368
  test_files:
369
+ - spec/lib/model_inspector/attribute_spec.rb
370
+ - spec/lib/model_inspector_spec.rb
378
371
  - spec/lib/erb_inspector/file_inspector_spec.rb
379
372
  - spec/lib/erb_inspector/translation_inspector_spec.rb
380
373
  - spec/lib/erb_inspector_spec.rb
@@ -487,18 +480,7 @@ test_files:
487
480
  - spec/dummy/config/application.rb
488
481
  - spec/dummy/config/environment.rb
489
482
  - spec/dummy/config/boot.rb
490
- - spec/dummy/config/locales/awesome_translations/app/views/users/da.yml
491
- - spec/dummy/config/locales/awesome_translations/app/views/users/de.yml
492
- - spec/dummy/config/locales/awesome_translations/app/views/users/en.yml
493
- - spec/dummy/config/locales/awesome_translations/da.yml
494
- - spec/dummy/config/locales/awesome_translations/models/role/da.yml
495
- - spec/dummy/config/locales/awesome_translations/models/role/de.yml
496
- - spec/dummy/config/locales/awesome_translations/models/role/en.yml
497
- - spec/dummy/config/locales/awesome_translations/models/user/da.yml
498
- - spec/dummy/config/locales/awesome_translations/models/user/de.yml
499
- - spec/dummy/config/locales/awesome_translations/models/user/en.yml
500
- - spec/dummy/config/locales/awesome_translations/de.yml
501
- - spec/dummy/config/locales/awesome_translations/en.yml
483
+ - spec/dummy/config/locales/translations.yml
502
484
  - spec/dummy/config/locales/en.yml
503
485
  - spec/dummy/config/database.yml
504
486
  - spec/dummy/config/routes.rb
@@ -1,5 +0,0 @@
1
- ---
2
- da:
3
- users:
4
- show:
5
- some_translation: En eller anden oversættelse
@@ -1,5 +0,0 @@
1
- ---
2
- de:
3
- users:
4
- show:
5
- some_translation: Eine Übersätsung
@@ -1,5 +0,0 @@
1
- ---
2
- en:
3
- users:
4
- show:
5
- some_translation: Some translation
@@ -1,4 +0,0 @@
1
- ---
2
- da:
3
- 'yes': Ja
4
- 'no': Nej
@@ -1,4 +0,0 @@
1
- ---
2
- de:
3
- 'yes': Ja
4
- 'no': Nein
@@ -1,4 +0,0 @@
1
- ---
2
- en:
3
- 'yes': 'Yes'
4
- 'no': 'No'
@@ -1,6 +0,0 @@
1
- ---
2
- da:
3
- activerecord:
4
- attributes:
5
- role:
6
- role: Rolle
@@ -1,6 +0,0 @@
1
- ---
2
- de:
3
- activerecord:
4
- attributes:
5
- role:
6
- role: Die type
@@ -1,6 +0,0 @@
1
- ---
2
- en:
3
- activerecord:
4
- attributes:
5
- role:
6
- role: Role
@@ -1,12 +0,0 @@
1
- ---
2
- da:
3
- activerecord:
4
- attributes:
5
- user:
6
- password: Adgangskode
7
- errors:
8
- models:
9
- user:
10
- attributes:
11
- email:
12
- blank: Indtast venligst email
@@ -1,12 +0,0 @@
1
- ---
2
- de:
3
- activerecord:
4
- attributes:
5
- user:
6
- password: Kenwort
7
- errors:
8
- models:
9
- user:
10
- attributes:
11
- email:
12
- blank: Bitte deine email geben
@@ -1,12 +0,0 @@
1
- ---
2
- en:
3
- activerecord:
4
- attributes:
5
- user:
6
- password: Password
7
- errors:
8
- models:
9
- user:
10
- attributes:
11
- email:
12
- blank: Please write your email