Class: PivotalConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/git-pivotal-tracker-integration/pivotal_configuration.rb

Class Method Summary collapse

Class Method Details

.api_tokenObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/git-pivotal-tracker-integration/pivotal_configuration.rb', line 21

def self.api_token
  api_token = `git config #{@@KEY_API_TOKEN}`

  if api_token.nil? || api_token.empty?
    api_token = ask("Pivotal API Key (found at https://www.pivotaltracker.com/profile): ")
    `git config --global #{@@KEY_API_TOKEN} #{api_token}`
    puts
  end

  api_token.strip
end

.merge_remoteObject



33
34
35
# File 'lib/git-pivotal-tracker-integration/pivotal_configuration.rb', line 33

def self.merge_remote
  `git config branch.#{merge_target}.#{@@KEY_REMOTE}`.strip
end

.merge_targetObject



37
38
39
# File 'lib/git-pivotal-tracker-integration/pivotal_configuration.rb', line 37

def self.merge_target
  `git config branch.#{branch_name}.#{@@KEY_MERGE_TARGET}`.strip
end

.merge_target=(value) ⇒ Object



41
42
43
44
# File 'lib/git-pivotal-tracker-integration/pivotal_configuration.rb', line 41

def self.merge_target=(value)
  `git config --local branch.#{branch_name}.#{@@KEY_MERGE_TARGET} #{value}`
  $? != 0
end

.project_idObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/git-pivotal-tracker-integration/pivotal_configuration.rb', line 55

def self.project_id
  project_id = `git config #{@@KEY_PROJECT_ID}`

  if project_id.nil? || project_id.empty?
    project_id = choose do |menu|
      menu.prompt = "Choose project associated with this repository: "

      PivotalTracker::Project.all.sort_by { |project| project.name }.each do |project|
        menu.choice(project.name) { project.id }
      end
    end

    `git config --local #{@@KEY_PROJECT_ID} #{project_id}`
    puts
  end

  project_id.strip
end

.story_idObject



46
47
48
# File 'lib/git-pivotal-tracker-integration/pivotal_configuration.rb', line 46

def self.story_id
  `git config branch.#{branch_name}.#{@@KEY_STORY_ID}`.strip
end

.story_id=(value) ⇒ Object



50
51
52
53
# File 'lib/git-pivotal-tracker-integration/pivotal_configuration.rb', line 50

def self.story_id=(value)
  `git config --local branch.#{branch_name}.#{@@KEY_STORY_ID} #{value}`
  $? != 0
end