module Ore # # Represents a RubyGem dependency. # class Dependency # The name of the dependency attr_reader :name # The required versions attr_reader :versions # # Creates a new dependency. # # @param [String] name # The name of the dependency. # # @param [Array] versions # The required versions. # def initialize(name,*versions) @name = name @versions = versions end # # Parses a version string. # # @param [String] name # The name of the dependency. # # @param [String, Array, nil] versions # The version(s). # # @return [Dependency] # The parsed dependency. # 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 # # Parses a dependencey string. # # @param [String] dependency # The dependencey string. # # @return [Dependency] # The parsed dependency. # def self.parse(dependency) name, versions = dependency.strip.split(/\s+/,2) return parse_versions(name,versions) end end end