Sha256: e3f762b2b53d8f842f5281f1c03af658b505a7c5c133af8598822e4f3f401164
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
module Bundler class DslError < StandardError; end class Dsl def self.evaluate(gemfile) builder = new builder.instance_eval(File.read(gemfile.to_s), gemfile.to_s, 1) builder.to_definition end def initialize @sources = [] # Gem.sources.map { |s| Source::Rubygems.new(:uri => s) } @dependencies = [] @group = nil end def gem(name, *args) options = Hash === args.last ? args.pop : {} version = args.last || ">= 0" _normalize_options(name, version, options) @dependencies << Dependency.new(name, version, options) end def source(source) source = case source when :gemcutter, :rubygems, :rubyforge then Source::Rubygems.new(:uri => "http://gemcutter.org") when String then Source::Rubygems.new(:uri => source) else source end @sources << source source end def path(path, options = {}) source Source::Path.new(options.merge(:path => path)) end def git(uri, options = {}) source Source::Git.new(options.merge(:uri => uri)) end def to_definition Definition.new(@dependencies, @sources) end def group(name, options = {}, &blk) old, @group = @group, name yield ensure @group = old end private def _version?(version) version && Gem::Version.new(version) rescue false end def _normalize_options(name, version, opts) opts.each do |k, v| opts[k.to_s] = v end opts["group"] ||= @group _normalize_git_options(name, version, opts) end def _normalize_git_options(name, version, opts) # Normalize Git options if opts["git"] source = git(opts["git"], :ref => opts["ref"]) source.default_spec name, version if _version?(version) opts["source"] = source end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bundler-0.9.0.pre3 | lib/bundler/dsl.rb |
bundler-0.9.0.pre2 | lib/bundler/dsl.rb |
bundler-0.9.0.pre1 | lib/bundler/dsl.rb |