padrino-contrib 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of padrino-contrib might be problematic. Click here for more details.
data/lib/padrino-contrib.rb
CHANGED
@@ -14,9 +14,9 @@ module Padrino
|
|
14
14
|
end # Padrino
|
15
15
|
|
16
16
|
if defined?(ActiveRecord)
|
17
|
-
Dir[File.join(File.expand_path('../', __FILE__), '/padrino-contrib/orm/active_record/**/*.rb')].each { |d| require d }
|
17
|
+
Dir[File.join(File.expand_path('../', __FILE__), '/padrino-contrib/orm/active_record/**/*.rb')].sort.each { |d| require d }
|
18
18
|
end
|
19
19
|
|
20
20
|
if defined?(MongoMapper)
|
21
|
-
Dir[File.join(File.expand_path('../', __FILE__), '/padrino-contrib/orm/mongo_mapper/**/*.rb')].each { |d| require d }
|
21
|
+
Dir[File.join(File.expand_path('../', __FILE__), '/padrino-contrib/orm/mongo_mapper/**/*.rb')].sort.each { |d| require d }
|
22
22
|
end
|
@@ -20,12 +20,12 @@ module Padrino
|
|
20
20
|
@_i18n_permalink_field = field
|
21
21
|
@_i18n_permalink_langs = options.delete(:langs)
|
22
22
|
before_save :generate_i18n_permalinks
|
23
|
-
|
23
|
+
i18n_permalink_langs.each do |lang|
|
24
24
|
validates_uniqueness_of :"#{field}_#{lang}", options
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def i18n_permalink_for(name)
|
29
29
|
name = Iconv.iconv('ascii//translit//IGNORE', 'utf-8', name).to_s
|
30
30
|
name.gsub!(/\W+/, ' ') # non-words to space
|
31
31
|
name.strip!
|
@@ -34,11 +34,11 @@ module Padrino
|
|
34
34
|
name
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def i18n_permalink_field
|
38
38
|
@_i18n_permalink_field
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def i18n_permalink_langs
|
42
42
|
@_i18n_permalink_langs
|
43
43
|
end
|
44
44
|
end
|
@@ -50,8 +50,8 @@ module Padrino
|
|
50
50
|
|
51
51
|
protected
|
52
52
|
def generate_i18n_permalinks
|
53
|
-
self.class.
|
54
|
-
self.send(:"permalink_#{lang}=", self.class.
|
53
|
+
self.class.i18n_permalink_langs.each do |lang|
|
54
|
+
self.send(:"permalink_#{lang}=", self.class.i18n_permalink_for(read_attribute(:"#{self.class.i18n_permalink_field}_#{lang}")))
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end # InstanceMethods
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 12
|
10
|
+
version: 0.1.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Davide D'Agostino
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
20
|
+
date: 2011-11-04 00:00:00 +01:00
|
21
21
|
default_executable:
|
22
22
|
dependencies: []
|
23
23
|
|