easy_translatable 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92e6ca6a6f1919678d40513de824e5f10866940d
4
- data.tar.gz: 20b38ee4b7dada0802f53fab8077ebc1079e60fc
3
+ metadata.gz: 07c01316196483c2f6af68455278d9e92c16dd48
4
+ data.tar.gz: 91caddf7318b585c7db393c4bda5784784e7b7b0
5
5
  SHA512:
6
- metadata.gz: 901ae4e1c1cfd1aa47b14e544f785e4dc595777e2aaf4aba0ecf871584cb7756071867bc08428bda2f6200ab137faa4208a7e42a842f3ca0d08203d16116a6fb
7
- data.tar.gz: f779b1fc88db5887f82ad102429f5c50279f368826776fa4a4262a62d35a7d774fd31bf0fce64fd6ebdd4511fe5e7cce9c71442d69969f7f0b8e604b3830fea2
6
+ metadata.gz: 61de0f484b7f8637f1ccff01d020eaa9ae3d47c24563c5dcbbec69de1f7643111f02dcc5e71ffb6d4c1b4f50fd9c1ab3dda40ab6379b98b6ba7fb3c7ecfe2817
7
+ data.tar.gz: 82d6f692782508f0d5555f0f0cc833feab8446aee5d1b3991be66bf4498471e16adde80a81b3106e49975d225fec7ae9d611686ce6b741d45315d9c9c69eaa9e
data/README.md CHANGED
@@ -20,8 +20,6 @@ gem 'easy_translatable', '~> 0.1.0'
20
20
 
21
21
  ## Todo
22
22
 
23
- - Tests, tests and tests
24
23
  - cleanup
25
24
  - doc
26
25
  - migration/model for translation table
27
- - serialized attributes (JSON/YML)
@@ -4,6 +4,7 @@ require File.expand_path '../active_record/attributes.rb', __FILE__
4
4
  require File.expand_path '../active_record/adapter.rb', __FILE__
5
5
  require File.expand_path '../active_record/macro.rb', __FILE__
6
6
  require File.expand_path '../active_record/translate.rb', __FILE__
7
+ require File.expand_path '../active_record/relation.rb', __FILE__
7
8
 
8
9
  module Translatable
9
10
  module ActiveRecord
@@ -0,0 +1,38 @@
1
+ module Translatable
2
+ module ActiveRecord
3
+ module Relation
4
+
5
+ # Ugly hack to override ActiveRecord::Relation#exec_queries method
6
+ # After ruby >= 2.0.0 it's possible to simply prepend http://ruby-doc.org/core-2.0/Module.html#method-i-prepend
7
+ def self.included(base)
8
+ base.class_eval do
9
+ alias_method_chain :exec_queries, :translations
10
+ end
11
+ end
12
+
13
+ def translate
14
+ @translate_records = true
15
+ self.eager_load(:translations)
16
+ end
17
+
18
+ def exec_queries_with_translations
19
+ if @translate_records
20
+ exec_queries_without_translations.map(&:translate)
21
+ else
22
+ exec_queries_without_translations
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+
30
+ class Railtie < Rails::Railtie
31
+
32
+ initializer "easy_translatable.configure_rails_initialization" do
33
+ ActiveSupport.on_load(:active_record) do
34
+ ActiveRecord::Relation.send :include, Translatable::ActiveRecord::Relation
35
+ end
36
+ end
37
+
38
+ end if defined?(Rails)
@@ -1,14 +1,8 @@
1
1
  module Translatable
2
2
  module ActiveRecord
3
3
  module Translate
4
-
5
- # Ask for translations
6
- def translate
7
-
8
- q = self.scoped
9
- q.map(&:translate)
10
- q
11
-
4
+ def self.translate
5
+ self.scoped.translate
12
6
  end
13
7
 
14
8
  end
@@ -1,3 +1,3 @@
1
1
  module Translatable
2
- VERSION = '0.1.7'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_translatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Bonaud
@@ -49,112 +49,112 @@ dependencies:
49
49
  name: mocha
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: pathname_local
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: test_declarative
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: friendly_id
92
92
  requirement: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: sqlite3
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: rake
120
120
  requirement: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  type: :development
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  - !ruby/object:Gem::Dependency
133
133
  name: rdoc
134
134
  requirement: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  type: :development
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: coveralls
148
148
  requirement: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - '>='
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  type: :development
154
154
  prerelease: false
155
155
  version_requirements: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - '>='
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  description: Handle translations for AR models into a single table. And provide a
@@ -172,6 +172,7 @@ files:
172
172
  - lib/translatable/active_record/class_methods.rb
173
173
  - lib/translatable/active_record/instance_methods.rb
174
174
  - lib/translatable/active_record/macro.rb
175
+ - lib/translatable/active_record/relation.rb
175
176
  - lib/translatable/active_record/translate.rb
176
177
  - lib/translatable/default.rb
177
178
  - lib/translatable/version.rb