hobo_fields 2.0.0.pre7 → 2.0.0.pre8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -3
- data/VERSION +1 -1
- data/hobo_fields.gemspec +1 -1
- data/lib/generators/hobo/model/templates/model_injection.rb.erb +1 -1
- data/lib/hobo_fields/types/markdown_string.rb +12 -1
- data/lib/hobo_fields/types/raw_markdown_string.rb +12 -1
- data/test/api.rdoctest +4 -4
- data/test/doc-only.rdoctest +5 -5
- data/test/generators.rdoctest +1 -3
- data/test/migration_generator.rdoctest +1 -1
- data/test/prepare_testapp.rb +1 -1
- data/test/rich_types.rdoctest +10 -10
- metadata +89 -72
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.
|
4
|
+
gem 'rails', '3.2.11'
|
5
5
|
gem 'yard'
|
6
6
|
gemspec :path => "../hobo_support"
|
7
7
|
gemspec
|
8
|
-
|
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.
|
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('
|
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")
|
@@ -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(
|
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? ? "" :
|
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.
|
data/test/doc-only.rdoctest
CHANGED
@@ -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/
|
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
|
|
data/test/generators.rdoctest
CHANGED
@@ -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
|
-
|
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
|
-
$
|
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
|
|
data/test/prepare_testapp.rb
CHANGED
@@ -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 '
|
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"
|
data/test/rich_types.rdoctest
CHANGED
@@ -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
|
-
#
|
150
|
-
|
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
|
151
|
+
=> "<p></div>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("
|
391
|
-
>> markdown.to_html
|
392
|
-
=> "<
|
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
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
26
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
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
|
-
|
43
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
44
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
58
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
72
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
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
|
-
|
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
|
-
|
142
|
-
|
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.
|
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:
|