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 144
144:     def self.deprecate(name, replacement = nil)
145:       define_method(name) do |*|
146:         message = "'#{name}' has been removed from the Gemfile DSL, "
147:         if replacement
148:           message << "and has been replaced with '#{replacement}'."
149:         else
150:           message << "and is no longer supported."
151:         end
152:         message << "\nSee the README for more information on upgrading from Bundler 0.8."
153:         raise DeprecatedError, message
154:       end
155:     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 135
135:     def env(name)
136:       @env, old = name, @env
137:       yield
138:     ensure
139:       @env = old
140:     end
gem(name, *args) click to toggle source
    # File lib/bundler/dsl.rb, line 47
47:     def gem(name, *args)
48:       if name.is_a?(Symbol)
49:         raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.}
50:       end
51: 
52:       options = Hash === args.last ? args.pop : {}
53:       version = args || [">= 0"]
54: 
55:       _deprecated_options(options)
56:       _normalize_options(name, version, options)
57: 
58:       dep = Dependency.new(name, version, options)
59: 
60:       if current = @dependencies.find { |d| d.name == dep.name }
61:         if current.requirement != dep.requirement
62:           raise DslError, "You cannot specify the same gem twice with different version requirements. "                            "You specified: #{current.name} (#{current.requirement}) and "                            "#{dep.name} (#{dep.requirement})"
63:         end
64: 
65:         if current.source != dep.source
66:           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}"
67:         end
68:       end
69:       @dependencies << Dependency.new(name, version, options)
70:     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 = Bundler.load_gemspec(gemspecs.first)
33:         raise InvalidOption, "There was an error loading the gemspec at #{gemspecs.first}." unless spec
34:         gem spec.name, :path => path
35:         group(development_group) do
36:           spec.development_dependencies.each do |dep|
37:             gem dep.name, *dep.requirement.as_list
38:           end
39:         end
40:       when 0
41:         raise InvalidOption, "There are no gemspecs at #{path}."
42:       else
43:         raise InvalidOption, "There are multiple gemspecs at #{path}. Please use the :name option to specify which one."
44:       end
45:     end
git(uri, options = {}, source_options = {}, &blk) click to toggle source
     # File lib/bundler/dsl.rb, line 99
 99:     def git(uri, options = {}, source_options = {}, &blk)
100:       unless block_given?
101:         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"
102:         raise DeprecatedError, msg
103:       end
104: 
105:       source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk
106:     end
group(*args, &blk) click to toggle source
     # File lib/bundler/dsl.rb, line 120
120:     def group(*args, &blk)
121:       @groups.concat args
122:       yield
123:     ensure
124:       args.each { @groups.pop }
125:     end
path(path, options = {}, source_options = {}, &blk) click to toggle source
    # File lib/bundler/dsl.rb, line 95
95:     def path(path, options = {}, source_options = {}, &blk)
96:       source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk
97:     end
platform(*platforms) click to toggle source
Alias for: platforms
platforms(*platforms) click to toggle source
     # File lib/bundler/dsl.rb, line 127
127:     def platforms(*platforms)
128:       @platforms.concat platforms
129:       yield
130:     ensure
131:       platforms.each { @platforms.pop }
132:     end
Also aliased as: platform
source(source, options = {}) click to toggle source
    # File lib/bundler/dsl.rb, line 76
76:     def source(source, options = {})
77:       case source
78:       when :gemcutter, :rubygems, :rubyforge then
79:         rubygems_source "http://rubygems.org"
80:         return
81:       when String
82:         rubygems_source source
83:         return
84:       end
85: 
86:       @source = source
87:       options[:prepend] ? @sources.unshift(@source) : @sources << @source
88: 
89:       yield if block_given?
90:       @source
91:     ensure
92:       @source = nil
93:     end
to_definition(lockfile, unlock) click to toggle source
     # File lib/bundler/dsl.rb, line 114
114:     def to_definition(lockfile, unlock)
115:       @sources << @rubygems_source
116:       @sources.uniq!
117:       Definition.new(lockfile, @dependencies, @sources, unlock)
118:     end

Private Instance Methods

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.