public
Description: personal bookshelf application, rails based.
Homepage: http://github.com/caffo/bookqueue/wikis
Clone URL: git://github.com/caffo/bookqueue.git
project update to 2.1
caffo (author)
Sun Sep 14 09:55:10 -0700 2008
commit  15e4d53520083be1ace7e1bc15355e0098feaae8
tree    f63abd1210857b9c9732601395532da8aefdb7bc
parent  7be79a2cd152325f6f82c9c9753f6f161520b89c
...
1
 
 
2
3
4
 
5
6
7
8
9
 
 
 
 
 
 
 
 
10
11
12
 
 
 
13
14
15
16
17
18
 
 
 
 
 
 
 
19
20
21
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
24
25
26
 
 
 
 
 
 
27
28
29
30
 
 
 
31
32
33
34
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
37
38
39
40
 
 
 
 
 
 
 
 
 
41
42
43
44
45
46
 
 
 
...
 
1
2
3
 
 
4
5
 
 
 
 
6
7
8
9
10
11
12
13
14
 
 
15
16
17
18
 
 
 
 
 
19
20
21
22
23
24
25
26
 
 
 
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
 
 
50
51
52
53
54
55
56
 
 
 
57
58
59
60
 
 
 
 
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 
 
 
95
96
97
98
99
100
101
102
103
104
105
 
 
 
106
107
108
109
0
@@ -1,46 +1,109 @@
0
-# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
0
+# Don't change this file!
0
+# Configure your app in config/environment.rb and config/environments/*.rb
0
 
0
-unless defined?(RAILS_ROOT)
0
-  root_path = File.join(File.dirname(__FILE__), '..')
0
+RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
0
 
0
-  unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
0
-    require 'pathname'
0
-    root_path = Pathname.new(root_path).cleanpath(true).to_s
0
-  end
0
+module Rails
0
+  class << self
0
+    def boot!
0
+      unless booted?
0
+        preinitialize
0
+        pick_boot.run
0
+      end
0
+    end
0
 
0
-  RAILS_ROOT = root_path
0
-end
0
+    def booted?
0
+      defined? Rails::Initializer
0
+    end
0
 
0
-unless defined?(Rails::Initializer)
0
-  if File.directory?("#{RAILS_ROOT}/vendor/rails")
0
-    require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
0
-  else
0
-    require 'rubygems'
0
+    def pick_boot
0
+      (vendor_rails? ? VendorBoot : GemBoot).new
0
+    end
0
+
0
+    def vendor_rails?
0
+      File.exist?("#{RAILS_ROOT}/vendor/rails")
0
+    end
0
 
0
-    environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join
0
-    environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/
0
-    rails_gem_version = $1
0
+    def preinitialize
0
+      load(preinitializer_path) if File.exist?(preinitializer_path)
0
+    end
0
+
0
+    def preinitializer_path
0
+      "#{RAILS_ROOT}/config/preinitializer.rb"
0
+    end
0
+  end
0
+
0
+  class Boot
0
+    def run
0
+      load_initializer
0
+      Rails::Initializer.run(:set_load_path)
0
+    end
0
+  end
0
+
0
+  class VendorBoot < Boot
0
+    def load_initializer
0
+      require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
0
+      Rails::Initializer.run(:install_gem_spec_stubs)
0
+    end
0
+  end
0
 
0
-    if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
0
-      # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems
0
-      rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last
0
+  class GemBoot < Boot
0
+    def load_initializer
0
+      self.class.load_rubygems
0
+      load_rails_gem
0
+      require 'initializer'
0
+    end
0
 
0
-      if rails_gem
0
-        gem "rails", "=#{rails_gem.version.version}"
0
-        require rails_gem.full_gem_path + '/lib/initializer'
0
+    def load_rails_gem
0
+      if version = self.class.gem_version
0
+        gem 'rails', version
0
       else
0
-        STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
0
-    Install the missing gem with 'gem install -v=#{version} rails', or
0
-    change environment.rb to define RAILS_GEM_VERSION with your desired version.
0
-  )
0
+        gem 'rails'
0
+      end
0
+    rescue Gem::LoadError => load_error
0
+      $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.)
0
+      exit 1
0
+    end
0
+
0
+    class << self
0
+      def rubygems_version
0
+        Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
0
+      end
0
+
0
+      def gem_version
0
+        if defined? RAILS_GEM_VERSION
0
+          RAILS_GEM_VERSION
0
+        elsif ENV.include?('RAILS_GEM_VERSION')
0
+          ENV['RAILS_GEM_VERSION']
0
+        else
0
+          parse_gem_version(read_environment_rb)
0
+        end
0
+      end
0
+
0
+      def load_rubygems
0
+        require 'rubygems'
0
+
0
+        unless rubygems_version >= '0.9.4'
0
+          $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
0
+          exit 1
0
+        end
0
+
0
+      rescue LoadError
0
+        $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
0
         exit 1
0
       end
0
-    else
0
-      gem "rails"
0
-      require 'initializer'
0
+
0
+      def parse_gem_version(text)
0
+        $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
0
+      end
0
+
0
+      private
0
+        def read_environment_rb
0
+          File.read("#{RAILS_ROOT}/config/environment.rb")
0
+        end
0
     end
0
   end
0
-  require 'yaml'
0
-  Rails::Initializer.run(:set_load_path)
0
-  APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV]
0
 end
0
+
0
+# All that for this:
0
+Rails.boot!
...
1
2
 
3
 
 
 
 
 
 
 
 
4
5
6
7
8
9
10
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
13
14
 
 
15
16
17
 
 
 
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
 
 
 
 
 
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
 
34
35
36
 
 
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
0
@@ -1,18 +1,67 @@
0
-RAILS_GEM_VERSION = '2.0.2'
0
-ENV['RAILS_ENV'] ||= 'production'
0
+# Be sure to restart your server when you modify this file
0
 
0
+# Uncomment below to force Rails into production mode when
0
+# you don't control web/app server and can't set it the proper way
0
+# ENV['RAILS_ENV'] ||= 'production'
0
+
0
+# Specifies gem version of Rails to use when vendor/rails is not present
0
+RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
0
+
0
+# Bootstrap the Rails environment, frameworks, and default configuration
0
 require File.join(File.dirname(__FILE__), 'boot')
0
 
0
 Rails::Initializer.run do |config|
0
-  config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase of at least 30 characters" }
0
-  config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir| 
0
-    File.directory?(lib = "#{dir}/lib") ? lib : dir
0
-  end
0
-end
0
+  # Settings in config/environments/* take precedence over those specified here.
0
+  # Application configuration should go into files in config/initializers
0
+  # -- all .rb files in that directory are automatically loaded.
0
+  # See Rails::Configuration for more options.
0
+
0
+  # Skip frameworks you're not going to use. To use Rails without a database
0
+  # you must remove the Active Record framework.
0
+  # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
0
+
0
+  # Specify gems that this application depends on. 
0
+  # They can then be installed with "rake gems:install" on new installations.
0
+  # config.gem "bj"
0
+  # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
0
+  # config.gem "aws-s3", :lib => "aws/s3"
0
+
0
+  # Only load the plugins named here, in the order given. By default, all plugins 
0
+  # in vendor/plugins are loaded in alphabetical order.
0
+  # :all can be used as a placeholder for all plugins not explicitly named
0
+  # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
0
 
0
-require('twitter')
0
-require('twitter/console')
0
+  # Add additional load paths for your own custom dirs
0
+  # config.load_paths += %W( #{RAILS_ROOT}/extras )
0
 
0
-twitter_config =  File.join(File.dirname(__FILE__), '..', 'config', 'twitter.yml')
0
-TWITTER        = Twitter::Client.from_config(twitter_config)
0
+  # Force all environments to use the same logger level
0
+  # (by default production uses :info, the others :debug)
0
+  # config.log_level = :debug
0
 
0
+  # Make Time.zone default to the specified zone, and make Active Record store time values
0
+  # in the database in UTC, and return them converted to the specified local zone.
0
+  # Run "rake -D time" for a list of tasks for finding time zone names. Uncomment to use default local time.
0
+  config.time_zone = 'UTC'
0
+
0
+  # Your secret key for verifying cookie session data integrity.
0
+  # If you change this key, all old sessions will become invalid!
0
+  # Make sure the secret is at least 30 characters and all random, 
0
+  # no regular words or you'll be exposed to dictionary attacks.
0
+  config.action_controller.session = {
0
+    :session_key => '_bookqueue_session',
0
+    :secret      => '19a72d0ed7a6265bcf61e40c67e6deb41b6cd053f43afb4452d523ff84bd8a6148dfd062c1a1350f34269603c7630d7e4f359335c28115eb0f1726ce17f15496'
0
+  }
0
+
0
+  # Use the database for sessions instead of the cookie-based default,
0
+  # which shouldn't be used to store highly confidential information
0
+  # (create the session table with "rake db:sessions:create")
0
+  # config.action_controller.session_store = :active_record_store
0
+
0
+  # Use SQL instead of Active Record's schema dumper when creating the test database.
0
+  # This is necessary if your schema can't be completely dumped by the schema dumper,
0
+  # like if you have constraints or database-specific column types
0
+  # config.active_record.schema_format = :sql
0
+
0
+  # Activate observers that should always be running
0
+  # config.active_record.observers = :cacher, :garbage_collector
0
+end
...
8
9
10
11
12
13
14
15
16
17
18
 
19
20
21
22
...
8
9
10
 
 
 
11
12
 
 
13
14
15
16
17
18
0
@@ -8,14 +8,10 @@ config.cache_classes = false
0
 # Log error messages when you accidentally call methods on nil.
0
 config.whiny_nils = true
0
 
0
-# Enable the breakpoint server that script/breakpointer connects to
0
-#config.breakpoint_server = true
0
-
0
 # Show full error reports and disable caching
0
 config.action_controller.consider_all_requests_local = true
0
-config.action_controller.perform_caching             = false
0
-config.action_view.cache_template_extensions         = false
0
 config.action_view.debug_rjs                         = true
0
+config.action_controller.perform_caching             = false
0
 
0
 # Don't care if the mailer can't send
0
 config.action_mailer.raise_delivery_errors = false
0
\ No newline at end of file
...
10
11
12
 
 
 
 
13
14
15
16
17
18
19
 
...
10
11
12
13
14
15
16
17
18
19
20
21
 
22
23
0
@@ -10,9 +10,13 @@ config.cache_classes = true
0
 # Full error reports are disabled and caching is turned on
0
 config.action_controller.consider_all_requests_local = false
0
 config.action_controller.perform_caching             = true
0
+config.action_view.cache_template_loading            = true
0
+
0
+# Use a different cache store in production
0
+# config.cache_store = :mem_cache_store
0
 
0
 # Enable serving of images, stylesheets, and javascripts from an asset server
0
 # config.action_controller.asset_host                  = "http://assets.example.com"
0
 
0
 # Disable delivery errors, bad email addresses will be ignored
0
-# config.action_mailer.raise_delivery_errors = false
0
\ No newline at end of file
0
+# config.action_mailer.raise_delivery_errors = false
...
13
14
15
16
 
 
 
 
17
18
19
20
 
...
13
14
15
 
16
17
18
19
20
21
 
22
23
0
@@ -13,7 +13,10 @@ config.whiny_nils = true
0
 config.action_controller.consider_all_requests_local = true
0
 config.action_controller.perform_caching             = false
0
 
0
-# Tell ActionMailer not to deliver emails to the real world.
0
+# Disable request forgery protection in test environment
0
+config.action_controller.allow_forgery_protection    = false
0
+
0
+# Tell Action Mailer not to deliver emails to the real world.
0
 # The :test delivery method accumulates sent emails in the
0
 # ActionMailer::Base.deliveries array.
0
-config.action_mailer.delivery_method = :test
0
\ No newline at end of file
0
+config.action_mailer.delivery_method = :test
...
1
2
3
4
 
...
1
2
 
3
4
0
@@ -1,3 +1,3 @@
0
 #!/usr/bin/env ruby
0
 require File.dirname(__FILE__) + '/../config/boot'
0
-require 'commands/about'
0
\ No newline at end of file
0
+require 'commands/about'
...
1
2
3
4
 
...
1
2
 
3
4
0
@@ -1,3 +1,3 @@
0
 #!/usr/bin/env ruby
0
 require File.dirname(__FILE__) + '/../config/boot'
0
-require 'commands/console'
0
\ No newline at end of file
0
+require 'commands/console'
...
1
2
3
4
 
...
1
2
 
3
4
0
@@ -1,3 +1,3 @@
0
 #!/usr/bin/env ruby
0
 require File.dirname(__FILE__) + '/../config/boot'
0
-require 'commands/destroy'
0
\ No newline at end of file
0
+require 'commands/destroy'
...
1
2
3
4
 
...
1
2
 
3
4
0
@@ -1,3 +1,3 @@
0
 #!/usr/bin/env ruby
0
 require File.dirname(__FILE__) + '/../config/boot'
0
-require 'commands/generate'
0
\ No newline at end of file
0
+require 'commands/generate'
...
1
2
3
4
 
...
1
2
 
3
4
0
@@ -1,3 +1,3 @@
0
 #!/usr/bin/env ruby
0
 require File.dirname(__FILE__) + '/../config/boot'
0
-require 'commands/plugin'
0
\ No newline at end of file
0
+require 'commands/plugin'
...
1
2
3
4
 
...
1
2
 
3
4
0
@@ -1,3 +1,3 @@
0
 #!/usr/bin/env ruby
0
 require File.dirname(__FILE__) + '/../config/boot'
0
-require 'commands/runner'
0
\ No newline at end of file
0
+require 'commands/runner'
...
1
2
3
4
 
...
1
2
 
3
4
0
@@ -1,3 +1,3 @@
0
 #!/usr/bin/env ruby
0
 require File.dirname(__FILE__) + '/../config/boot'
0
-require 'commands/server'
0
\ No newline at end of file
0
+require 'commands/server'

Comments