hobo_fields 1.3.3 → 1.4.0.pre2
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/Rakefile +3 -1
- data/VERSION +1 -1
- data/hobo_fields.gemspec +1 -1
- data/lib/generators/hobo/migration/migrator.rb +1 -1
- data/lib/hobo_fields/model.rb +1 -1
- data/lib/hobo_fields/types/email_address.rb +1 -1
- data/test/generators.rdoctest +8 -2
- data/test/interactive_primary_key.rdoctest +2 -0
- data/test/{migration_generator_comments.rdoctest → migration_generator_comments.rdoctestDISABLED} +1 -1
- data/test/prepare_testapp.rb +6 -3
- data/test/rich_types.rdoctest +7 -6
- metadata +60 -74
data/Rakefile
CHANGED
@@ -2,6 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'active_record'
|
3
3
|
require 'tmpdir'
|
4
4
|
|
5
|
+
include Rake::DSL
|
6
|
+
|
5
7
|
ActiveRecord::ActiveRecordError # hack for https://rails.lighthouseapp.com/projects/8994/tickets/2577-when-using-activerecordassociations-outside-of-rails-a-nameerror-is-thrown
|
6
8
|
|
7
9
|
RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
|
@@ -13,7 +15,7 @@ require 'hobo_support'
|
|
13
15
|
require 'hobo_fields'
|
14
16
|
|
15
17
|
GEM_ROOT = File.expand_path('../', __FILE__)
|
16
|
-
TESTAPP_PATH = File.join
|
18
|
+
TESTAPP_PATH = ENV['TESTAPP_PATH'] || File.join(Dir.tmpdir, 'hobo_fields_testapp')
|
17
19
|
BIN = File.expand_path('../bin/hobofields', __FILE__)
|
18
20
|
require 'hobo_support/common_tasks'
|
19
21
|
include HoboSupport::CommonTasks
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0.pre2
|
data/hobo_fields.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.add_runtime_dependency('hobo_support', ["= #{version}"])
|
15
15
|
s.add_development_dependency('rubydoctest', [">= 0"])
|
16
|
-
s.add_development_dependency('
|
16
|
+
s.add_development_dependency('RedCloth', [">= 0"]) # for testing rich types
|
17
17
|
s.add_development_dependency('bluecloth', [">= 0"]) # for testing rich types
|
18
18
|
|
19
19
|
s.executables = ["hobofields"]
|
@@ -7,7 +7,7 @@ module Generators
|
|
7
7
|
def self.from_reflection(refl)
|
8
8
|
result = self.new
|
9
9
|
result.join_table = refl.options[:join_table].to_s
|
10
|
-
result.foreign_keys = [refl.
|
10
|
+
result.foreign_keys = [refl.foreign_key.to_s, refl.association_foreign_key.to_s].sort
|
11
11
|
# this may fail in weird ways if HABTM is running across two DB connections (assuming that's even supported)
|
12
12
|
# figure that anybody who sets THAT up can deal with their own migrations...
|
13
13
|
result.connection = refl.active_record.connection
|
data/lib/hobo_fields/model.rb
CHANGED
@@ -92,7 +92,7 @@ module HoboFields
|
|
92
92
|
index_options[:name] = options.delete(:index) if options.has_key?(:index)
|
93
93
|
bt = belongs_to_without_field_declarations(name, options, &block)
|
94
94
|
refl = reflections[name.to_sym]
|
95
|
-
fkey = refl.
|
95
|
+
fkey = refl.foreign_key
|
96
96
|
declare_field(fkey.to_sym, :integer, column_options)
|
97
97
|
if refl.options[:polymorphic]
|
98
98
|
declare_polymorphic_type_field(name, column_options)
|
@@ -15,7 +15,7 @@ module HoboFields
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_html(xmldoctype = true)
|
18
|
-
ERB::Util.html_escape(self).sub('@', " at ").gsub('.', ' dot ')
|
18
|
+
ERB::Util.html_escape(self).sub('@', " at ").gsub('.', ' dot ').html_safe
|
19
19
|
end
|
20
20
|
|
21
21
|
HoboFields.register_type(:email_address, self)
|
data/test/generators.rdoctest
CHANGED
@@ -28,11 +28,17 @@ doctest: test file exists
|
|
28
28
|
|
29
29
|
doctest: test content matches
|
30
30
|
>> File.read 'test/unit/alpha/beta_test.rb'
|
31
|
-
=>
|
31
|
+
=>
|
32
|
+
require 'test_helper'
|
32
33
|
|
34
|
+
class Alpha::BetaTest < ActiveSupport::TestCase
|
35
|
+
# test "the truth" do
|
36
|
+
# assert true
|
37
|
+
# end
|
38
|
+
end
|
33
39
|
|
34
40
|
doctest: fixture file exists
|
35
|
-
>> File.exist? 'test/fixtures/alpha/
|
41
|
+
>> File.exist? 'test/fixtures/alpha/beta.yml'
|
36
42
|
=> true
|
37
43
|
|
38
44
|
|
@@ -31,6 +31,7 @@ And requires also that you enter the right choice when prompted. OK we're ready
|
|
31
31
|
class Foo < ActiveRecord::Base
|
32
32
|
set_primary_key "id"
|
33
33
|
end
|
34
|
+
puts "\n\e[45m Please enter 'id' (no quotes) at the next prompt \e[0m"
|
34
35
|
>> Rails::Generators.invoke 'hobo:migration', %w(-n -m)
|
35
36
|
>> Foo.primary_key
|
36
37
|
=> 'id'
|
@@ -42,6 +43,7 @@ And requires also that you enter the right choice when prompted. OK we're ready
|
|
42
43
|
class Foo < ActiveRecord::Base
|
43
44
|
set_primary_key "foo_id"
|
44
45
|
end
|
46
|
+
puts "\n\e[45m Please enter 'drop id' (no quotes) at the next prompt \e[0m"
|
45
47
|
>> Rails::Generators.invoke 'hobo:migration', %w(-n -m)
|
46
48
|
>> Foo.primary_key
|
47
49
|
=> 'foo_id'
|
data/test/{migration_generator_comments.rdoctest → migration_generator_comments.rdoctestDISABLED}
RENAMED
@@ -5,7 +5,7 @@ Our test requires to prepare the testapp for a different environment:
|
|
5
5
|
|
6
6
|
doctest_require: ENV["RAILS_ENV"] = 'mysql_test'; 'prepare_testapp'
|
7
7
|
|
8
|
-
>> system "cd #{TESTAPP_PATH} && rake db:setup"
|
8
|
+
>> system "cd #{TESTAPP_PATH} && rake --trace db:setup"
|
9
9
|
=> true
|
10
10
|
|
11
11
|
>> p Rails.env
|
data/test/prepare_testapp.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
|
3
|
-
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
TESTAPP_PATH = ENV['TESTAPP_PATH'] || File.join(Dir.tmpdir, 'hobo_fields_testapp')
|
5
|
+
system %(rake test:prepare_testapp TESTAPP_PATH=#{TESTAPP_PATH})
|
6
|
+
system %(echo "gem 'bluecloth'" >> #{TESTAPP_PATH}/Gemfile)
|
7
|
+
system %(echo "gem 'RedCloth'" >> #{TESTAPP_PATH}/Gemfile)
|
4
8
|
FileUtils.chdir TESTAPP_PATH
|
5
9
|
require "#{TESTAPP_PATH}/config/environment"
|
6
10
|
require 'rails/generators'
|
7
11
|
Rails::Generators.configure!
|
8
|
-
|
data/test/rich_types.rdoctest
CHANGED
@@ -97,7 +97,7 @@ Provides validation of correct email address format.
|
|
97
97
|
|
98
98
|
>> nasty = HoboFields::Types::EmailAddress.new("foo<nasty><nasty>@baa.com")
|
99
99
|
>> nasty.to_html
|
100
|
-
=> "foo<nasty><nasty> at baa dot com"
|
100
|
+
=> "foo<nasty>&lt;nasty&gt; at baa dot com"
|
101
101
|
>> nasty.to_html.html_safe?
|
102
102
|
=> true
|
103
103
|
|
@@ -134,7 +134,6 @@ Provides validation of correct email address format.
|
|
134
134
|
|
135
135
|
`HoboFields::Types::MarkdownString` provides a `to_html` that renders markdown syntax into html. It requires the bluecloth gem.
|
136
136
|
|
137
|
-
>> require 'bluecloth'
|
138
137
|
>> markdown = HoboFields::Types::MarkdownString.new %(
|
139
138
|
This is a heading
|
140
139
|
=================
|
@@ -158,7 +157,6 @@ Provides validation of correct email address format.
|
|
158
157
|
|
159
158
|
`HoboFields::Types::TextileString` provides a `to_html` that renders markdown syntax into html. It requires the redcloth gem.
|
160
159
|
|
161
|
-
>> require 'redcloth'
|
162
160
|
>> textile = HoboFields::Types::TextileString.new %(
|
163
161
|
Text can be _emphasised_
|
164
162
|
)
|
@@ -242,9 +240,12 @@ restrict the column type.
|
|
242
240
|
>> Vault2.create!(:content => {:key => "in Vault"})
|
243
241
|
>> Vault2.first.content
|
244
242
|
=> {:key => "in Vault"}
|
245
|
-
>> Vault2.
|
246
|
-
>> Vault2.
|
247
|
-
|
243
|
+
>> puts Vault2.count
|
244
|
+
>> v = Vault2.create!(:content => 17)
|
245
|
+
>> Vault2.count
|
246
|
+
=> 2 # Invalid type is successfully created...
|
247
|
+
>> v.reload rescue 'broken' # ActiveRecord::SerializationTypeMismatch
|
248
|
+
=> 'broken'
|
248
249
|
|
249
250
|
## Enum Strings
|
250
251
|
|
metadata
CHANGED
@@ -1,87 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobo_fields
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: 6
|
5
|
+
version: 1.4.0.pre2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Tom Locke
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2012-03-28 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: hobo_support
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - '='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.3.3
|
22
|
-
type: :runtime
|
23
17
|
prerelease: false
|
24
|
-
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
19
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
30
|
-
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.4.0.pre2
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
31
27
|
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
28
|
prerelease: false
|
40
|
-
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
30
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version:
|
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'
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
54
35
|
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: RedCloth
|
55
39
|
prerelease: false
|
56
|
-
|
57
|
-
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
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
65
41
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version:
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
70
46
|
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bluecloth
|
71
50
|
prerelease: false
|
72
|
-
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
52
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
78
59
|
description: Rich field types and migration generator for Rails
|
79
60
|
email: tom@tomlocke.com
|
80
|
-
executables:
|
61
|
+
executables:
|
81
62
|
- hobofields
|
82
63
|
extensions: []
|
64
|
+
|
83
65
|
extra_rdoc_files: []
|
84
|
-
|
66
|
+
|
67
|
+
files:
|
85
68
|
- CHANGES.txt
|
86
69
|
- LICENSE.txt
|
87
70
|
- README.txt
|
@@ -121,33 +104,36 @@ files:
|
|
121
104
|
- test/generators.rdoctest
|
122
105
|
- test/interactive_primary_key.rdoctest
|
123
106
|
- test/migration_generator.rdoctest
|
124
|
-
- test/migration_generator_comments.
|
107
|
+
- test/migration_generator_comments.rdoctestDISABLED
|
125
108
|
- test/prepare_testapp.rb
|
126
109
|
- test/rich_types.rdoctest
|
127
110
|
homepage: http://hobocentral.net
|
128
111
|
licenses: []
|
112
|
+
|
129
113
|
post_install_message:
|
130
|
-
rdoc_options:
|
114
|
+
rdoc_options:
|
131
115
|
- --charset=UTF-8
|
132
|
-
require_paths:
|
116
|
+
require_paths:
|
133
117
|
- lib
|
134
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
119
|
none: false
|
136
|
-
requirements:
|
137
|
-
- -
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version:
|
140
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "0"
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
125
|
none: false
|
142
|
-
requirements:
|
143
|
-
- -
|
144
|
-
- !ruby/object:Gem::Version
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
145
129
|
version: 1.3.6
|
146
130
|
requirements: []
|
131
|
+
|
147
132
|
rubyforge_project: hobo
|
148
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.17
|
149
134
|
signing_key:
|
150
135
|
specification_version: 3
|
151
136
|
summary: Rich field types and migration generator for Rails
|
152
137
|
test_files: []
|
138
|
+
|
153
139
|
has_rdoc:
|