Class: GitPivotalTrackerIntegration::Command::Configuration
- Inherits:
-
Object
- Object
- GitPivotalTrackerIntegration::Command::Configuration
- Defined in:
- lib/git-pivotal-tracker-integration/command/configuration.rb
Overview
A class that exposes configuration that commands can use
Instance Method Summary collapse
-
#api_token ⇒ String
Returns the user’s Pivotal Tracker API token.
-
#project_id ⇒ String
Returns the Pivotal Tracker project id for this repository.
-
#story(project) ⇒ PivotalTracker::Story
Returns the story associated with the current development branch.
-
#story=(story) ⇒ void
Stores the story associated with the current development branch.
Instance Method Details
#api_token ⇒ String
Returns the user’s Pivotal Tracker API token. If this token has not been configured, prompts the user for the value. The value is checked for in the inherited Git configuration, but is stored in the global Git configuration so that it can be used across multiple repositories.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git-pivotal-tracker-integration/command/configuration.rb', line 30 def api_token api_token = GitPivotalTrackerIntegration::Util::Git.get_config KEY_API_TOKEN, :inherited if api_token.empty? api_token = ask('Pivotal API Token (found at https://www.pivotaltracker.com/profile): ').strip GitPivotalTrackerIntegration::Util::Git.set_config KEY_API_TOKEN, api_token, :global puts end api_token end |
#project_id ⇒ String
Returns the Pivotal Tracker project id for this repository. If this id has not been configuration, prompts the user for the value. The value is checked for in the inherited Git configuration, but is stored in the local Git configuration so that it is specific to this repository.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/git-pivotal-tracker-integration/command/configuration.rb', line 48 def project_id project_id = GitPivotalTrackerIntegration::Util::Git.get_config KEY_PROJECT_ID, :inherited if project_id.empty? project_id = choose do || .prompt = 'Choose project associated with this repository: ' PivotalTracker::Project.all.sort_by { |project| project.name }.each do |project| .choice(project.name) { project.id } end end GitPivotalTrackerIntegration::Util::Git.set_config KEY_PROJECT_ID, project_id, :local puts end project_id end |
#story(project) ⇒ PivotalTracker::Story
Returns the story associated with the current development branch
71 72 73 74 |
# File 'lib/git-pivotal-tracker-integration/command/configuration.rb', line 71 def story(project) story_id = GitPivotalTrackerIntegration::Util::Git.get_config KEY_STORY_ID, :branch project.stories.find story_id.to_i end |
#story=(story) ⇒ void
This method returns an undefined value.
Stores the story associated with the current development branch
80 81 82 |
# File 'lib/git-pivotal-tracker-integration/command/configuration.rb', line 80 def story=(story) GitPivotalTrackerIntegration::Util::Git.set_config KEY_STORY_ID, story.id, :branch end |