Class: Ore::Dependency

Inherits:
Gem::Dependency
  • Object
show all
Defined in:
lib/ore/dependency.rb

Overview

Represents a RubyGem dependency.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(dependency) ⇒ Dependency

Parses a dependency string.

Parameters:

  • dependency (String)

    The dependency string.

Returns:



43
44
45
46
47
# File 'lib/ore/dependency.rb', line 43

def self.parse(dependency)
  name, versions = dependency.strip.split(/\s+/,2)

  return parse_versions(name,versions)
end

.parse_versions(name, versions) ⇒ Dependency

Parses a version string.

Parameters:

  • name (String)

    The name of the dependency.

  • versions (String, Array, nil)

    The version(s).

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ore/dependency.rb', line 21

def self.parse_versions(name,versions)
  versions = case versions
             when String
               versions.strip.split(/,\s*/)
             when Array
               versions.map { |v| v.to_s }
             else
               []
             end

  return new(name,*versions)
end

Instance Method Details

#versionsArray<String>

The version requirements of the dependency.

Returns:

  • (Array<String>)

    The version requirement Strings.

Since:

  • 0.1.3



57
58
59
# File 'lib/ore/dependency.rb', line 57

def versions
  requirements_list.map { |req| req.to_s }
end