hobofields 0.9.103 → 0.9.104

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
@@ -3,7 +3,7 @@ require 'active_record'
3
3
  ActiveRecord::ActiveRecordError # hack for https://rails.lighthouseapp.com/projects/8994/tickets/2577-when-using-activerecordassociations-outside-of-rails-a-nameerror-is-thrown
4
4
 
5
5
  RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
6
- RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} `which rubydoctest`"
6
+ RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"
7
7
 
8
8
  $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '/../hobofields/lib')
9
9
  $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '/../hobosupport/lib')
@@ -13,7 +13,8 @@ require 'hobofields'
13
13
  namespace "test" do
14
14
  desc "Run the doctests"
15
15
  task :doctest do |t|
16
- exit(1) if !system("#{RUBYDOCTEST} test/*.rdoctest")
16
+ files=Dir['test/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
17
+ exit(1) if !system("#{RUBYDOCTEST} #{files}")
17
18
  end
18
19
 
19
20
  desc "Run the unit tests"
@@ -375,7 +375,9 @@ module HoboFields
375
375
  end
376
376
 
377
377
  def drop_index(table, name)
378
- "remove_index :#{table}, :name => :#{name}"
378
+ # see https://hobo.lighthouseapp.com/projects/8324/tickets/566
379
+ # for why the rescue exists
380
+ "remove_index :#{table}, :name => :#{name} rescue ActiveRecord::StatementInvalid"
379
381
  end
380
382
 
381
383
  def format_options(options, type, changing=false)
data/lib/hobo_fields.rb CHANGED
@@ -9,7 +9,7 @@ end
9
9
 
10
10
  module HoboFields
11
11
 
12
- VERSION = "0.9.103"
12
+ VERSION = "0.9.104"
13
13
 
14
14
  extend self
15
15
 
@@ -103,10 +103,15 @@ module HoboFields
103
103
  # automatically load other rich types from app/rich_types/*.rb
104
104
  # don't assume we're in a Rails app
105
105
  if defined?(::Rails)
106
- Dir[File.join(::Rails.root, 'app', 'rich_types', '*.rb')].each do |f|
107
- # 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
108
- require f
106
+ plugins = Rails.configuration.plugin_loader.new(HoboFields.rails_initializer).plugins
107
+ ([::Rails.root] + plugins.map(&:directory)).each do |dir|
108
+ ActiveSupport::Dependencies.load_paths << File.join(dir, 'app', 'rich_types')
109
+ Dir[File.join(dir, 'app', 'rich_types', '*.rb')].each do |f|
110
+ # 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
+ require_dependency f
112
+ end
109
113
  end
114
+
110
115
  end
111
116
 
112
117
  # Monkey patch ActiveRecord so that the attribute read & write methods
@@ -155,6 +160,3 @@ module HoboFields
155
160
  end
156
161
 
157
162
  end
158
-
159
-
160
- HoboFields.enable if defined? ActiveRecord
data/rails/init.rb ADDED
@@ -0,0 +1,9 @@
1
+ module ::HoboFields
2
+ class << self
3
+ attr_accessor :rails_initializer
4
+ end
5
+ end
6
+ ::HoboFields.rails_initializer = initializer
7
+
8
+ require File.dirname(__FILE__) + "/../lib/hobofields"
9
+ HoboFields.enable
@@ -62,9 +62,9 @@ The source lives on GitHub as part of the main Hobo repo:
62
62
 
63
63
  - [http://github.com/tablatom/hobo](http://github.com/tablatom/hobo)
64
64
 
65
- The simplest way to install HoboFields as a plugin is to use the subversion mirror:
66
-
67
- svn export svn://hobocentral.net/hobo/tags/rel_0.7.5/hobofields vendor/plugins
65
+ To use hobofields 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
+ `hobofields` subdirectory into `/vendors/plugins`
68
68
 
69
69
  ## Rich Types
70
70
 
@@ -41,6 +41,7 @@ Require the module we're testing:
41
41
 
42
42
  >> require 'hobosupport'
43
43
  >> require 'hobofields'
44
+ >> HoboFields.enable
44
45
 
45
46
  ## Example Models
46
47
 
@@ -39,6 +39,7 @@ And we'll require:
39
39
 
40
40
  >> require 'hobosupport'
41
41
  >> require 'hobofields'
42
+ >> HoboFields.enable
42
43
 
43
44
  ## The migration generator -- introduction
44
45
 
@@ -275,7 +276,7 @@ foreign-key field. It also generates an index on the field.
275
276
  =>
276
277
  "remove_column :adverts, :category_id
277
278
 
278
- remove_index :adverts, :name => :index_adverts_on_category_id"
279
+ remove_index :adverts, :name => :index_adverts_on_category_id rescue ActiveRecord::StatementInvalid"
279
280
 
280
281
  Cleanup:
281
282
  {.hidden}
@@ -571,7 +572,7 @@ Adding a subclass or two should introduce the 'type' column and no other changes
571
572
  =>
572
573
  "remove_column :adverts, :type
573
574
 
574
- remove_index :adverts, :name => :index_adverts_on_type"
575
+ remove_index :adverts, :name => :index_adverts_on_type rescue ActiveRecord::StatementInvalid"
575
576
 
576
577
  Cleanup
577
578
  {.hidden}
@@ -33,6 +33,7 @@ And we'll require:
33
33
 
34
34
  >> require 'hobosupport'
35
35
  >> require 'hobofields'
36
+ >> HoboFields.enable
36
37
 
37
38
  OK we're ready to get going.
38
39
 
@@ -40,6 +40,7 @@ Finally we can require hobofields:
40
40
 
41
41
  >> require 'hobosupport'
42
42
  >> require 'hobofields'
43
+ >> HoboFields.enable
43
44
 
44
45
  ## `to_html` method
45
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobofields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.103
4
+ version: 0.9.104
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Locke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-10 00:00:00 -05:00
12
+ date: 2010-01-21 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - "="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.103
33
+ version: 0.9.104
34
34
  version:
35
35
  description:
36
36
  email: tom@tomlocke.com
@@ -45,7 +45,6 @@ files:
45
45
  - LICENSE.txt
46
46
  - README.txt
47
47
  - Rakefile
48
- - init.rb
49
48
  - lib/hobo_fields.rb
50
49
  - lib/hobo_fields/email_address.rb
51
50
  - lib/hobo_fields/enum_string.rb
@@ -66,6 +65,7 @@ files:
66
65
  - lib/hobo_fields/text.rb
67
66
  - lib/hobo_fields/textile_string.rb
68
67
  - lib/hobofields.rb
68
+ - rails/init.rb
69
69
  - rails_generators/hobo_migration/USAGE
70
70
  - rails_generators/hobo_migration/hobo_migration_generator.rb
71
71
  - rails_generators/hobo_migration/templates/migration.rb
data/init.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'hobosupport'
2
-
3
- # Use ActiveSupport to load if it hasn't been loaded already
4
- HoboFields