acts_as_markup 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.2.0 / 2008-09-10
2
+ * 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
+ * Add string methods to all markup objects via the StringLike mixin. (crnixon[http://github.com/crnixon/])
4
+ * Other Minor bug fixes
5
+
1
6
  == 1.1.2 / 2008-08-22
2
7
  * Make sure all markup objects properly respond to the .blank? method call.
3
8
 
@@ -7,11 +7,12 @@ acts_as_markup.gemspec
7
7
  lib/acts/as_markup.rb
8
8
  lib/acts_as_markup.rb
9
9
  lib/acts_as_markup/exts/maruku.rb
10
+ lib/acts_as_markup/exts/object.rb
10
11
  lib/acts_as_markup/exts/peg_markdown.rb
11
12
  lib/acts_as_markup/exts/rdiscount.rb
12
13
  lib/acts_as_markup/exts/rdoc.rb
13
- lib/acts_as_markup/exts/string.rb
14
14
  lib/acts_as_markup/exts/wikitext.rb
15
+ lib/acts_as_markup/stringlike.rb
15
16
  tasks/bones.rake
16
17
  tasks/gem.rake
17
18
  tasks/git.rake
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{acts_as_markup}
3
- s.version = "1.1.2"
3
+ s.version = "1.2.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-08-22}
7
+ s.date = %q{2008-09-10}
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"]
11
- s.files = ["CHANGELOG", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "acts_as_markup.gemspec", "lib/acts/as_markup.rb", "lib/acts_as_markup.rb", "lib/acts_as_markup/exts/maruku.rb", "lib/acts_as_markup/exts/peg_markdown.rb", "lib/acts_as_markup/exts/rdiscount.rb", "lib/acts_as_markup/exts/rdoc.rb", "lib/acts_as_markup/exts/string.rb", "lib/acts_as_markup/exts/wikitext.rb", "tasks/bones.rake", "tasks/gem.rake", "tasks/git.rake", "tasks/manifest.rake", "tasks/post_load.rake", "tasks/rdoc.rake", "tasks/rubyforge.rake", "tasks/setup.rb", "tasks/test.rake", "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", "test/test_helper.rb"]
11
+ s.files = ["CHANGELOG", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "acts_as_markup.gemspec", "lib/acts/as_markup.rb", "lib/acts_as_markup.rb", "lib/acts_as_markup/exts/maruku.rb", "lib/acts_as_markup/exts/object.rb", "lib/acts_as_markup/exts/peg_markdown.rb", "lib/acts_as_markup/exts/rdiscount.rb", "lib/acts_as_markup/exts/rdoc.rb", "lib/acts_as_markup/exts/wikitext.rb", "lib/acts_as_markup/stringlike.rb", "tasks/bones.rake", "tasks/gem.rake", "tasks/git.rake", "tasks/manifest.rake", "tasks/post_load.rake", "tasks/rdoc.rake", "tasks/rubyforge.rake", "tasks/setup.rb", "tasks/test.rake", "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", "test/test_helper.rb"]
12
12
  s.has_rdoc = true
13
13
  s.homepage = %q{http://viget.rubyforge.com/acts_as_markup}
14
14
  s.rdoc_options = ["--main", "README.rdoc"]
@@ -23,23 +23,23 @@ Gem::Specification.new do |s|
23
23
  s.specification_version = 2
24
24
 
25
25
  if current_version >= 3 then
26
- s.add_runtime_dependency(%q<activesupport>, [">= 2.1.0"])
27
- s.add_runtime_dependency(%q<activerecord>, [">= 2.1.0"])
28
- s.add_runtime_dependency(%q<rdiscount>, [">= 1.2.7.1"])
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
29
  s.add_runtime_dependency(%q<RedCloth>, [">= 4.0.3"])
30
- s.add_runtime_dependency(%q<wikitext>, [">= 1.1.1"])
30
+ s.add_runtime_dependency(%q<wikitext>, [">= 1.2"])
31
31
  else
32
- s.add_dependency(%q<activesupport>, [">= 2.1.0"])
33
- s.add_dependency(%q<activerecord>, [">= 2.1.0"])
34
- s.add_dependency(%q<rdiscount>, [">= 1.2.7.1"])
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
35
  s.add_dependency(%q<RedCloth>, [">= 4.0.3"])
36
- s.add_dependency(%q<wikitext>, [">= 1.1.1"])
36
+ s.add_dependency(%q<wikitext>, [">= 1.2"])
37
37
  end
38
38
  else
39
- s.add_dependency(%q<activesupport>, [">= 2.1.0"])
40
- s.add_dependency(%q<activerecord>, [">= 2.1.0"])
41
- s.add_dependency(%q<rdiscount>, [">= 1.2.7.1"])
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
42
  s.add_dependency(%q<RedCloth>, [">= 4.0.3"])
43
- s.add_dependency(%q<wikitext>, [">= 1.1.1"])
43
+ s.add_dependency(%q<wikitext>, [">= 1.2"])
44
44
  end
45
45
  end
@@ -76,7 +76,7 @@ module ActiveRecord # :nodoc:
76
76
  rdoc_klass = 'RDocText'
77
77
  options[:language_column] ||= :markup_language
78
78
  else
79
- raise ActsAsMarkup::UnsportedMarkupLanguage, "#{options[:langauge]} is not a currently supported markup language."
79
+ raise ActsAsMarkup::UnsupportedMarkupLanguage, "#{options[:langauge]} is not a currently supported markup language."
80
80
  end
81
81
 
82
82
  options[:columns].each do |col|
@@ -2,20 +2,20 @@ require 'active_support'
2
2
 
3
3
  module ActsAsMarkup
4
4
  # :stopdoc:
5
- VERSION = '1.1.2'
5
+ VERSION = '1.2.0'
6
6
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
7
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
8
  # :startdoc:
9
9
 
10
10
  # This exception is raised when an unsupported markup language is supplied to acts_as_markup.
11
- class UnsportedMarkupLanguage < ArgumentError
11
+ class UnsupportedMarkupLanguage < ArgumentError
12
12
  end
13
13
 
14
14
  # This exception is raised when an unsupported Markdown library is set to the config value.
15
15
  class UnsportedMarkdownLibrary < ArgumentError
16
16
  end
17
17
 
18
- DEFAULT_MAKRDOWN_LIB = :rdiscount
18
+ DEFAULT_MARKDOWN_LIB = :rdiscount
19
19
 
20
20
  MARKDOWN_LIBS = { :rdiscount => {:class_name => "RDiscount",
21
21
  :lib_name => "rdiscount"},
@@ -28,7 +28,7 @@ module ActsAsMarkup
28
28
 
29
29
  LIBRARY_EXTENSIONS = Set.new(Dir[ActsAsMarkup::LIBPATH + 'acts_as_markup/exts/*.rb'].map {|file| File.basename(file, '.rb')}).delete('string')
30
30
 
31
- @@markdown_library = DEFAULT_MAKRDOWN_LIB
31
+ @@markdown_library = DEFAULT_MARKDOWN_LIB
32
32
  mattr_accessor :markdown_library
33
33
 
34
34
  # :stopdoc:
@@ -39,14 +39,14 @@ module ActsAsMarkup
39
39
  end
40
40
 
41
41
  # Returns the library path for the module. If any arguments are given,
42
- # they will be joined to the end of the libray path using
42
+ # they will be joined to the end of the library path using
43
43
  # <tt>File.join</tt>.
44
44
  #
45
45
  def self.libpath( *args )
46
46
  args.empty? ? LIBPATH : ::File.join(LIBPATH, *args)
47
47
  end
48
48
 
49
- # Returns the lpath for the module. If any arguments are given,
49
+ # Returns the path for the module. If any arguments are given,
50
50
  # they will be joined to the end of the path using
51
51
  # <tt>File.join</tt>.
52
52
  #
@@ -70,5 +70,6 @@ module ActsAsMarkup
70
70
 
71
71
  end # module ActsAsMarkup
72
72
 
73
- require 'acts_as_markup/exts/string'
73
+ require 'acts_as_markup/exts/object'
74
+ require 'acts_as_markup/stringlike'
74
75
  ActsAsMarkup.require_all_libs_relative_to __FILE__, 'acts'
@@ -1,6 +1,8 @@
1
1
  require 'maruku'
2
2
 
3
3
  class Maruku
4
+ include Stringlike
5
+
4
6
  attr_reader :text
5
7
 
6
8
  def initialize(s=nil, meta={})
@@ -0,0 +1 @@
1
+ Object.send :alias_method, :to_html, :to_s
@@ -1,6 +1,8 @@
1
1
  require 'peg_markdown'
2
2
 
3
3
  class PEGMarkdown
4
+ include Stringlike
5
+
4
6
  # used to be compatable with Rails/ActiveSupport
5
7
  def blank?
6
8
  self.text.blank?
@@ -1,6 +1,8 @@
1
1
  require 'rdiscount'
2
2
 
3
3
  class RDiscount
4
+ include Stringlike
5
+
4
6
  # Used to get the original Markdown text.
5
7
  def to_s
6
8
  self.text
@@ -0,0 +1,7 @@
1
+ # This mixin allows our markup objects (like RDiscount or RedCloth) to have
2
+ # all the normal string methods that are available.
3
+ module Stringlike
4
+ def method_missing(method, *params)
5
+ self.to_s.send(method, *params)
6
+ end
7
+ end
@@ -14,6 +14,8 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
14
14
  end
15
15
  @post = Post.create!(:title => 'Blah', :body => @markdown_text)
16
16
  end
17
+
18
+ should_act_like_a_string
17
19
 
18
20
  should "have a RDiscount object returned for the column value" do
19
21
  assert_kind_of RDiscount, @post.body
@@ -27,7 +29,7 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
27
29
  assert !@post.body.blank?
28
30
  end
29
31
 
30
- should "return formated html for a `to_html` method call on the column value" do
32
+ should "return formatted html for a `to_html` method call on the column value" do
31
33
  assert_match(/<h2(\s\w+\=['"]\w*['"])*\s*>\s*Markdown Test Text\s*<\/h2>/, @post.body.to_html)
32
34
  end
33
35
 
@@ -69,6 +71,8 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
69
71
  end
70
72
  @post = Post.create!(:title => 'Blah', :body => @markdown_text)
71
73
  end
74
+
75
+ should_act_like_a_string
72
76
 
73
77
  should "have a Ruby PEG Markdown object returned for the column value" do
74
78
  assert_kind_of PEGMarkdown, @post.body
@@ -124,6 +128,8 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
124
128
  end
125
129
  @post = Post.create!(:title => 'Blah', :body => @markdown_text)
126
130
  end
131
+
132
+ should_act_like_a_string
127
133
 
128
134
  should "have a BlueCloth object returned for the column value" do
129
135
  assert_kind_of BlueCloth, @post.body
@@ -179,6 +185,8 @@ class ActsAsMarkdownTest < ActsAsMarkupTestCase
179
185
  end
180
186
  @post = Post.create!(:title => 'Blah', :body => @markdown_text)
181
187
  end
188
+
189
+ should_act_like_a_string
182
190
 
183
191
  should "have a Maruku object returned for the column value" do
184
192
  assert_kind_of Maruku, @post.body
@@ -7,7 +7,7 @@ class ActsAsMarkupTest < ActsAsMarkupTestCase
7
7
 
8
8
  context 'acts_as_markup' do
9
9
  setup do
10
- ActsAsMarkup.markdown_library = ActsAsMarkup::DEFAULT_MAKRDOWN_LIB
10
+ ActsAsMarkup.markdown_library = ActsAsMarkup::DEFAULT_MARKDOWN_LIB
11
11
 
12
12
  @textile_text = "h2. Textile Test Text"
13
13
  class ::TextilePost < ActiveRecord::Base
@@ -76,7 +76,7 @@ class ActsAsMarkupTest < ActsAsMarkupTestCase
76
76
 
77
77
  context 'acts_as_markup with variable language' do
78
78
  setup do
79
- ActsAsMarkup.markdown_library = ActsAsMarkup::DEFAULT_MAKRDOWN_LIB
79
+ ActsAsMarkup.markdown_library = ActsAsMarkup::DEFAULT_MARKDOWN_LIB
80
80
  class ::VariablePost < ActiveRecord::Base
81
81
  acts_as_markup :language => :variable, :columns => [:body]
82
82
  end
@@ -325,7 +325,7 @@ class ActsAsMarkupTest < ActsAsMarkupTestCase
325
325
 
326
326
  context 'acts_as_markup with variable language setting the language column' do
327
327
  setup do
328
- ActsAsMarkup.markdown_library = ActsAsMarkup::DEFAULT_MAKRDOWN_LIB
328
+ ActsAsMarkup.markdown_library = ActsAsMarkup::DEFAULT_MARKDOWN_LIB
329
329
  class ::VariableLanguagePost < ActiveRecord::Base
330
330
  acts_as_markup :language => :variable, :columns => [:body], :language_column => :language_name
331
331
  end
@@ -567,7 +567,7 @@ class ActsAsMarkupTest < ActsAsMarkupTestCase
567
567
 
568
568
  context 'acts_as_markup with bad language name' do
569
569
  should 'raise exception when a non-supported language is passed to acts_as_markup' do
570
- assert_raise ActsAsMarkup::UnsportedMarkupLanguage do
570
+ assert_raise ActsAsMarkup::UnsupportedMarkupLanguage do
571
571
  class ::Post < ActiveRecord::Base
572
572
  acts_as_markup :language => :fake, :columns => [:body]
573
573
  end
@@ -1,4 +1,5 @@
1
1
  require 'test/unit'
2
+ require 'rubygems'
2
3
  require 'shoulda'
3
4
  require 'active_support'
4
5
  require 'active_support/test_case'
@@ -56,4 +57,11 @@ class ActsAsMarkupTestCase < ActiveSupport::TestCase
56
57
  def teardown
57
58
  teardown_db
58
59
  end
60
+
61
+ def self.should_act_like_a_string
62
+ should "act like a string" do
63
+ assert_equal @post.body.split(' '), ['##', 'Markdown', 'Test', 'Text']
64
+ assert @post.body.match(/Te[sx]t/)
65
+ end
66
+ end
59
67
  end
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.1.2
4
+ version: 1.2.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-08-22 00:00:00 -04:00
12
+ date: 2008-09-10 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.1.0
23
+ version: 2.1.1
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.0
33
+ version: 2.1.1
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rdiscount
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 1.2.7.1
43
+ version: 1.2.9
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: RedCloth
@@ -60,7 +60,7 @@ dependencies:
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 1.1.1
63
+ version: "1.2"
64
64
  version:
65
65
  description: Represent ActiveRecord Markdown, Textile, Wiki text, RDoc columns as Markdown, Textile Wikitext, RDoc objects using various external libraries to convert to HTML.
66
66
  email: brian.landau@viget.com
@@ -82,11 +82,12 @@ files:
82
82
  - lib/acts/as_markup.rb
83
83
  - lib/acts_as_markup.rb
84
84
  - lib/acts_as_markup/exts/maruku.rb
85
+ - lib/acts_as_markup/exts/object.rb
85
86
  - lib/acts_as_markup/exts/peg_markdown.rb
86
87
  - lib/acts_as_markup/exts/rdiscount.rb
87
88
  - lib/acts_as_markup/exts/rdoc.rb
88
- - lib/acts_as_markup/exts/string.rb
89
89
  - lib/acts_as_markup/exts/wikitext.rb
90
+ - lib/acts_as_markup/stringlike.rb
90
91
  - tasks/bones.rake
91
92
  - tasks/gem.rake
92
93
  - tasks/git.rake
@@ -1 +0,0 @@
1
- String.send :alias_method, :to_html, :to_s