Class: Berkshelf::GithubLocation
- Inherits:
-
GitLocation
- Object
- GitLocation
- Berkshelf::GithubLocation
- Defined in:
- lib/berkshelf/locations/github_location.rb
Constant Summary collapse
- DEFAULT_PROTOCOL =
:git
Constants included from Location
Location::OPSCODE_COMMUNITY_API
Instance Attribute Summary collapse
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#repo_identifier ⇒ Object
Returns the value of attribute repo_identifier.
Attributes inherited from GitLocation
#branch, #options, #ref, #rel, #uri
Attributes included from Location
Instance Method Summary collapse
-
#github_url ⇒ String
Returns the appropriate GitHub url given the specified protocol.
-
#initialize(name, version_constraint, options = {}) ⇒ GithubLocation
constructor
Wraps GitLocation allowing the short form GitHub repo identifier to be used in place of the complete repo url.
- #to_s ⇒ Object
Methods inherited from GitLocation
Methods included from Location
#download, included, init, #to_hash, #to_json, #validate_cached
Constructor Details
#initialize(name, version_constraint, options = {}) ⇒ GithubLocation
Wraps GitLocation allowing the short form GitHub repo identifier to be used in place of the complete repo url.
20 21 22 23 24 25 |
# File 'lib/berkshelf/locations/github_location.rb', line 20 def initialize(name, version_constraint, = {}) @repo_identifier = .delete(:github) @protocol = (.delete(:protocol) || DEFAULT_PROTOCOL).to_sym [:git] = github_url super end |
Instance Attribute Details
#protocol ⇒ Object
Returns the value of attribute protocol.
8 9 10 |
# File 'lib/berkshelf/locations/github_location.rb', line 8 def protocol @protocol end |
#repo_identifier ⇒ Object
Returns the value of attribute repo_identifier.
9 10 11 |
# File 'lib/berkshelf/locations/github_location.rb', line 9 def repo_identifier @repo_identifier end |
Instance Method Details
#github_url ⇒ String
Returns the appropriate GitHub url given the specified protocol
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/berkshelf/locations/github_location.rb', line 33 def github_url case protocol when :ssh "[email protected]:#{repo_identifier}.git" when :https "https://github.com/#{repo_identifier}.git" when :git "git://github.com/#{repo_identifier}.git" else raise UnknownGitHubProtocol.new(protocol) end end |
#to_s ⇒ Object
46 47 48 49 50 51 |
# File 'lib/berkshelf/locations/github_location.rb', line 46 def to_s s = "#{self.class.location_key}: '#{repo_identifier}'" s << " with branch: '#{branch}'" if branch s << " over protocol: '#{protocol}'" s end |