Class: ReaPack::Index::Provides
- Inherits:
-
Struct
- Object
- Struct
- ReaPack::Index::Provides
- Defined in:
- lib/reapack/index/provides.rb
Constant Summary collapse
- PROVIDES_REGEX =
/ \A (?: \[ \s* (?<options> .+? ) \s* \] )? \s* (?<pattern>.+?) (?: \s*>\s*(?<target>.+?) | \s+ (?<url_tpl>(?:file|https?):\/\/.+) )? \z /x.freeze
Instance Attribute Summary collapse
-
#file_pattern ⇒ Object
Returns the value of attribute file_pattern.
-
#main ⇒ Object
(also: #main?)
Returns the value of attribute main.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url_template ⇒ Object
Returns the value of attribute url_template.
Class Method Summary collapse
Instance Attribute Details
#file_pattern ⇒ Object
Returns the value of attribute file_pattern
2 3 4 |
# File 'lib/reapack/index/provides.rb', line 2 def file_pattern @file_pattern end |
#main ⇒ Object Also known as: main?
Returns the value of attribute main
2 3 4 |
# File 'lib/reapack/index/provides.rb', line 2 def main @main end |
#platform ⇒ Object
Returns the value of attribute platform
2 3 4 |
# File 'lib/reapack/index/provides.rb', line 2 def platform @platform end |
#target ⇒ Object
Returns the value of attribute target
2 3 4 |
# File 'lib/reapack/index/provides.rb', line 2 def target @target end |
#type ⇒ Object
Returns the value of attribute type
2 3 4 |
# File 'lib/reapack/index/provides.rb', line 2 def type @type end |
#url_template ⇒ Object
Returns the value of attribute url_template
2 3 4 |
# File 'lib/reapack/index/provides.rb', line 2 def url_template @url_template end |
Class Method Details
.parse(line) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/reapack/index/provides.rb', line 27 def parse(line) m = line.strip.match PROVIDES_REGEX return unless m instance = self.new m[:pattern], m[:url_tpl], m[:target] m[:options]&.split("\x20")&.each {|user_opt| user_opt.strip! next if user_opt.empty? opt = user_opt.downcase if Source.is_platform? opt instance.platform = opt.to_sym elsif type = ReaPack::Index.resolve_type(opt) instance.type = type elsif opt =~ /\A(nomain)|main(?:=(.+))?\Z/ if $1 # nomain instance.main = false elsif $2 # explicit sections instance.main = $2.split(',').reject(&:empty?).map {|s| s.to_sym } else # implicit sections instance.main = true end else raise Error, "unknown option '#{user_opt}'" end } instance end |
.parse_each(input) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/reapack/index/provides.rb', line 19 def parse_each(input) if block_given? input.to_s.lines.map {|line| i = parse(line) and yield i } else enum_for :parse_each, input end end |