Parent

Class Index [+]

Quicksearch

Bundler::Dsl

Constants

VALID_PLATFORMS

Public Class Methods

deprecate(name, replacement = nil) click to toggle source

Deprecated methods

     # File lib/bundler/dsl.rb, line 147
147:     def self.deprecate(name, replacement = nil)
148:       define_method(name) do |*|
149:         message = "'#{name}' has been removed from the Gemfile DSL, "
150:         if replacement
151:           message << "and has been replaced with '#{replacement}'."
152:         else
153:           message << "and is no longer supported."
154:         end
155:         message << "\nSee the README for more information on upgrading from Bundler 0.8."
156:         raise DeprecatedError, message
157:       end
158:     end
evaluate(gemfile, lockfile, unlock) click to toggle source
   # File lib/bundler/dsl.rb, line 5
5:     def self.evaluate(gemfile, lockfile, unlock)
6:       builder = new
7:       builder.instance_eval(Bundler.read_file(gemfile.to_s), gemfile.to_s, 1)
8:       builder.to_definition(lockfile, unlock)
9:     end
new() click to toggle source
    # File lib/bundler/dsl.rb, line 13
13:     def initialize
14:       @rubygems_source = Source::Rubygems.new
15:       @source          = nil
16:       @sources         = []
17:       @dependencies    = []
18:       @groups          = []
19:       @platforms       = []
20:       @env             = nil
21:     end

Public Instance Methods

env(name) click to toggle source
     # File lib/bundler/dsl.rb, line 138
138:     def env(name)
139:       @env, old = name, @env
140:       yield
141:     ensure
142:       @env = old
143:     end
gem(name, *args) click to toggle source
    # File lib/bundler/dsl.rb, line 50
50:     def gem(name, *args)
51:       if name.is_a?(Symbol)
52:         raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.}
53:       end
54: 
55:       options = Hash === args.last ? args.pop : {}
56:       version = args || [">= 0"]
57: 
58:       _deprecated_options(options)
59:       _normalize_options(name, version, options)
60: 
61:       dep = Dependency.new(name, version, options)
62: 
63:       if current = @dependencies.find { |d| d.name == dep.name }
64:         if current.requirement != dep.requirement
65:           raise DslError, "You cannot specify the same gem twice with different version requirements. "                            "You specified: #{current.name} (#{current.requirement}) and "                            "#{dep.name} (#{dep.requirement})"
66:         end
67: 
68:         if current.source != dep.source
69:           raise DslError, "You cannot specify the same gem twice coming from different sources. You "                            "specified that #{dep.name} (#{dep.requirement}) should come from "                            "#{current.source || 'an unspecfied source'} and #{dep.source}"
70:         end
71:       end
72:       @dependencies << Dependency.new(name, version, options)
73:     end
gemspec(opts = nil) click to toggle source
    # File lib/bundler/dsl.rb, line 23
23:     def gemspec(opts = nil)
24:       path              = opts && opts[:path] || '.'
25:       name              = opts && opts[:name] || '*'
26:       development_group = opts && opts[:development_group] || :development
27:       path              = File.expand_path(path, Bundler.default_gemfile.dirname)
28:       gemspecs = Dir[File.join(path, "#{name}.gemspec")]
29: 
30:       case gemspecs.size
31:       when 1
32:         spec = Gem::Specification.load(gemspecs.first)
33:         raise InvalidOption, "There was an error loading the gemspec at #{gemspecs.first}." unless spec
34:         gem spec.name, :path => path
35:         spec.runtime_dependencies.each do |dep|
36:           gem dep.name, *dep.requirement.as_list
37:         end
38:         group(development_group) do
39:           spec.development_dependencies.each do |dep|
40:             gem dep.name, *dep.requirement.as_list
41:           end
42:         end
43:       when 0
44:         raise InvalidOption, "There are no gemspecs at #{path}."
45:       else
46:         raise InvalidOption, "There are multiple gemspecs at #{path}. Please use the :name option to specify which one."
47:       end
48:     end
git(uri, options = {}, source_options = {}, &blk) click to toggle source
     # File lib/bundler/dsl.rb, line 102
102:     def git(uri, options = {}, source_options = {}, &blk)
103:       unless block_given?
104:         msg = "You can no longer specify a git source by itself. Instead, \n"                "either use the :git option on a gem, or specify the gems that \n"                "bundler should find in the git source by passing a block to \n"                "the git method, like: \n\n"                "  git 'git://github.com/rails/rails.git' do\n"                "    gem 'rails'\n"                "  end"
105:         raise DeprecatedError, msg
106:       end
107: 
108:       source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk
109:     end
group(*args, &blk) click to toggle source
     # File lib/bundler/dsl.rb, line 123
123:     def group(*args, &blk)
124:       @groups.concat args
125:       yield
126:     ensure
127:       args.each { @groups.pop }
128:     end
path(path, options = {}, source_options = {}, &blk) click to toggle source
     # File lib/bundler/dsl.rb, line 98
 98:     def path(path, options = {}, source_options = {}, &blk)
 99:       source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk
100:     end
platform(*platforms) click to toggle source
Alias for: platforms
platforms(*platforms) click to toggle source
     # File lib/bundler/dsl.rb, line 130
130:     def platforms(*platforms)
131:       @platforms.concat platforms
132:       yield
133:     ensure
134:       platforms.each { @platforms.pop }
135:     end
Also aliased as: platform
source(source, options = {}) click to toggle source
    # File lib/bundler/dsl.rb, line 79
79:     def source(source, options = {})
80:       case source
81:       when :gemcutter, :rubygems, :rubyforge then
82:         rubygems_source "http://rubygems.org"
83:         return
84:       when String
85:         rubygems_source source
86:         return
87:       end
88: 
89:       @source = source
90:       options[:prepend] ? @sources.unshift(@source) : @sources << @source
91: 
92:       yield if block_given?
93:       @source
94:     ensure
95:       @source = nil
96:     end
to_definition(lockfile, unlock) click to toggle source
     # File lib/bundler/dsl.rb, line 117
117:     def to_definition(lockfile, unlock)
118:       @sources << @rubygems_source
119:       @sources.uniq!
120:       Definition.new(lockfile, @dependencies, @sources, unlock)
121:     end

Private Instance Methods

_deprecated_options(options) click to toggle source
     # File lib/bundler/dsl.rb, line 234
234:     def _deprecated_options(options)
235:       if options.include?(:require_as)
236:         raise DeprecatedError, "Please replace :require_as with :require"
237:       elsif options.include?(:vendored_at)
238:         raise DeprecatedError, "Please replace :vendored_at with :path"
239:       elsif options.include?(:only)
240:         raise DeprecatedError, "Please replace :only with :group"
241:       elsif options.include?(:except)
242:         raise DeprecatedError, "The :except option is no longer supported"
243:       end
244:     end
_normalize_hash(opts) click to toggle source
     # File lib/bundler/dsl.rb, line 175
175:     def _normalize_hash(opts)
176:       # Cannot modify a hash during an iteration in 1.9
177:       opts.keys.each do |k|
178:         next if String === k
179:         v = opts[k]
180:         opts.delete(k)
181:         opts[k.to_s] = v
182:       end
183:       opts
184:     end
_normalize_options(name, version, opts) click to toggle source
     # File lib/bundler/dsl.rb, line 186
186:     def _normalize_options(name, version, opts)
187:       _normalize_hash(opts)
188: 
189:       invalid_keys = opts.keys - %(group groups git path name branch ref tag require submodules platform platforms)
190:       if invalid_keys.any?
191:         plural = invalid_keys.size > 1
192:         message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} "
193:         if plural
194:           message << "as options for gem '#{name}', but they are invalid."
195:         else
196:           message << "as an option for gem '#{name}', but it is invalid."
197:         end
198:         raise InvalidOption, message
199:       end
200: 
201:       groups = @groups.dup
202:       opts["group"] = opts.delete("groups") || opts["group"]
203:       groups.concat Array(opts.delete("group"))
204:       groups = [:default] if groups.empty?
205: 
206:       platforms = @platforms.dup
207:       opts["platforms"] = opts["platform"] || opts["platforms"]
208:       platforms.concat Array(opts.delete("platforms"))
209:       platforms.map! { |p| p.to_sym }
210:       platforms.each do |p|
211:         next if VALID_PLATFORMS.include?(p)
212:         raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
213:       end
214: 
215:       # Normalize git and path options
216:       ["git", "path"].each do |type|
217:         if param = opts[type]
218:           if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
219:             options = opts.merge("name" => name, "version" => $1)
220:           else
221:             options = opts.dup
222:           end
223:           source = send(type, param, options, :prepend => true) {}
224:           opts["source"] = source
225:         end
226:       end
227: 
228:       opts["source"]  ||= @source
229:       opts["env"]     ||= @env
230:       opts["platforms"] = platforms.dup
231:       opts["group"]     = groups
232:     end
rubygems_source(source) click to toggle source
     # File lib/bundler/dsl.rb, line 170
170:     def rubygems_source(source)
171:       @rubygems_source.add_remote source
172:       @sources << @rubygems_source
173:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.