Class: Asgit::Url
- Inherits:
-
Object
- Object
- Asgit::Url
- Defined in:
- lib/asgit/url.rb
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #branch(name) ⇒ Object
- #commit(sha) ⇒ Object
- #compare(ref_a, ref_b) ⇒ Object
- #file(file_path, options = {}) ⇒ Object
- #file_at_commit(file_path, commit = commit, options = {}) ⇒ Object
-
#initialize(details, service) ⇒ Url
constructor
A new instance of Url.
- #project ⇒ Object
Constructor Details
#initialize(details, service) ⇒ Url
Returns a new instance of Url.
6 7 8 9 |
# File 'lib/asgit/url.rb', line 6 def initialize details, service @details = details @service = service end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
4 5 6 |
# File 'lib/asgit/url.rb', line 4 def details @details end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
4 5 6 |
# File 'lib/asgit/url.rb', line 4 def service @service end |
Instance Method Details
#branch(name) ⇒ Object
23 24 25 |
# File 'lib/asgit/url.rb', line 23 def branch name File.join( project, service.branch_uri % { branch: name } ) end |
#commit(sha) ⇒ Object
19 20 21 |
# File 'lib/asgit/url.rb', line 19 def commit sha File.join( project, service.commit_uri % { commit: sha } ) end |
#compare(ref_a, ref_b) ⇒ Object
42 43 44 |
# File 'lib/asgit/url.rb', line 42 def compare ref_a, ref_b File.join( project, service.compare_uri % { ref_a: ref_a, ref_b: ref_b }) end |
#file(file_path, options = {}) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/asgit/url.rb', line 27 def file file_path, ={} file_path = file_path.gsub( /^\//, '' ) branch = .fetch(:branch) { details.default_branch } line = .has_key?(:line) ? format_lines([:line]) : '' File.join( project, service.file_uri % { file_path: file_path, branch: branch, line: line } ) end |
#file_at_commit(file_path, commit = commit, options = {}) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/asgit/url.rb', line 35 def file_at_commit file_path, commit=commit, ={} file_path = file_path.gsub( /^\//, '' ) line = .has_key?(:line) ? format_lines([:line]) : '' File.join( project, service.file_at_commit_uri % { file_path: file_path, commit: commit, line: line } ) end |
#project ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/asgit/url.rb', line 11 def project service.base_structure % { base_url: service.base_url, organization: details.organization, project: details.project } end |