vigetlabs-acts_as_markup 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == 1.3.0 / 2008-11-19
2
+ * Add ability to accept options that will be passed to supported markup parsers. (chewi[http://github.com/chewi/])
3
+
1
4
  == 1.2.0 / 2008-09-10
2
5
  * Allow all objects to have a to_html method that defaults as to_s instead just doing this for strings. (idea from crnixon[http://github.com/crnixon/])
3
6
  * Add string methods to all markup objects via the StringLike mixin. (crnixon[http://github.com/crnixon/])
data/README.rdoc CHANGED
@@ -27,6 +27,13 @@ a config value in your environment.rb file:
27
27
 
28
28
  By default RDiscount will be used.
29
29
 
30
+ You can specify additional options to pass to the markup library by using
31
+ <tt>:markdown_options</tt>, <tt>:textile_options</tt> or <tt>:wikitext_options</tt>.
32
+ RDoc does not support any useful options. The options should be given as an
33
+ array of arguments. You can specify options for multiple languages when
34
+ allowing more than one. See each library's documentation for more details on
35
+ what options are available.
36
+
30
37
  == EXAMPLES:
31
38
 
32
39
  ==== Using +acts_as_markdown+:
@@ -96,6 +103,21 @@ By default RDiscount will be used.
96
103
  @post.body.to_html # => "<h2> Markdown Headline</h2>"
97
104
 
98
105
 
106
+ ==== Using options
107
+
108
+ class Post < ActiveRecord
109
+ acts_as_markdown :body, :markdown_options => [ :filter_html ]
110
+ end
111
+
112
+ class Post < ActiveRecord
113
+ acts_as_textile :body, :textile_options => [ [ :filter_html ] ]
114
+ end
115
+
116
+ class Post < ActiveRecord
117
+ acts_as_wikitext :body, :wikitext_options => [ { :space_to_underscore => true } ]
118
+ end
119
+
120
+
99
121
  == REQUIREMENTS:
100
122
 
101
123
  You will need the RedCloth[http://whytheluckystiff.net/ruby/redcloth/] library
@@ -138,7 +160,7 @@ Make a fork on GitHub, make your changes and do a pull request. Good places to s
138
160
  3. Add the same lines you added to the previous "<tt>when</tt>" statement to the "<tt>:variable</tt>" "<tt>when</tt>" statement. But replace "<tt>klass</tt>" with "<tt>language_klass</tt>" (e.g. "<tt>markdown_klass</tt>").
139
161
  4. Add a relevant "<tt>when</tt>" statement to the <tt>class_eval</tt> block for the "<tt>:variable</tt>" language option. This should look something like:
140
162
  when /markdown/i
141
- @#{col.to_s} = #{markdown_klass}.new(self['#{col.to_s}'].to_s)
163
+ markup_klasses[:markdown].new self[col].to_s
142
164
  5. Add a convenience method (e.g. "<tt>acts_as_markdown</tt>")
143
165
  6. Add an extension file to the "lib/acts_as_markup/exts/" directory if you need to modify the object in anyway.
144
166
  7. Add appropriate tests (see current tests).
data/Rakefile CHANGED
@@ -18,7 +18,6 @@ PROJ.rubyforge.name = 'viget'
18
18
  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
- PROJ.test.files = FileList['test/**/*_test.rb']
22
21
  PROJ.rcov.opts = ['--no-html', '-T', '--sort coverage',
23
22
  '-x "\/Library\/Ruby\/"',
24
23
  '-x "\/opt\/local\/lib/ruby"',
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{acts_as_markup}
3
- s.version = "1.2.1"
3
+ s.version = "1.3.0"
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-30}
7
+ s.date = %q{2008-11-19}
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"]
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.rdoc_options = ["--main", "README.rdoc"]
15
15
  s.require_paths = ["lib"]
16
16
  s.rubyforge_project = %q{viget}
17
- s.rubygems_version = %q{1.2.0}
17
+ s.rubygems_version = %q{1.3.1}
18
18
  s.summary = %q{Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML}
19
19
  s.test_files = ["test/acts_as_markdown_test.rb", "test/acts_as_markup_test.rb", "test/acts_as_rdoc_test.rb", "test/acts_as_textile_test.rb", "test/acts_as_wikitext_test.rb"]
20
20
 
@@ -22,24 +22,24 @@ Gem::Specification.new do |s|
22
22
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
23
  s.specification_version = 2
24
24
 
25
- if current_version >= 3 then
26
- s.add_runtime_dependency(%q<activesupport>, [">= 2.1.1"])
27
- s.add_runtime_dependency(%q<activerecord>, [">= 2.1.1"])
28
- s.add_runtime_dependency(%q<rdiscount>, [">= 1.2.9"])
29
- s.add_runtime_dependency(%q<RedCloth>, [">= 4.0.3"])
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.2.1"])
27
+ s.add_runtime_dependency(%q<activerecord>, [">= 2.2.1"])
28
+ s.add_runtime_dependency(%q<rdiscount>, [">= 1.2.11"])
29
+ s.add_runtime_dependency(%q<RedCloth>, [">= 4.1.0"])
30
30
  s.add_runtime_dependency(%q<wikitext>, [">= 1.2.1"])
31
31
  else
32
- s.add_dependency(%q<activesupport>, [">= 2.1.1"])
33
- s.add_dependency(%q<activerecord>, [">= 2.1.1"])
34
- s.add_dependency(%q<rdiscount>, [">= 1.2.9"])
35
- s.add_dependency(%q<RedCloth>, [">= 4.0.3"])
32
+ s.add_dependency(%q<activesupport>, [">= 2.2.1"])
33
+ s.add_dependency(%q<activerecord>, [">= 2.2.1"])
34
+ s.add_dependency(%q<rdiscount>, [">= 1.2.11"])
35
+ s.add_dependency(%q<RedCloth>, [">= 4.1.0"])
36
36
  s.add_dependency(%q<wikitext>, [">= 1.2.1"])
37
37
  end
38
38
  else
39
- s.add_dependency(%q<activesupport>, [">= 2.1.1"])
40
- s.add_dependency(%q<activerecord>, [">= 2.1.1"])
41
- s.add_dependency(%q<rdiscount>, [">= 1.2.9"])
42
- s.add_dependency(%q<RedCloth>, [">= 4.0.3"])
39
+ s.add_dependency(%q<activesupport>, [">= 2.2.1"])
40
+ s.add_dependency(%q<activerecord>, [">= 2.2.1"])
41
+ s.add_dependency(%q<rdiscount>, [">= 1.2.11"])
42
+ s.add_dependency(%q<RedCloth>, [">= 4.1.0"])
43
43
  s.add_dependency(%q<wikitext>, [">= 1.2.1"])
44
44
  end
45
45
  end
@@ -20,13 +20,20 @@ module ActiveRecord # :nodoc:
20
20
  # the correct object (Markdown, Textile, Wikitext or RDoc) based on the value
21
21
  # of the language column. If any value besides markdown, textile, wikitext, or
22
22
  # RDoc is supplied for the markup language the text will pass through as a string.
23
+ #
24
+ # You can specify additional options to pass to the markup library by using
25
+ # <tt>:markdown_options</tt>, <tt>:textile_options</tt> or <tt>:wikitext_options</tt>.
26
+ # RDoc does not support any useful options. The options should be given as an array
27
+ # of arguments. You can specify options for more than one language when using
28
+ # <tt>:variable</tt>. See each library's documentation for more details on what
29
+ # options are available.
23
30
  #
24
31
  #
25
32
  # ==== Examples
26
33
  #
27
34
  # ===== Using Markdown language
28
35
  #
29
- # class Post < ActiveRecrod
36
+ # class Post < ActiveRecord
30
37
  # acts_as_markup :language => :markdown, :columns => [:body]
31
38
  # end
32
39
  #
@@ -37,7 +44,7 @@ module ActiveRecord # :nodoc:
37
44
  #
38
45
  # ===== Using variable language
39
46
  #
40
- # class Post < ActiveRecrod
47
+ # class Post < ActiveRecord
41
48
  # acts_as_markup :language => :variable, :columns => [:body], :language_column => 'language_name'
42
49
  # end
43
50
  #
@@ -47,6 +54,21 @@ module ActiveRecord # :nodoc:
47
54
  # @post.body.to_html # => "<h2> Markdown Headline</h2>"
48
55
  #
49
56
  #
57
+ # ===== Using options
58
+ #
59
+ # class Post < ActiveRecord
60
+ # acts_as_markup :language => :markdown, :columns => [:body], :markdown_options => [ :filter_html ]
61
+ # end
62
+ #
63
+ # class Post < ActiveRecord
64
+ # acts_as_markup :language => :textile, :columns => [:body], :textile_options => [ [ :filter_html ] ]
65
+ # end
66
+ #
67
+ # class Post < ActiveRecord
68
+ # acts_as_markup :language => :wikitext, :columns => [:body], :wikitext_options => [ { :space_to_underscore => true } ]
69
+ # end
70
+ #
71
+ #
50
72
  def acts_as_markup(options)
51
73
  case options[:language].to_sym
52
74
  when :markdown, :textile, :wikitext, :rdoc
@@ -61,70 +83,77 @@ module ActiveRecord # :nodoc:
61
83
  raise ActsAsMarkup::UnsupportedMarkupLanguage, "#{options[:langauge]} is not a currently supported markup language."
62
84
  end
63
85
 
64
- options[:columns].each do |col|
65
- unless options[:language].to_sym == :variable
66
- class_eval <<-EOV
67
- def #{col.to_s}
68
- if @#{col.to_s}
69
- unless self.#{col.to_s}_changed?
70
- return @#{col.to_s}
71
- end
86
+ unless options[:language].to_sym == :variable
87
+ markup_options = options["#{options[:language]}_options".to_sym] || []
88
+ options[:columns].each do |col|
89
+ define_method col do
90
+ if instance_variable_defined?("@#{col}")
91
+ unless send("#{col}_changed?")
92
+ return instance_variable_get("@#{col}")
72
93
  end
73
- @#{col.to_s} = #{klass}.new(self['#{col.to_s}'].to_s)
74
94
  end
75
- EOV
76
- else
77
- class_eval <<-EOV
78
- def #{col.to_s}
79
- if @#{col.to_s}
80
- unless self.#{col.to_s}_changed? || self.#{options[:language_column].to_s}_changed?
81
- return @#{col.to_s}
82
- end
83
- end
84
- case self.#{options[:language_column].to_s}
85
- when /markdown/i
86
- @#{col.to_s} = #{markup_klasses[:markdown]}.new(self['#{col.to_s}'].to_s)
87
- when /textile/i
88
- @#{col.to_s} = #{markup_klasses[:textile]}.new(self['#{col.to_s}'].to_s)
89
- when /wikitext/i
90
- @#{col.to_s} = #{markup_klasses[:wikitext]}.new(self['#{col.to_s}'].to_s)
91
- when /rdoc/i
92
- @#{col.to_s} = #{markup_klasses[:rdoc]}.new(self['#{col.to_s}'].to_s)
93
- else
94
- @#{col.to_s} = self['#{col.to_s}']
95
+ instance_variable_set("@#{col}", klass.new(self[col].to_s, *markup_options))
96
+ end
97
+ end
98
+ else
99
+ options[:columns].each do |col|
100
+ define_method col do
101
+ if instance_variable_defined?("@#{col}")
102
+ unless send("#{col}_changed?") || send("#{options[:language_column]}_changed?")
103
+ return instance_variable_get("@#{col}")
95
104
  end
96
105
  end
97
- EOV
106
+ instance_variable_set("@#{col}", case send(options[:language_column])
107
+ when /markdown/i
108
+ markup_klasses[:markdown].new self[col].to_s, *(options[:markdown_options] || [])
109
+ when /textile/i
110
+ markup_klasses[:textile].new self[col].to_s, *(options[:textile_options] || [])
111
+ when /wikitext/i
112
+ markup_klasses[:wikitext].new self[col].to_s, *(options[:wikitext_options] || [])
113
+ when /rdoc/i
114
+ markup_klasses[:rdoc].new self[col].to_s
115
+ else
116
+ self[col]
117
+ end)
118
+ end
98
119
  end
99
120
  end
100
121
  end
101
122
 
102
123
  # This is a convenience method for
103
124
  # `<tt>acts_as_markup :language => :markdown, :columns => [:body]</tt>`
125
+ # Additional options can be given at the end, if necessary.
104
126
  #
105
127
  def acts_as_markdown(*columns)
106
- acts_as_markup :language => :markdown, :columns => columns
128
+ options = columns.extract_options!
129
+ acts_as_markup options.merge(:language => :markdown, :columns => columns)
107
130
  end
108
131
 
109
132
  # This is a convenience method for
110
133
  # `<tt>acts_as_markup :language => :textile, :columns => [:body]</tt>`
134
+ # Additional options can be given at the end, if necessary.
111
135
  #
112
136
  def acts_as_textile(*columns)
113
- acts_as_markup :language => :textile, :columns => columns
137
+ options = columns.extract_options!
138
+ acts_as_markup options.merge(:language => :textile, :columns => columns)
114
139
  end
115
140
 
116
141
  # This is a convenience method for
117
142
  # `<tt>acts_as_markup :language => :wikitext, :columns => [:body]</tt>`
143
+ # Additional options can be given at the end, if necessary.
118
144
  #
119
145
  def acts_as_wikitext(*columns)
120
- acts_as_markup :language => :wikitext, :columns => columns
146
+ options = columns.extract_options!
147
+ acts_as_markup options.merge(:language => :wikitext, :columns => columns)
121
148
  end
122
149
 
123
150
  # This is a convenience method for
124
151
  # `<tt>acts_as_markup :language => :rdoc, :columns => [:body]</tt>`
152
+ # Additional options can be given at the end, if necessary.
125
153
  #
126
154
  def acts_as_rdoc(*columns)
127
- acts_as_markup :language => :rdoc, :columns => columns
155
+ options = columns.extract_options!
156
+ acts_as_markup options.merge(:language => :rdoc, :columns => columns)
128
157
  end
129
158
 
130
159
 
@@ -134,7 +163,7 @@ module ActiveRecord # :nodoc:
134
163
  markdown_library_names = ActsAsMarkup::MARKDOWN_LIBS[ActsAsMarkup.markdown_library]
135
164
  require markdown_library_names[:lib_name]
136
165
  require_extensions(markdown_library_names[:lib_name])
137
- return markdown_library_names[:class_name]
166
+ return markdown_library_names[:class_name].constantize
138
167
  else
139
168
  raise ActsAsMarkup::UnsportedMarkdownLibrary, "#{ActsAsMarkup.markdown_library} is not currently supported."
140
169
  end
@@ -142,7 +171,7 @@ module ActiveRecord # :nodoc:
142
171
 
143
172
  def require_extensions(library)# :nodoc:
144
173
  if ActsAsMarkup::LIBRARY_EXTENSIONS.include? library.to_s
145
- require "acts_as_markup/exts/#{library.to_s}"
174
+ require "#{ActsAsMarkup::LIBPATH}/acts_as_markup/exts/#{library}"
146
175
  end
147
176
  end
148
177
 
@@ -152,18 +181,18 @@ module ActiveRecord # :nodoc:
152
181
  return get_markdown_class
153
182
  when :textile
154
183
  require 'redcloth'
155
- return 'RedCloth'
184
+ return RedCloth
156
185
  when :wikitext
157
186
  require 'wikitext'
158
187
  require_extensions 'wikitext'
159
- return 'WikitextString'
188
+ return WikitextString
160
189
  when :rdoc
161
190
  require 'rdoc/markup/simple_markup'
162
191
  require 'rdoc/markup/simple_markup/to_html'
163
192
  require_extensions 'rdoc'
164
- return 'RDocText'
193
+ return RDocText
165
194
  else
166
- return 'String'
195
+ return String
167
196
  end
168
197
  end
169
198
 
@@ -8,10 +8,10 @@ class WikitextString < String
8
8
  attr_reader :text
9
9
  attr_reader :html
10
10
 
11
- def initialize(str)
11
+ def initialize(str, *options)
12
12
  super(str)
13
13
  @text = str.to_s
14
- @html = Wikitext::Parser.new.parse(@text)
14
+ @html = Wikitext::Parser.new(*options).parse(@text)
15
15
  end
16
16
 
17
17
  def to_html
@@ -2,7 +2,7 @@ require 'active_support'
2
2
 
3
3
  module ActsAsMarkup
4
4
  # :stopdoc:
5
- VERSION = '1.2.1'
5
+ VERSION = '1.3.0'
6
6
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
7
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
8
  # :startdoc:
data/tasks/gem.rake CHANGED
@@ -1,6 +1,92 @@
1
- # $Id$
2
1
 
3
- require 'rake/gempackagetask'
2
+ require 'find'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/user_interaction'
5
+ require 'rubygems/builder'
6
+
7
+ module Bones
8
+ class GemPackageTask < Rake::PackageTask
9
+ # Ruby GEM spec containing the metadata for this package. The
10
+ # name, version and package_files are automatically determined
11
+ # from the GEM spec and don't need to be explicitly provided.
12
+ #
13
+ attr_accessor :gem_spec
14
+
15
+ # Tasks from the Bones gem directory
16
+ attr_reader :bones_files
17
+
18
+ # Create a GEM Package task library. Automatically define the gem
19
+ # if a block is given. If no block is supplied, then +define+
20
+ # needs to be called to define the task.
21
+ #
22
+ def initialize(gem_spec)
23
+ init(gem_spec)
24
+ yield self if block_given?
25
+ define if block_given?
26
+ end
27
+
28
+ # Initialization tasks without the "yield self" or define
29
+ # operations.
30
+ #
31
+ def init(gem)
32
+ super(gem.name, gem.version)
33
+ @gem_spec = gem
34
+ @package_files += gem_spec.files if gem_spec.files
35
+ @bones_files = []
36
+
37
+ local_setup = File.join(Dir.pwd, %w[tasks setup.rb])
38
+ if !test(?e, local_setup)
39
+ Dir.glob(::Bones.path(%w[lib bones tasks *])).each {|fn| bones_files << fn}
40
+ gem_spec.files = (gem_spec.files +
41
+ bones_files.map {|fn| File.join('tasks', File.basename(fn))}).sort
42
+ end
43
+ end
44
+
45
+ # Create the Rake tasks and actions specified by this
46
+ # GemPackageTask. (+define+ is automatically called if a block is
47
+ # given to +new+).
48
+ #
49
+ def define
50
+ super
51
+ task :prereqs
52
+ task :package => ['gem:prereqs', "#{package_dir_path}/#{gem_file}"]
53
+ file "#{package_dir_path}/#{gem_file}" => [package_dir_path] + package_files + bones_files do
54
+ when_writing("Creating GEM") {
55
+ chdir(package_dir_path) do
56
+ Gem::Builder.new(gem_spec).build
57
+ verbose(true) {
58
+ mv gem_file, "../#{gem_file}"
59
+ }
60
+ end
61
+ }
62
+ end
63
+
64
+ file package_dir_path => bones_files do
65
+ mkdir_p package_dir rescue nil
66
+ bones_files.each do |fn|
67
+ base_fn = File.join('tasks', File.basename(fn))
68
+ f = File.join(package_dir_path, base_fn)
69
+ fdir = File.dirname(f)
70
+ mkdir_p(fdir) if !File.exist?(fdir)
71
+ if File.directory?(fn)
72
+ mkdir_p(f)
73
+ else
74
+ raise "file name conflict for '#{base_fn}' (conflicts with '#{fn}')" if test(?e, f)
75
+ safe_ln(fn, f)
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ def gem_file
82
+ if @gem_spec.platform == Gem::Platform::RUBY
83
+ "#{package_name}.gem"
84
+ else
85
+ "#{package_name}-#{@gem_spec.platform}.gem"
86
+ end
87
+ end
88
+ end # class GemPackageTask
89
+ end # module Bones
4
90
 
5
91
  namespace :gem do
6
92
 
@@ -19,6 +105,10 @@ namespace :gem do
19
105
  s.add_dependency(*dep)
20
106
  end
21
107
 
108
+ PROJ.gem.development_dependencies.each do |dep|
109
+ s.add_development_dependency(*dep)
110
+ end
111
+
22
112
  s.files = PROJ.gem.files
23
113
  s.executables = PROJ.gem.executables.map {|fn| File.basename(fn)}
24
114
  s.extensions = PROJ.gem.files.grep %r/extconf\.rb$/
@@ -57,37 +147,14 @@ namespace :gem do
57
147
  end
58
148
  end # Gem::Specification.new
59
149
 
60
- # A prerequisites task that all other tasks depend upon
61
- task :prereqs
62
-
63
- desc 'Show information about the gem'
64
- task :debug => 'gem:prereqs' do
65
- puts PROJ.gem._spec.to_ruby
66
- end
67
-
68
- pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
150
+ Bones::GemPackageTask.new(PROJ.gem._spec) do |pkg|
69
151
  pkg.need_tar = PROJ.gem.need_tar
70
152
  pkg.need_zip = PROJ.gem.need_zip
71
- pkg.package_files += PROJ.gem._spec.files
72
153
  end
73
- Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
74
-
75
- gem_file = if PROJ.gem._spec.platform == Gem::Platform::RUBY
76
- "#{pkg.package_name}.gem"
77
- else
78
- "#{pkg.package_name}-#{PROJ.gem._spec.platform}.gem"
79
- end
80
154
 
81
- desc "Build the gem file #{gem_file}"
82
- task :package => ['gem:prereqs', "#{pkg.package_dir}/#{gem_file}"]
83
-
84
- file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.gem._spec.files do
85
- when_writing("Creating GEM") {
86
- Gem::Builder.new(PROJ.gem._spec).build
87
- verbose(true) {
88
- mv gem_file, "#{pkg.package_dir}/#{gem_file}"
89
- }
90
- }
155
+ desc 'Show information about the gem'
156
+ task :debug => 'gem:prereqs' do
157
+ puts PROJ.gem._spec.to_ruby
91
158
  end
92
159
 
93
160
  desc 'Install the gem'
@@ -113,14 +180,13 @@ namespace :gem do
113
180
  task :cleanup do
114
181
  sh "#{SUDO} #{GEM} cleanup #{PROJ.gem._spec.name}"
115
182
  end
116
-
117
183
  end # namespace :gem
118
184
 
185
+
119
186
  desc 'Alias to gem:package'
120
187
  task :gem => 'gem:package'
121
188
 
122
189
  task :clobber => 'gem:clobber_package'
123
-
124
- remove_desc_for_task %w(gem:clobber_package)
190
+ remove_desc_for_task 'gem:clobber_package'
125
191
 
126
192
  # EOF
data/tasks/manifest.rake CHANGED
@@ -1,4 +1,3 @@
1
- # $Id$
2
1
 
3
2
  require 'find'
4
3
 
@@ -15,9 +14,9 @@ namespace :manifest do
15
14
  lines.map! do |line|
16
15
  case line
17
16
  when %r/^(-{3}|\+{3})/; nil
18
- when %r/^@/; Console::ANSICode.blue line
19
- when %r/^\+/; Console::ANSICode.green line
20
- when %r/^\-/; Console::ANSICode.red line
17
+ when %r/^@/; ANSICode.blue line
18
+ when %r/^\+/; ANSICode.green line
19
+ when %r/^\-/; ANSICode.red line
21
20
  else line end
22
21
  end
23
22
  end
data/tasks/post_load.rake CHANGED
@@ -1,16 +1,15 @@
1
- # $Id$
2
1
 
3
2
  # This file does not define any rake tasks. It is used to load some project
4
3
  # settings if they are not defined by the user.
5
4
 
6
5
  PROJ.rdoc.exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
7
- PROJ.exclude << ["^#{Regexp.escape(PROJ.ann.file)}$",
8
- "^#{Regexp.escape(PROJ.rdoc.dir)}/",
6
+ PROJ.exclude << ["^#{Regexp.escape(PROJ.rdoc.dir)}/",
9
7
  "^#{Regexp.escape(PROJ.rcov.dir)}/"]
10
8
 
11
9
  flatten_arrays = lambda do |this,os|
12
10
  os.instance_variable_get(:@table).each do |key,val|
13
- next if key == :dependencies
11
+ next if key == :dependencies \
12
+ or key == :development_dependencies
14
13
  case val
15
14
  when Array; val.flatten!
16
15
  when OpenStruct; this.call(this,val)
data/tasks/rdoc.rake CHANGED
@@ -7,7 +7,7 @@ namespace :doc do
7
7
  desc 'Generate RDoc documentation'
8
8
  Rake::RDocTask.new do |rd|
9
9
  rdoc = PROJ.rdoc
10
- rd.main = rdoc.main
10
+ rd.main = rdoc.main || PROJ.readme_file
11
11
  rd.rdoc_dir = rdoc.dir
12
12
 
13
13
  incl = Regexp.new(rdoc.include.join('|'))
@@ -22,9 +22,6 @@ namespace :doc do
22
22
 
23
23
  title = "#{PROJ.name}-#{PROJ.version} Documentation"
24
24
 
25
- rf_name = PROJ.rubyforge.name
26
- title = "#{rf_name}'s " + title if rf_name.valid? and rf_name != title
27
-
28
25
  rd.options << "-t #{title}"
29
26
  rd.options.concat(rdoc.opts)
30
27
  end
data/tasks/rubyforge.rake CHANGED
@@ -6,7 +6,7 @@ require 'rake/contrib/sshpublisher'
6
6
 
7
7
  namespace :gem do
8
8
  desc 'Package and upload to RubyForge'
9
- task :release => [:clobber, 'gem:package'] do |t|
9
+ task :release => [:clobber, 'gem'] do |t|
10
10
  v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
11
11
  abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
12
12
  pkg = "pkg/#{PROJ.gem._spec.full_name}"
@@ -26,9 +26,7 @@ namespace :gem do
26
26
  c['release_changes'] = PROJ.changes if PROJ.changes
27
27
  c['preformatted'] = true
28
28
 
29
- files = [(PROJ.gem.need_tar ? "#{pkg}.tgz" : nil),
30
- (PROJ.gem.need_zip ? "#{pkg}.zip" : nil),
31
- "#{pkg}.gem"].compact
29
+ files = Dir.glob("#{pkg}*.*")
32
30
 
33
31
  puts "Releasing #{PROJ.name} v. #{PROJ.version}"
34
32
  rf.add_release PROJ.rubyforge.name, PROJ.name, PROJ.version, *files
data/tasks/setup.rb CHANGED
@@ -18,7 +18,7 @@ PROJ = OpenStruct.new(
18
18
  :email => nil,
19
19
  :url => "\000",
20
20
  :version => ENV['VERSION'] || '0.0.0',
21
- :exclude => %w(tmp$ bak$ ~$ CVS \.svn/ \.git ^pkg/),
21
+ :exclude => %w(tmp$ bak$ ~$ CVS \.svn/ \.git/ ^pkg/),
22
22
  :release_name => ENV['RELEASE'],
23
23
 
24
24
  # System Defaults
@@ -28,26 +28,10 @@ PROJ = OpenStruct.new(
28
28
  :manifest_file => 'Manifest.txt',
29
29
  :readme_file => 'README.rdoc',
30
30
 
31
- # Announce
32
- :ann => OpenStruct.new(
33
- :file => 'announcement.txt',
34
- :text => nil,
35
- :paragraphs => [],
36
- :email => {
37
- :from => nil,
38
- :to => %w(ruby-talk@ruby-lang.org),
39
- :server => 'localhost',
40
- :port => 25,
41
- :domain => ENV['HOSTNAME'],
42
- :acct => nil,
43
- :passwd => nil,
44
- :authtype => :plain
45
- }
46
- ),
47
-
48
31
  # Gem Packaging
49
32
  :gem => OpenStruct.new(
50
33
  :dependencies => [],
34
+ :development_dependencies => [],
51
35
  :executables => nil,
52
36
  :extensions => FileList['ext/**/extconf.rb'],
53
37
  :files => nil,
@@ -66,9 +50,7 @@ PROJ = OpenStruct.new(
66
50
  # Rcov
67
51
  :rcov => OpenStruct.new(
68
52
  :dir => 'coverage',
69
- :opts => %w[--sort coverage -T],
70
- :threshold => 90.0,
71
- :threshold_exact => false
53
+ :opts => %w[--sort coverage -T --no-html]
72
54
  ),
73
55
 
74
56
  # Rdoc
@@ -86,32 +68,19 @@ PROJ = OpenStruct.new(
86
68
  :name => "\000"
87
69
  ),
88
70
 
89
- # Rspec
90
- :spec => OpenStruct.new(
91
- :files => FileList['spec/**/*_spec.rb'],
92
- :opts => []
93
- ),
94
-
95
- # Subversion Repository
96
- :svn => OpenStruct.new(
97
- :root => nil,
98
- :path => '',
99
- :trunk => 'trunk',
100
- :tags => 'tags',
101
- :branches => 'branches'
102
- ),
103
-
104
71
  # Test::Unit
105
72
  :test => OpenStruct.new(
106
- :files => FileList['test/**/test_*.rb'],
73
+ :files => FileList['test/**/*_test.rb'],
107
74
  :file => 'test/all.rb',
108
75
  :opts => []
109
76
  )
110
77
  )
111
78
 
112
79
  # Load the other rake files in the tasks folder
113
- rakefiles = Dir.glob('tasks/*.rake').sort
114
- rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
80
+ tasks_dir = File.expand_path(File.dirname(__FILE__))
81
+ post_load_fn = File.join(tasks_dir, 'post_load.rake')
82
+ rakefiles = Dir.glob(File.join(tasks_dir, '*.rake')).sort
83
+ rakefiles.unshift(rakefiles.delete(post_load_fn)).compact!
115
84
  import(*rakefiles)
116
85
 
117
86
  # Setup the project libraries
@@ -32,6 +32,11 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
32
32
  should "return formatted html for a `to_html` method call on the column value" do
33
33
  assert_match(/<h2(\s\w+\=['"]\w*['"])*\s*>\s*Markdown Test Text\s*<\/h2>/, @post.body.to_html)
34
34
  end
35
+
36
+ should "not return escaped html" do
37
+ @post.body = "## Markdown <i>Test</i> Text"
38
+ assert_match(/<i>Test<\/i>/, @post.body.to_html)
39
+ end
35
40
 
36
41
  context "changing value of markdown field should return new markdown object" do
37
42
  setup do
@@ -62,6 +67,20 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
62
67
  Post.delete_all
63
68
  end
64
69
  end
70
+
71
+ context 'using RDiscount with options' do
72
+ setup do
73
+ class ::Post
74
+ acts_as_markdown :body, :markdown_options => [ :filter_html ]
75
+ end
76
+ @post = Post.new(:title => 'Blah')
77
+ end
78
+
79
+ should "return escaped html because of :filter_html" do
80
+ @post.body = "## Markdown <i>Test</i> Text"
81
+ assert_match(/&lt;i>Test&lt;\/i>/, @post.body.to_html)
82
+ end
83
+ end
65
84
 
66
85
  context 'using Ruby PEG Markdown' do
67
86
  setup do
@@ -89,6 +108,11 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
89
108
  should "return formated html for a `to_html` method call on the column value" do
90
109
  assert_match(/<h2(\s\w+\=['"]\w*['"])*\s*>\s*Markdown Test Text\s*<\/h2>/, @post.body.to_html)
91
110
  end
111
+
112
+ should "not return escaped html" do
113
+ @post.body = "## Markdown <i>Test</i> Text"
114
+ assert_match(/<i>Test<\/i>/, @post.body.to_html)
115
+ end
92
116
 
93
117
  context "changing value of markdown field should return new markdown object" do
94
118
  setup do
@@ -120,6 +144,20 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
120
144
  end
121
145
  end
122
146
 
147
+ context 'using Ruby PEG Markdown with options' do
148
+ setup do
149
+ class ::Post
150
+ acts_as_markdown :body, :markdown_options => [ :filter_html ]
151
+ end
152
+ @post = Post.new(:title => 'Blah')
153
+ end
154
+
155
+ should "return no html because of :filter_html" do
156
+ @post.body = "## Markdown <i>Test</i> Text"
157
+ assert_match(/Markdown Test Text/, @post.body.to_html)
158
+ end
159
+ end
160
+
123
161
  context 'using BlueCloth' do
124
162
  setup do
125
163
  ActsAsMarkup.markdown_library = :bluecloth
@@ -146,6 +184,11 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
146
184
  should "return formated html for a `to_html` method call on the column value" do
147
185
  assert_match(/<h2(\s\w+\=['"]\w*['"])*\s*>\s*Markdown Test Text\s*<\/h2>/, @post.body.to_html)
148
186
  end
187
+
188
+ should "not return escaped html" do
189
+ @post.body = "## Markdown <i>Test</i> Text"
190
+ assert_match(/<i>Test<\/i>/, @post.body.to_html)
191
+ end
149
192
 
150
193
  context "changing value of markdown field should return new markdown object" do
151
194
  setup do
@@ -177,6 +220,20 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
177
220
  end
178
221
  end
179
222
 
223
+ context 'using BlueCloth with options' do
224
+ setup do
225
+ class ::Post
226
+ acts_as_markdown :body, :markdown_options => [ :filter_html ]
227
+ end
228
+ @post = Post.new(:title => 'Blah')
229
+ end
230
+
231
+ should "return escaped html because of :filter_html" do
232
+ @post.body = "## Markdown <i>Test</i> Text"
233
+ assert_match(/&lt;i&gt;Test&lt;\/i&gt;/, @post.body.to_html)
234
+ end
235
+ end
236
+
180
237
  context 'using Maruku' do
181
238
  setup do
182
239
  ActsAsMarkup.markdown_library = :maruku
@@ -25,6 +25,11 @@ class ActsAsTextileTest < ActsAsMarkupTestCase
25
25
  should "return formated html for a `to_html` method call on the column value" do
26
26
  assert_match(/<h2>Textile Test Text<\/h2>/, @post.body.to_html)
27
27
  end
28
+
29
+ should "not return escaped html" do
30
+ @post.body = "h2. Textile <i>Test</i> Text"
31
+ assert_match(/<i>Test<\/i>/, @post.body.to_html)
32
+ end
28
33
 
29
34
  context "changing value of textile field should return new textile object" do
30
35
  setup do
@@ -55,4 +60,18 @@ class ActsAsTextileTest < ActsAsMarkupTestCase
55
60
  Post.delete_all
56
61
  end
57
62
  end
63
+
64
+ context 'acts_as_textile with options' do
65
+ setup do
66
+ class ::Post
67
+ acts_as_textile :body, :textile_options => [ [ :filter_html ] ]
68
+ end
69
+ @post = Post.new(:title => 'Blah')
70
+ end
71
+
72
+ should "return escaped html because of :filter_html" do
73
+ @post.body = "h2. Textile <i>Test</i> Text"
74
+ assert_match(/&lt;i&gt;Test&lt;\/i&gt;/, @post.body.to_html)
75
+ end
76
+ end
58
77
  end
@@ -25,6 +25,11 @@ class ActsAsWikitextTest < ActsAsMarkupTestCase
25
25
  should "return formated html for a `to_html` method call on the column value" do
26
26
  assert_match(/<h2>Wikitext Test Text<\/h2>/, @post.body.to_html)
27
27
  end
28
+
29
+ should "not underscore spaces in URLs" do
30
+ @post.body = "[[foo bar]]"
31
+ assert_match(/<a href="\/wiki\/foo%20bar">foo bar<\/a>/, @post.body.to_html)
32
+ end
28
33
 
29
34
  context "changing value of wikitext field should return new wikitext object" do
30
35
  setup do
@@ -55,4 +60,18 @@ class ActsAsWikitextTest < ActsAsMarkupTestCase
55
60
  Post.delete_all
56
61
  end
57
62
  end
63
+
64
+ context 'acts_as_wikitext with options' do
65
+ setup do
66
+ class ::Post
67
+ acts_as_wikitext :body, :wikitext_options => [ { :space_to_underscore => true } ]
68
+ end
69
+ @post = Post.new(:title => 'Blah')
70
+ end
71
+
72
+ should "underscore spaces in URLs because of :space_to_underscore" do
73
+ @post.body = "[[foo bar]]"
74
+ assert_match(/<a href="\/wiki\/foo_bar">foo bar<\/a>/, @post.body.to_html)
75
+ end
76
+ end
58
77
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'test/unit'
2
2
  require 'rubygems'
3
+ gem 'sqlite3-ruby'
3
4
  require 'shoulda'
4
5
  require 'active_support'
5
6
  require 'active_support/test_case'
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.1
4
+ version: 1.3.0
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-30 00:00:00 -07:00
12
+ date: 2008-11-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 2.1.1
22
+ version: 2.2.1
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: activerecord
@@ -28,7 +28,7 @@ dependencies:
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: 2.1.1
31
+ version: 2.2.1
32
32
  version:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rdiscount
@@ -37,7 +37,7 @@ dependencies:
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2.9
40
+ version: 1.2.11
41
41
  version:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: RedCloth
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 4.0.3
49
+ version: 4.1.0
50
50
  version:
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: wikitext