Class: Bundler::Dependency
- Inherits:
-
Gem::Dependency
- Object
- Gem::Dependency
- Bundler::Dependency
- Defined in:
- lib/bowline/bundler/dependency.rb
Instance Attribute Summary collapse
-
#except ⇒ Object
readonly
Returns the value of attribute except.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#only ⇒ Object
readonly
Returns the value of attribute only.
-
#require_as ⇒ Object
readonly
Returns the value of attribute require_as.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #in?(environment) ⇒ Boolean
-
#initialize(name, options = {}, &block) ⇒ Dependency
constructor
A new instance of Dependency.
- #no_bundle? ⇒ Boolean
- #require_env(environment) ⇒ Object
Methods inherited from Gem::Dependency
Constructor Details
#initialize(name, options = {}, &block) ⇒ Dependency
Returns a new instance of Dependency.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bowline/bundler/dependency.rb', line 8 def initialize(name, = {}, &block) .dup.each do |key, value| [key.to_s] = .delete(key) end super(name, ["version"] || ">= 0") @require_as = ["require_as"] @only = ["only"] @except = ["except"] @source = ["source"] @block = block if (@only && @only.include?("rubygems")) || (@except && @except.include?("rubygems")) raise InvalidEnvironmentName, "'rubygems' is not a valid environment name" end end |
Instance Attribute Details
#except ⇒ Object (readonly)
Returns the value of attribute except.
5 6 7 |
# File 'lib/bowline/bundler/dependency.rb', line 5 def except @except end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/bowline/bundler/dependency.rb', line 5 def name @name end |
#only ⇒ Object (readonly)
Returns the value of attribute only.
5 6 7 |
# File 'lib/bowline/bundler/dependency.rb', line 5 def only @only end |
#require_as ⇒ Object (readonly)
Returns the value of attribute require_as.
5 6 7 |
# File 'lib/bowline/bundler/dependency.rb', line 5 def require_as @require_as end |
#source ⇒ Object
Returns the value of attribute source.
6 7 8 |
# File 'lib/bowline/bundler/dependency.rb', line 6 def source @source end |
Instance Method Details
#==(o) ⇒ Object
54 55 56 57 |
# File 'lib/bowline/bundler/dependency.rb', line 54 def ==(o) [name, version, require_as, only, except] == [o.name, o.version, o.require_as, o.only, o.except] end |
#in?(environment) ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/bowline/bundler/dependency.rb', line 26 def in?(environment) environment = environment.to_s return false unless !@only || @only.include?(environment) return false if @except && @except.include?(environment) true end |
#no_bundle? ⇒ Boolean
50 51 52 |
# File 'lib/bowline/bundler/dependency.rb', line 50 def no_bundle? source == SystemGemSource.instance end |
#require_env(environment) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bowline/bundler/dependency.rb', line 34 def require_env(environment) return unless in?(environment) if @require_as Array(@require_as).each { |file| require file } else begin require name rescue LoadError # Do nothing end end @block.call if @block end |