Class: Harvest::Vcs
- Inherits:
-
Object
- Object
- Harvest::Vcs
- Defined in:
- lib/harvest/vcs.rb
Instance Attribute Summary collapse
-
#current_branch ⇒ Object
readonly
Returns the value of attribute current_branch.
-
#project_code ⇒ Object
readonly
Returns the value of attribute project_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(project_code) ⇒ Vcs
constructor
A new instance of Vcs.
- #ticket_id ⇒ Object
Constructor Details
#initialize(project_code) ⇒ Vcs
Returns a new instance of Vcs.
11 12 13 14 |
# File 'lib/harvest/vcs.rb', line 11 def initialize(project_code) @project_code = project_code @current_branch = git_command_for_current_branch[0..-2] end |
Instance Attribute Details
#current_branch ⇒ Object (readonly)
Returns the value of attribute current_branch.
3 4 5 |
# File 'lib/harvest/vcs.rb', line 3 def current_branch @current_branch end |
#project_code ⇒ Object (readonly)
Returns the value of attribute project_code.
3 4 5 |
# File 'lib/harvest/vcs.rb', line 3 def project_code @project_code end |
Class Method Details
.current_project ⇒ Object
5 6 7 8 9 |
# File 'lib/harvest/vcs.rb', line 5 def self.current_project remote_url = `git config --local remote.origin.url`.strip URI(remote_url).path.split('/').last.gsub('.git', '') end |
Instance Method Details
#ticket_id ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/harvest/vcs.rb', line 16 def ticket_id branch_names = current_branch.gsub(/[^0-9a-z]/i, ' ').split return nil if branch_names.index(project_code).nil? branch_names[branch_names.index(project_code)+1] end |