Module: PivotalShell::Configuration
- Defined in:
- lib/pivotal_shell/configuration.rb
Constant Summary collapse
- DEFAULTS =
{ 'refresh_interval' => 15 }
Class Method Summary collapse
- .cache ⇒ Object
- .estimate_icon(estimate) ⇒ Object
- .global_config_path ⇒ Object
- .icon(type, status, estimate) ⇒ Object
- .load ⇒ Object
- .me ⇒ Object
- .project ⇒ Object
- .project_config_path ⇒ Object
- .refresh_interval ⇒ Object
- .status_icon(status) ⇒ Object
- .type_icon(type) ⇒ Object
Class Method Details
.cache ⇒ Object
19 20 21 |
# File 'lib/pivotal_shell/configuration.rb', line 19 def self.cache @cache ||= PivotalShell::Cache.new(File.join(project_config_path,'.pivotal_cache')) end |
.estimate_icon(estimate) ⇒ Object
51 52 53 |
# File 'lib/pivotal_shell/configuration.rb', line 51 def self.estimate_icon(estimate) estimate.nil? ? '*' : ({-1 => '?', 0 => '0', 1=>'1', 2=>'2', 3 => '3'}[estimate] || "[#{estimate.inspect}]") end |
.global_config_path ⇒ Object
31 32 33 |
# File 'lib/pivotal_shell/configuration.rb', line 31 def self.global_config_path @global_config_path ||= File.('~/.pivotalrc') end |
.icon(type, status, estimate) ⇒ Object
59 60 61 |
# File 'lib/pivotal_shell/configuration.rb', line 59 def self.icon(type, status, estimate) type_icon(type).to_s + ' ' + estimate_icon(estimate).to_s + ' ' + status_icon(status).to_s end |
.load ⇒ Object
9 10 11 12 13 |
# File 'lib/pivotal_shell/configuration.rb', line 9 def self.load @global_config = YAML.load_file(global_config_path) @project_config = YAML.load_file(File.join(project_config_path,'.pivotalrc')) PivotalTracker::Client.token = @global_config['api_token'] end |
.me ⇒ Object
23 24 25 |
# File 'lib/pivotal_shell/configuration.rb', line 23 def self.me @me ||= @project_config['me'] end |
.project ⇒ Object
15 16 17 |
# File 'lib/pivotal_shell/configuration.rb', line 15 def self.project @project ||= PivotalTracker::Project.find(@project_config['project_id']) end |
.project_config_path ⇒ Object
35 36 37 |
# File 'lib/pivotal_shell/configuration.rb', line 35 def self.project_config_path @project_config_path ||= find_project_config end |
.refresh_interval ⇒ Object
27 28 29 |
# File 'lib/pivotal_shell/configuration.rb', line 27 def self.refresh_interval @refresh_interval ||= @project_config['refresh_interval'] || @global_config['refresh_interval'] || DEFAULTS['refresh_interval'] end |
.status_icon(status) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pivotal_shell/configuration.rb', line 39 def self.status_icon(status) { 'unscheduled' => ' ', 'unstarted' => '.', 'started' => 'S', 'finished' => 'F', 'delivered' => 'D', 'accepted' => 'A', 'rejected' => 'R' }[status] end |
.type_icon(type) ⇒ Object
55 56 57 |
# File 'lib/pivotal_shell/configuration.rb', line 55 def self.type_icon(type) {'feature' => 'F', 'chore' => 'C', 'bug' => 'B'}[type] end |