Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

untangle the bootstrap process a bit

  • Loading branch information...
commit 5c2fd610a071f706d681ac0f3cc05561740fc3d0 1 parent 8b449c3
@mislav authored
View
23 Rakefile
@@ -1,4 +1,3 @@
-require File.dirname(__FILE__) + "/lib/integrity"
require "rake/testtask"
require "rcov/rcovtask"
@@ -50,19 +49,29 @@ namespace :test do
end
end
+task :environment do
+ $:.unshift "#{File.dirname(__FILE__)}/lib"
+ require 'integrity'
+end
+
namespace :db do
desc "Setup connection."
- task :connect do
- config = File.expand_path(ENV['CONFIG']) if ENV['CONFIG']
- config = Integrity.root / 'config.yml' if File.exists?(Integrity.root / 'config.yml')
+ task :connect => :environment do
+ if ENV['CONFIG']
+ config = File.expand_path(ENV['CONFIG'])
+ elsif config_file = Integrity.root / 'config' / 'config.yml' and File.exists?(config_file)
+ config = config_file
+ else
+ config = nil
+ end
Integrity.new(config)
end
desc "Automigrate the database"
task :migrate => :connect do
- require "project"
- require "build"
- require "notifier"
+ require "integrity/project"
+ require "integrity/build"
+ require "integrity/notifier"
DataMapper.auto_migrate!
end
end
View
6 app.rb
@@ -1,7 +1,7 @@
-require File.dirname(__FILE__) + "/lib/integrity"
+require "integrity"
+require "integrity/helpers"
require "sinatra"
-require "helpers"
-require "hacks"
+# require "hacks"
set :root, Integrity.root
set :public, Integrity.root / "public"
View
11 bin/integrity
@@ -1,4 +1,13 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + "/../lib/integrity/installer"
+unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
+ require 'pathname'
+ lib_dir = Pathname.new(__FILE__).realpath.dirname + '../lib'
+else
+ # windows
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
+end
+$:.unshift(lib_dir) unless $:.include?(lib_dir)
+
+require 'integrity/installer'
Integrity::Installer.start
View
28 lib/integrity.rb
@@ -1,6 +1,3 @@
-__DIR__ = File.dirname(__FILE__)
-$:.unshift "#{__DIR__}/integrity", *Dir["#{__DIR__}/../vendor/**/lib"].to_a
-
require "rubygems"
require "json"
require "dm-core"
@@ -16,16 +13,16 @@
require "ostruct"
require "fileutils"
-require "core_ext/object"
-require "core_ext/string"
-require "core_ext/time"
+require "integrity/core_ext/object"
+require "integrity/core_ext/string"
+require "integrity/core_ext/time"
-require "project"
-require "build"
-require "project_builder"
-require "scm"
-require "scm/git"
-require "notifier"
+require "integrity/project"
+require "integrity/build"
+require "integrity/project_builder"
+require "integrity/scm"
+require "integrity/scm/git"
+require "integrity/notifier"
module Integrity
def self.new(config_file = nil)
@@ -34,7 +31,7 @@ def self.new(config_file = nil)
end
def self.root
- File.expand_path(File.join(File.dirname(__FILE__), ".."))
+ @root ||= File.expand_path(File.dirname(__FILE__) / "..")
end
def self.default_configuration
@@ -47,7 +44,7 @@ def self.default_configuration
end
def self.config
- @config ||= default_configuration
+ @config ||= default_configuration.dup
end
def self.config=(file)
@@ -72,3 +69,6 @@ def call(severity, time, progname, msg)
end
end
end
+
+# push vendored libraries to load paths
+$:.unshift *Dir["#{Integrity.root}/vendor/**/lib"].to_a
View
2  lib/integrity/installer.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + "/../integrity"
+require "integrity"
require "thor"
module Integrity
Please sign in to comment.
Something went wrong with that request. Please try again.