Class: Gem2Rpm::RpmDependencyList
- Inherits:
-
Object
- Object
- Gem2Rpm::RpmDependencyList
- Includes:
- Enumerable
- Defined in:
- lib/gem2rpm/rpm_dependency_list.rb
Instance Method Summary collapse
-
#comment_out ⇒ Object
Comment out the dependency.
-
#each ⇒ Object
Calls the given block once for each element in self, passing that element as a parameter.
-
#initialize(dependencies) ⇒ RpmDependencyList
constructor
A new instance of RpmDependencyList.
-
#reject ⇒ Object
Returns a new array containing the items in self for which the given block is not true.
-
#to_rpm ⇒ Object
Returns string with all dependencies from the list converted into entries suitable for RPM .spec file.
-
#virtualize ⇒ Object
Convert to rubygem() virtual provide dependencies.
-
#with_requires ⇒ Object
Output dependencies with RPM requires tag.
Constructor Details
#initialize(dependencies) ⇒ RpmDependencyList
Returns a new instance of RpmDependencyList.
7 8 9 |
# File 'lib/gem2rpm/rpm_dependency_list.rb', line 7 def initialize(dependencies) @items = dependencies.map { |r| RpmDependency.new(r) } end |
Instance Method Details
#comment_out ⇒ Object
Comment out the dependency.
46 47 48 49 50 |
# File 'lib/gem2rpm/rpm_dependency_list.rb', line 46 def comment_out dep_list = self.map(&:comment_out) self.class.new dep_list end |
#each ⇒ Object
Calls the given block once for each element in self, passing that element as a parameter. Returns the array itself. If no block is given, an Enumerator is returned.
14 15 16 17 18 19 |
# File 'lib/gem2rpm/rpm_dependency_list.rb', line 14 def each # Return Enumerator when called withoug block. return to_enum(__callee__) unless block_given? @items.each { |item| yield item } end |
#reject ⇒ Object
Returns a new array containing the items in self for which the given block is not true. The ordering of non-rejected elements is maintained. If no block is given, an Enumerator is returned instead.
24 25 26 27 28 29 |
# File 'lib/gem2rpm/rpm_dependency_list.rb', line 24 def reject # Return Enumerator when called withoug block. return to_enum(__callee__) unless block_given? self.class.new(@items.reject { |item| yield item }) end |
#to_rpm ⇒ Object
Returns string with all dependencies from the list converted into entries suitable for RPM .spec file. Thise entries should include all necessary macros depending on file categorization.
55 56 57 58 |
# File 'lib/gem2rpm/rpm_dependency_list.rb', line 55 def to_rpm s = entries.map(&:to_rpm).join("\n") s += "\n" unless s.empty? end |
#virtualize ⇒ Object
Convert to rubygem() virtual provide dependencies.
32 33 34 35 36 |
# File 'lib/gem2rpm/rpm_dependency_list.rb', line 32 def virtualize dep_list = self.map(&:virtualize) self.class.new dep_list end |
#with_requires ⇒ Object
Output dependencies with RPM requires tag.
39 40 41 42 43 |
# File 'lib/gem2rpm/rpm_dependency_list.rb', line 39 def with_requires dep_list = self.map(&:with_requires) self.class.new dep_list end |