Permalink
Browse files

Use autoload instead of Dir#glob.

Dir#glob returns a unordered file list.  The order may differ from system
to system. `autoload` solves this issue.
  • Loading branch information...
1 parent c18d64f commit e818f2d4142e309ee8dd65c7a2d22b77344e1f11 Peter Suschlik committed Oct 26, 2010
Showing with 14 additions and 6 deletions.
  1. +2 −2 Rakefile
  2. +8 −4 lib/cockpit.rb
  3. +4 −0 lib/cockpit/core/settings.rb
View
@@ -28,7 +28,7 @@ task :test do
Dir["test/**/*"].each do |file|
next unless File.basename(file) =~ /test_/
next unless File.extname(file) == ".rb"
- system "ruby #{file}"
+ system "ruby -Ilib #{file}"
end
end
@@ -76,4 +76,4 @@ end
task :yank do
`gem yank #{spec.name} -v #{spec.version}`
-end
+end
View
@@ -1,10 +1,14 @@
require 'rubygems'
require 'defined-by'
-this = File.expand_path(File.dirname(__FILE__))
-Dir["#{this}/cockpit/*"].each { |c| require c unless File.directory?(c) }
-Dir["#{this}/cockpit/core/*"].each { |c| require c unless File.directory?(c) }
-Dir["#{this}/cockpit/adapters/*"].each { |c| require c unless File.directory?(c) }
+module Cockpit
+ autoload :Scope, 'cockpit/core/scope'
+ autoload :Settings, 'cockpit/core/settings'
+ autoload :Store, 'cockpit/core/store'
+ autoload :ViewHelpers, 'cockpit/core/helpers'
+end
+
+require 'lib/cockpit/core/include'
ActiveRecord::Base.send(:include, Cockpit) if defined?(ActiveRecord::Base)
@@ -1,6 +1,10 @@
module Cockpit
# settings have one direct definition and many child proxy
class Settings
+ autoload :Definition, 'cockpit/core/definition'
+ autoload :Global, 'cockpit/core/global'
+ autoload :Spec, 'cockpit/core/spec'
+
include Global
class << self

0 comments on commit e818f2d

Please sign in to comment.