vigetlabs-acts_as_markup 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -0
- data/acts_as_markup.gemspec +5 -5
- data/lib/acts/as_markup.rb +31 -28
- data/lib/acts_as_markup/exts/maruku.rb +11 -16
- data/lib/acts_as_markup.rb +1 -1
- data/tasks/test.rake +6 -11
- metadata +3 -3
data/Rakefile
CHANGED
@@ -19,6 +19,11 @@ PROJ.version = ActsAsMarkup::VERSION
|
|
19
19
|
PROJ.rdoc.include = %w(^lib/ LICENSE CHANGELOG README\.rdoc)
|
20
20
|
PROJ.rdoc.remote_dir = 'acts_as_markup'
|
21
21
|
PROJ.test.files = FileList['test/**/*_test.rb']
|
22
|
+
PROJ.rcov.opts = ['--no-html', '-T', '--sort coverage',
|
23
|
+
'-x "\/Library\/Ruby\/"',
|
24
|
+
'-x "\/opt\/local\/lib/ruby"',
|
25
|
+
'-x "\/System\/Library\/"']
|
26
|
+
PROJ.rcov.pattern = 'test/**/*_test.rb'
|
22
27
|
|
23
28
|
%W(activesupport activerecord rdiscount RedCloth wikitext).each do |gem|
|
24
29
|
depend_on gem
|
data/acts_as_markup.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{acts_as_markup}
|
3
|
-
s.version = "1.2.
|
3
|
+
s.version = "1.2.1"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Brian Landau"]
|
7
|
-
s.date = %q{2008-09-
|
7
|
+
s.date = %q{2008-09-30}
|
8
8
|
s.description = %q{Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML.}
|
9
9
|
s.email = %q{brian.landau@viget.com}
|
10
10
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc"]
|
@@ -27,19 +27,19 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency(%q<activerecord>, [">= 2.1.1"])
|
28
28
|
s.add_runtime_dependency(%q<rdiscount>, [">= 1.2.9"])
|
29
29
|
s.add_runtime_dependency(%q<RedCloth>, [">= 4.0.3"])
|
30
|
-
s.add_runtime_dependency(%q<wikitext>, [">= 1.2"])
|
30
|
+
s.add_runtime_dependency(%q<wikitext>, [">= 1.2.1"])
|
31
31
|
else
|
32
32
|
s.add_dependency(%q<activesupport>, [">= 2.1.1"])
|
33
33
|
s.add_dependency(%q<activerecord>, [">= 2.1.1"])
|
34
34
|
s.add_dependency(%q<rdiscount>, [">= 1.2.9"])
|
35
35
|
s.add_dependency(%q<RedCloth>, [">= 4.0.3"])
|
36
|
-
s.add_dependency(%q<wikitext>, [">= 1.2"])
|
36
|
+
s.add_dependency(%q<wikitext>, [">= 1.2.1"])
|
37
37
|
end
|
38
38
|
else
|
39
39
|
s.add_dependency(%q<activesupport>, [">= 2.1.1"])
|
40
40
|
s.add_dependency(%q<activerecord>, [">= 2.1.1"])
|
41
41
|
s.add_dependency(%q<rdiscount>, [">= 1.2.9"])
|
42
42
|
s.add_dependency(%q<RedCloth>, [">= 4.0.3"])
|
43
|
-
s.add_dependency(%q<wikitext>, [">= 1.2"])
|
43
|
+
s.add_dependency(%q<wikitext>, [">= 1.2.1"])
|
44
44
|
end
|
45
45
|
end
|
data/lib/acts/as_markup.rb
CHANGED
@@ -49,31 +49,13 @@ module ActiveRecord # :nodoc:
|
|
49
49
|
#
|
50
50
|
def acts_as_markup(options)
|
51
51
|
case options[:language].to_sym
|
52
|
-
when :markdown
|
53
|
-
klass =
|
54
|
-
when :textile
|
55
|
-
require 'redcloth'
|
56
|
-
klass = 'RedCloth'
|
57
|
-
when :wikitext
|
58
|
-
require 'wikitext'
|
59
|
-
require_extensions 'wikitext'
|
60
|
-
klass = 'WikitextString'
|
61
|
-
when :rdoc
|
62
|
-
require 'rdoc/markup/simple_markup'
|
63
|
-
require 'rdoc/markup/simple_markup/to_html'
|
64
|
-
require_extensions 'rdoc'
|
65
|
-
klass = 'RDocText'
|
52
|
+
when :markdown, :textile, :wikitext, :rdoc
|
53
|
+
klass = require_library_and_get_class(options[:language].to_sym)
|
66
54
|
when :variable
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
require 'rdoc/markup/simple_markup/to_html'
|
72
|
-
require_extensions 'wikitext'
|
73
|
-
require_extensions 'rdoc'
|
74
|
-
textile_klass = 'RedCloth'
|
75
|
-
wiki_klass = 'WikitextString'
|
76
|
-
rdoc_klass = 'RDocText'
|
55
|
+
markup_klasses = {}
|
56
|
+
[:textile, :wikitext, :rdoc, :markdown].each do |language|
|
57
|
+
markup_klasses[language] = require_library_and_get_class(language)
|
58
|
+
end
|
77
59
|
options[:language_column] ||= :markup_language
|
78
60
|
else
|
79
61
|
raise ActsAsMarkup::UnsupportedMarkupLanguage, "#{options[:langauge]} is not a currently supported markup language."
|
@@ -101,13 +83,13 @@ module ActiveRecord # :nodoc:
|
|
101
83
|
end
|
102
84
|
case self.#{options[:language_column].to_s}
|
103
85
|
when /markdown/i
|
104
|
-
@#{col.to_s} = #{
|
86
|
+
@#{col.to_s} = #{markup_klasses[:markdown]}.new(self['#{col.to_s}'].to_s)
|
105
87
|
when /textile/i
|
106
|
-
@#{col.to_s} = #{
|
88
|
+
@#{col.to_s} = #{markup_klasses[:textile]}.new(self['#{col.to_s}'].to_s)
|
107
89
|
when /wikitext/i
|
108
|
-
@#{col.to_s} = #{
|
90
|
+
@#{col.to_s} = #{markup_klasses[:wikitext]}.new(self['#{col.to_s}'].to_s)
|
109
91
|
when /rdoc/i
|
110
|
-
@#{col.to_s} = #{
|
92
|
+
@#{col.to_s} = #{markup_klasses[:rdoc]}.new(self['#{col.to_s}'].to_s)
|
111
93
|
else
|
112
94
|
@#{col.to_s} = self['#{col.to_s}']
|
113
95
|
end
|
@@ -163,6 +145,27 @@ module ActiveRecord # :nodoc:
|
|
163
145
|
require "acts_as_markup/exts/#{library.to_s}"
|
164
146
|
end
|
165
147
|
end
|
148
|
+
|
149
|
+
def require_library_and_get_class(language)
|
150
|
+
case language
|
151
|
+
when :markdown
|
152
|
+
return get_markdown_class
|
153
|
+
when :textile
|
154
|
+
require 'redcloth'
|
155
|
+
return 'RedCloth'
|
156
|
+
when :wikitext
|
157
|
+
require 'wikitext'
|
158
|
+
require_extensions 'wikitext'
|
159
|
+
return 'WikitextString'
|
160
|
+
when :rdoc
|
161
|
+
require 'rdoc/markup/simple_markup'
|
162
|
+
require 'rdoc/markup/simple_markup/to_html'
|
163
|
+
require_extensions 'rdoc'
|
164
|
+
return 'RDocText'
|
165
|
+
else
|
166
|
+
return 'String'
|
167
|
+
end
|
168
|
+
end
|
166
169
|
|
167
170
|
end
|
168
171
|
end
|
@@ -44,30 +44,25 @@ module MaRuKu # :nodoc:
|
|
44
44
|
# method because we need +to_html+ to return the original text on plain text fields of
|
45
45
|
# the variable language option on +acts_as_markup+
|
46
46
|
def array_to_html(array)
|
47
|
-
|
48
|
-
array.each do |
|
49
|
-
method =
|
50
|
-
|
51
|
-
|
52
|
-
if not c.respond_to?(method)
|
53
|
-
#raise "Object does not answer to #{method}: #{c.class} #{c.inspect}"
|
47
|
+
elements = []
|
48
|
+
array.each do |item|
|
49
|
+
method = item.kind_of?(MDElement) ? "to_html_#{item.node_type}" : "to_xml"
|
50
|
+
unless item.respond_to?(method)
|
54
51
|
next
|
55
52
|
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
raise "Nil html created by method #{method}:\n#{h.inspect}\n"+
|
61
|
-
" for object #{c.inspect[0,300]}"
|
54
|
+
html_text = item.send(method)
|
55
|
+
if html_text.nil?
|
56
|
+
raise "Nil html created by method #{method}:\n#{html_text.inspect}\n for object #{item.inspect[0,300]}"
|
62
57
|
end
|
63
58
|
|
64
|
-
if
|
65
|
-
|
59
|
+
if html_text.kind_of?Array
|
60
|
+
elements = elements + html_text
|
66
61
|
else
|
67
|
-
|
62
|
+
elements << html_text
|
68
63
|
end
|
69
64
|
end
|
70
|
-
|
65
|
+
elements
|
71
66
|
end
|
72
67
|
|
73
68
|
end
|
data/lib/acts_as_markup.rb
CHANGED
data/tasks/test.rake
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'rake/testtask'
|
2
|
+
if HAVE_RCOV
|
3
|
+
require 'rcov/rcovtask'
|
4
|
+
end
|
2
5
|
|
3
6
|
namespace :test do
|
4
7
|
|
@@ -12,17 +15,9 @@ namespace :test do
|
|
12
15
|
|
13
16
|
if HAVE_RCOV
|
14
17
|
desc 'Run rcov on the unit tests'
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
files = if test(?f, PROJ.test.file) then [PROJ.test.file]
|
19
|
-
else PROJ.test.files end
|
20
|
-
files = files.join(' ')
|
21
|
-
sh "#{RCOV} #{files} #{opts}"
|
22
|
-
end
|
23
|
-
|
24
|
-
task :clobber_rcov do
|
25
|
-
rm_r 'coverage' rescue nil
|
18
|
+
Rcov::RcovTask.new do |t|
|
19
|
+
t.pattern = PROJ.rcov.pattern
|
20
|
+
t.rcov_opts = PROJ.rcov.opts
|
26
21
|
end
|
27
22
|
end
|
28
23
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vigetlabs-acts_as_markup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Landau
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
58
|
+
version: 1.2.1
|
59
59
|
version:
|
60
60
|
description: Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML.
|
61
61
|
email: brian.landau@viget.com
|