captain_planet 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/Gemfile +1 -0
- data/LICENSE +20 -0
- data/README.markdown +26 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/captain_planet.gemspec +81 -0
- data/lib/captain_planet.rb +7 -0
- data/lib/captain_planet/builder.rb +43 -0
- data/lib/captain_planet/environment.rb +10 -0
- data/spec/captain_planet/builder_spec.rb +13 -0
- data/spec/captain_planet/environment_spec.rb +18 -0
- data/spec/captain_planet_spec.rb +4 -0
- data/spec/fixtures/super_app/environment.rb +5 -0
- data/spec/fixtures/super_app/environments/development.rb +1 -0
- data/spec/fixtures/super_app/environments/production.rb +1 -0
- data/spec/fixtures/super_app/environments/test.rb +1 -0
- data/spec/fixtures/web_env.rb +3 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +12 -0
- data/vendor/gems/cache/dirge-0.0.3.gem +0 -0
- data/vendor/gems/environment.rb +84 -0
- data/vendor/gems/gems/dirge-0.0.3/README.rdoc +26 -0
- data/vendor/gems/gems/dirge-0.0.3/Rakefile +29 -0
- data/vendor/gems/gems/dirge-0.0.3/VERSION +1 -0
- data/vendor/gems/gems/dirge-0.0.3/lib/dirge.rb +34 -0
- data/vendor/gems/gems/dirge-0.0.3/spec/dirge_spec.rb +29 -0
- data/vendor/gems/gems/dirge-0.0.3/spec/test:2test/test.rb +1 -0
- data/vendor/gems/specifications/dirge-0.0.3.gemspec +30 -0
- metadata +102 -0
data/.document
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gem 'dirge'
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Brad Gessler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Captain Planet
|
2
|
+
|
3
|
+
YML sucks. When configs are implemented in YML, a lot of code is written that interprets the YML values into various classes and configuration points in the application. Captain Planet saves the environment by doing away with YML by exposing classes in a way that can be configured with blocks.
|
4
|
+
|
5
|
+
## Example Configuration
|
6
|
+
|
7
|
+
class MyEnv < CaptainPlanet::Environment
|
8
|
+
attr_accessor :webdav_mount_root, :webdav_url
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
webdav_mount_root = '/default/'
|
12
|
+
webdav_url = 'http://www.com/default/'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Environment = CaptainPlanet::Builder.new(MyEnv, %{
|
17
|
+
env 'production' do |prod|
|
18
|
+
prod.webdav_mount_root = '/Volumes/localhost'
|
19
|
+
prod.webdav_url = 'http://localhost:5000/'
|
20
|
+
end
|
21
|
+
|
22
|
+
env 'development' do |dev|
|
23
|
+
dev.webdav_mount_root = '/Volumes/www.polleverywhere.com'
|
24
|
+
dev.webdav_url = 'http://www.polleverywhere.com/'
|
25
|
+
end
|
26
|
+
})[ENV['ENV'] || 'development']
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "captain_planet"
|
8
|
+
gem.summary = %Q{DSL for dealing with environments in Ruby projects}
|
9
|
+
gem.description = %Q{Captain Planet is a Ruby DSL that makes dealing with Environments much easier.}
|
10
|
+
gem.email = "brad@bradgessler.com"
|
11
|
+
gem.homepage = "http://github.com/bradgessler/captain_planet"
|
12
|
+
gem.authors = ["Brad Gessler"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
spec.libs << 'lib' << 'spec'
|
24
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
spec.rcov = true
|
31
|
+
end
|
32
|
+
|
33
|
+
task :spec => :check_dependencies
|
34
|
+
|
35
|
+
task :default => :spec
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "captain_planet #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{captain_planet}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Brad Gessler"]
|
12
|
+
s.date = %q{2010-01-20}
|
13
|
+
s.description = %q{Captain Planet is a Ruby DSL that makes dealing with Environments much easier.}
|
14
|
+
s.email = %q{brad@bradgessler.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"captain_planet.gemspec",
|
28
|
+
"lib/captain_planet.rb",
|
29
|
+
"lib/captain_planet/builder.rb",
|
30
|
+
"lib/captain_planet/environment.rb",
|
31
|
+
"spec/captain_planet/builder_spec.rb",
|
32
|
+
"spec/captain_planet/environment_spec.rb",
|
33
|
+
"spec/captain_planet_spec.rb",
|
34
|
+
"spec/fixtures/super_app/environment.rb",
|
35
|
+
"spec/fixtures/super_app/environments/development.rb",
|
36
|
+
"spec/fixtures/super_app/environments/production.rb",
|
37
|
+
"spec/fixtures/super_app/environments/test.rb",
|
38
|
+
"spec/fixtures/web_env.rb",
|
39
|
+
"spec/spec.opts",
|
40
|
+
"spec/spec_helper.rb",
|
41
|
+
"vendor/gems/cache/dirge-0.0.3.gem",
|
42
|
+
"vendor/gems/environment.rb",
|
43
|
+
"vendor/gems/gems/dirge-0.0.3/README.rdoc",
|
44
|
+
"vendor/gems/gems/dirge-0.0.3/Rakefile",
|
45
|
+
"vendor/gems/gems/dirge-0.0.3/VERSION",
|
46
|
+
"vendor/gems/gems/dirge-0.0.3/lib/dirge.rb",
|
47
|
+
"vendor/gems/gems/dirge-0.0.3/spec/dirge_spec.rb",
|
48
|
+
"vendor/gems/gems/dirge-0.0.3/spec/test:2test/test.rb",
|
49
|
+
"vendor/gems/specifications/dirge-0.0.3.gemspec"
|
50
|
+
]
|
51
|
+
s.homepage = %q{http://github.com/bradgessler/captain_planet}
|
52
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
53
|
+
s.require_paths = ["lib"]
|
54
|
+
s.rubygems_version = %q{1.3.5}
|
55
|
+
s.summary = %q{DSL for dealing with environments in Ruby projects}
|
56
|
+
s.test_files = [
|
57
|
+
"spec/captain_planet/builder_spec.rb",
|
58
|
+
"spec/captain_planet/environment_spec.rb",
|
59
|
+
"spec/captain_planet_spec.rb",
|
60
|
+
"spec/fixtures/super_app/environment.rb",
|
61
|
+
"spec/fixtures/super_app/environments/development.rb",
|
62
|
+
"spec/fixtures/super_app/environments/production.rb",
|
63
|
+
"spec/fixtures/super_app/environments/test.rb",
|
64
|
+
"spec/fixtures/web_env.rb",
|
65
|
+
"spec/spec_helper.rb"
|
66
|
+
]
|
67
|
+
|
68
|
+
if s.respond_to? :specification_version then
|
69
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
70
|
+
s.specification_version = 3
|
71
|
+
|
72
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
73
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
74
|
+
else
|
75
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
76
|
+
end
|
77
|
+
else
|
78
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module CaptainPlanet
|
2
|
+
class Builder
|
3
|
+
attr_reader :environments
|
4
|
+
|
5
|
+
def self.process(klass,pattern)
|
6
|
+
builder = Builder.new(klass)
|
7
|
+
Dir[pattern].each do |path|
|
8
|
+
name = File.basename(path, '.rb')
|
9
|
+
config = File.read(path)
|
10
|
+
builder[name] = config
|
11
|
+
end
|
12
|
+
builder
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(klass=Environment)
|
16
|
+
@klass = klass
|
17
|
+
@environments = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
# Add a new environment to the thing or find an existing one.
|
21
|
+
def environment name, config=nil, &block
|
22
|
+
environments[name] = klass.configure(config, &block)
|
23
|
+
end
|
24
|
+
alias_method :[]=, :environment
|
25
|
+
|
26
|
+
def [] name
|
27
|
+
environments[name]
|
28
|
+
end
|
29
|
+
|
30
|
+
# Converts the incoming klass value into something we can instanciate for realz
|
31
|
+
def klass
|
32
|
+
if @klass.is_a?(Class)
|
33
|
+
@klass
|
34
|
+
else
|
35
|
+
unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ @klass.to_s
|
36
|
+
raise NameError, "#{@klass.inspect} is not a valid constant name!"
|
37
|
+
end
|
38
|
+
|
39
|
+
Object.module_eval("::#{$1}", __FILE__, __LINE__)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
require ~'../fixtures/super_app/environment'
|
4
|
+
|
5
|
+
describe Builder, "processor" do
|
6
|
+
it "should detect environments" do
|
7
|
+
SuperFun::Environments.environments.keys.should include(*%w[production development test])
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should read infered environment settings" do
|
11
|
+
SuperFun::Environments['production'].lang.should eql('German')
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
require ~'../fixtures/web_env'
|
4
|
+
|
5
|
+
describe Environment do
|
6
|
+
it "should eval string" do
|
7
|
+
WebEnv.configure(%{
|
8
|
+
env.host = 'fun.com'
|
9
|
+
env.root = '/www/fun'
|
10
|
+
}).host.should eql('fun.com')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should eval block" do
|
14
|
+
WebEnv.configure { |env|
|
15
|
+
env.host = 'fun'
|
16
|
+
}.host.should eql('fun')
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
class SuperFun < CaptainPlanet::Environment
|
2
|
+
attr_accessor :name, :lang
|
3
|
+
end
|
4
|
+
|
5
|
+
SuperFun::Environments = CaptainPlanet::Builder.process(:SuperFun, File.join(File.dirname(__FILE__), 'environments/*.rb' )) # Assum that this stuff works from the root that its being called
|
@@ -0,0 +1 @@
|
|
1
|
+
env.name = "Henryetta"
|
@@ -0,0 +1 @@
|
|
1
|
+
env.lang = "German"
|
@@ -0,0 +1 @@
|
|
1
|
+
env.lang = "Spanish"
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'captain_planet'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
|
8
|
+
include CaptainPlanet
|
9
|
+
|
10
|
+
Spec::Runner.configure do |config|
|
11
|
+
|
12
|
+
end
|
Binary file
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# DO NOT MODIFY THIS FILE
|
2
|
+
module Bundler
|
3
|
+
file = File.expand_path(__FILE__)
|
4
|
+
dir = File.dirname(file)
|
5
|
+
|
6
|
+
ENV["PATH"] = "#{dir}/../../bin:#{ENV["PATH"]}"
|
7
|
+
ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}"
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift File.expand_path("#{dir}/gems/dirge-0.0.3/bin")
|
10
|
+
$LOAD_PATH.unshift File.expand_path("#{dir}/gems/dirge-0.0.3/lib")
|
11
|
+
|
12
|
+
@gemfile = "#{dir}/../../Gemfile"
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
|
16
|
+
@bundled_specs = {}
|
17
|
+
@bundled_specs["dirge"] = eval(File.read("#{dir}/specifications/dirge-0.0.3.gemspec"))
|
18
|
+
@bundled_specs["dirge"].loaded_from = "#{dir}/specifications/dirge-0.0.3.gemspec"
|
19
|
+
|
20
|
+
def self.add_specs_to_loaded_specs
|
21
|
+
Gem.loaded_specs.merge! @bundled_specs
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.add_specs_to_index
|
25
|
+
@bundled_specs.each do |name, spec|
|
26
|
+
Gem.source_index.add_spec spec
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
add_specs_to_loaded_specs
|
31
|
+
add_specs_to_index
|
32
|
+
|
33
|
+
def self.require_env(env = nil)
|
34
|
+
context = Class.new do
|
35
|
+
def initialize(env) @env = env && env.to_s ; end
|
36
|
+
def method_missing(*) ; end
|
37
|
+
def only(env)
|
38
|
+
old, @only = @only, _combine_onlys(env)
|
39
|
+
yield
|
40
|
+
@only = old
|
41
|
+
end
|
42
|
+
def except(env)
|
43
|
+
old, @except = @except, _combine_excepts(env)
|
44
|
+
yield
|
45
|
+
@except = old
|
46
|
+
end
|
47
|
+
def gem(name, *args)
|
48
|
+
opt = args.last || {}
|
49
|
+
only = _combine_onlys(opt[:only] || opt["only"])
|
50
|
+
except = _combine_excepts(opt[:except] || opt["except"])
|
51
|
+
files = opt[:require_as] || opt["require_as"] || name
|
52
|
+
files = [files] unless files.respond_to?(:each)
|
53
|
+
|
54
|
+
return unless !only || only.any? {|e| e == @env }
|
55
|
+
return if except && except.any? {|e| e == @env }
|
56
|
+
|
57
|
+
files.each { |f| require f }
|
58
|
+
yield if block_given?
|
59
|
+
true
|
60
|
+
end
|
61
|
+
private
|
62
|
+
def _combine_onlys(only)
|
63
|
+
return @only unless only
|
64
|
+
only = [only].flatten.compact.uniq.map { |o| o.to_s }
|
65
|
+
only &= @only if @only
|
66
|
+
only
|
67
|
+
end
|
68
|
+
def _combine_excepts(except)
|
69
|
+
return @except unless except
|
70
|
+
except = [except].flatten.compact.uniq.map { |o| o.to_s }
|
71
|
+
except |= @except if @except
|
72
|
+
except
|
73
|
+
end
|
74
|
+
end
|
75
|
+
context.new(env && env.to_s).instance_eval(File.read(@gemfile))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
module Gem
|
80
|
+
def source_index.refresh!
|
81
|
+
super
|
82
|
+
Bundler.add_specs_to_index
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
=Dirge
|
2
|
+
|
3
|
+
==Usage
|
4
|
+
|
5
|
+
require 'dirge'
|
6
|
+
require_relative '../to_my_file'
|
7
|
+
|
8
|
+
Or, the much simpler notation
|
9
|
+
|
10
|
+
require ~'../to_my_file'
|
11
|
+
|
12
|
+
annnd.
|
13
|
+
|
14
|
+
class MyAwesomeClass
|
15
|
+
autoload_relative :MyConstant, 'my_awesome_class/my_constant'
|
16
|
+
end
|
17
|
+
|
18
|
+
Again, this could be
|
19
|
+
|
20
|
+
class MyAwesomeClass
|
21
|
+
autoload :MyConstant, ~'my_awesome_class/my_constant'
|
22
|
+
end
|
23
|
+
|
24
|
+
All of this is powered by the new function:
|
25
|
+
|
26
|
+
__DIR__
|
@@ -0,0 +1,29 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |s|
|
4
|
+
s.name = "dirge"
|
5
|
+
s.description = s.summary = "Relative require, relative autoload and __DIR__"
|
6
|
+
s.email = "joshbuddy@gmail.com"
|
7
|
+
s.homepage = "http://github.com/joshbuddy/dirge"
|
8
|
+
s.authors = ["Joshua Hull"]
|
9
|
+
s.files = FileList["[A-Z]*", "{lib}/**/*"]
|
10
|
+
end
|
11
|
+
Jeweler::GemcutterTasks.new
|
12
|
+
rescue LoadError
|
13
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'spec'
|
17
|
+
require 'spec/rake/spectask'
|
18
|
+
task :spec => 'spec:all'
|
19
|
+
namespace(:spec) do
|
20
|
+
Spec::Rake::SpecTask.new(:all) do |t|
|
21
|
+
t.spec_opts ||= []
|
22
|
+
t.spec_opts << "-rubygems"
|
23
|
+
t.spec_opts << '-rlib/dirge'
|
24
|
+
t.spec_opts << "--options" << "spec/spec.opts"
|
25
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
0.0.3
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Kernel
|
2
|
+
def __DIR_REL__(called_from = nil)
|
3
|
+
called_from ||= caller.first
|
4
|
+
caller_path = called_from[/(.*?(?=:\d+(:|$)))/, 1]
|
5
|
+
caller_path = '.' if caller_path == ''
|
6
|
+
File.expand_path(File.dirname(caller_path))
|
7
|
+
end
|
8
|
+
|
9
|
+
unless method_defined?(:__DIR__)
|
10
|
+
alias_method :__DIR__, :__DIR_REL__
|
11
|
+
end
|
12
|
+
|
13
|
+
unless method_defined?(:require_relative)
|
14
|
+
def require_relative(path)
|
15
|
+
require File.join(__DIR_REL__(caller.first), path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Module
|
21
|
+
unless method_defined?(:autoload_relative)
|
22
|
+
def autoload_relative(name, filename)
|
23
|
+
autoload name, File.join(__DIR_REL__(caller.first), filename)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class String
|
29
|
+
unless method_defined?(:~@)
|
30
|
+
def ~@
|
31
|
+
File.expand_path(File.join(__DIR_REL__(caller.first), self))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe 'Dirge' do
|
2
|
+
it "should resolve a path" do
|
3
|
+
(~'test:2test/test').should == File.expand_path(File.join(File.dirname(__FILE__), 'test:2test', 'test'))
|
4
|
+
end
|
5
|
+
|
6
|
+
it 'should require a relative path' do
|
7
|
+
proc {
|
8
|
+
require_relative 'test:2test/test'
|
9
|
+
}.should raise_error(RuntimeError, 'okay okay, you included me')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should autoload a relative path' do
|
13
|
+
proc {
|
14
|
+
mod = Module.new do
|
15
|
+
autoload_relative :TestingTime, 'test:2test/test'
|
16
|
+
end
|
17
|
+
mod::TestingTime
|
18
|
+
}.should raise_error(RuntimeError, 'okay okay, you included me')
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should define __DIR__" do
|
22
|
+
__DIR__.should == File.expand_path(File.dirname(__FILE__))
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should define __DIR__ with a custom caller" do
|
26
|
+
__DIR__('testing/test.rb:3').should == File.expand_path('testing')
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
raise 'okay okay, you included me'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{dirge}
|
5
|
+
s.version = "0.0.3"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Joshua Hull"]
|
9
|
+
s.date = %q{2009-11-21}
|
10
|
+
s.description = %q{Relative require, relative autoload and __DIR__}
|
11
|
+
s.email = %q{joshbuddy@gmail.com}
|
12
|
+
s.extra_rdoc_files = ["README.rdoc"]
|
13
|
+
s.files = ["README.rdoc", "Rakefile", "VERSION", "lib/dirge.rb", "spec/dirge_spec.rb", "spec/test:2test/test.rb"]
|
14
|
+
s.homepage = %q{http://github.com/joshbuddy/dirge}
|
15
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubygems_version = %q{1.3.5}
|
18
|
+
s.summary = %q{Relative require, relative autoload and __DIR__}
|
19
|
+
s.test_files = ["spec/dirge_spec.rb", "spec/test:2test/test.rb"]
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: captain_planet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brad Gessler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-20 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
description: Captain Planet is a Ruby DSL that makes dealing with Environments much easier.
|
26
|
+
email: brad@bradgessler.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.markdown
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE
|
39
|
+
- README.markdown
|
40
|
+
- Rakefile
|
41
|
+
- VERSION
|
42
|
+
- captain_planet.gemspec
|
43
|
+
- lib/captain_planet.rb
|
44
|
+
- lib/captain_planet/builder.rb
|
45
|
+
- lib/captain_planet/environment.rb
|
46
|
+
- spec/captain_planet/builder_spec.rb
|
47
|
+
- spec/captain_planet/environment_spec.rb
|
48
|
+
- spec/captain_planet_spec.rb
|
49
|
+
- spec/fixtures/super_app/environment.rb
|
50
|
+
- spec/fixtures/super_app/environments/development.rb
|
51
|
+
- spec/fixtures/super_app/environments/production.rb
|
52
|
+
- spec/fixtures/super_app/environments/test.rb
|
53
|
+
- spec/fixtures/web_env.rb
|
54
|
+
- spec/spec.opts
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
- vendor/gems/cache/dirge-0.0.3.gem
|
57
|
+
- vendor/gems/environment.rb
|
58
|
+
- vendor/gems/gems/dirge-0.0.3/README.rdoc
|
59
|
+
- vendor/gems/gems/dirge-0.0.3/Rakefile
|
60
|
+
- vendor/gems/gems/dirge-0.0.3/VERSION
|
61
|
+
- vendor/gems/gems/dirge-0.0.3/lib/dirge.rb
|
62
|
+
- vendor/gems/gems/dirge-0.0.3/spec/dirge_spec.rb
|
63
|
+
- vendor/gems/gems/dirge-0.0.3/spec/test:2test/test.rb
|
64
|
+
- vendor/gems/specifications/dirge-0.0.3.gemspec
|
65
|
+
has_rdoc: true
|
66
|
+
homepage: http://github.com/bradgessler/captain_planet
|
67
|
+
licenses: []
|
68
|
+
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options:
|
71
|
+
- --charset=UTF-8
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.3.5
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: DSL for dealing with environments in Ruby projects
|
93
|
+
test_files:
|
94
|
+
- spec/captain_planet/builder_spec.rb
|
95
|
+
- spec/captain_planet/environment_spec.rb
|
96
|
+
- spec/captain_planet_spec.rb
|
97
|
+
- spec/fixtures/super_app/environment.rb
|
98
|
+
- spec/fixtures/super_app/environments/development.rb
|
99
|
+
- spec/fixtures/super_app/environments/production.rb
|
100
|
+
- spec/fixtures/super_app/environments/test.rb
|
101
|
+
- spec/fixtures/web_env.rb
|
102
|
+
- spec/spec_helper.rb
|