Module: ConfigFiles

Included in:
ProjectOpen, StoryAccept
Defined in:
lib/pivotal-github/config_files.rb

Instance Method Summary collapse

Instance Method Details

#api_tokenObject

Returns the Pivotal Tracker API token.



4
5
6
# File 'lib/pivotal-github/config_files.rb', line 4

def api_token
  config_filename('.api_token', 'your Pivotal tracker API token')
end

#config_filename(filename, description) ⇒ Object

Facilitate the creation of config variables based on files.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pivotal-github/config_files.rb', line 14

def config_filename(filename, description)
  if File.exist?(filename)
    add_to_gitignore(filename)
    varname = '@' + filename.sub('.', '')
    value = File.read(filename).strip
    instance_variable_set(varname, value)
  else
    puts "Please create a file called '#{filename}'"
    puts "containing #{description}."
    add_to_gitignore(filename)
    exit 1
  end
end

#project_idObject

Returns the Pivotal Tracker project id.



9
10
11
# File 'lib/pivotal-github/config_files.rb', line 9

def project_id
  config_filename('.project_id', 'the Pivotal tracker project id')
end