hobofields 1.1.0.pre0 → 1.1.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/hobo_fields.rb +11 -3
- data/lib/hobo_fields/enum_string.rb +1 -1
- data/lib/hobo_fields/model_extensions.rb +10 -11
- data/lib/hobo_fields/sanitize_html.rb +3 -3
- data/test/test_hobofield_model_generator.rb +1 -1
- metadata +14 -6
data/Rakefile
CHANGED
@@ -34,7 +34,7 @@ Jeweler::Tasks.new do |gemspec|
|
|
34
34
|
gemspec.homepage = "http://hobocentral.net/"
|
35
35
|
gemspec.authors = ["Tom Locke"]
|
36
36
|
gemspec.rubyforge_project = "hobo"
|
37
|
-
gemspec.add_dependency("rails", [">= 2.2.2"])
|
37
|
+
gemspec.add_dependency("rails", [">= 2.2.2", "< 3.0.0"])
|
38
38
|
gemspec.add_dependency("hobosupport", ["= #{HoboFields::VERSION}"])
|
39
39
|
end
|
40
40
|
Jeweler::GemcutterTasks.new
|
data/lib/hobo_fields.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'hobosupport'
|
2
2
|
|
3
|
-
ActiveSupport::Dependencies.
|
3
|
+
if ActiveSupport::Dependencies.respond_to?(:autoload_paths)
|
4
|
+
ActiveSupport::Dependencies.autoload_paths |= [ File.dirname(__FILE__)]
|
5
|
+
else
|
6
|
+
ActiveSupport::Dependencies.load_paths |= [ File.dirname(__FILE__)]
|
7
|
+
end
|
4
8
|
|
5
9
|
module Hobo
|
6
10
|
# Empty class to represent the boolean type.
|
@@ -9,7 +13,7 @@ end
|
|
9
13
|
|
10
14
|
module HoboFields
|
11
15
|
|
12
|
-
VERSION = "1.1.0.
|
16
|
+
VERSION = "1.1.0.pre2"
|
13
17
|
|
14
18
|
extend self
|
15
19
|
|
@@ -105,7 +109,11 @@ module HoboFields
|
|
105
109
|
if defined?(::Rails)
|
106
110
|
plugins = Rails.configuration.plugin_loader.new(HoboFields.rails_initializer).plugins
|
107
111
|
([::Rails.root] + plugins.map(&:directory)).each do |dir|
|
108
|
-
ActiveSupport::Dependencies.
|
112
|
+
if ActiveSupport::Dependencies.respond_to?(:autoload_paths)
|
113
|
+
ActiveSupport::Dependencies.autoload_paths << File.join(dir, 'app', 'rich_types')
|
114
|
+
else
|
115
|
+
ActiveSupport::Dependencies.load_paths << File.join(dir, 'app', 'rich_types')
|
116
|
+
end
|
109
117
|
Dir[File.join(dir, 'app', 'rich_types', '*.rb')].each do |f|
|
110
118
|
# TODO: should we complain if field_types doesn't get a new value? Might be useful to warn people if they're missing a register_type
|
111
119
|
require_dependency f
|
@@ -82,7 +82,7 @@ module HoboFields
|
|
82
82
|
COLUMN_TYPE = :string
|
83
83
|
|
84
84
|
def initialize(value)
|
85
|
-
super(self.class.detranslated_values.nil? ? value
|
85
|
+
super(self.class.detranslated_values.nil? ? value: (self.class.detranslated_values[value.to_s] || value))
|
86
86
|
end
|
87
87
|
|
88
88
|
def validate
|
@@ -87,18 +87,17 @@ module HoboFields
|
|
87
87
|
|
88
88
|
index_options = {}
|
89
89
|
index_options[:name] = options.delete(:index) if options.has_key?(:index)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
index(fkey, index_options) if index_options[:name]!=false
|
100
|
-
end
|
90
|
+
bt = belongs_to_without_field_declarations(name, options, &block)
|
91
|
+
refl = reflections[name.to_sym]
|
92
|
+
fkey = refl.primary_key_name
|
93
|
+
declare_field(fkey.to_sym, :integer, column_options)
|
94
|
+
if refl.options[:polymorphic]
|
95
|
+
declare_polymorphic_type_field(name, column_options)
|
96
|
+
index(["#{name}_type", fkey], index_options) if index_options[:name]!=false
|
97
|
+
else
|
98
|
+
index(fkey, index_options) if index_options[:name]!=false
|
101
99
|
end
|
100
|
+
bt
|
102
101
|
end
|
103
102
|
class << self
|
104
103
|
alias_method_chain :belongs_to, :field_declarations
|
@@ -4,10 +4,10 @@ module HoboFields
|
|
4
4
|
|
5
5
|
PERMITTED_TAGS = %w(a abbr acronym address b bdo big blockquote br caption center cite code colgroup dd del dfn dir
|
6
6
|
div dl dt em fieldset font h1 h2 h3 h4 h5 h6 i img ins kbd label legend li map menu ol optgroup
|
7
|
-
option p pre q s samp select small span strike strong sub sup tbody td textarea tfoot
|
7
|
+
option p pre q s samp select small span strike strong sub sup table tbody td textarea tfoot
|
8
8
|
th thead tr tt u ul var)
|
9
9
|
|
10
|
-
PERMITTED_ATTRIBUTES = %w(href title class style align name src label target)
|
10
|
+
PERMITTED_ATTRIBUTES = %w(href title class style align name src label target border)
|
11
11
|
|
12
12
|
class Helper; include ActionView::Helpers::SanitizeHelper; extend ActionView::Helpers::SanitizeHelper::ClassMethods; end
|
13
13
|
|
@@ -17,4 +17,4 @@ module HoboFields
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
end
|
20
|
+
end
|
@@ -4,7 +4,7 @@ require 'rails_generator'
|
|
4
4
|
# we get a SystemStackError on JRuby
|
5
5
|
exit(0) if defined? JRUBY_VERSION
|
6
6
|
|
7
|
-
require File.join(File.dirname(__FILE__),
|
7
|
+
require "./#{File.join(File.dirname(__FILE__), 'test_generator_helper.rb')}"
|
8
8
|
|
9
9
|
class TestHobofieldModelGenerator < Test::Unit::TestCase
|
10
10
|
include RubiGen::GeneratorTestHelper
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobofields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -1876988167
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 1.1.0.
|
10
|
+
- pre2
|
11
|
+
version: 1.1.0.pre2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Tom Locke
|
@@ -33,6 +33,14 @@ dependencies:
|
|
33
33
|
- 2
|
34
34
|
- 2
|
35
35
|
version: 2.2.2
|
36
|
+
- - <
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
hash: 7
|
39
|
+
segments:
|
40
|
+
- 3
|
41
|
+
- 0
|
42
|
+
- 0
|
43
|
+
version: 3.0.0
|
36
44
|
type: :runtime
|
37
45
|
version_requirements: *id001
|
38
46
|
- !ruby/object:Gem::Dependency
|
@@ -43,13 +51,13 @@ dependencies:
|
|
43
51
|
requirements:
|
44
52
|
- - "="
|
45
53
|
- !ruby/object:Gem::Version
|
46
|
-
hash: -
|
54
|
+
hash: -1876988167
|
47
55
|
segments:
|
48
56
|
- 1
|
49
57
|
- 1
|
50
58
|
- 0
|
51
|
-
-
|
52
|
-
version: 1.1.0.
|
59
|
+
- pre2
|
60
|
+
version: 1.1.0.pre2
|
53
61
|
type: :runtime
|
54
62
|
version_requirements: *id002
|
55
63
|
description:
|