Class: Autoproj::PackageManagers::BundlerManager::GemEntry
- Inherits:
-
Struct
- Object
- Struct
- Autoproj::PackageManagers::BundlerManager::GemEntry
- Defined in:
- lib/autoproj/package_managers/bundler_manager.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .parse(object) ⇒ Object
-
.parse_from_hash(hash) ⇒ Object
Parse an option hash into a GemEntry.
-
.parse_from_string(entry) ⇒ (String,String), (String,nil)
Parse an osdep entry string into a gem name and gem version.
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
462 463 464 |
# File 'lib/autoproj/package_managers/bundler_manager.rb', line 462 def name @name end |
#options ⇒ Object
Returns the value of attribute options
462 463 464 |
# File 'lib/autoproj/package_managers/bundler_manager.rb', line 462 def @options end |
#version ⇒ Object
Returns the value of attribute version
462 463 464 |
# File 'lib/autoproj/package_managers/bundler_manager.rb', line 462 def version @version end |
Class Method Details
.parse(object) ⇒ Object
463 464 465 466 467 468 469 470 471 472 |
# File 'lib/autoproj/package_managers/bundler_manager.rb', line 463 def self.parse(object) if object.respond_to?(:to_str) parse_from_string(object) elsif object.respond_to?(:to_hash) parse_from_hash(object) else raise ArgumentError, "expected #{object} to either be a string or a map" end end |
.parse_from_hash(hash) ⇒ Object
Parse an option hash into a GemEntry
491 492 493 494 495 496 497 498 499 500 |
# File 'lib/autoproj/package_managers/bundler_manager.rb', line 491 def self.parse_from_hash(hash) hash = hash.dup unless (name = hash.delete("name")) raise ArgumentError, "expected gem entry #{hash} to have at least a 'name' key" end version = hash.delete("version") GemEntry.new(name, version, hash) end |
.parse_from_string(entry) ⇒ (String,String), (String,nil)
Parse an osdep entry string into a gem name and gem version
The ‘gem’ entries in the osdep files can contain a version specification. This method parses the two parts and return them
482 483 484 485 486 487 488 |
# File 'lib/autoproj/package_managers/bundler_manager.rb', line 482 def self.parse_from_string(entry) if entry =~ /^([^><=~]*)([><=~]+.*)$/ GemEntry.new($1.strip, $2.strip, {}) else GemEntry.new(entry, nil, {}) end end |
Instance Method Details
#to_gemfile_line ⇒ Object
502 503 504 505 506 507 508 509 510 |
# File 'lib/autoproj/package_managers/bundler_manager.rb', line 502 def to_gemfile_line = .map { |k, v| "#{k}: \"#{v}\"" }.join(", ") entries = [ "\"#{name}\"", ("\"#{version}\"" if version), ( unless .empty?) ].compact "gem #{entries.join(', ')}" end |