acts_as_markup 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.3.1 / 2008-04-27
2
+ * Update rake tasks and way RDoc is generated
3
+ * Ensure works with Rails 2.3.2 and latest version of related markup gems.
4
+
1
5
  == 1.3.0 / 2008-11-19
2
6
  * Add ability to accept options that will be passed to supported markup parsers. (chewi[http://github.com/chewi/])
3
7
 
data/Rakefile CHANGED
@@ -24,6 +24,10 @@ PROJ.rcov.opts = ['--no-html', '-T', '--sort coverage',
24
24
  '-x "\/System\/Library\/"']
25
25
  PROJ.rcov.pattern = 'test/**/*_test.rb'
26
26
 
27
- %W(activesupport activerecord rdiscount RedCloth wikitext).each do |gem|
28
- depend_on gem
29
- end
27
+ PROJ.gem.development_dependencies << ['voloko-sdoc', '~> 0.2.12']
28
+ PROJ.gem.development_dependencies << ['thoughtbot-shoulda', '~> 2.0']
29
+ depend_on 'activesupport', '~> 2.3.1'
30
+ depend_on 'activerecord', '~> 2.3.1'
31
+ depend_on 'activerecord', '~> 1.3'
32
+ depend_on 'wikitext', '~> 1.5'
33
+ depend_on 'RedCloth', '~> 4.1'
@@ -1,10 +1,12 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = %q{acts_as_markup}
3
- s.version = "1.3.0"
5
+ s.version = "1.3.1"
4
6
 
5
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
8
  s.authors = ["Brian Landau"]
7
- s.date = %q{2008-11-19}
9
+ s.date = %q{2009-04-27}
8
10
  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
11
  s.email = %q{brian.landau@viget.com}
10
12
  s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc"]
@@ -14,32 +16,38 @@ Gem::Specification.new do |s|
14
16
  s.rdoc_options = ["--main", "README.rdoc"]
15
17
  s.require_paths = ["lib"]
16
18
  s.rubyforge_project = %q{viget}
17
- s.rubygems_version = %q{1.3.1}
19
+ s.rubygems_version = %q{1.3.2}
18
20
  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
21
  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
22
 
21
23
  if s.respond_to? :specification_version then
22
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
- s.specification_version = 2
25
+ s.specification_version = 3
24
26
 
25
27
  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
- s.add_runtime_dependency(%q<wikitext>, [">= 1.2.1"])
28
+ s.add_runtime_dependency(%q<activesupport>, ["~> 2.3.1"])
29
+ s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.1"])
30
+ s.add_runtime_dependency(%q<activerecord>, ["~> 1.3"])
31
+ s.add_runtime_dependency(%q<wikitext>, ["~> 1.5"])
32
+ s.add_runtime_dependency(%q<RedCloth>, ["~> 4.1"])
33
+ s.add_development_dependency(%q<voloko-sdoc>, ["~> 0.2.12"])
34
+ s.add_development_dependency(%q<thoughtbot-shoulda>, ["~> 2.0"])
31
35
  else
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
- s.add_dependency(%q<wikitext>, [">= 1.2.1"])
36
+ s.add_dependency(%q<activesupport>, ["~> 2.3.1"])
37
+ s.add_dependency(%q<activerecord>, ["~> 2.3.1"])
38
+ s.add_dependency(%q<activerecord>, ["~> 1.3"])
39
+ s.add_dependency(%q<wikitext>, ["~> 1.5"])
40
+ s.add_dependency(%q<RedCloth>, ["~> 4.1"])
41
+ s.add_dependency(%q<voloko-sdoc>, ["~> 0.2.12"])
42
+ s.add_dependency(%q<thoughtbot-shoulda>, ["~> 2.0"])
37
43
  end
38
44
  else
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
- s.add_dependency(%q<wikitext>, [">= 1.2.1"])
45
+ s.add_dependency(%q<activesupport>, ["~> 2.3.1"])
46
+ s.add_dependency(%q<activerecord>, ["~> 2.3.1"])
47
+ s.add_dependency(%q<activerecord>, ["~> 1.3"])
48
+ s.add_dependency(%q<wikitext>, ["~> 1.5"])
49
+ s.add_dependency(%q<RedCloth>, ["~> 4.1"])
50
+ s.add_dependency(%q<voloko-sdoc>, ["~> 0.2.12"])
51
+ s.add_dependency(%q<thoughtbot-shoulda>, ["~> 2.0"])
44
52
  end
45
53
  end
@@ -2,7 +2,7 @@ require 'active_support'
2
2
 
3
3
  module ActsAsMarkup
4
4
  # :stopdoc:
5
- VERSION = '1.3.0'
5
+ VERSION = '1.3.1'
6
6
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
7
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
8
  # :startdoc:
@@ -5,25 +5,25 @@ class Maruku
5
5
 
6
6
  attr_reader :text
7
7
 
8
- def initialize(s=nil, meta={})
9
- super(nil)
10
- self.attributes.merge! meta
11
- if s
12
- @text = s
13
- parse_doc(s)
14
- end
15
- end
16
-
17
- # Used to get the original Markdown text.
18
- def to_s
19
- @text
8
+ def initialize(s=nil, meta={})
9
+ super(nil)
10
+ self.attributes.merge! meta
11
+ if s
12
+ @text = s
13
+ parse_doc(s)
14
+ end
15
+ end
16
+
17
+ # Used to get the original Markdown text.
18
+ def to_s
19
+ @text
20
20
  end
21
21
 
22
22
  # used to be compatable with Rails/ActiveSupport
23
23
  def blank?
24
24
  @text.blank?
25
25
  end
26
-
26
+
27
27
  end
28
28
 
29
29
  class String
@@ -44,26 +44,26 @@ 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
- elements = []
48
- array.each do |item|
49
- method = item.kind_of?(MDElement) ? "to_html_#{item.node_type}" : "to_xml"
47
+ elements = []
48
+ array.each do |item|
49
+ method = item.kind_of?(MDElement) ? "to_html_#{item.node_type}" : "to_xml"
50
50
  unless item.respond_to?(method)
51
- next
52
- end
51
+ next
52
+ end
53
53
 
54
- html_text = item.send(method)
54
+ html_text = item.send(method)
55
55
  if html_text.nil?
56
- raise "Nil html created by method #{method}:\n#{html_text.inspect}\n for object #{item.inspect[0,300]}"
57
- end
56
+ raise "Nil html created by method #{method}:\n#{html_text.inspect}\n for object #{item.inspect[0,300]}"
57
+ end
58
58
 
59
- if html_text.kind_of?Array
60
- elements = elements + html_text
61
- else
62
- elements << html_text
63
- end
64
- end
65
- elements
66
- end
59
+ if html_text.kind_of?Array
60
+ elements = elements + html_text
61
+ else
62
+ elements << html_text
63
+ end
64
+ end
65
+ elements
66
+ end
67
67
 
68
68
  end
69
69
  end
data/tasks/gem.rake CHANGED
@@ -37,8 +37,6 @@ class GemPackageTask < Rake::PackageTask
37
37
  local_setup = File.join(Dir.pwd, %w[tasks setup.rb])
38
38
  if !test(?e, local_setup)
39
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
40
  end
43
41
  end
44
42
 
@@ -63,6 +61,10 @@ class GemPackageTask < Rake::PackageTask
63
61
 
64
62
  file package_dir_path => bones_files do
65
63
  mkdir_p package_dir rescue nil
64
+
65
+ gem_spec.files = (gem_spec.files +
66
+ bones_files.map {|fn| File.join('tasks', File.basename(fn))}).sort
67
+
66
68
  bones_files.each do |fn|
67
69
  base_fn = File.join('tasks', File.basename(fn))
68
70
  f = File.join(package_dir_path, base_fn)
@@ -156,6 +158,13 @@ namespace :gem do
156
158
  task :debug => 'gem:prereqs' do
157
159
  puts PROJ.gem._spec.to_ruby
158
160
  end
161
+
162
+ desc 'Write the gemspec '
163
+ task :spec => 'gem:prereqs' do
164
+ File.open("#{PROJ.name}.gemspec", 'w') do |f|
165
+ f.write PROJ.gem._spec.to_ruby
166
+ end
167
+ end
159
168
 
160
169
  desc 'Install the gem'
161
170
  task :install => [:clobber, 'gem:package'] do
data/tasks/manifest.rake CHANGED
@@ -26,7 +26,7 @@ namespace :manifest do
26
26
 
27
27
  desc 'Create a new manifest'
28
28
  task :create do
29
- files = manifest_files
29
+ files = manifest
30
30
  unless test(?f, PROJ.manifest_file)
31
31
  files << PROJ.manifest_file
32
32
  files.sort!
data/tasks/post_load.rake CHANGED
@@ -24,12 +24,7 @@ PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
24
24
 
25
25
  PROJ.summary ||= PROJ.description.split('.').first
26
26
 
27
- PROJ.gem.files ||=
28
- if test(?f, PROJ.manifest_file)
29
- files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
30
- files.delete ''
31
- files
32
- else [] end
27
+ PROJ.gem.files ||= manifest
33
28
 
34
29
  PROJ.gem.executables ||= PROJ.gem.files.find_all {|fn| fn =~ %r/^bin/}
35
30
 
data/tasks/rdoc.rake CHANGED
@@ -1,5 +1,6 @@
1
1
  # $Id$
2
2
 
3
+ require 'sdoc'
3
4
  require 'rake/rdoctask'
4
5
 
5
6
  namespace :doc do
@@ -21,8 +22,9 @@ namespace :doc do
21
22
  rd.rdoc_files.push(*files)
22
23
 
23
24
  title = "#{PROJ.name}-#{PROJ.version} Documentation"
24
-
25
- rd.options << "-t #{title}"
25
+
26
+ rd.template = 'direct'
27
+ rd.options << "-t #{title} --fmt shtml"
26
28
  rd.options.concat(rdoc.opts)
27
29
  end
28
30
 
data/tasks/setup.rb CHANGED
@@ -5,8 +5,9 @@ require 'rake'
5
5
  require 'rake/clean'
6
6
  require 'fileutils'
7
7
  require 'ostruct'
8
+ require 'find'
8
9
 
9
- class OpenStruct; undef :gem; end
10
+ class OpenStruct; undef :gem if defined? :gem; end
10
11
 
11
12
  PROJ = OpenStruct.new(
12
13
  # Project Defaults
@@ -27,6 +28,7 @@ PROJ = OpenStruct.new(
27
28
  :history_file => 'CHANGELOG',
28
29
  :manifest_file => 'Manifest.txt',
29
30
  :readme_file => 'README.rdoc',
31
+ :ignore_file => '.gitignore',
30
32
 
31
33
  # Gem Packaging
32
34
  :gem => OpenStruct.new(
@@ -87,9 +89,7 @@ import(*rakefiles)
87
89
  %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
88
90
 
89
91
  # Setup some constants
90
- WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
91
-
92
- DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
92
+ DEV_NULL = File.exist?('/dev/null') ? '/dev/null' : 'NUL:'
93
93
 
94
94
  def quiet( &block )
95
95
  io = [STDOUT.dup, STDERR.dup]
@@ -102,21 +102,15 @@ ensure
102
102
  $stdout, $stderr = STDOUT, STDERR
103
103
  end
104
104
 
105
- DIFF = if WIN32 then 'diff.exe'
106
- else
107
- if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
108
- else 'diff' end
109
- end unless defined? DIFF
105
+ DIFF = if system("gdiff '#{__FILE__}' '#{__FILE__}' > #{DEV_NULL} 2>&1") then 'gdiff'
106
+ else 'diff' end unless defined? DIFF
110
107
 
111
- SUDO = if WIN32 then ''
112
- else
113
- if quiet {system 'which sudo'} then 'sudo'
114
- else '' end
115
- end
108
+ SUDO = if system("which sudo > #{DEV_NULL} 2>&1") then 'sudo'
109
+ else '' end unless defined? SUDO
116
110
 
117
- RCOV = WIN32 ? 'rcov.bat' : 'rcov'
118
- RDOC = WIN32 ? 'rdoc.bat' : 'rdoc'
119
- GEM = WIN32 ? 'gem.bat' : 'gem'
111
+ RCOV = "#{RUBY} -S rcov"
112
+ RDOC = "#{RUBY} -S rdoc"
113
+ GEM = "#{RUBY} -S gem"
120
114
 
121
115
  %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
122
116
  begin
@@ -212,9 +206,30 @@ end
212
206
  # Scans the current working directory and creates a list of files that are
213
207
  # candidates to be in the manifest.
214
208
  #
215
- def manifest_files
209
+ def manifest
216
210
  files = []
217
- exclude = Regexp.new(PROJ.exclude.join('|'))
211
+ exclude = PROJ.exclude.dup
212
+ comment = %r/^\s*#/
213
+ exclude << Regexp.escape(PROJ.ignore_file)
214
+
215
+ # process the ignore file and add the items there to the exclude list
216
+ if test(?f, PROJ.ignore_file)
217
+ ary = []
218
+ File.readlines(PROJ.ignore_file).each do |line|
219
+ next if line =~ comment
220
+ line.chomp!
221
+ line.strip!
222
+ next if line.nil? or line.empty?
223
+
224
+ glob = line =~ %r/\*\./ ? File.join('**', line) : line
225
+ Dir.glob(glob).each {|fn| ary << "^#{Regexp.escape(fn)}"}
226
+ end
227
+ exclude.concat ary
228
+ end
229
+
230
+ # generate a regular expression from the exclude list
231
+ exclude = Regexp.new(exclude.join('|'))
232
+
218
233
  Find.find '.' do |path|
219
234
  path.sub! %r/^(\.\/|\/)/o, ''
220
235
  next unless test ?f, path
@@ -26,11 +26,11 @@ class ActsAsWikitextTest < ActsAsMarkupTestCase
26
26
  assert_match(/<h2>Wikitext Test Text<\/h2>/, @post.body.to_html)
27
27
  end
28
28
 
29
- should "not underscore spaces in URLs" do
29
+ should "underscore spaces in URLs" do
30
30
  @post.body = "[[foo bar]]"
31
- assert_match(/<a href="\/wiki\/foo%20bar">foo bar<\/a>/, @post.body.to_html)
31
+ assert_match(/<a href="\/wiki\/foo_bar">foo bar<\/a>/, @post.body.to_html)
32
32
  end
33
-
33
+
34
34
  context "changing value of wikitext field should return new wikitext object" do
35
35
  setup do
36
36
  @old_body = @post.body
@@ -64,14 +64,14 @@ class ActsAsWikitextTest < ActsAsMarkupTestCase
64
64
  context 'acts_as_wikitext with options' do
65
65
  setup do
66
66
  class ::Post
67
- acts_as_wikitext :body, :wikitext_options => [ { :space_to_underscore => true } ]
67
+ acts_as_wikitext :body, :wikitext_options => [ { :space_to_underscore => false } ]
68
68
  end
69
69
  @post = Post.new(:title => 'Blah')
70
70
  end
71
71
 
72
- should "underscore spaces in URLs because of :space_to_underscore" do
72
+ should "not underscore spaces in URLs because of :space_to_underscore option" do
73
73
  @post.body = "[[foo bar]]"
74
- assert_match(/<a href="\/wiki\/foo_bar">foo bar<\/a>/, @post.body.to_html)
74
+ assert_match(/<a href="\/wiki\/foo%20bar">foo bar<\/a>/, @post.body.to_html)
75
75
  end
76
76
  end
77
77
  end
data/test/test_helper.rb CHANGED
@@ -5,6 +5,7 @@ require 'shoulda'
5
5
  require 'active_support'
6
6
  require 'active_support/test_case'
7
7
  require File.expand_path( File.join(File.dirname(__FILE__), %w[.. lib acts_as_markup]) )
8
+ ActiveRecord::Schema.verbose = false
8
9
 
9
10
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
10
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.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-11-19 00:00:00 -05:00
12
+ date: 2009-04-27 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ">="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 2.2.1
23
+ version: 2.3.1
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
@@ -28,39 +28,59 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 2.2.1
33
+ version: 2.3.1
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
- name: rdiscount
36
+ name: activerecord
37
37
  type: :runtime
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ">="
41
+ - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 1.2.11
43
+ version: "1.3"
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
- name: RedCloth
46
+ name: wikitext
47
47
  type: :runtime
48
48
  version_requirement:
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 4.1.0
53
+ version: "1.5"
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
- name: wikitext
56
+ name: RedCloth
57
57
  type: :runtime
58
58
  version_requirement:
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: "4.1"
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: voloko-sdoc
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ~>
62
72
  - !ruby/object:Gem::Version
63
- version: 1.2.1
73
+ version: 0.2.12
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: thoughtbot-shoulda
77
+ type: :development
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: "2.0"
64
84
  version:
65
85
  description: Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML.
66
86
  email: brian.landau@viget.com
@@ -105,6 +125,8 @@ files:
105
125
  - test/test_helper.rb
106
126
  has_rdoc: true
107
127
  homepage: http://viget.rubyforge.com/acts_as_markup
128
+ licenses: []
129
+
108
130
  post_install_message:
109
131
  rdoc_options:
110
132
  - --main
@@ -126,9 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
148
  requirements: []
127
149
 
128
150
  rubyforge_project: viget
129
- rubygems_version: 1.3.1
151
+ rubygems_version: 1.3.2
130
152
  signing_key:
131
- specification_version: 2
153
+ specification_version: 3
132
154
  summary: Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML
133
155
  test_files:
134
156
  - test/acts_as_markdown_test.rb