hobo 1.3.0.pre13 → 1.3.0.pre14

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/rdoctask'
3
3
  require 'rake/testtask'
4
+ require 'tmpdir'
4
5
 
5
6
  require 'active_record'
6
7
  ActiveRecord::ActiveRecordError # hack for https://rails.lighthouseapp.com/projects/8994/tickets/2577-when-using-activerecordassociations-outside-of-rails-a-nameerror-is-thrown
@@ -14,7 +15,7 @@ RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).
14
15
  RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"
15
16
 
16
17
  GEM_ROOT = File.expand_path('../', __FILE__)
17
- TESTAPP_PATH = '/tmp/hobo_testapp'
18
+ TESTAPP_PATH = File.join Dir.tmpdir, 'hobo_testapp'
18
19
  BIN = File.expand_path('../bin/hobo', __FILE__)
19
20
  require 'hobo_support/common_tasks'
20
21
  include HoboSupport::CommonTasks
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre13
1
+ 1.3.0.pre14
@@ -9,7 +9,7 @@ module Generators
9
9
  attr_reader :subsite, :controller, :model, :record, :records
10
10
 
11
11
  def initialize(subsite, controller)
12
- raise "#{controller} is not a Hobo::Controller::Model" unless controller < ::Hobo::Controller::Model
12
+ raise ::Hobo::Error, "#{controller} is not a Hobo::Controller::Model" unless controller < ::Hobo::Controller::Model
13
13
  @subsite = subsite
14
14
  @controller = controller
15
15
  @model = controller.model
@@ -53,7 +53,7 @@ module Generators
53
53
  routes = []
54
54
  controller.owner_actions.each_pair do |owner, actions|
55
55
  collection_refl = model.reverse_reflection(owner)
56
- raise Hobo::Error, "Hob routing error -- can't find reverse association for #{model}##{owner} " +
56
+ raise ::Hobo::Error, "Hob routing error -- can't find reverse association for #{model}##{owner} " +
57
57
  "(e.g. the :has_many that corresponds to a :belongs_to)" if collection_refl.nil?
58
58
  collection = collection_refl.name
59
59
  owner_class = model.reflections[owner].klass.name.underscore
data/lib/hobo/engine.rb CHANGED
@@ -13,6 +13,7 @@ module Hobo
13
13
  h.routes_path = Pathname.new File.expand_path('config/hobo_routes.rb', Rails.root)
14
14
  h.rapid_generators_path = Pathname.new File.expand_path('lib/hobo/rapid/generators', Hobo.root)
15
15
  h.auto_taglibs_path = Pathname.new File.expand_path('app/views/taglibs/auto', Rails.root)
16
+ h.read_only_file_system = !!ENV['HEROKU_TYPE']
16
17
  end
17
18
 
18
19
  ActiveSupport.on_load(:action_controller) do
@@ -27,6 +28,7 @@ module Hobo
27
28
  require 'hobo/extensions/active_record/hobo_methods'
28
29
  require 'hobo/extensions/active_record/permissions'
29
30
  require 'hobo/extensions/active_record/scopes'
31
+ require 'hobo/extensions/active_record/relation_with_origin'
30
32
  require 'hobo/extensions/active_model/name'
31
33
  require 'hobo/extensions/active_model/translation'
32
34
  end
@@ -47,18 +49,28 @@ module Hobo
47
49
  initializer 'hobo.routes' do |app|
48
50
  h = app.config.hobo
49
51
  # generate at first boot, so no manual generation is required
50
- Rails::Generators.invoke('hobo:routes', %w[-f -q]) unless File.exists?(h.routes_path)
52
+ unless File.exists?(h.routes_path)
53
+ if h.read_only_file_system
54
+ raise Hobo::Error, "No #{h.routes_path} found!"
55
+ else
56
+ Rails::Generators.invoke('hobo:routes', %w[-f -q])
57
+ end
58
+ end
51
59
  app.routes_reloader.paths << h.routes_path
52
- app.config.to_prepare do
53
- Rails::Generators.configure!
54
- # generate before each request in development
55
- Rails::Generators.invoke('hobo:routes', %w[-f -q])
60
+ unless h.read_only_file_system
61
+ app.config.to_prepare do
62
+ Rails::Generators.configure!
63
+ # generate before each request in development
64
+ Rails::Generators.invoke('hobo:routes', %w[-f -q])
65
+ end
56
66
  end
57
67
  end
58
68
 
59
69
  initializer 'hobo.dryml' do |app|
60
- app.config.to_prepare do
61
- Dryml::DrymlGenerator.run
70
+ unless app.config.hobo.read_only_file_system
71
+ app.config.to_prepare do
72
+ Dryml::DrymlGenerator.run
73
+ end
62
74
  end
63
75
  end
64
76
 
@@ -0,0 +1,28 @@
1
+ module ActiveRecord
2
+
3
+ class Relation
4
+ attr_accessor :origin, :origin_attribute
5
+ end
6
+
7
+ module Associations
8
+ class AssociationCollection
9
+
10
+ def scoped_with_origin
11
+ relation = scoped_without_origin.clone
12
+ relation.origin = @owner
13
+ relation.origin_attribute = @reflection.name
14
+ relation
15
+ end
16
+ alias_method_chain :scoped, :origin
17
+
18
+ def method_missing_with_origin(method, *args)
19
+ res = method_missing_without_origin(method, *args)
20
+ res.origin = @owner if res.respond_to?(:origin)
21
+ res.origin_attribute = @reflection.name if res.respond_to?(:origin_attribute)
22
+ res
23
+ end
24
+ alias_method_chain :method_missing, :origin
25
+
26
+ end
27
+ end
28
+ end
data/lib/hobo/model.rb CHANGED
@@ -333,6 +333,11 @@ module Hobo
333
333
  class_name.safe_constantize or Object.class_eval("class #{class_name} < Hobo::ViewHints; end; #{class_name}")
334
334
  end
335
335
 
336
+ def table_exists?
337
+ @table_exists_cache = super if @table_exists_cache.nil?
338
+ @table_exists_cache
339
+ end
340
+
336
341
 
337
342
  end # --- of ClassMethods --- #
338
343
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1637175964
4
+ hash: -1637175963
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
- - pre13
11
- version: 1.3.0.pre13
10
+ - pre14
11
+ version: 1.3.0.pre14
12
12
  platform: ruby
13
13
  authors:
14
14
  - Tom Locke
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-20 00:00:00 -04:00
19
+ date: 2010-10-27 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -59,13 +59,13 @@ dependencies:
59
59
  requirements:
60
60
  - - "="
61
61
  - !ruby/object:Gem::Version
62
- hash: -1637175964
62
+ hash: -1637175963
63
63
  segments:
64
64
  - 1
65
65
  - 3
66
66
  - 0
67
- - pre13
68
- version: 1.3.0.pre13
67
+ - pre14
68
+ version: 1.3.0.pre14
69
69
  type: :runtime
70
70
  version_requirements: *id003
71
71
  - !ruby/object:Gem::Dependency
@@ -76,13 +76,13 @@ dependencies:
76
76
  requirements:
77
77
  - - "="
78
78
  - !ruby/object:Gem::Version
79
- hash: -1637175964
79
+ hash: -1637175963
80
80
  segments:
81
81
  - 1
82
82
  - 3
83
83
  - 0
84
- - pre13
85
- version: 1.3.0.pre13
84
+ - pre14
85
+ version: 1.3.0.pre14
86
86
  type: :runtime
87
87
  version_requirements: *id004
88
88
  - !ruby/object:Gem::Dependency
@@ -93,13 +93,13 @@ dependencies:
93
93
  requirements:
94
94
  - - "="
95
95
  - !ruby/object:Gem::Version
96
- hash: -1637175964
96
+ hash: -1637175963
97
97
  segments:
98
98
  - 1
99
99
  - 3
100
100
  - 0
101
- - pre13
102
- version: 1.3.0.pre13
101
+ - pre14
102
+ version: 1.3.0.pre14
103
103
  type: :runtime
104
104
  version_requirements: *id005
105
105
  - !ruby/object:Gem::Dependency
@@ -274,6 +274,7 @@ files:
274
274
  - lib/hobo/extensions/active_record/association_reflection.rb
275
275
  - lib/hobo/extensions/active_record/hobo_methods.rb
276
276
  - lib/hobo/extensions/active_record/permissions.rb
277
+ - lib/hobo/extensions/active_record/relation_with_origin.rb
277
278
  - lib/hobo/extensions/active_record/scopes.rb
278
279
  - lib/hobo/extensions/array.rb
279
280
  - lib/hobo/extensions/enumerable.rb