Class: Rake::DevEiate::GemDepFinder
- Inherits:
-
Object
- Object
- Rake::DevEiate::GemDepFinder
- Defined in:
- lib/rake/deveiate/gem_dep_finder.rb
Overview
A dependency finder that groks the GemDependencyApi
Instance Attribute Summary collapse
-
#current_groups ⇒ Object
readonly
The current set of groups to add to any declared gems.
-
#dependencies ⇒ Object
readonly
The Set of Gem::Dependency objects that describe the loaded dependencies.
-
#depfile ⇒ Object
readonly
The Pathname of the file to find dependencies in.
Instance Method Summary collapse
-
#gem(name, *requirements, **options) ⇒ Object
Declare a dependency on a gem.
-
#gemspec ⇒ Object
Raise, as the gemdeps file should be the authoritative source.
-
#group(*names) ⇒ Object
Declare a group block.
-
#initialize(depfile) ⇒ GemDepFinder
constructor
Create a new GemDepFinder that will find dependencies in the given
depfile. -
#load ⇒ Object
Load the dependencies file.
-
#no_op_method ⇒ Object
(also: #source, #git, #platform, #platforms, #ruby)
Ignore a gem dependency API call.
Constructor Details
#initialize(depfile) ⇒ GemDepFinder
Create a new GemDepFinder that will find dependencies in the given depfile.
14 15 16 17 18 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 14 def initialize( depfile ) @depfile = Pathname( depfile ) @dependencies = Set.new @current_groups = Set.new end |
Instance Attribute Details
#current_groups ⇒ Object (readonly)
The current set of groups to add to any declared gems
36 37 38 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 36 def current_groups @current_groups end |
#dependencies ⇒ Object (readonly)
The Set of Gem::Dependency objects that describe the loaded dependencies
32 33 34 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 32 def dependencies @dependencies end |
#depfile ⇒ Object (readonly)
The Pathname of the file to find dependencies in
28 29 30 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 28 def depfile @depfile end |
Instance Method Details
#gem(name, *requirements, **options) ⇒ Object
Declare a dependency on a gem. Ignores every option except :group.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 52 def gem( name, *requirements, ** ) if [:group] == :development || [:groups]&.include?( :development ) || self.current_groups.include?( :development ) requirements.push( :development ) end dependency = Gem::Dependency.new( name, *requirements ) self.dependencies.add( dependency ) end |
#gemspec ⇒ Object
Raise, as the gemdeps file should be the authoritative source.
79 80 81 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 79 def gemspec( * ) raise "Circular dependency: can't depend on the gemspec to build itself" end |
#group(*names) ⇒ Object
Declare a group block.
67 68 69 70 71 72 73 74 75 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 67 def group( *names ) = names.pop if names.last.is_a?( Hash ) previous_groups = self.current_groups.dup self.current_groups.replace( names ) yield ensure self.current_groups.replace( previous_groups ) if previous_groups end |
#load ⇒ Object
Load the dependencies file.
40 41 42 43 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 40 def load source = self.depfile.read self.instance_eval( source, self.depfile.to_s, 1 ) end |
#no_op_method ⇒ Object Also known as: source, git, platform, platforms, ruby
Ignore a gem dependency API call.
85 86 87 |
# File 'lib/rake/deveiate/gem_dep_finder.rb', line 85 def no_op_method( * ) # :nodoc: yield if block_given? end |