has_many_polymorphs 2.11 → 2.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +3 -1
  3. data/Manifest +43 -61
  4. data/README +30 -0
  5. data/TODO +0 -3
  6. data/generators/tagging/tagging_generator.rb +2 -0
  7. data/generators/tagging/templates/tag_test.rb +7 -2
  8. data/generators/tagging/templates/tagging.rb +2 -2
  9. data/generators/tagging/templates/tagging_extensions.rb +49 -2
  10. data/generators/tagging/templates/tagging_test.rb +32 -9
  11. data/generators/tagging/templates/tags.yml +2 -2
  12. data/has_many_polymorphs.gemspec +20 -13
  13. data/lib/has_many_polymorphs.rb +0 -1
  14. data/lib/has_many_polymorphs/autoload.rb +45 -37
  15. data/lib/has_many_polymorphs/class_methods.rb +2 -15
  16. data/lib/has_many_polymorphs/configuration.rb +2 -2
  17. data/lib/has_many_polymorphs/rake_task_redefine_task.rb +9 -1
  18. data/test/generator/tagging_generator_test.rb +42 -0
  19. data/test/integration/app/app/controllers/bones_controller.rb +5 -0
  20. data/test/integration/app/app/helpers/bones_helper.rb +2 -0
  21. data/test/integration/app/app/models/bone.rb +2 -0
  22. data/test/integration/app/app/models/double_sti_parent.rb +2 -0
  23. data/test/integration/app/app/models/double_sti_parent_relationship.rb +2 -0
  24. data/test/integration/app/app/models/organic_substance.rb +2 -0
  25. data/test/integration/app/app/models/single_sti_parent.rb +4 -0
  26. data/test/integration/app/app/models/single_sti_parent_relationship.rb +4 -0
  27. data/test/integration/app/app/models/stick.rb +2 -0
  28. data/test/integration/app/app/models/stone.rb +2 -0
  29. data/test/integration/app/app/views/bones/index.rhtml +5 -0
  30. data/test/integration/app/config/boot.rb +97 -32
  31. data/test/integration/app/config/database.yml +8 -12
  32. data/test/integration/app/config/environment.rb +9 -3
  33. data/test/integration/app/config/environment.rb.canonical +19 -0
  34. data/test/integration/app/config/environments/development.rb +6 -5
  35. data/test/integration/app/db/migrate/001_create_sticks.rb +11 -0
  36. data/test/integration/app/db/migrate/002_create_stones.rb +11 -0
  37. data/test/integration/app/db/migrate/003_create_organic_substances.rb +11 -0
  38. data/test/integration/app/db/migrate/004_create_bones.rb +8 -0
  39. data/test/integration/app/db/migrate/005_create_single_sti_parents.rb +11 -0
  40. data/test/integration/app/db/migrate/006_create_double_sti_parents.rb +11 -0
  41. data/test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb +13 -0
  42. data/test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb +14 -0
  43. data/test/integration/app/db/migrate/009_create_library_model.rb +11 -0
  44. data/test/integration/app/db/schema.rb +21 -121
  45. data/test/integration/app/hmp_development +0 -0
  46. data/test/integration/app/lib/library_model.rb +2 -0
  47. data/test/integration/app/test/fixtures/double_sti_parent_relationships.yml +7 -0
  48. data/test/integration/app/test/fixtures/double_sti_parents.yml +7 -0
  49. data/test/integration/app/test/fixtures/organic_substances.yml +5 -0
  50. data/test/integration/app/test/fixtures/single_sti_parent_relationships.yml +7 -0
  51. data/test/integration/app/test/fixtures/single_sti_parents.yml +7 -0
  52. data/test/integration/app/test/fixtures/sticks.yml +7 -0
  53. data/test/integration/app/test/fixtures/stones.yml +7 -0
  54. data/test/integration/app/test/{unit/user_test.rb → functional/bones_controller_test.rb} +1 -3
  55. data/test/integration/app/test/test_helper.rb +1 -21
  56. data/test/integration/app/test/unit/{state_test.rb → bone_test.rb} +1 -3
  57. data/test/integration/app/test/unit/{seller_test.rb → double_sti_parent_relationship_test.rb} +1 -3
  58. data/test/integration/app/test/unit/{address_test.rb → double_sti_parent_test.rb} +1 -3
  59. data/test/integration/app/test/unit/organic_substance_test.rb +8 -0
  60. data/test/integration/app/test/unit/single_sti_parent_relationship_test.rb +8 -0
  61. data/test/integration/app/test/unit/single_sti_parent_test.rb +8 -0
  62. data/test/integration/app/test/unit/stick_test.rb +8 -0
  63. data/test/integration/app/test/unit/stone_test.rb +8 -0
  64. data/test/integration/server_test.rb +43 -0
  65. data/test/patches/symlinked_plugins_1.2.6.diff +46 -0
  66. data/test/setup.rb +6 -2
  67. data/test/test_helper.rb +32 -16
  68. data/test/unit/{polymorph_test.rb → has_many_polymorphs_test.rb} +16 -16
  69. metadata +49 -65
  70. metadata.gz.sig +0 -0
  71. data/generators/commenting/commenting_generator.rb +0 -94
  72. data/generators/commenting/templates/comment.rb +0 -33
  73. data/generators/commenting/templates/comment_test.rb +0 -12
  74. data/generators/commenting/templates/commenting.rb +0 -13
  75. data/generators/commenting/templates/commenting_extensions.rb +0 -30
  76. data/generators/commenting/templates/commenting_test.rb +0 -30
  77. data/generators/commenting/templates/commentings.yml +0 -23
  78. data/generators/commenting/templates/comments.yml +0 -13
  79. data/generators/commenting/templates/migration.rb +0 -28
  80. data/lib/has_many_polymorphs/dependencies.rb +0 -41
  81. data/test/integration/app/app/controllers/addresses_controller.rb +0 -85
  82. data/test/integration/app/app/controllers/sellers_controller.rb +0 -85
  83. data/test/integration/app/app/controllers/states_controller.rb +0 -85
  84. data/test/integration/app/app/controllers/users_controller.rb +0 -85
  85. data/test/integration/app/app/models/address.rb +0 -4
  86. data/test/integration/app/app/models/citation.rb +0 -3
  87. data/test/integration/app/app/models/citations_item.rb +0 -4
  88. data/test/integration/app/app/models/seller.rb +0 -4
  89. data/test/integration/app/app/models/state.rb +0 -3
  90. data/test/integration/app/app/models/user.rb +0 -4
  91. data/test/integration/app/db/migrate/001_create_users.rb +0 -16
  92. data/test/integration/app/db/migrate/002_create_sellers.rb +0 -14
  93. data/test/integration/app/db/migrate/003_create_addresses.rb +0 -19
  94. data/test/integration/app/db/migrate/004_create_states.rb +0 -12
  95. data/test/integration/app/db/migrate/005_add_capitalization_to_seller.rb +0 -9
  96. data/test/integration/app/db/migrate/006_add_deleted_to_user.rb +0 -9
  97. data/test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb +0 -11
  98. data/test/integration/app/db/migrate/008_create_citations.rb +0 -12
  99. data/test/integration/app/db/migrate/009_create_citations_items.rb +0 -14
  100. data/test/integration/app/generated_models/aquatic_fish.rb +0 -109
  101. data/test/integration/app/generated_models/aquatic_pupils_whale.rb +0 -13
  102. data/test/integration/app/generated_models/aquatic_whale.rb +0 -42
  103. data/test/integration/app/generated_models/beautiful_fight_relationship.rb +0 -25
  104. data/test/integration/app/generated_models/citation.rb +0 -40
  105. data/test/integration/app/generated_models/citations_item.rb +0 -12
  106. data/test/integration/app/generated_models/dog.rb +0 -183
  107. data/test/integration/app/generated_models/eaters_foodstuff.rb +0 -13
  108. data/test/integration/app/generated_models/frog.rb +0 -78
  109. data/test/integration/app/generated_models/kitten.rb +0 -161
  110. data/test/integration/app/generated_models/parentship.rb +0 -14
  111. data/test/integration/app/generated_models/person.rb +0 -53
  112. data/test/integration/app/generated_models/petfood.rb +0 -125
  113. data/test/integration/app/generated_models/polymorph_test_some_model.rb +0 -25
  114. data/test/integration/app/generated_models/seller.rb +0 -30
  115. data/test/integration/app/generated_models/tabby.rb +0 -26
  116. data/test/integration/app/generated_models/user.rb +0 -34
  117. data/test/integration/app/generated_models/wild_boar.rb +0 -87
  118. data/test/integration/app/test/fixtures/addresses.yml +0 -13
  119. data/test/integration/app/test/fixtures/citations.yml +0 -9
  120. data/test/integration/app/test/fixtures/citations_items.yml +0 -9
  121. data/test/integration/app/test/fixtures/sellers.yml +0 -10
  122. data/test/integration/app/test/fixtures/states.yml +0 -216
  123. data/test/integration/app/test/fixtures/users.yml +0 -11
  124. data/test/integration/app/test/unit/citation_test.rb +0 -10
  125. data/test/integration/app/test/unit/citations_item_test.rb +0 -10
  126. data/test/test_all.rb +0 -16
@@ -21,7 +21,6 @@ end
21
21
  if defined? Rails and RAILS_ENV and RAILS_ROOT
22
22
  _logger_warn "rails environment detected"
23
23
  require 'has_many_polymorphs/configuration'
24
- require 'has_many_polymorphs/dependencies'
25
24
  require 'has_many_polymorphs/autoload'
26
25
  end
27
26
 
@@ -1,7 +1,8 @@
1
1
 
2
- require 'initializer' unless defined? Rails::Initializer
2
+ require 'initializer' unless defined? ::Rails::Initializer
3
+ require 'dispatcher' unless defined? ::ActionController::Dispatcher
3
4
 
4
- class Rails::Initializer #:nodoc:
5
+ module HasManyPolymorphs
5
6
 
6
7
  =begin rdoc
7
8
  Searches for models that use <tt>has_many_polymorphs</tt> or <tt>acts_as_double_polymorphic_join</tt> and makes sure that they get loaded during app initialization. This ensures that helper methods are injected into the target classes.
@@ -11,52 +12,59 @@ Note that you can override DEFAULT_OPTIONS via Rails::Configuration#has_many_pol
11
12
  # your other configuration here
12
13
 
13
14
  config.after_initialize do
14
- config.has_many_polymorphs_options['requirements'] << '/lib/my_extension'
15
+ config.has_many_polymorphs_options['requirements'] << 'lib/my_extension'
15
16
  end
16
17
  end
17
18
 
18
19
  =end
19
20
 
20
- module HasManyPolymorphsAutoload
21
-
22
- DEFAULT_OPTIONS = {
23
- :file_pattern => "#{RAILS_ROOT}/app/models/**/*.rb",
24
- :file_exclusions => ['svn', 'CVS', 'bzr'],
25
- :methods => ['has_many_polymorphs', 'acts_as_double_polymorphic_join'],
26
- :requirements => []}
27
-
28
- mattr_accessor :options
29
- @@options = HashWithIndifferentAccess.new(DEFAULT_OPTIONS)
21
+ DEFAULT_OPTIONS = {
22
+ :file_pattern => "#{RAILS_ROOT}/app/models/**/*.rb",
23
+ :file_exclusions => ['svn', 'CVS', 'bzr'],
24
+ :methods => ['has_many_polymorphs', 'acts_as_double_polymorphic_join'],
25
+ :requirements => []}
26
+
27
+ mattr_accessor :options
28
+ @@options = HashWithIndifferentAccess.new(DEFAULT_OPTIONS)
30
29
 
31
- # Override for Rails::Initializer#after_initialize.
32
- def after_initialize_with_autoload
33
- after_initialize_without_autoload
30
+ # Dispatcher callback to load polymorphic relationships from the top down.
31
+ def self.autoload
34
32
 
35
- _logger_debug "autoload hook invoked"
36
-
37
- HasManyPolymorphsAutoload.options[:requirements].each do |requirement|
38
- require requirement
39
- end
33
+ _logger_debug "autoload hook invoked"
40
34
 
41
- Dir[HasManyPolymorphsAutoload.options[:file_pattern]].each do |filename|
42
- next if filename =~ /#{HasManyPolymorphsAutoload.options[:file_exclusions].join("|")}/
43
- open filename do |file|
44
- if file.grep(/#{HasManyPolymorphsAutoload.options[:methods].join("|")}/).any?
45
- begin
46
- model = File.basename(filename)[0..-4].camelize
47
- _logger_warn "preloading parent model #{model}"
48
- model.constantize
49
- rescue Object => e
50
- _logger_warn "WARNING; possibly critical error preloading #{model}: #{e.inspect}"
51
- end
35
+ options[:requirements].each do |requirement|
36
+ _logger_warn "forcing requirement load of #{requirement}"
37
+ require requirement
38
+ end
39
+
40
+ Dir[options[:file_pattern]].each do |filename|
41
+ next if filename =~ /#{options[:file_exclusions].join("|")}/
42
+ open filename do |file|
43
+ if file.grep(/#{options[:methods].join("|")}/).any?
44
+ begin
45
+ model = File.basename(filename)[0..-4].camelize
46
+ _logger_warn "preloading parent model #{model}"
47
+ model.constantize
48
+ rescue Object => e
49
+ _logger_warn "#{model} could not be preloaded: #{e.inspect}"
52
50
  end
53
51
  end
54
52
  end
55
- end
53
+ end
54
+ end
56
55
 
56
+ end
57
+
58
+ class Rails::Initializer #:nodoc:
59
+ # Make sure it gets loaded in the console, tests, and migrations
60
+ def after_initialize_with_autoload
61
+ after_initialize_without_autoload
62
+ HasManyPolymorphs.autoload
57
63
  end
58
-
59
- include HasManyPolymorphsAutoload
60
-
61
- alias_method_chain :after_initialize, :autoload
64
+ alias_method_chain :after_initialize, :autoload
65
+ end
66
+
67
+ Dispatcher.to_prepare(:has_many_polymorphs_autoload) do
68
+ # Make sure it gets loaded in the app
69
+ HasManyPolymorphs.autoload
62
70
  end
@@ -340,11 +340,7 @@ Be aware, however, that <tt>NULL != 'Spot'</tt> returns <tt>false</tt> due to SQ
340
340
  options[:parent_extend] = spiked_create_extension_module(association_id, Array(options[:parent_extend]), "Parent")
341
341
 
342
342
  # create the reflection object
343
- returning(create_reflection(:has_many_polymorphs, association_id, options, self)) do |reflection|
344
- if defined? Dependencies and defined? RAILS_ENV and RAILS_ENV == "development"
345
- inject_dependencies(association_id, reflection) if Dependencies.mechanism == :load
346
- end
347
-
343
+ returning(create_reflection(:has_many_polymorphs, association_id, options, self)) do |reflection|
348
344
  # set up the other related associations
349
345
  create_join_association(association_id, reflection)
350
346
  create_has_many_through_associations_for_parent_to_children(association_id, reflection)
@@ -381,16 +377,7 @@ Be aware, however, that <tt>NULL != 'Spot'</tt> returns <tt>false</tt> due to SQ
381
377
  "#{table} AS #{_alias}"
382
378
  end.sort).join(", ")
383
379
  end
384
-
385
- # model caching
386
- def inject_dependencies(association_id, reflection)
387
- _logger_debug "injecting dependencies"
388
- requirements = [self, reflection.klass].map{|klass| [klass, klass.base_class]}.flatten.uniq
389
- (all_classes_for(association_id, reflection) - requirements).each do |target_klass|
390
- Dependencies.inject_dependency(target_klass, *requirements)
391
- end
392
- end
393
-
380
+
394
381
  # method sub-builders
395
382
 
396
383
  def create_join_association(association_id, reflection)
@@ -6,11 +6,11 @@ Access the <tt>has_many_polymorphs_options</tt> hash in your Rails::Initializer.
6
6
  class Rails::Configuration
7
7
 
8
8
  def has_many_polymorphs_options
9
- Rails::Initializer::HasManyPolymorphsAutoload.options
9
+ ::HasManyPolymorphs.options
10
10
  end
11
11
 
12
12
  def has_many_polymorphs_options=(hash)
13
- Rails::Initializer::HasManyPolymorphsAutoload.options = hash
13
+ ::HasManyPolymorphs.options = HashWithIndifferentAccess.new(hash)
14
14
  end
15
15
 
16
16
  end
@@ -24,4 +24,12 @@ module Rake
24
24
  end
25
25
  end
26
26
  end
27
- end
27
+ end
28
+
29
+ class Object
30
+ def silently
31
+ stderr, stdout, $stderr, $stdout = $stderr, $stdout, StringIO.new, StringIO.new
32
+ yield
33
+ $stderr, $stdout = stderr, stdout
34
+ end
35
+ end
@@ -0,0 +1,42 @@
1
+ require 'fileutils'
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+
4
+ class TaggingGeneratorTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ Dir.chdir RAILS_ROOT do
8
+ truncate
9
+
10
+ # Revert environment lib requires
11
+ FileUtils.cp "config/environment.rb.canonical", "config/environment.rb"
12
+
13
+ # Delete generator output
14
+ ["app/models/tag.rb", "app/models/tagging.rb",
15
+ "test/unit/tag_test.rb", "test/unit/tagging_test.rb",
16
+ "test/fixtures/tags.yml", "test/fixtures/taggings.yml",
17
+ "lib/tagging_extensions.rb",
18
+ "db/migrate/010_create_tags_and_taggings.rb"].each do |file|
19
+ File.delete file if File.exist? file
20
+ end
21
+
22
+ # Rebuild database
23
+ Echoe.silence do
24
+ system("ruby #{HERE}/setup.rb")
25
+ end
26
+ end
27
+ end
28
+
29
+ alias :teardown :setup
30
+
31
+ def test_generator
32
+ Dir.chdir RAILS_ROOT do
33
+ Echoe.silence do
34
+ assert system("script/generate tagging Stick Stone -q -f")
35
+ assert system("rake db:migrate")
36
+ assert system("rake db:fixtures:load")
37
+ assert system("rake test:units")
38
+ end
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,5 @@
1
+ class BonesController < ApplicationController
2
+ def index
3
+ @bones = Bone.find(:all)
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ module BonesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class Bone < OrganicSubstance
2
+ end
@@ -0,0 +1,2 @@
1
+ class DoubleStiParent < ActiveRecord::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class DoubleStiParentRelationship < ActiveRecord::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class OrganicSubstance < ActiveRecord::Base
2
+ end
@@ -0,0 +1,4 @@
1
+
2
+ class SingleStiParent < ActiveRecord::Base
3
+ has_many_polymorphs :the_bones, :from => [:bones], :through => :single_sti_parent_relationship
4
+ end
@@ -0,0 +1,4 @@
1
+ class SingleStiParentRelationship < ActiveRecord::Base
2
+ belongs_to :single_sti_parent
3
+ belongs_to :the_bone, :polymorphic => true
4
+ end
@@ -0,0 +1,2 @@
1
+ class Stick < ActiveRecord::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class Stone < ActiveRecord::Base
2
+ end
@@ -0,0 +1,5 @@
1
+
2
+ <p>Bones: index</p>
3
+ <% @bones.each do |bone| %>
4
+ <p>ID: <%= bone.id %></p>
5
+ <% end %>
@@ -1,45 +1,110 @@
1
- # Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
2
3
 
3
- unless defined?(RAILS_ROOT)
4
- root_path = File.join(File.dirname(__FILE__), '..')
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
5
 
6
- unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
7
- require 'pathname'
8
- root_path = Pathname.new(root_path).cleanpath(true).to_s
9
- end
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
10
14
 
11
- RAILS_ROOT = root_path
12
- end
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
13
26
 
14
- unless defined?(Rails::Initializer)
15
- if File.directory?("#{RAILS_ROOT}/vendor/rails")
16
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
17
- else
18
- require 'rubygems'
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exists?(preinitializer_path)
29
+ end
19
30
 
20
- environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join
21
- environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/
22
- rails_gem_version = $1
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
23
35
 
24
- if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
25
- # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems
26
- rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
27
42
 
28
- if rails_gem
29
- gem "rails", "=#{rails_gem.version.version}"
30
- require rails_gem.full_gem_path + '/lib/initializer'
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ end
47
+ end
48
+
49
+ class GemBoot < Boot
50
+ def load_initializer
51
+ self.class.load_rubygems
52
+ load_rails_gem
53
+ require 'initializer'
54
+ end
55
+
56
+ def load_rails_gem
57
+ if version = self.class.gem_version
58
+ STDERR.puts "Boot.rb loading version #{version}"
59
+ gem 'rails', version
31
60
  else
32
- STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
33
- Install the missing gem with 'gem install -v=#{version} rails', or
34
- change environment.rb to define RAILS_GEM_VERSION with your desired version.
35
- )
61
+ STDERR.puts "Boot.rb loading latest available version"
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
+ exit 1
67
+ end
68
+
69
+ class << self
70
+ def rubygems_version
71
+ Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
72
+ end
73
+
74
+ def gem_version
75
+ if defined? RAILS_GEM_VERSION
76
+ RAILS_GEM_VERSION
77
+ elsif ENV.include?('RAILS_GEM_VERSION')
78
+ ENV['RAILS_GEM_VERSION']
79
+ else
80
+ parse_gem_version(read_environment_rb)
81
+ end
82
+ end
83
+
84
+ def load_rubygems
85
+ require 'rubygems'
86
+
87
+ unless rubygems_version >= '0.9.4'
88
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
+ exit 1
90
+ end
91
+
92
+ rescue LoadError
93
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
36
94
  exit 1
37
95
  end
38
- else
39
- gem "rails"
40
- require 'initializer'
96
+
97
+ def parse_gem_version(text)
98
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([!~<>=]*\s*[\d.]+)'/
99
+ end
100
+
101
+ private
102
+ def read_environment_rb
103
+ File.read("#{RAILS_ROOT}/config/environment.rb")
104
+ end
41
105
  end
42
106
  end
43
-
44
- Rails::Initializer.run(:set_load_path)
45
107
  end
108
+
109
+ # All that for this:
110
+ Rails.boot!
@@ -1,21 +1,17 @@
1
1
 
2
- development:
3
- adapter: mysql
2
+ defaults: &defaults
3
+ adapter: <%= ENV['DB'] || 'mysql' %>
4
4
  host: localhost
5
5
  database: hmp_development
6
6
  username: root
7
7
  password:
8
8
 
9
+ development:
10
+ <<: *defaults
11
+
9
12
  test:
10
- adapter: mysql
11
- host: localhost
12
- database: hmp_test
13
- username: root
14
- password:
13
+ <<: *defaults
15
14
 
16
15
  production:
17
- adapter: mysql
18
- host: localhost
19
- database: hmp_production
20
- username: root
21
- password:
16
+ <<: *defaults
17
+
@@ -1,13 +1,19 @@
1
-
2
1
  require File.join(File.dirname(__FILE__), 'boot')
2
+ require 'action_controller'
3
3
 
4
4
  Rails::Initializer.run do |config|
5
5
 
6
- if config.action_controller.respond_to? :"session="
7
- config.action_controller.session = { :session_key => "_myapp_session", :secret => "this is a super secret phrase" }
6
+ if ActionController::Base.respond_to? 'session='
7
+ config.action_controller.session = {:session_key => '_app_session', :secret => '22cde4d5c1a61ba69a81795322cde4d5c1a61ba69a817953'}
8
8
  end
9
9
 
10
10
  config.load_paths << "#{RAILS_ROOT}/app/models/person" # moduleless model path
11
+
12
+ config.after_initialize do
13
+ config.has_many_polymorphs_options['requirements'] << "#{RAILS_ROOT}/lib/library_model"
14
+ end
11
15
  end
12
16
 
13
17
  # Dependencies.log_activity = true
18
+
19
+ ENV['RAILS_ASSET_ID'] = Time.now.to_i.to_s