hobofields 1.0.1 → 1.0.2

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 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
@@ -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 : self.class.detranslated_values[value.to_s])
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
@@ -86,18 +86,17 @@ module HoboFields
86
86
 
87
87
  index_options = {}
88
88
  index_options[:name] = options.delete(:index) if options.has_key?(:index)
89
-
90
- returning belongs_to_without_field_declarations(name, options, &block) do
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
99
- end
89
+ bt = belongs_to_without_field_declarations(name, options, &block)
90
+ refl = reflections[name.to_sym]
91
+ fkey = refl.primary_key_name
92
+ declare_field(fkey.to_sym, :integer, column_options)
93
+ if refl.options[:polymorphic]
94
+ declare_polymorphic_type_field(name, column_options)
95
+ index(["#{name}_type", fkey], index_options) if index_options[:name]!=false
96
+ else
97
+ index(fkey, index_options) if index_options[:name]!=false
100
98
  end
99
+ bt
101
100
  end
102
101
  class << self
103
102
  alias_method_chain :belongs_to, :field_declarations
data/lib/hobo_fields.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'hobosupport'
2
2
 
3
- ActiveSupport::Dependencies.load_paths |= [ File.dirname(__FILE__) ]
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.0.1"
16
+ VERSION = "1.0.2"
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.load_paths << File.join(dir, 'app', 'rich_types')
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
@@ -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__), "test_generator_helper.rb")
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,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobofields
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 1
9
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Tom Locke
@@ -14,35 +15,47 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-01 00:00:00 +01:00
18
+ date: 2010-11-12 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rails
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 2
29
32
  - 2
30
33
  - 2
31
34
  version: 2.2.2
35
+ - - <
36
+ - !ruby/object:Gem::Version
37
+ hash: 7
38
+ segments:
39
+ - 3
40
+ - 0
41
+ - 0
42
+ version: 3.0.0
32
43
  type: :runtime
33
44
  version_requirements: *id001
34
45
  - !ruby/object:Gem::Dependency
35
46
  name: hobosupport
36
47
  prerelease: false
37
48
  requirement: &id002 !ruby/object:Gem::Requirement
49
+ none: false
38
50
  requirements:
39
51
  - - "="
40
52
  - !ruby/object:Gem::Version
53
+ hash: 19
41
54
  segments:
42
55
  - 1
43
56
  - 0
44
- - 1
45
- version: 1.0.1
57
+ - 2
58
+ version: 1.0.2
46
59
  type: :runtime
47
60
  version_requirements: *id002
48
61
  description:
@@ -51,9 +64,8 @@ executables: []
51
64
 
52
65
  extensions: []
53
66
 
54
- extra_rdoc_files:
55
- - LICENSE.txt
56
- - README.txt
67
+ extra_rdoc_files: []
68
+
57
69
  files:
58
70
  - CHANGES.txt
59
71
  - LICENSE.txt
@@ -107,23 +119,27 @@ rdoc_options:
107
119
  require_paths:
108
120
  - lib
109
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
110
123
  requirements:
111
124
  - - ">="
112
125
  - !ruby/object:Gem::Version
126
+ hash: 3
113
127
  segments:
114
128
  - 0
115
129
  version: "0"
116
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
117
132
  requirements:
118
133
  - - ">="
119
134
  - !ruby/object:Gem::Version
135
+ hash: 3
120
136
  segments:
121
137
  - 0
122
138
  version: "0"
123
139
  requirements: []
124
140
 
125
141
  rubyforge_project: hobo
126
- rubygems_version: 1.3.6
142
+ rubygems_version: 1.3.7
127
143
  signing_key:
128
144
  specification_version: 3
129
145
  summary: Rich field types and migration generator for Rails