Class: Bundler::Dsl
- Inherits:
-
Object
- Object
- Bundler::Dsl
- Defined in:
- lib/bowline/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(bundle, environment) ⇒ Dsl
constructor
A new instance of Dsl.
- #only(*env) ⇒ Object
- #source(source) ⇒ Object
Constructor Details
#initialize(bundle, environment) ⇒ Dsl
Returns a new instance of Dsl.
13 14 15 16 17 18 19 |
# File 'lib/bowline/bundler/dsl.rb', line 13 def initialize(bundle, environment) @bundle = bundle @environment = environment @directory_sources = [] @git_sources = {} @only, @except, @directory, @git = nil, nil, nil, nil end |
Class Method Details
.evaluate(file, bundle, environment) ⇒ Object
7 8 9 10 11 |
# File 'lib/bowline/bundler/dsl.rb', line 7 def self.evaluate(file, bundle, environment) builder = new(bundle, environment) builder.instance_eval(File.read(file.to_s), file.to_s, 1) environment end |
Instance Method Details
#bin_path(path) ⇒ Object
25 26 27 |
# File 'lib/bowline/bundler/dsl.rb', line 25 def bin_path(path) @bundle.bindir = Pathname.new(path) end |
#bundle_path(path) ⇒ Object
21 22 23 |
# File 'lib/bowline/bundler/dsl.rb', line 21 def bundle_path(path) @bundle.path = Pathname.new(path) end |
#clear_sources ⇒ Object
76 77 78 |
# File 'lib/bowline/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/bowline/bundler/dsl.rb', line 56 def directory(path, = {}) raise DirectorySourceError, "cannot nest calls to directory or git" if @directory || @git @directory = DirectorySource.new(@bundle, .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/bowline/bundler/dsl.rb', line 29 def disable_rubygems @environment.rubygems = false end |
#disable_system_gems ⇒ Object
33 34 35 |
# File 'lib/bowline/bundler/dsl.rb', line 33 def disable_system_gems @environment.system_gems = false end |
#except(*env) ⇒ Object
50 51 52 53 54 |
# File 'lib/bowline/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 104 105 106 107 108 |
# File 'lib/bowline/bundler/dsl.rb', line 80 def gem(name, *args) = args.last.is_a?(Hash) ? args.pop : {} version = args.last keys = :vendored_at, :path, :only, :except, :git, :path, :bundle, :require_as, :tag, :branch, :ref unless (invalid = .keys - keys).empty? raise InvalidKey, "Only #{keys.join(", ")} are valid options to #gem. You used #{invalid.join(", ")}" end 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.new(@bundle) 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/bowline/bundler/dsl.rb', line 66 def git(uri, = {}) raise DirectorySourceError, "cannot nest calls to directory or git" if @directory || @git @git = GitSource.new(@bundle, .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/bowline/bundler/dsl.rb', line 44 def only(*env) old, @only = @only, _combine_only(env) yield @only = old end |