localized_fields 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +4 -3
- data/CHANGELOG.md +13 -3
- data/Gemfile +2 -2
- data/README.md +1 -1
- data/gemfiles/mongoid-2.4.gemfile +10 -0
- data/gemfiles/mongoid-3.0.gemfile +9 -0
- data/lib/localized_fields/helpers/form_helper.rb +1 -1
- data/lib/localized_fields/version.rb +1 -1
- data/localized_fields.gemspec +3 -3
- data/spec/localized_fields_spec.rb +20 -12
- metadata +36 -14
- data/Gemfile.lock +0 -73
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,25 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.2.0 - June 15, 2012
|
2
|
+
|
3
|
+
### Improvements
|
4
|
+
|
5
|
+
* Adding support to Mongoid 3.
|
6
|
+
|
7
|
+
### Major Changes (Backwards Incompatible)
|
8
|
+
|
9
|
+
* LocalizedFields no longer supports Ruby 1.8.7.
|
10
|
+
|
11
|
+
## 0.1.0 - January 15, 2012
|
2
12
|
|
3
13
|
### Improvements
|
4
14
|
|
5
15
|
* Adding support to options on helpers.
|
6
16
|
|
7
|
-
## 0.0.2
|
17
|
+
## 0.0.2 - January 06, 2012
|
8
18
|
|
9
19
|
### Bug fixes
|
10
20
|
|
11
21
|
* The value of the textarea fields were not displayed.
|
12
22
|
|
13
|
-
## 0.0.1
|
23
|
+
## 0.0.1 - January 05, 2012
|
14
24
|
|
15
25
|
Initial release.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ module LocalizedFields
|
|
4
4
|
def localized_fields(field = nil, options = {}, &block)
|
5
5
|
if field
|
6
6
|
field_name = "#{field}_translations"
|
7
|
-
object = @object.send(field_name)
|
7
|
+
object = @object.send(field_name).try(:empty?) ? nil : @object.send(field_name)
|
8
8
|
name = "#{object_name}[#{field_name}]"
|
9
9
|
|
10
10
|
@template.fields_for(name, object, options.merge(:builder => LocalizedFields::FormBuilder), &block).html_safe
|
data/localized_fields.gemspec
CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.summary = %q{Localized Fields provides form helpers to create forms with localized fields using Mongoid.}
|
9
9
|
gem.homepage = ""
|
10
10
|
|
11
|
-
gem.add_dependency 'mongoid',
|
12
|
-
gem.add_dependency 'actionpack', '
|
11
|
+
gem.add_dependency 'mongoid', '>= 2.4'
|
12
|
+
gem.add_dependency 'actionpack', '~> 3.1'
|
13
13
|
|
14
|
-
gem.add_development_dependency 'rspec', '~> 2.8
|
14
|
+
gem.add_development_dependency 'rspec', '~> 2.8'
|
15
15
|
|
16
16
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
gem.files = `git ls-files`.split("\n")
|
@@ -136,10 +136,11 @@ describe 'LocalizedFields' do
|
|
136
136
|
describe 'text_area' do
|
137
137
|
it 'should return a text_area tag for en' do
|
138
138
|
output = @builder.localized_fields(:title) do |localized_field|
|
139
|
-
localized_field.text_area :en
|
139
|
+
localized_field.text_area :en, :value => "text"
|
140
140
|
end
|
141
141
|
|
142
|
-
expected =
|
142
|
+
expected = %{<textarea cols="40" id="post_title_translations_en" name="post[title_translations][en]" rows="20">\n}
|
143
|
+
expected << %{</textarea>}
|
143
144
|
|
144
145
|
output.should eq(expected)
|
145
146
|
end
|
@@ -149,8 +150,10 @@ describe 'LocalizedFields' do
|
|
149
150
|
localized_field.text_area :title
|
150
151
|
end
|
151
152
|
|
152
|
-
expected =
|
153
|
-
|
153
|
+
expected = %{<textarea cols="40" id="post_title_translations_en" name="post[title_translations][en]" rows="20">\n}
|
154
|
+
expected << %{</textarea>}
|
155
|
+
expected << %{<textarea cols="40" id="post_title_translations_pt" name="post[title_translations][pt]" rows="20">\n}
|
156
|
+
expected << %{</textarea>}
|
154
157
|
|
155
158
|
output.should eq(expected)
|
156
159
|
end
|
@@ -159,10 +162,12 @@ describe 'LocalizedFields' do
|
|
159
162
|
output = @builder.localized_fields do |localized_field|
|
160
163
|
localized_field.text_area :title, :class => 'field'
|
161
164
|
end
|
162
|
-
|
163
|
-
expected =
|
164
|
-
|
165
|
-
|
165
|
+
|
166
|
+
expected = %{<textarea class="field" cols="40" id="post_title_translations_en" name="post[title_translations][en]" rows="20">\n}
|
167
|
+
expected << %{</textarea>}
|
168
|
+
expected << %{<textarea class="field" cols="40" id="post_title_translations_pt" name="post[title_translations][pt]" rows="20">\n}
|
169
|
+
expected << %{</textarea>}
|
170
|
+
|
166
171
|
output.should eq(expected)
|
167
172
|
end
|
168
173
|
|
@@ -180,7 +185,8 @@ describe 'LocalizedFields' do
|
|
180
185
|
localized_field.text_area :en
|
181
186
|
end
|
182
187
|
|
183
|
-
expected =
|
188
|
+
expected = %{<textarea cols="40" id="post_title_translations_en" name="post[title_translations][en]" rows="20">\ntitle en}
|
189
|
+
expected << %{</textarea>}
|
184
190
|
|
185
191
|
output.should eq(expected)
|
186
192
|
end
|
@@ -189,9 +195,11 @@ describe 'LocalizedFields' do
|
|
189
195
|
output = @builder.localized_fields do |localized_field|
|
190
196
|
localized_field.text_area :title
|
191
197
|
end
|
192
|
-
|
193
|
-
expected =
|
194
|
-
|
198
|
+
|
199
|
+
expected = %{<textarea cols="40" id="post_title_translations_en" name="post[title_translations][en]" rows="20">\ntitle en}
|
200
|
+
expected << %{</textarea>}
|
201
|
+
expected << %{<textarea cols="40" id="post_title_translations_pt" name="post[title_translations][pt]" rows="20">\ntitle pt}
|
202
|
+
expected << %{</textarea>}
|
195
203
|
|
196
204
|
output.should eq(expected)
|
197
205
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localized_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,41 +9,56 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.4
|
21
|
+
version: '2.4'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.4'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: actionpack
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
|
-
- -
|
35
|
+
- - ~>
|
31
36
|
- !ruby/object:Gem::Version
|
32
|
-
version: 3.1
|
37
|
+
version: '3.1'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.1'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.8
|
53
|
+
version: '2.8'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.8'
|
47
62
|
description: Helps you to create forms with localized fields using Mongoid.
|
48
63
|
email:
|
49
64
|
- tiagogodinho3@gmail.com
|
@@ -56,10 +71,11 @@ files:
|
|
56
71
|
- .travis.yml
|
57
72
|
- CHANGELOG.md
|
58
73
|
- Gemfile
|
59
|
-
- Gemfile.lock
|
60
74
|
- LICENSE
|
61
75
|
- README.md
|
62
76
|
- Rakefile
|
77
|
+
- gemfiles/mongoid-2.4.gemfile
|
78
|
+
- gemfiles/mongoid-3.0.gemfile
|
63
79
|
- lib/localized_fields.rb
|
64
80
|
- lib/localized_fields/form_builder.rb
|
65
81
|
- lib/localized_fields/helpers.rb
|
@@ -81,15 +97,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
97
|
- - ! '>='
|
82
98
|
- !ruby/object:Gem::Version
|
83
99
|
version: '0'
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
hash: 4016080345825084054
|
84
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
104
|
none: false
|
86
105
|
requirements:
|
87
106
|
- - ! '>='
|
88
107
|
- !ruby/object:Gem::Version
|
89
108
|
version: '0'
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
hash: 4016080345825084054
|
90
112
|
requirements: []
|
91
113
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.8.
|
114
|
+
rubygems_version: 1.8.24
|
93
115
|
signing_key:
|
94
116
|
specification_version: 3
|
95
117
|
summary: Localized Fields provides form helpers to create forms with localized fields
|
data/Gemfile.lock
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
localized_fields (0.1.0)
|
5
|
-
actionpack (>= 3.1.0)
|
6
|
-
mongoid (>= 2.4.0)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
actionpack (3.1.3)
|
12
|
-
activemodel (= 3.1.3)
|
13
|
-
activesupport (= 3.1.3)
|
14
|
-
builder (~> 3.0.0)
|
15
|
-
erubis (~> 2.7.0)
|
16
|
-
i18n (~> 0.6)
|
17
|
-
rack (~> 1.3.5)
|
18
|
-
rack-cache (~> 1.1)
|
19
|
-
rack-mount (~> 0.8.2)
|
20
|
-
rack-test (~> 0.6.1)
|
21
|
-
sprockets (~> 2.0.3)
|
22
|
-
activemodel (3.1.3)
|
23
|
-
activesupport (= 3.1.3)
|
24
|
-
builder (~> 3.0.0)
|
25
|
-
i18n (~> 0.6)
|
26
|
-
activesupport (3.1.3)
|
27
|
-
multi_json (~> 1.0)
|
28
|
-
bson (1.5.2)
|
29
|
-
bson_ext (1.5.2)
|
30
|
-
bson (= 1.5.2)
|
31
|
-
builder (3.0.0)
|
32
|
-
diff-lcs (1.1.3)
|
33
|
-
erubis (2.7.0)
|
34
|
-
hike (1.2.1)
|
35
|
-
i18n (0.6.0)
|
36
|
-
mongo (1.5.2)
|
37
|
-
bson (= 1.5.2)
|
38
|
-
mongoid (2.4.1)
|
39
|
-
activemodel (~> 3.1)
|
40
|
-
mongo (~> 1.3)
|
41
|
-
tzinfo (~> 0.3.22)
|
42
|
-
multi_json (1.0.4)
|
43
|
-
rack (1.3.6)
|
44
|
-
rack-cache (1.1)
|
45
|
-
rack (>= 0.4)
|
46
|
-
rack-mount (0.8.3)
|
47
|
-
rack (>= 1.0.0)
|
48
|
-
rack-test (0.6.1)
|
49
|
-
rack (>= 1.0)
|
50
|
-
rake (0.9.2.2)
|
51
|
-
rspec (2.8.0)
|
52
|
-
rspec-core (~> 2.8.0)
|
53
|
-
rspec-expectations (~> 2.8.0)
|
54
|
-
rspec-mocks (~> 2.8.0)
|
55
|
-
rspec-core (2.8.0)
|
56
|
-
rspec-expectations (2.8.0)
|
57
|
-
diff-lcs (~> 1.1.2)
|
58
|
-
rspec-mocks (2.8.0)
|
59
|
-
sprockets (2.0.3)
|
60
|
-
hike (~> 1.2)
|
61
|
-
rack (~> 1.0)
|
62
|
-
tilt (~> 1.1, != 1.3.0)
|
63
|
-
tilt (1.3.3)
|
64
|
-
tzinfo (0.3.31)
|
65
|
-
|
66
|
-
PLATFORMS
|
67
|
-
ruby
|
68
|
-
|
69
|
-
DEPENDENCIES
|
70
|
-
bson_ext
|
71
|
-
localized_fields!
|
72
|
-
rake
|
73
|
-
rspec (~> 2.8.0)
|