vigetlabs-acts_as_markup 1.0.0 → 1.1.0

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.1.0 / 2008-08-12
2
+
3
+ * Use a default for markup language column name when the variable options is used.
4
+
1
5
  == 1.0.0 / 2008-08-11
2
6
 
3
7
  * Add support for Maruku Markdown Library.
data/README.rdoc CHANGED
@@ -87,7 +87,7 @@ By default RDiscount will be used.
87
87
  ==== Using +acts_as_markup+ with <tt>:variable</tt> language:
88
88
 
89
89
  class Post < ActiveRecrod
90
- acts_as_markup :language => :variable, :columns => [:body], :language_column => 'markup_language'
90
+ acts_as_markup :language => :variable, :columns => [:body]
91
91
  end
92
92
 
93
93
  @post = Post.find(:first)
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{acts_as_markup}
3
- s.version = "1.0.0"
3
+ s.version = "1.1.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-11}
7
+ s.date = %q{2008-08-12}
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"]
@@ -13,12 +13,13 @@ module ActiveRecord # :nodoc:
13
13
  # Markdown, Textile, Wikitext or RDoc content.
14
14
  # Then you can simply call <tt>.to_html</tt> method on the attribute.
15
15
  #
16
- # You can also specify the language as <tt>:variable</tt> you will then
17
- # need to add an additional option of <tt>:language_column</tt>. When
18
- # a value is accessed it will create the correct object (Markdown, Textile,
19
- # Wikitext or RDoc) based on the value of the language column. If any value
20
- # besides markdown, textile, wikitext, or RDoc is supplied for the markup
21
- # language the text will pass through as a string.
16
+ # You can also specify the language as <tt>:variable</tt>. The language used
17
+ # to process the column will be based on another column. By default a column
18
+ # named "<tt>markup_language</tt>" is used, but this can be changed by providing
19
+ # a <tt>:language_column</tt> option. When a value is accessed it will create
20
+ # the correct object (Markdown, Textile, Wikitext or RDoc) based on the value
21
+ # of the language column. If any value besides markdown, textile, wikitext, or
22
+ # RDoc is supplied for the markup language the text will pass through as a string.
22
23
  #
23
24
  #
24
25
  # ==== Examples
@@ -37,11 +38,11 @@ module ActiveRecord # :nodoc:
37
38
  # ===== Using variable language
38
39
  #
39
40
  # class Post < ActiveRecrod
40
- # acts_as_markup :language => :variable, :columns => [:body], :language_column => 'markup_language'
41
+ # acts_as_markup :language => :variable, :columns => [:body], :language_column => 'language_name'
41
42
  # end
42
43
  #
43
44
  # @post = Post.find(:first)
44
- # @post.markup_language # => "markdown"
45
+ # @post.language_name # => "markdown"
45
46
  # @post.body.to_s # => "## Markdown Headline"
46
47
  # @post.body.to_html # => "<h2> Markdown Headline</h2>"
47
48
  #
@@ -73,6 +74,7 @@ module ActiveRecord # :nodoc:
73
74
  textile_klass = 'RedCloth'
74
75
  wiki_klass = 'WikitextString'
75
76
  rdoc_klass = 'RDocText'
77
+ options[:language_column] ||= :markup_language
76
78
  else
77
79
  raise ActsAsMarkup::UnsportedMarkupLanguage, "#{options[:langauge]} is not a currently supported markup language."
78
80
  end
@@ -2,7 +2,7 @@ require 'active_support'
2
2
 
3
3
  module ActsAsMarkup
4
4
  # :stopdoc:
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
6
6
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
7
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
8
  # :startdoc:
@@ -78,7 +78,7 @@ class ActsAsMarkupTest < ActsAsMarkupTestCase
78
78
  setup do
79
79
  ActsAsMarkup.markdown_library = ActsAsMarkup::DEFAULT_MAKRDOWN_LIB
80
80
  class ::VariablePost < ActiveRecord::Base
81
- acts_as_markup :language => :variable, :columns => [:body], :language_column => :markup_language
81
+ acts_as_markup :language => :variable, :columns => [:body]
82
82
  end
83
83
  end
84
84
 
@@ -323,6 +323,28 @@ class ActsAsMarkupTest < ActsAsMarkupTestCase
323
323
  end
324
324
  end
325
325
 
326
+ context 'acts_as_markup with variable language setting the language column' do
327
+ setup do
328
+ ActsAsMarkup.markdown_library = ActsAsMarkup::DEFAULT_MAKRDOWN_LIB
329
+ class ::VariableLanguagePost < ActiveRecord::Base
330
+ acts_as_markup :language => :variable, :columns => [:body], :language_column => :language_name
331
+ end
332
+ end
333
+
334
+ should "use the correct language column" do
335
+ markdown_text = '## Markdown Test Text'
336
+ markdown_post = VariableLanguagePost.create!(:title => 'Blah', :body => markdown_text, :language_name => 'Markdown')
337
+
338
+ assert_kind_of RDiscount, markdown_post.body
339
+ assert_equal markdown_text, markdown_post.body.to_s
340
+ assert_match(/<h2(\s\w+\=['"]\w*['"])*\s*>\s*Markdown Test Text\s*<\/h2>/, markdown_post.body.to_html)
341
+ end
342
+
343
+ teardown do
344
+ VariableLanguagePost.delete_all
345
+ end
346
+ end
347
+
326
348
  context 'with a nil value for the text' do
327
349
  setup do
328
350
  @text = nil
data/test/test_helper.rb CHANGED
@@ -32,6 +32,13 @@ def setup_db
32
32
  t.column :markup_language, :string
33
33
  t.timestamps
34
34
  end
35
+
36
+ create_table :variable_language_posts do |t|
37
+ t.column :title, :string
38
+ t.column :body, :text
39
+ t.column :language_name, :string
40
+ t.timestamps
41
+ end
35
42
  end
36
43
  end
37
44
 
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.0.0
4
+ version: 1.1.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-11 00:00:00 -07:00
12
+ date: 2008-08-12 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency