model_formatting 0.2.3.10 → 0.2.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +4 -4
- data/Gemfile.lock +10 -10
- data/Rakefile +8 -8
- data/lib/model_formatting.rb +10 -3
- data/test/formatting_test.rb +7 -7
- data/test/model_formatting_test.rb +3 -3
- metadata +42 -43
data/Gemfile
CHANGED
@@ -2,10 +2,10 @@ source :gemcutter
|
|
2
2
|
source "http://gem.entp.com"
|
3
3
|
|
4
4
|
gem 'rake'
|
5
|
-
gem '
|
6
|
-
gem '
|
7
|
-
gem '
|
8
|
-
gem '
|
5
|
+
gem 'actionpack', '~> 2.3.15'
|
6
|
+
gem 'activerecord', '~> 2.3.15'
|
7
|
+
gem 'activesupport', '~> 2.3.15'
|
8
|
+
gem 'redcarpet', '~> 2.2'
|
9
9
|
gem 'tidy_ffi', '~> 0.1.2'
|
10
10
|
|
11
11
|
group :development, :test do
|
data/Gemfile.lock
CHANGED
@@ -2,18 +2,18 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
remote: http://gem.entp.com/
|
4
4
|
specs:
|
5
|
-
actionpack (2.3.
|
6
|
-
activesupport (= 2.3.
|
5
|
+
actionpack (2.3.15)
|
6
|
+
activesupport (= 2.3.15)
|
7
7
|
rack (~> 1.1.0)
|
8
|
-
activerecord (2.3.
|
9
|
-
activesupport (= 2.3.
|
10
|
-
activesupport (2.3.
|
8
|
+
activerecord (2.3.15)
|
9
|
+
activesupport (= 2.3.15)
|
10
|
+
activesupport (2.3.15)
|
11
11
|
context (0.5.5)
|
12
12
|
ffi (1.0.10)
|
13
13
|
matchy (0.4.0)
|
14
14
|
rack (1.1.2)
|
15
15
|
rake (0.9.2)
|
16
|
-
|
16
|
+
redcarpet (2.2.2)
|
17
17
|
tidy_ffi (0.1.3)
|
18
18
|
ffi (>= 0.3.5)
|
19
19
|
|
@@ -21,11 +21,11 @@ PLATFORMS
|
|
21
21
|
ruby
|
22
22
|
|
23
23
|
DEPENDENCIES
|
24
|
-
actionpack (~> 2.3.
|
25
|
-
activerecord (~> 2.3.
|
26
|
-
activesupport (~> 2.3.
|
24
|
+
actionpack (~> 2.3.15)
|
25
|
+
activerecord (~> 2.3.15)
|
26
|
+
activesupport (~> 2.3.15)
|
27
27
|
context (= 0.5.5)
|
28
28
|
matchy (~> 0.4.0)
|
29
29
|
rake
|
30
|
-
|
30
|
+
redcarpet (~> 2.2)
|
31
31
|
tidy_ffi (~> 0.1.2)
|
data/Rakefile
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems/package_task'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
4
|
spec = Gem::Specification.new do |s|
|
5
5
|
s.name = "model_formatting"
|
6
|
-
s.version = "0.2.3.
|
6
|
+
s.version = "0.2.3.11"
|
7
7
|
s.author = "ENTP"
|
8
8
|
s.email = "company@entp.com"
|
9
9
|
s.homepage = "http://github.com/entp"
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
|
-
s.summary = "Automatically format model attributes using
|
11
|
+
s.summary = "Automatically format model attributes using redcarpet (markdown) and Tender/Lighthouse extensions."
|
12
12
|
s.files = FileList['[a-zA-Z]*', 'bin/*', 'lib/**/*', 'rails/**/*', 'test/**/*']
|
13
13
|
s.has_rdoc = false
|
14
14
|
s.extra_rdoc_files = ["README"]
|
15
|
-
s.add_dependency("
|
16
|
-
s.add_dependency("actionpack", "~>2.3.
|
17
|
-
s.add_dependency("activerecord", "~>2.3.
|
18
|
-
s.add_dependency("activesupport", "~>2.3.
|
15
|
+
s.add_dependency("redcarpet", "~>2.2")
|
16
|
+
s.add_dependency("actionpack", "~>2.3.15")
|
17
|
+
s.add_dependency("activerecord", "~>2.3.15")
|
18
|
+
s.add_dependency("activesupport", "~>2.3.15")
|
19
19
|
s.add_dependency("tidy_ffi", "~>0.1.2")
|
20
20
|
s.add_development_dependency("jeremymcanally-context", "~>0.5.5")
|
21
21
|
s.add_development_dependency("jeremymcanally-matchy", "~>0.1.0")
|
@@ -23,7 +23,7 @@ end
|
|
23
23
|
|
24
24
|
|
25
25
|
desc 'Build the gem.'
|
26
|
-
|
26
|
+
Gem::PackageTask.new(spec) do |pkg|
|
27
27
|
pkg.gem_spec = spec
|
28
28
|
end
|
29
29
|
|
data/lib/model_formatting.rb
CHANGED
@@ -193,12 +193,19 @@ module ModelFormatting
|
|
193
193
|
end
|
194
194
|
|
195
195
|
begin
|
196
|
-
require '
|
196
|
+
require 'redcarpet'
|
197
197
|
def self.process_markdown(text)
|
198
|
-
|
198
|
+
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
|
199
|
+
:no_intra_emphasis => true,
|
200
|
+
:tables => true,
|
201
|
+
:fenced_code_blocks => true,
|
202
|
+
:space_after_headers => true,
|
203
|
+
# :hard_wrap => true,
|
204
|
+
# :with_toc_data => true,
|
205
|
+
:autolink => true).render(text)
|
199
206
|
end
|
200
207
|
rescue LoadError
|
201
|
-
puts "No
|
208
|
+
puts "No Redcarpet gem found. `gem install redcarpet`."
|
202
209
|
def self.process_markdown(text)
|
203
210
|
text
|
204
211
|
end
|
data/test/formatting_test.rb
CHANGED
@@ -24,7 +24,7 @@ module ModelFormatting
|
|
24
24
|
formats :body
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
context "Simple with formatting" do
|
28
28
|
it "has attribute from #formats arguments" do
|
29
29
|
Simple.model_formatting_attributes[:body].should == "formatted_body"
|
30
30
|
end
|
@@ -39,7 +39,7 @@ module ModelFormatting
|
|
39
39
|
record.save
|
40
40
|
record.formatted_body.should == %(<div><p>booya</p></div>)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
it "bolds the string 'Name'" do
|
44
44
|
record = Simple.new
|
45
45
|
record.body = "My name is __Name__"
|
@@ -68,7 +68,7 @@ module ModelFormatting
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
context "base with after callback" do
|
72
72
|
it "does not leave mkd-extraction artifacts" do
|
73
73
|
record = BaseWithAfter.new
|
74
74
|
record.body = File.read(File.dirname(__FILE__) + '/fixtures/mkd-extraction.txt')
|
@@ -94,7 +94,7 @@ module ModelFormatting
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
|
97
|
+
context "Post with formatting" do
|
98
98
|
it "has attribute from #formats arguments" do
|
99
99
|
Post.model_formatting_attributes[:body].should == "formatted_body"
|
100
100
|
end
|
@@ -115,7 +115,7 @@ module ModelFormatting
|
|
115
115
|
Post.before_save.should == :format_content_with_model_formatting
|
116
116
|
end
|
117
117
|
|
118
|
-
|
118
|
+
context "being saved" do
|
119
119
|
before do
|
120
120
|
@record = Post.new
|
121
121
|
@record.body = 'booya'
|
@@ -152,7 +152,7 @@ module ModelFormatting
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
|
155
|
+
context "ChildPost with formatting" do
|
156
156
|
it "has attribute from #formats arguments" do
|
157
157
|
ChildPost.model_formatting_attributes[:body].should == "formatted_body"
|
158
158
|
end
|
@@ -169,7 +169,7 @@ module ModelFormatting
|
|
169
169
|
ChildPost.before_save.should == :format_content_with_model_formatting
|
170
170
|
end
|
171
171
|
|
172
|
-
|
172
|
+
context "being saved" do
|
173
173
|
before do
|
174
174
|
@record = ChildPost.new
|
175
175
|
@record.body = 'booya'
|
@@ -71,11 +71,11 @@ class ModelFormattingTest < Test::Unit::TestCase
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it "converts @@@ with params to code blocks" do
|
74
|
-
ModelFormatting.process(:html, "foo\n@@@ ninja\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n").should == "<div><p>foo
|
74
|
+
ModelFormatting.process(:html, "foo\n@@@ ninja\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n").should == "<div><p>foo<br></p>\n<pre>\n<code class=\"ninja\">bar</code>\n</pre>\n<pre>\n<code>baz</code>\n</pre>\n@@@ wah wah</div>"
|
75
75
|
end
|
76
76
|
|
77
77
|
it "fixes irregular number of @@@'s" do
|
78
|
-
ModelFormatting.process(:html, "foo\n@@@\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n@@@").should == "<div><p>foo
|
78
|
+
ModelFormatting.process(:html, "foo\n@@@\nbar\n@@@\n@@@\nbaz\n@@@\n@@@ wah wah \n \n@@@").should == "<div><p>foo<br></p>\n<pre>\n<code>bar</code>\n</pre>\n<pre>\n<code>baz</code>\n</pre>\n@@@ wah wah\n<pre>\n\n</pre></div>"
|
79
79
|
end
|
80
80
|
|
81
81
|
it "converts @@@ with params to code blocks with text format" do
|
@@ -92,7 +92,7 @@ class ModelFormattingTest < Test::Unit::TestCase
|
|
92
92
|
|
93
93
|
end
|
94
94
|
|
95
|
-
|
95
|
+
context "GFM" do
|
96
96
|
it "does not touch single underscores inside words" do
|
97
97
|
assert_equal "foo_bar", ModelFormatting.gfm("foo_bar")
|
98
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_formatting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 69
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 3
|
10
|
-
-
|
11
|
-
version: 0.2.3.
|
10
|
+
- 11
|
11
|
+
version: 0.2.3.11
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- ENTP
|
@@ -16,73 +16,74 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2013-01-19 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
name: redcarpet
|
23
|
+
prerelease: false
|
22
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
25
|
none: false
|
24
26
|
requirements:
|
25
27
|
- - ~>
|
26
28
|
- !ruby/object:Gem::Version
|
27
|
-
hash:
|
29
|
+
hash: 7
|
28
30
|
segments:
|
29
|
-
-
|
30
|
-
-
|
31
|
-
|
32
|
-
version: 1.6.5
|
33
|
-
version_requirements: *id001
|
31
|
+
- 2
|
32
|
+
- 2
|
33
|
+
version: "2.2"
|
34
34
|
type: :runtime
|
35
|
-
|
36
|
-
prerelease: false
|
35
|
+
version_requirements: *id001
|
37
36
|
- !ruby/object:Gem::Dependency
|
37
|
+
name: actionpack
|
38
|
+
prerelease: false
|
38
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
42
|
- - ~>
|
42
43
|
- !ruby/object:Gem::Version
|
43
|
-
hash:
|
44
|
+
hash: 29
|
44
45
|
segments:
|
45
46
|
- 2
|
46
47
|
- 3
|
47
|
-
-
|
48
|
-
version: 2.3.
|
49
|
-
version_requirements: *id002
|
48
|
+
- 15
|
49
|
+
version: 2.3.15
|
50
50
|
type: :runtime
|
51
|
-
|
52
|
-
prerelease: false
|
51
|
+
version_requirements: *id002
|
53
52
|
- !ruby/object:Gem::Dependency
|
53
|
+
name: activerecord
|
54
|
+
prerelease: false
|
54
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
56
|
none: false
|
56
57
|
requirements:
|
57
58
|
- - ~>
|
58
59
|
- !ruby/object:Gem::Version
|
59
|
-
hash:
|
60
|
+
hash: 29
|
60
61
|
segments:
|
61
62
|
- 2
|
62
63
|
- 3
|
63
|
-
-
|
64
|
-
version: 2.3.
|
65
|
-
version_requirements: *id003
|
64
|
+
- 15
|
65
|
+
version: 2.3.15
|
66
66
|
type: :runtime
|
67
|
-
|
68
|
-
prerelease: false
|
67
|
+
version_requirements: *id003
|
69
68
|
- !ruby/object:Gem::Dependency
|
69
|
+
name: activesupport
|
70
|
+
prerelease: false
|
70
71
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
72
|
none: false
|
72
73
|
requirements:
|
73
74
|
- - ~>
|
74
75
|
- !ruby/object:Gem::Version
|
75
|
-
hash:
|
76
|
+
hash: 29
|
76
77
|
segments:
|
77
78
|
- 2
|
78
79
|
- 3
|
79
|
-
-
|
80
|
-
version: 2.3.
|
81
|
-
version_requirements: *id004
|
80
|
+
- 15
|
81
|
+
version: 2.3.15
|
82
82
|
type: :runtime
|
83
|
-
|
84
|
-
prerelease: false
|
83
|
+
version_requirements: *id004
|
85
84
|
- !ruby/object:Gem::Dependency
|
85
|
+
name: tidy_ffi
|
86
|
+
prerelease: false
|
86
87
|
requirement: &id005 !ruby/object:Gem::Requirement
|
87
88
|
none: false
|
88
89
|
requirements:
|
@@ -94,11 +95,11 @@ dependencies:
|
|
94
95
|
- 1
|
95
96
|
- 2
|
96
97
|
version: 0.1.2
|
97
|
-
version_requirements: *id005
|
98
98
|
type: :runtime
|
99
|
-
|
100
|
-
prerelease: false
|
99
|
+
version_requirements: *id005
|
101
100
|
- !ruby/object:Gem::Dependency
|
101
|
+
name: jeremymcanally-context
|
102
|
+
prerelease: false
|
102
103
|
requirement: &id006 !ruby/object:Gem::Requirement
|
103
104
|
none: false
|
104
105
|
requirements:
|
@@ -110,11 +111,11 @@ dependencies:
|
|
110
111
|
- 5
|
111
112
|
- 5
|
112
113
|
version: 0.5.5
|
113
|
-
version_requirements: *id006
|
114
114
|
type: :development
|
115
|
-
|
116
|
-
prerelease: false
|
115
|
+
version_requirements: *id006
|
117
116
|
- !ruby/object:Gem::Dependency
|
117
|
+
name: jeremymcanally-matchy
|
118
|
+
prerelease: false
|
118
119
|
requirement: &id007 !ruby/object:Gem::Requirement
|
119
120
|
none: false
|
120
121
|
requirements:
|
@@ -126,10 +127,8 @@ dependencies:
|
|
126
127
|
- 1
|
127
128
|
- 0
|
128
129
|
version: 0.1.0
|
129
|
-
version_requirements: *id007
|
130
130
|
type: :development
|
131
|
-
|
132
|
-
prerelease: false
|
131
|
+
version_requirements: *id007
|
133
132
|
description:
|
134
133
|
email: company@entp.com
|
135
134
|
executables: []
|
@@ -141,13 +140,13 @@ extra_rdoc_files:
|
|
141
140
|
files:
|
142
141
|
- Gemfile
|
143
142
|
- Gemfile.lock
|
144
|
-
- Rakefile
|
145
143
|
- README
|
144
|
+
- Rakefile
|
146
145
|
- bin/model_formatting
|
146
|
+
- lib/model_formatting.rb
|
147
147
|
- lib/model_formatting/config.rb
|
148
148
|
- lib/model_formatting/init.rb
|
149
149
|
- lib/model_formatting/instance_methods.rb
|
150
|
-
- lib/model_formatting.rb
|
151
150
|
- rails/init.rb
|
152
151
|
- test/fixtures/mkd-extraction.txt
|
153
152
|
- test/formatting_test.rb
|
@@ -182,9 +181,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
181
|
requirements: []
|
183
182
|
|
184
183
|
rubyforge_project:
|
185
|
-
rubygems_version: 1.8.
|
184
|
+
rubygems_version: 1.8.24
|
186
185
|
signing_key:
|
187
186
|
specification_version: 3
|
188
|
-
summary: Automatically format model attributes using
|
187
|
+
summary: Automatically format model attributes using redcarpet (markdown) and Tender/Lighthouse extensions.
|
189
188
|
test_files: []
|
190
189
|
|