Class: Bundler::Dsl
- Inherits:
-
Object
- Object
- Bundler::Dsl
- Defined in:
- lib/bundler/dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
- #bin_path(path) ⇒ Object
- #bundle_path(path) ⇒ Object
- #clear_sources ⇒ Object
- #directory(path, options = {}) ⇒ Object
- #disable_rubygems ⇒ Object
- #disable_system_gems ⇒ Object
- #except(*env) ⇒ Object
- #gem(name, *args) ⇒ Object
- #git(uri, options = {}) ⇒ Object
-
#initialize(environment) ⇒ Dsl
constructor
A new instance of Dsl.
- #only(*env) ⇒ Object
- #source(source) ⇒ Object
Constructor Details
#initialize(environment) ⇒ Dsl
Returns a new instance of Dsl.
10 11 12 13 14 15 |
# File 'lib/bundler/dsl.rb', line 10 def initialize(environment) @environment = environment @directory_sources = [] @git_sources = {} @only, @except, @directory, @git = nil, nil, nil, nil end |
Class Method Details
.evaluate(environment, file) ⇒ Object
5 6 7 8 |
# File 'lib/bundler/dsl.rb', line 5 def self.evaluate(environment, file) builder = new(environment) builder.instance_eval(File.read(file.to_s), file.to_s, 1) end |
Instance Method Details
#bin_path(path) ⇒ Object
23 24 25 26 27 |
# File 'lib/bundler/dsl.rb', line 23 def bin_path(path) path = Pathname.new(path) @environment.bindir = (path.relative? ? @environment.root.join(path) : path). end |
#bundle_path(path) ⇒ Object
17 18 19 20 21 |
# File 'lib/bundler/dsl.rb', line 17 def bundle_path(path) path = Pathname.new(path) @environment.gem_path = (path.relative? ? @environment.root.join(path) : path). end |
#clear_sources ⇒ Object
76 77 78 |
# File 'lib/bundler/dsl.rb', line 76 def clear_sources @environment.clear_sources end |
#directory(path, options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/bundler/dsl.rb', line 56 def directory(path, = {}) raise DirectorySourceError, "cannot nest calls to directory or git" if @directory || @git @directory = DirectorySource.new(.merge(:location => path)) @directory_sources << @directory @environment.add_priority_source(@directory) retval = yield if block_given? @directory = nil retval end |
#disable_rubygems ⇒ Object
29 30 31 |
# File 'lib/bundler/dsl.rb', line 29 def disable_rubygems @environment.rubygems = false end |
#disable_system_gems ⇒ Object
33 34 35 |
# File 'lib/bundler/dsl.rb', line 33 def disable_system_gems @environment.system_gems = false end |
#except(*env) ⇒ Object
50 51 52 53 54 |
# File 'lib/bundler/dsl.rb', line 50 def except(*env) old, @except = @except, _combine_except(env) yield @except = old end |
#gem(name, *args) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/bundler/dsl.rb', line 80 def gem(name, *args) = args.last.is_a?(Hash) ? args.pop : {} version = args.last if path = .delete(:vendored_at) [:path] = path warn "The :vendored_at option is deprecated. Use :path instead.\nFrom #{caller[0]}" end [:only] = _combine_only([:only] || ["only"]) [:except] = _combine_except([:except] || ["except"]) dep = Dependency.new(name, .merge(:version => version)) if .key?(:bundle) && ![:bundle] dep.source = SystemGemSource.instance elsif @git || [:git] dep.source = _handle_git_option(name, version, ) elsif @directory || [:path] dep.source = _handle_vendored_option(name, version, ) end @environment.dependencies << dep end |
#git(uri, options = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/bundler/dsl.rb', line 66 def git(uri, = {}) raise DirectorySourceError, "cannot nest calls to directory or git" if @directory || @git @git = GitSource.new(.merge(:uri => uri)) @git_sources[uri] = @git @environment.add_priority_source(@git) retval = yield if block_given? @git = nil retval end |
#only(*env) ⇒ Object
44 45 46 47 48 |
# File 'lib/bundler/dsl.rb', line 44 def only(*env) old, @only = @only, _combine_only(env) yield @only = old end |