mongoid-textile 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +8 -2
- data/Gemfile +2 -2
- data/Gemfile.lock +10 -10
- data/lib/mongoid-textile.rb +21 -4
- data/lib/mongoid-textile/version.rb +1 -1
- data/mongoid-textile.gemspec +3 -3
- data/spec/mongoid-textile_spec.rb +36 -0
- metadata +16 -16
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
-
## 0.0
|
1
|
+
## 0.1.0 - February 14, 2012
|
2
|
+
|
3
|
+
### Improvements
|
4
|
+
|
5
|
+
* Inclusion of support for localized fields.
|
6
|
+
|
7
|
+
## 0.0.2 - January 17, 2012
|
2
8
|
|
3
9
|
### Improvements
|
4
10
|
|
5
11
|
* Removing InstanceMethods module inside of ActiveSupport::Concern because it is deprecated on ActiveSupport 3.2.0.
|
6
12
|
|
7
|
-
## 0.0.1
|
13
|
+
## 0.0.1 - January 11, 2012
|
8
14
|
|
9
15
|
Initial release.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mongoid-textile (0.0
|
5
|
-
RedCloth (
|
6
|
-
mongoid (
|
4
|
+
mongoid-textile (0.1.0)
|
5
|
+
RedCloth (~> 4.2.0)
|
6
|
+
mongoid (~> 2.4.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
RedCloth (4.2.9)
|
12
|
-
activemodel (3.1
|
13
|
-
activesupport (= 3.1
|
12
|
+
activemodel (3.2.1)
|
13
|
+
activesupport (= 3.2.1)
|
14
14
|
builder (~> 3.0.0)
|
15
|
+
activesupport (3.2.1)
|
15
16
|
i18n (~> 0.6)
|
16
|
-
activesupport (3.1.3)
|
17
17
|
multi_json (~> 1.0)
|
18
18
|
bson (1.5.2)
|
19
19
|
bson_ext (1.5.2)
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
i18n (0.6.0)
|
24
24
|
mongo (1.5.2)
|
25
25
|
bson (= 1.5.2)
|
26
|
-
mongoid (2.4.
|
26
|
+
mongoid (2.4.4)
|
27
27
|
activemodel (~> 3.1)
|
28
28
|
mongo (~> 1.3)
|
29
29
|
tzinfo (~> 0.3.22)
|
@@ -43,7 +43,7 @@ PLATFORMS
|
|
43
43
|
ruby
|
44
44
|
|
45
45
|
DEPENDENCIES
|
46
|
-
bson_ext
|
46
|
+
bson_ext (~> 1.5.2)
|
47
47
|
mongoid-textile!
|
48
|
-
rake
|
49
|
-
rspec (
|
48
|
+
rake (~> 0.9.2.2)
|
49
|
+
rspec (~> 2.8.0)
|
data/lib/mongoid-textile.rb
CHANGED
@@ -14,9 +14,22 @@ module Mongoid
|
|
14
14
|
def textile_to_html
|
15
15
|
textile_fields.each do |textile_field_name|
|
16
16
|
field_name = textile_field_name.gsub(/_formatted/, '')
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
|
18
|
+
if self.fields[field_name.to_s].localized?
|
19
|
+
values = self.send("#{field_name}_translations")
|
20
|
+
|
21
|
+
formatted_text = {}
|
22
|
+
|
23
|
+
values.each do |key, value|
|
24
|
+
formatted_text[key.to_s] = RedCloth.new(value.to_s).to_html
|
25
|
+
end
|
26
|
+
|
27
|
+
self.send("#{textile_field_name}_translations=", formatted_text)
|
28
|
+
else
|
29
|
+
value = self.send(field_name)
|
30
|
+
formatted_text = RedCloth.new(value.to_s).to_html
|
31
|
+
self.send("#{textile_field_name}=", formatted_text)
|
32
|
+
end
|
20
33
|
end
|
21
34
|
end
|
22
35
|
|
@@ -29,7 +42,11 @@ module Mongoid
|
|
29
42
|
module ClassMethods
|
30
43
|
def textlize(*fields)
|
31
44
|
fields.each do |field_name|
|
32
|
-
|
45
|
+
if self.fields[field_name.to_s].localized?
|
46
|
+
field("#{field_name}_formatted", :localize => true)
|
47
|
+
else
|
48
|
+
field("#{field_name}_formatted")
|
49
|
+
end
|
33
50
|
end
|
34
51
|
end
|
35
52
|
end
|
data/mongoid-textile.gemspec
CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = Mongoid::Textile::VERSION
|
18
18
|
|
19
|
-
gem.add_dependency '
|
20
|
-
gem.add_dependency '
|
19
|
+
gem.add_dependency 'mongoid', '~> 2.4.0'
|
20
|
+
gem.add_dependency 'RedCloth', '~> 4.2.0'
|
21
21
|
|
22
|
-
gem.add_development_dependency 'rspec', '2.8.0'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 2.8.0'
|
23
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
class Article
|
@@ -9,6 +11,15 @@ class Article
|
|
9
11
|
textlize :text
|
10
12
|
end
|
11
13
|
|
14
|
+
class Post
|
15
|
+
include Mongoid::Document
|
16
|
+
include Mongoid::Textile
|
17
|
+
|
18
|
+
field :text, :localize => true
|
19
|
+
|
20
|
+
textlize :text
|
21
|
+
end
|
22
|
+
|
12
23
|
describe Mongoid::Textile do
|
13
24
|
let(:article) { Article.create(:text => "h1. proud to be a rails developer") }
|
14
25
|
|
@@ -42,4 +53,29 @@ describe Mongoid::Textile do
|
|
42
53
|
article.text_formatted.should eq("")
|
43
54
|
end
|
44
55
|
end
|
56
|
+
|
57
|
+
context 'multiple languages' do
|
58
|
+
let(:post) { Post.create(:text_translations => { 'en' => 'h1. ruby makes me happy', 'de' => 'h1. ruby macht mich glücklich' }) }
|
59
|
+
|
60
|
+
context 'in english' do
|
61
|
+
before :all do
|
62
|
+
I18n.locale = :en
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should set formatted field from textile to html' do
|
66
|
+
post.text_formatted.should eq('<h1>ruby makes me happy</h1>')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'in german' do
|
71
|
+
before :all do
|
72
|
+
I18n.locale = :de
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should set formatted field from textile to html' do
|
76
|
+
post.text_formatted.should eq('<h1>ruby macht mich glücklich</h1>')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
45
81
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-textile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,41 +10,41 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
-
requirement: &
|
16
|
+
name: mongoid
|
17
|
+
requirement: &2151854880 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
|
-
- -
|
20
|
+
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 4.
|
22
|
+
version: 2.4.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2151854880
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
28
|
-
requirement: &
|
27
|
+
name: RedCloth
|
28
|
+
requirement: &2151853160 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 4.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2151853160
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec
|
39
|
-
requirement: &
|
39
|
+
requirement: &2151851820 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: 2.8.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2151851820
|
48
48
|
description: Textile texts directly from MongoDB.
|
49
49
|
email:
|
50
50
|
- contato@lucasrenan.com
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.8.
|
90
|
+
rubygems_version: 1.8.10
|
91
91
|
signing_key:
|
92
92
|
specification_version: 3
|
93
93
|
summary: Mongoid Textile caches Textile texts on MongoDB to eliminate reprocessing.
|