hobo_fields 2.0.0.pre7 → 2.0.0.pre8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,9 +1,13 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'rubydoctest', :git => 'git://github.com/bryanlarsen/rubydoctest.git'
4
- gem 'rails', '3.2.8'
4
+ gem 'rails', '3.2.11'
5
5
  gem 'yard'
6
6
  gemspec :path => "../hobo_support"
7
7
  gemspec
8
- gem 'sqlite3'
9
-
8
+ platform :ruby do
9
+ gem 'sqlite3'
10
+ end
11
+ platform :jruby do
12
+ gem 'activerecord-jdbcsqlite3-adapter'
13
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.pre7
1
+ 2.0.0.pre8
data/hobo_fields.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.add_runtime_dependency('hobo_support', ["= #{version}"])
15
15
  s.add_development_dependency('rubydoctest', [">= 0"])
16
16
  s.add_development_dependency('RedCloth', [">= 0"]) # for testing rich types
17
- s.add_development_dependency('bluecloth', [">= 0"]) # for testing rich types
17
+ s.add_development_dependency('kramdown', [">= 0"]) # for testing rich types
18
18
 
19
19
  s.executables = ["hobofields"]
20
20
  s.files = `git ls-files -x #{name}/* -z`.split("\0")
@@ -7,7 +7,7 @@
7
7
  timestamps
8
8
  <% end -%>
9
9
  end
10
- attr_accessible <%= accessible_attributes.map {|a| ":#{a.name}"}.join ", " %>
10
+ attr_accessible <%= accessible_attributes.map {|a| ":#{a}"}.join ", " %>
11
11
 
12
12
  <% for bt in bts -%>
13
13
  belongs_to :<%= bt %>
@@ -6,8 +6,19 @@ module HoboFields
6
6
 
7
7
  HoboFields.register_type(:markdown, self)
8
8
 
9
+ @@markdown_class = case
10
+ when defined?(RDiscount)
11
+ RDiscount
12
+ when defined?(Kramdown)
13
+ Kramdown::Document
14
+ when defined?(Maruku)
15
+ Maruku
16
+ else
17
+ Markdown
18
+ end
19
+
9
20
  def to_html(xmldoctype = true)
10
- blank? ? "" : HoboFields::SanitizeHtml.sanitize(Markdown.new(self).to_html)
21
+ blank? ? "" : HoboFields::SanitizeHtml.sanitize(@@markdown_class.new(self).to_html)
11
22
  end
12
23
 
13
24
  end
@@ -2,10 +2,21 @@ module HoboFields
2
2
  module Types
3
3
  class RawMarkdownString < HoboFields::Types::Text
4
4
 
5
+ @@markdown_class = case
6
+ when defined?(RDiscount)
7
+ RDiscount
8
+ when defined?(Kramdown)
9
+ Kramdown::Document
10
+ when defined?(Maruku)
11
+ Maruku
12
+ else
13
+ Markdown
14
+ end
15
+
5
16
  HoboFields.register_type(:raw_markdown, self)
6
17
 
7
18
  def to_html(xmldoctype = true)
8
- blank? ? "" : Markdown.new(self).to_html.html_safe
19
+ blank? ? "" : @@markdown_class.new(self).to_html.html_safe
9
20
  end
10
21
 
11
22
  end
data/test/api.rdoctest CHANGED
@@ -13,11 +13,11 @@ Let's define some example models that we can use to demonstrate the API. With Ho
13
13
 
14
14
  $ rails generate hobo:model advert title:string body:text contact_address:email_address
15
15
 
16
+ This will generate the test, fixture and a model file like this:
17
+
16
18
  >> Rails::Generators.invoke 'hobo:model', %w(advert title:string body:text contact_address:email_address)
17
19
  {.hidden}
18
20
 
19
- This will generate the test, fixture and a model file like this:
20
-
21
21
  class Advert < ActiveRecord::Base
22
22
  fields do
23
23
  title :string
@@ -33,12 +33,12 @@ The migration generator uses this information to create a migration. The followi
33
33
 
34
34
  $ rails generate hobo:migration -n -m
35
35
 
36
+ We're now ready to start demonstrating the API
37
+
36
38
  >> Rails::Generators.invoke 'hobo:migration', %w(-n -m)
37
39
  >> Rails::Generators.invoke 'hobo:migration', %w(-n -m)
38
40
  {.hidden}
39
41
 
40
- We're now ready to start demonstrating the API
41
-
42
42
  ## The Basics
43
43
 
44
44
  The main feature of HoboFields, aside from the migration generator, is the ability to declare rich types for your fields. For example, you can declare that a field is an email address, and the field will be automatically validated for correct email address syntax.
@@ -16,6 +16,10 @@ First off, if you're using the migration generator outside of Hobo, do remember
16
16
 
17
17
  $ rails generate model blog_post --skip-migration
18
18
 
19
+ If you're using Hobo:
20
+
21
+ $ rails generate hobo:model blog_post
22
+
19
23
  Now edit your model as follows:
20
24
 
21
25
  class BlogPost < ActiveRecord::Base
@@ -60,11 +64,7 @@ The simplest and recommended way to install HoboFields is as a gem:
60
64
 
61
65
  The source lives on GitHub as part of the main Hobo repo:
62
66
 
63
- - [http://github.com/tablatom/hobo](http://github.com/tablatom/hobo)
64
-
65
- To use hobo_fields as a plugin is not as simple as it should be. You
66
- will have to clone `git://github.com/tablatom/hobo` and then copy the
67
- `hobo_fields` subdirectory into `/vendors/plugins`
67
+ - [http://github.com/Hobo/hobo](http://github.com/Hobo/hobo)
68
68
 
69
69
  ## Rich Types
70
70
 
@@ -54,7 +54,5 @@ doctest: db file exists
54
54
  => true
55
55
 
56
56
  doctest: Alpha::Beta class exists
57
- >> Alpha::Beta.connection.schema_cache.clear!
58
- >> Alpha::Beta.reset_column_information
59
57
  >> Alpha::Beta
60
- => Alpha::Beta(id: integer, one: string, two: integer)
58
+ # will error if class doesn't exist
@@ -17,7 +17,7 @@ The migration generator works by:
17
17
 
18
18
  Normally you would run the migration generator as a regular Rails generator. You would type
19
19
 
20
- $ script/generator hobo_migration
20
+ $ rails generate hobo:migration
21
21
 
22
22
  in your Rails app, and the migration file would be created in `db/migrate`.
23
23
 
@@ -3,7 +3,7 @@ require 'tmpdir'
3
3
 
4
4
  TESTAPP_PATH = ENV['TESTAPP_PATH'] || File.join(Dir.tmpdir, 'hobo_fields_testapp')
5
5
  system %(rake test:prepare_testapp TESTAPP_PATH=#{TESTAPP_PATH})
6
- system %(echo "gem 'bluecloth'" >> #{TESTAPP_PATH}/Gemfile)
6
+ system %(echo "gem 'kramdown'" >> #{TESTAPP_PATH}/Gemfile)
7
7
  system %(echo "gem 'RedCloth'" >> #{TESTAPP_PATH}/Gemfile)
8
8
  FileUtils.chdir TESTAPP_PATH
9
9
  require "#{TESTAPP_PATH}/config/environment"
@@ -132,8 +132,7 @@ Provides validation of correct email address format.
132
132
 
133
133
 
134
134
  ### `HoboFields::Types::MarkdownString`
135
-
136
- `HoboFields::Types::MarkdownString` provides a `to_html` that renders markdown syntax into html. It requires the bluecloth gem.
135
+ `HoboFields::Types::MarkdownString` provides a `to_html` that renders markdown syntax into html. It looks for RDiscount, Kramdown, Maruku or BlueCloth in that order.
137
136
 
138
137
  >> markdown = HoboFields::Types::MarkdownString.new %(
139
138
  This is a heading
@@ -141,16 +140,17 @@ Provides validation of correct email address format.
141
140
 
142
141
  And text can be *emphasised*
143
142
  )
144
- >> markdown.to_html
143
+ >> markdown.to_html.strip
145
144
  => "<h1>This is a heading</h1>\n\n<p>And text can be <em>emphasised</em></p>"
146
145
  >> markdown.to_html.html_safe?
147
146
  => true
148
147
 
149
- # some unsafe html fragements are removed by `to_html`,
150
- # but there's no guarantees that it is well-formed
151
- >> markdown = HoboFields::Types::MarkdownString.new("</div>>>p1<script>p2")
148
+ # unsafe html behaviour depends on the parser used.
149
+ >> markdown = HoboFields::Types::MarkdownString.new("</div>p1<script>p2")
152
150
  >> markdown.to_html
153
- => "<p></div>>>p1</p>"
151
+ => "<p>&lt;/div&gt;p1</p>\n"
152
+ # Bluecloth would return
153
+ # => "<p></div>p1</p>"
154
154
  >> markdown.to_html.html_safe?
155
155
  => true
156
156
 
@@ -387,9 +387,9 @@ Translations only work with named EnumString's. The recommended way of naming t
387
387
 
388
388
  # no safety treatments are done by `to_html`.
389
389
  # even if `markdown.to_html` is actually unsafe, it is marked as html_safe.
390
- >> markdown = HoboFields::Types::RawMarkdownString.new("</div>>>p1<script>p2")
391
- >> markdown.to_html
392
- => "<p></div>>>p1<script>p2</p>"
390
+ >> markdown = HoboFields::Types::RawMarkdownString.new("<script>foo</script>")
391
+ >> markdown.to_html.strip
392
+ => "<script>foo</script>"
393
393
  >> markdown.to_html.html_safe?
394
394
  => true
395
395
 
metadata CHANGED
@@ -1,87 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hobo_fields
3
- version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre7
3
+ version: !ruby/object:Gem::Version
4
+ hash: 554064403
5
5
  prerelease: 6
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ - pre
11
+ - 8
12
+ version: 2.0.0.pre8
6
13
  platform: ruby
7
- authors:
14
+ authors:
8
15
  - Tom Locke
9
16
  autorequire:
10
17
  bindir: bin
11
18
  cert_chain: []
12
- date: 2012-12-06 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
19
+
20
+ date: 2013-02-04 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
15
23
  name: hobo_support
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - '='
20
- - !ruby/object:Gem::Version
21
- version: 2.0.0.pre7
22
- type: :runtime
23
24
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
+ requirement: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
- requirements:
27
- - - '='
28
- - !ruby/object:Gem::Version
29
- version: 2.0.0.pre7
30
- - !ruby/object:Gem::Dependency
27
+ requirements:
28
+ - - "="
29
+ - !ruby/object:Gem::Version
30
+ hash: 554064403
31
+ segments:
32
+ - 2
33
+ - 0
34
+ - 0
35
+ - pre
36
+ - 8
37
+ version: 2.0.0.pre8
38
+ type: :runtime
39
+ version_requirements: *id001
40
+ - !ruby/object:Gem::Dependency
31
41
  name: rubydoctest
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
42
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
43
+ requirement: &id002 !ruby/object:Gem::Requirement
41
44
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: RedCloth
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ hash: 3
49
+ segments:
50
+ - 0
51
+ version: "0"
54
52
  type: :development
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: RedCloth
55
56
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
+ requirement: &id003 !ruby/object:Gem::Requirement
57
58
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: bluecloth
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
70
66
  type: :development
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: kramdown
71
70
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
71
+ requirement: &id004 !ruby/object:Gem::Requirement
73
72
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ type: :development
81
+ version_requirements: *id004
78
82
  description: Rich field types and migration generator for Rails
79
83
  email: tom@tomlocke.com
80
- executables:
84
+ executables:
81
85
  - hobofields
82
86
  extensions: []
87
+
83
88
  extra_rdoc_files: []
84
- files:
89
+
90
+ files:
85
91
  - CHANGES.txt
86
92
  - Gemfile
87
93
  - LICENSE.txt
@@ -128,28 +134,39 @@ files:
128
134
  - test_responses.txt
129
135
  homepage: http://hobocentral.net
130
136
  licenses: []
137
+
131
138
  post_install_message:
132
- rdoc_options:
139
+ rdoc_options:
133
140
  - --charset=UTF-8
134
- require_paths:
141
+ require_paths:
135
142
  - lib
136
- required_ruby_version: !ruby/object:Gem::Requirement
143
+ required_ruby_version: !ruby/object:Gem::Requirement
137
144
  none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ hash: 3
149
+ segments:
150
+ - 0
151
+ version: "0"
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
153
  none: false
144
- requirements:
145
- - - ! '>='
146
- - !ruby/object:Gem::Version
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ hash: 23
158
+ segments:
159
+ - 1
160
+ - 3
161
+ - 6
147
162
  version: 1.3.6
148
163
  requirements: []
164
+
149
165
  rubyforge_project: hobo
150
- rubygems_version: 1.8.24
166
+ rubygems_version: 1.8.25
151
167
  signing_key:
152
168
  specification_version: 3
153
169
  summary: Rich field types and migration generator for Rails
154
170
  test_files: []
171
+
155
172
  has_rdoc: