Class: GemCache::InfoParser
- Inherits:
-
Object
- Object
- GemCache::InfoParser
- Defined in:
- lib/gemcache/parsers/info_parser.rb
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
The SHA256 checksum of the gem from the info entry.
-
#dependencies ⇒ Object
readonly
A list of Gem::Dependencies from the info entry.
-
#ruby ⇒ Object
readonly
The required Ruby version of the gem from the info entry.
-
#rubygems ⇒ Object
readonly
The required rubygems version of the gem from the info entry.
-
#version ⇒ Object
readonly
The version of the gem from the info entry.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(entry) ⇒ InfoParser
constructor
A new instance of InfoParser.
Constructor Details
#initialize(entry) ⇒ InfoParser
Returns a new instance of InfoParser.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gemcache/parsers/info_parser.rb', line 18 def initialize(entry) # Split line into two parts: # (0) Semantic version and runtime dependencies # (1) Checksum and required ruby/rubygems versions split = entry.split("|") ver_and_deps = split[0].strip sha_and_ruby = split[1].strip # Parse each part of the entry in the info file parts = parse_version(ver_and_deps) parse_dependencies(parts) parts = parse_checksum(sha_and_ruby) parts = parse_ruby(parts) parse_rubygems(parts) end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
The SHA256 checksum of the gem from the info entry.
10 11 12 |
# File 'lib/gemcache/parsers/info_parser.rb', line 10 def checksum @checksum end |
#dependencies ⇒ Object (readonly)
A list of Gem::Dependencies from the info entry.
7 8 9 |
# File 'lib/gemcache/parsers/info_parser.rb', line 7 def dependencies @dependencies end |
#ruby ⇒ Object (readonly)
The required Ruby version of the gem from the info entry.
13 14 15 |
# File 'lib/gemcache/parsers/info_parser.rb', line 13 def ruby @ruby end |
#rubygems ⇒ Object (readonly)
The required rubygems version of the gem from the info entry.
16 17 18 |
# File 'lib/gemcache/parsers/info_parser.rb', line 16 def rubygems @rubygems end |
#version ⇒ Object (readonly)
The version of the gem from the info entry.
4 5 6 |
# File 'lib/gemcache/parsers/info_parser.rb', line 4 def version @version end |
Class Method Details
.info(version, stories) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/gemcache/parsers/info_parser.rb', line 34 def self.info(version, stories) stories.each do |s| return s if s.version == version end nil end |
.parse(raw) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/gemcache/parsers/info_parser.rb', line 41 def self.parse(raw) stories = [] raw.lines.drop(1).each do |l| stories << new(l) end stories.reverse end |