globalize 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -0
- data/Gemfile.lock +232 -28
- data/lib/globalize.rb +5 -0
- data/lib/globalize/active_record/adapter.rb +12 -9
- data/lib/globalize/active_record/class_methods.rb +18 -16
- data/lib/globalize/active_record/query_methods.rb +5 -8
- data/lib/globalize/version.rb +1 -1
- data/lib/patches/i18n/interpolate.rb +37 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34b357eb2051fae6a0a588bac79f4865412887c7
|
4
|
+
data.tar.gz: 87dcd21c654f413edc206becf2a249433a7128b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934e4cbf69e650b3adc36fe5569007343d91bd6d9d1145e9b01e40e5c0039cebc4ddce55c9d109c46e76f657550f59477a291f86566eb33fdde8d1572596a468
|
7
|
+
data.tar.gz: 432ad39f1c190b723e688170306f94f9b98c6797fd70b73f3cfcee85366629338ded33aaeae0e827ff46535b4f1a8c3c306eacb4903251b6f405835cb2a363d9
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/airblade/paper_trail.git
|
3
|
-
revision:
|
3
|
+
revision: c4e188c27040888515866660bac94740b92a262b
|
4
4
|
branch: master
|
5
5
|
specs:
|
6
|
-
paper_trail (3.0.0
|
6
|
+
paper_trail (3.0.0)
|
7
7
|
activerecord (>= 3.0, < 5.0)
|
8
8
|
activesupport (>= 3.0, < 5.0)
|
9
9
|
|
10
10
|
GIT
|
11
11
|
remote: git://github.com/bmabey/database_cleaner.git
|
12
|
-
revision:
|
12
|
+
revision: c0c7885466287dcde3dbac195a5f10df306db098
|
13
13
|
branch: master
|
14
14
|
specs:
|
15
15
|
database_cleaner (1.2.0)
|
@@ -17,7 +17,7 @@ GIT
|
|
17
17
|
PATH
|
18
18
|
remote: .
|
19
19
|
specs:
|
20
|
-
globalize (4.0.0.alpha.
|
20
|
+
globalize (4.0.0.alpha.3)
|
21
21
|
activemodel (>= 4.0.0)
|
22
22
|
activerecord (>= 4.0.0)
|
23
23
|
paper_trail (~> 3.0.0.beta)
|
@@ -25,50 +25,253 @@ PATH
|
|
25
25
|
GEM
|
26
26
|
remote: https://rubygems.org/
|
27
27
|
specs:
|
28
|
-
activemodel (4.0.
|
29
|
-
activesupport (= 4.0.
|
28
|
+
activemodel (4.0.2)
|
29
|
+
activesupport (= 4.0.2)
|
30
30
|
builder (~> 3.1.0)
|
31
|
-
activerecord (4.0.
|
32
|
-
activemodel (= 4.0.
|
31
|
+
activerecord (4.0.2)
|
32
|
+
activemodel (= 4.0.2)
|
33
33
|
activerecord-deprecated_finders (~> 1.0.2)
|
34
|
-
activesupport (= 4.0.
|
34
|
+
activesupport (= 4.0.2)
|
35
35
|
arel (~> 4.0.0)
|
36
36
|
activerecord-deprecated_finders (1.0.3)
|
37
|
-
activesupport (4.0.
|
37
|
+
activesupport (4.0.2)
|
38
38
|
i18n (~> 0.6, >= 0.6.4)
|
39
39
|
minitest (~> 4.2)
|
40
40
|
multi_json (~> 1.3)
|
41
41
|
thread_safe (~> 0.1)
|
42
42
|
tzinfo (~> 0.3.37)
|
43
|
+
ansi (1.4.3)
|
43
44
|
arel (4.0.1)
|
44
45
|
atomic (1.1.14)
|
45
46
|
builder (3.1.4)
|
46
|
-
coderay (1.0
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
debugger-linecache (~> 1.2.0)
|
51
|
-
debugger-ruby_core_source (~> 1.2.3)
|
52
|
-
debugger-linecache (1.2.0)
|
53
|
-
debugger-ruby_core_source (1.2.3)
|
54
|
-
i18n (0.6.5)
|
47
|
+
coderay (1.1.0)
|
48
|
+
ffi2-generators (0.1.1)
|
49
|
+
hashie (2.0.5)
|
50
|
+
i18n (0.6.9)
|
55
51
|
json (1.8.1)
|
56
52
|
method_source (0.8.2)
|
57
53
|
minitest (4.7.5)
|
58
|
-
minitest-
|
59
|
-
|
54
|
+
minitest-reporters (0.14.23)
|
55
|
+
ansi
|
56
|
+
builder
|
57
|
+
minitest (>= 2.12, < 5.0)
|
58
|
+
powerbar
|
60
59
|
multi_json (1.8.2)
|
61
|
-
|
62
|
-
|
60
|
+
powerbar (1.0.11)
|
61
|
+
ansi (~> 1.4.0)
|
62
|
+
hashie (>= 1.1.0)
|
63
|
+
pry (0.9.12.4)
|
64
|
+
coderay (~> 1.0)
|
63
65
|
method_source (~> 0.8)
|
64
66
|
slop (~> 3.4)
|
65
|
-
pry-
|
66
|
-
debugger (~> 1.3)
|
67
|
+
pry-nav (0.2.3)
|
67
68
|
pry (~> 0.9.10)
|
68
69
|
rake (10.1.0)
|
69
70
|
rdoc (3.12.2)
|
70
71
|
json (~> 1.4)
|
71
|
-
|
72
|
+
rubysl (2.0.15)
|
73
|
+
rubysl-abbrev (~> 2.0)
|
74
|
+
rubysl-base64 (~> 2.0)
|
75
|
+
rubysl-benchmark (~> 2.0)
|
76
|
+
rubysl-bigdecimal (~> 2.0)
|
77
|
+
rubysl-cgi (~> 2.0)
|
78
|
+
rubysl-cgi-session (~> 2.0)
|
79
|
+
rubysl-cmath (~> 2.0)
|
80
|
+
rubysl-complex (~> 2.0)
|
81
|
+
rubysl-continuation (~> 2.0)
|
82
|
+
rubysl-coverage (~> 2.0)
|
83
|
+
rubysl-csv (~> 2.0)
|
84
|
+
rubysl-curses (~> 2.0)
|
85
|
+
rubysl-date (~> 2.0)
|
86
|
+
rubysl-delegate (~> 2.0)
|
87
|
+
rubysl-digest (~> 2.0)
|
88
|
+
rubysl-drb (~> 2.0)
|
89
|
+
rubysl-e2mmap (~> 2.0)
|
90
|
+
rubysl-english (~> 2.0)
|
91
|
+
rubysl-enumerator (~> 2.0)
|
92
|
+
rubysl-erb (~> 2.0)
|
93
|
+
rubysl-etc (~> 2.0)
|
94
|
+
rubysl-expect (~> 2.0)
|
95
|
+
rubysl-fcntl (~> 2.0)
|
96
|
+
rubysl-fiber (~> 2.0)
|
97
|
+
rubysl-fileutils (~> 2.0)
|
98
|
+
rubysl-find (~> 2.0)
|
99
|
+
rubysl-forwardable (~> 2.0)
|
100
|
+
rubysl-getoptlong (~> 2.0)
|
101
|
+
rubysl-gserver (~> 2.0)
|
102
|
+
rubysl-io-console (~> 2.0)
|
103
|
+
rubysl-io-nonblock (~> 2.0)
|
104
|
+
rubysl-io-wait (~> 2.0)
|
105
|
+
rubysl-ipaddr (~> 2.0)
|
106
|
+
rubysl-irb (~> 2.0)
|
107
|
+
rubysl-logger (~> 2.0)
|
108
|
+
rubysl-mathn (~> 2.0)
|
109
|
+
rubysl-matrix (~> 2.0)
|
110
|
+
rubysl-mkmf (~> 2.0)
|
111
|
+
rubysl-monitor (~> 2.0)
|
112
|
+
rubysl-mutex_m (~> 2.0)
|
113
|
+
rubysl-net-ftp (~> 2.0)
|
114
|
+
rubysl-net-http (~> 2.0)
|
115
|
+
rubysl-net-imap (~> 2.0)
|
116
|
+
rubysl-net-pop (~> 2.0)
|
117
|
+
rubysl-net-protocol (~> 2.0)
|
118
|
+
rubysl-net-smtp (~> 2.0)
|
119
|
+
rubysl-net-telnet (~> 2.0)
|
120
|
+
rubysl-nkf (~> 2.0)
|
121
|
+
rubysl-observer (~> 2.0)
|
122
|
+
rubysl-open-uri (~> 2.0)
|
123
|
+
rubysl-open3 (~> 2.0)
|
124
|
+
rubysl-openssl (~> 2.0)
|
125
|
+
rubysl-optparse (~> 2.0)
|
126
|
+
rubysl-ostruct (~> 2.0)
|
127
|
+
rubysl-pathname (~> 2.0)
|
128
|
+
rubysl-prettyprint (~> 2.0)
|
129
|
+
rubysl-prime (~> 2.0)
|
130
|
+
rubysl-profile (~> 2.0)
|
131
|
+
rubysl-profiler (~> 2.0)
|
132
|
+
rubysl-pstore (~> 2.0)
|
133
|
+
rubysl-pty (~> 2.0)
|
134
|
+
rubysl-rational (~> 2.0)
|
135
|
+
rubysl-readline (~> 2.0)
|
136
|
+
rubysl-resolv (~> 2.0)
|
137
|
+
rubysl-rexml (~> 2.0)
|
138
|
+
rubysl-rinda (~> 2.0)
|
139
|
+
rubysl-rss (~> 2.0)
|
140
|
+
rubysl-scanf (~> 2.0)
|
141
|
+
rubysl-securerandom (~> 2.0)
|
142
|
+
rubysl-set (~> 2.0)
|
143
|
+
rubysl-shellwords (~> 2.0)
|
144
|
+
rubysl-singleton (~> 2.0)
|
145
|
+
rubysl-socket (~> 2.0)
|
146
|
+
rubysl-stringio (~> 2.0)
|
147
|
+
rubysl-strscan (~> 2.0)
|
148
|
+
rubysl-sync (~> 2.0)
|
149
|
+
rubysl-syslog (~> 2.0)
|
150
|
+
rubysl-tempfile (~> 2.0)
|
151
|
+
rubysl-thread (~> 2.0)
|
152
|
+
rubysl-thwait (~> 2.0)
|
153
|
+
rubysl-time (~> 2.0)
|
154
|
+
rubysl-timeout (~> 2.0)
|
155
|
+
rubysl-tmpdir (~> 2.0)
|
156
|
+
rubysl-tsort (~> 2.0)
|
157
|
+
rubysl-un (~> 2.0)
|
158
|
+
rubysl-uri (~> 2.0)
|
159
|
+
rubysl-weakref (~> 2.0)
|
160
|
+
rubysl-webrick (~> 2.0)
|
161
|
+
rubysl-xmlrpc (~> 2.0)
|
162
|
+
rubysl-yaml (~> 2.0)
|
163
|
+
rubysl-zlib (~> 2.0)
|
164
|
+
rubysl-abbrev (2.0.4)
|
165
|
+
rubysl-base64 (2.0.0)
|
166
|
+
rubysl-benchmark (2.0.1)
|
167
|
+
rubysl-bigdecimal (2.0.2)
|
168
|
+
rubysl-cgi (2.0.1)
|
169
|
+
rubysl-cgi-session (2.0.1)
|
170
|
+
rubysl-cmath (2.0.0)
|
171
|
+
rubysl-complex (2.0.0)
|
172
|
+
rubysl-continuation (2.0.0)
|
173
|
+
rubysl-coverage (2.0.3)
|
174
|
+
rubysl-csv (2.0.2)
|
175
|
+
rubysl-english (~> 2.0)
|
176
|
+
rubysl-curses (2.0.0)
|
177
|
+
rubysl-date (2.0.6)
|
178
|
+
rubysl-delegate (2.0.1)
|
179
|
+
rubysl-digest (2.0.3)
|
180
|
+
rubysl-drb (2.0.1)
|
181
|
+
rubysl-e2mmap (2.0.0)
|
182
|
+
rubysl-english (2.0.0)
|
183
|
+
rubysl-enumerator (2.0.0)
|
184
|
+
rubysl-erb (2.0.1)
|
185
|
+
rubysl-etc (2.0.3)
|
186
|
+
ffi2-generators (~> 0.1)
|
187
|
+
rubysl-expect (2.0.0)
|
188
|
+
rubysl-fcntl (2.0.4)
|
189
|
+
ffi2-generators (~> 0.1)
|
190
|
+
rubysl-fiber (2.0.0)
|
191
|
+
rubysl-fileutils (2.0.3)
|
192
|
+
rubysl-find (2.0.1)
|
193
|
+
rubysl-forwardable (2.0.1)
|
194
|
+
rubysl-getoptlong (2.0.0)
|
195
|
+
rubysl-gserver (2.0.0)
|
196
|
+
rubysl-socket (~> 2.0)
|
197
|
+
rubysl-thread (~> 2.0)
|
198
|
+
rubysl-io-console (2.0.0)
|
199
|
+
rubysl-io-nonblock (2.0.0)
|
200
|
+
rubysl-io-wait (2.0.0)
|
201
|
+
rubysl-ipaddr (2.0.0)
|
202
|
+
rubysl-irb (2.0.4)
|
203
|
+
rubysl-e2mmap (~> 2.0)
|
204
|
+
rubysl-mathn (~> 2.0)
|
205
|
+
rubysl-readline (~> 2.0)
|
206
|
+
rubysl-thread (~> 2.0)
|
207
|
+
rubysl-logger (2.0.0)
|
208
|
+
rubysl-mathn (2.0.0)
|
209
|
+
rubysl-matrix (2.1.0)
|
210
|
+
rubysl-e2mmap (~> 2.0)
|
211
|
+
rubysl-mkmf (2.0.1)
|
212
|
+
rubysl-fileutils (~> 2.0)
|
213
|
+
rubysl-shellwords (~> 2.0)
|
214
|
+
rubysl-monitor (2.0.0)
|
215
|
+
rubysl-mutex_m (2.0.0)
|
216
|
+
rubysl-net-ftp (2.0.1)
|
217
|
+
rubysl-net-http (2.0.4)
|
218
|
+
rubysl-cgi (~> 2.0)
|
219
|
+
rubysl-erb (~> 2.0)
|
220
|
+
rubysl-singleton (~> 2.0)
|
221
|
+
rubysl-net-imap (2.0.1)
|
222
|
+
rubysl-net-pop (2.0.1)
|
223
|
+
rubysl-net-protocol (2.0.1)
|
224
|
+
rubysl-net-smtp (2.0.1)
|
225
|
+
rubysl-net-telnet (2.0.0)
|
226
|
+
rubysl-nkf (2.0.1)
|
227
|
+
rubysl-observer (2.0.0)
|
228
|
+
rubysl-open-uri (2.0.0)
|
229
|
+
rubysl-open3 (2.0.0)
|
230
|
+
rubysl-openssl (2.0.5)
|
231
|
+
rubysl-optparse (2.0.1)
|
232
|
+
rubysl-shellwords (~> 2.0)
|
233
|
+
rubysl-ostruct (2.0.4)
|
234
|
+
rubysl-pathname (2.0.0)
|
235
|
+
rubysl-prettyprint (2.0.2)
|
236
|
+
rubysl-prime (2.0.1)
|
237
|
+
rubysl-profile (2.0.0)
|
238
|
+
rubysl-profiler (2.0.1)
|
239
|
+
rubysl-pstore (2.0.0)
|
240
|
+
rubysl-pty (2.0.2)
|
241
|
+
rubysl-rational (2.0.1)
|
242
|
+
rubysl-readline (2.0.2)
|
243
|
+
rubysl-resolv (2.0.0)
|
244
|
+
rubysl-rexml (2.0.2)
|
245
|
+
rubysl-rinda (2.0.0)
|
246
|
+
rubysl-rss (2.0.0)
|
247
|
+
rubysl-scanf (2.0.0)
|
248
|
+
rubysl-securerandom (2.0.0)
|
249
|
+
rubysl-set (2.0.1)
|
250
|
+
rubysl-shellwords (2.0.0)
|
251
|
+
rubysl-singleton (2.0.0)
|
252
|
+
rubysl-socket (2.0.1)
|
253
|
+
rubysl-stringio (2.0.0)
|
254
|
+
rubysl-strscan (2.0.0)
|
255
|
+
rubysl-sync (2.0.0)
|
256
|
+
rubysl-syslog (2.0.1)
|
257
|
+
ffi2-generators (~> 0.1)
|
258
|
+
rubysl-tempfile (2.0.1)
|
259
|
+
rubysl-thread (2.0.2)
|
260
|
+
rubysl-thwait (2.0.0)
|
261
|
+
rubysl-time (2.0.3)
|
262
|
+
rubysl-timeout (2.0.0)
|
263
|
+
rubysl-tmpdir (2.0.0)
|
264
|
+
rubysl-tsort (2.0.1)
|
265
|
+
rubysl-un (2.0.0)
|
266
|
+
rubysl-fileutils (~> 2.0)
|
267
|
+
rubysl-optparse (~> 2.0)
|
268
|
+
rubysl-uri (2.0.0)
|
269
|
+
rubysl-weakref (2.0.0)
|
270
|
+
rubysl-webrick (2.0.0)
|
271
|
+
rubysl-xmlrpc (2.0.0)
|
272
|
+
rubysl-yaml (2.0.4)
|
273
|
+
rubysl-zlib (2.0.1)
|
274
|
+
slop (3.4.7)
|
72
275
|
sqlite3 (1.3.8)
|
73
276
|
thread_safe (0.1.3)
|
74
277
|
atomic
|
@@ -81,10 +284,11 @@ DEPENDENCIES
|
|
81
284
|
database_cleaner!
|
82
285
|
globalize!
|
83
286
|
minitest
|
84
|
-
minitest-
|
287
|
+
minitest-reporters
|
85
288
|
paper_trail!
|
86
289
|
pry
|
87
|
-
pry-
|
290
|
+
pry-nav
|
88
291
|
rake
|
89
292
|
rdoc
|
293
|
+
rubysl (~> 2.0)
|
90
294
|
sqlite3
|
data/lib/globalize.rb
CHANGED
@@ -3,6 +3,11 @@ require 'patches/active_record/xml_attribute_serializer'
|
|
3
3
|
require 'patches/active_record/query_method'
|
4
4
|
require 'patches/active_record/uniqueness_validator'
|
5
5
|
|
6
|
+
# until https://github.com/svenfuchs/i18n/issues/232 is resolved
|
7
|
+
unless I18n.respond_to?(:interpolate)
|
8
|
+
require 'patches/i18n/interpolate'
|
9
|
+
end
|
10
|
+
|
6
11
|
module Globalize
|
7
12
|
autoload :ActiveRecord, 'globalize/active_record'
|
8
13
|
autoload :Versioning, 'globalize/versioning'
|
@@ -46,14 +46,12 @@ module Globalize
|
|
46
46
|
existing_translations_by_locale[t.locale.to_s] = t
|
47
47
|
end
|
48
48
|
|
49
|
-
stash.each do |locale, attrs|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
translation.save!
|
56
|
-
end
|
49
|
+
stash.reject {|locale, attrs| attrs.empty?}.each do |locale, attrs|
|
50
|
+
translation = existing_translations_by_locale[locale.to_s] ||
|
51
|
+
record.translations.build(:locale => locale.to_s)
|
52
|
+
attrs.each { |name, value| translation[name] = value }
|
53
|
+
ensure_foreign_key_for(translation)
|
54
|
+
translation.save!
|
57
55
|
end
|
58
56
|
|
59
57
|
reset
|
@@ -63,7 +61,12 @@ module Globalize
|
|
63
61
|
stash.clear
|
64
62
|
end
|
65
63
|
|
66
|
-
|
64
|
+
protected
|
65
|
+
|
66
|
+
def ensure_foreign_key_for(translation)
|
67
|
+
# Sometimes the translation is initialised before a foreign key can be set.
|
68
|
+
translation[record.class.translation_options[:foreign_key]] = record.id
|
69
|
+
end
|
67
70
|
|
68
71
|
def type_cast(name, value)
|
69
72
|
if value.nil?
|
@@ -141,24 +141,26 @@ module Globalize
|
|
141
141
|
private
|
142
142
|
|
143
143
|
# Override the default relation method in order to return a subclass
|
144
|
-
# of ActiveRecord::Relation with custom
|
145
|
-
#
|
146
|
-
|
147
|
-
relation
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
144
|
+
# of ActiveRecord::Relation with custom where_values_hash method,
|
145
|
+
# for use in find_or_create_by_instantiator (Rails version >= 3.2.1)
|
146
|
+
if ::ActiveRecord::VERSION::STRING >= "3.2.1"
|
147
|
+
def relation
|
148
|
+
relation = globalize_relation_class.new(self, arel_table)
|
149
|
+
|
150
|
+
if finder_needs_type_condition?
|
151
|
+
relation.where(type_condition).create_with(inheritance_column.to_sym => sti_name)
|
152
|
+
else
|
153
|
+
relation
|
154
|
+
end
|
153
155
|
end
|
154
|
-
end
|
155
156
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
157
|
+
# Use pattern defined in FriendlyId 4.x to avoid conflict with any other
|
158
|
+
# gems (such as FriendlyId) which override relation method.
|
159
|
+
def globalize_relation_class
|
160
|
+
@globalize_relation_class ||= Class.new(relation_without_globalize.class).tap do |klass|
|
161
|
+
klass.send :include, QueryMethods
|
162
|
+
const_set('GlobalizeActiveRecordRelation', klass)
|
163
|
+
end
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
@@ -1,15 +1,12 @@
|
|
1
1
|
module Globalize
|
2
2
|
module ActiveRecord
|
3
3
|
module QueryMethods
|
4
|
+
def where_values_hash
|
5
|
+
equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
|
6
|
+
node.left.relation.name == translations_table_name
|
7
|
+
}
|
4
8
|
|
5
|
-
|
6
|
-
def where_values_hash
|
7
|
-
equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
|
8
|
-
node.left.relation.name == translations_table_name
|
9
|
-
}
|
10
|
-
|
11
|
-
super.merge(Hash[equalities.map { |where| [where.left.name, where.right] }]).with_indifferent_access
|
12
|
-
end
|
9
|
+
super.merge(Hash[equalities.map { |where| [where.left.name, where.right] }]).with_indifferent_access
|
13
10
|
end
|
14
11
|
end
|
15
12
|
end
|
data/lib/globalize/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# heavily based on Masao Mutoh's gettext String interpolation extension
|
2
|
+
# http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb
|
3
|
+
|
4
|
+
module I18n
|
5
|
+
INTERPOLATION_PATTERN = Regexp.union(
|
6
|
+
/%%/,
|
7
|
+
/%\{(\w+)\}/, # matches placeholders like "%{foo}"
|
8
|
+
/%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d"
|
9
|
+
)
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Return String or raises MissingInterpolationArgument exception.
|
13
|
+
# Missing argument's logic is handled by I18n.config.missing_interpolation_argument_handler.
|
14
|
+
def interpolate(string, values)
|
15
|
+
raise ReservedInterpolationKey.new($1.to_sym, string) if string =~ Backend::Base::RESERVED_KEYS_PATTERN
|
16
|
+
raise ArgumentError.new('Interpolation values must be a Hash.') unless values.kind_of?(Hash)
|
17
|
+
interpolate_hash(string, values)
|
18
|
+
end
|
19
|
+
|
20
|
+
def interpolate_hash(string, values)
|
21
|
+
string.gsub(INTERPOLATION_PATTERN) do |match|
|
22
|
+
if match == '%%'
|
23
|
+
'%'
|
24
|
+
else
|
25
|
+
key = ($1 || $2).to_sym
|
26
|
+
value = if values.key?(key)
|
27
|
+
values[key]
|
28
|
+
else
|
29
|
+
raise(MissingInterpolationArgument.new(values, string))
|
30
|
+
end
|
31
|
+
value = value.call(values) if value.respond_to?(:call)
|
32
|
+
$3 ? sprintf("%#{$3}", value) : value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2013-12-
|
17
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|
@@ -114,6 +114,20 @@ dependencies:
|
|
114
114
|
- - '>='
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: friendly_id
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
132
|
name: sqlite3
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,6 +152,7 @@ files:
|
|
138
152
|
- lib/patches/active_record/xml_attribute_serializer.rb
|
139
153
|
- lib/patches/active_record/uniqueness_validator.rb
|
140
154
|
- lib/patches/active_record/query_method.rb
|
155
|
+
- lib/patches/i18n/interpolate.rb
|
141
156
|
- lib/globalize/active_record.rb
|
142
157
|
- lib/globalize/versioning/paper_trail.rb
|
143
158
|
- lib/globalize/active_record/adapter.rb
|