Skip to content

Commit

Permalink
Moving in thor
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlhuda committed Jan 11, 2010
1 parent 2f42417 commit 67859e4
Show file tree
Hide file tree
Showing 45 changed files with 4,901 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
.DS_Store
tmp
pkg
20 changes: 20 additions & 0 deletions LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2009 Engine Yard

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 changes: 46 additions & 0 deletions Rakefile
@@ -0,0 +1,46 @@
$:.unshift File.expand_path("../lib", __FILE__)

require 'rubygems'
require 'rubygems/specification'
require 'bubble'

spec = Gem::Specification.new do |s|
s.name = "bubble"
s.version = Bubble::VERSION
s.authors = ["Carl Lerche", "Yehuda Katz"]
s.email = ["carlhuda@engineyard.com"]
s.homepage = "http://github.com/carlhuda/bubble"
s.summary = "Bubbles are fun"

s.platform = Gem::Platform::RUBY

s.required_rubygems_version = ">= 1.3.5"

s.files = Dir.glob("{bin,lib}/**/*") + %w(LICENSE README)
s.executables = ['bbl']
s.require_path = 'lib'
end

begin
require 'spec/rake/spectask'
rescue LoadError
task :spec do
$stderr.puts '`gem install rspec` to run specs'
end
else
desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = %w(-fs --color)
t.warning = true
end
end

desc "create a gemspec file"
task :gemspec do
File.open("#{spec.name}.gemspec", 'w') do |file|
file.puts spec.to_ruby
end
end

task :default => :spec
20 changes: 20 additions & 0 deletions lib/bubble.rb
@@ -0,0 +1,20 @@
module Bubble
VERSION = "0.9.0.pre"

autoload :Definition, 'bubble/definition'
autoload :Dependency, 'bubble/dependency'
autoload :Dsl, 'bubble/dsl'
autoload :Environment, 'bubble/environment'

class GemfileNotFound < StandardError; end
class GemNotFound < StandardError; end
class VersionConflict < StandardError; end

def self.load(gemfile = nil)
Environment.new(definition(gemfile))
end

def self.definition(gemfile = nil)
Definition.from_gemfile(gemfile)
end
end
33 changes: 33 additions & 0 deletions lib/bubble/definition.rb
@@ -0,0 +1,33 @@
module Bubble
class Definition
def self.from_gemfile(gemfile)
gemfile = Pathname.new(gemfile || default_gemfile).expand_path

unless gemfile.file?
raise GemfileNotFound, "`#{gemfile}` not found"
end

definition = new
Dsl.evaluate(gemfile, definition)
definition
end

def self.default_gemfile
current = Pathname.new(Dir.pwd)

until current.root?
filename = current.join("Gemfile")
return filename if filename.exist?
current = current.parent
end

raise GemfileNotFound, "the default Gemfile was not found"
end

attr_reader :dependencies

def initialize
@dependencies = []
end
end
end
13 changes: 13 additions & 0 deletions lib/bubble/dependency.rb
@@ -0,0 +1,13 @@
require 'rubygems/dependency'

module Bubble
class Dependency < Gem::Dependency
def initialize(name, version, options = {}, &blk)
options.each do |k, v|
options[k.to_s] = v
end

super(name, version)
end
end
end
20 changes: 20 additions & 0 deletions lib/bubble/dsl.rb
@@ -0,0 +1,20 @@
module Bubble
class Dsl
def self.evaluate(gemfile, definition)
builder = new(definition)
builder.instance_eval(File.read(gemfile.to_s), gemfile.to_s, 1)
definition
end

def initialize(definition)
@definition = definition
end

def gem(name, *args)
options = Hash === args.last ? args.pop : {}
version = args.last || ">= 0"

@definition.dependencies << Dependency.new(name, version, options)
end
end
end
15 changes: 15 additions & 0 deletions lib/bubble/environment.rb
@@ -0,0 +1,15 @@
module Bubble
class Environment
def initialize(definition)
@definition = definition
end

def dependencies
@definition.dependencies
end

def gems
[]
end
end
end

0 comments on commit 67859e4

Please sign in to comment.