Class: Story

Inherits:
ActiveResource::Base
  • Object
show all
Includes:
Comparable
Defined in:
lib/story.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config(project_id = 'project_id') ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/story.rb', line 10

def self.config(project_id='project_id')
  @@config = yaml
  scheme =  if !!@@config['ssl']
              self.ssl_options = {  :verify_mode => OpenSSL::SSL::VERIFY_PEER,
                                    :ca_file => File.join(File.dirname(__FILE__), "cacert.pem") }
              "https"
            else
              "http"
            end
  self.site = "#{scheme}://www.pivotaltracker.com/services/v3/projects/:project_id"
  @@config
end

.find_unlinked_epics(story_query) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/story.rb', line 23

def self.find_unlinked_epics(story_query)
  @@config = yaml
  stories = Array.new
  stories << Story.find(story_query||:all, :params => {:filter => 'label:epic', :project_id => @@config['project_id']})
  require 'ruby-debug'; Debugger.start; Debugger.settings[:autoeval] = 1; Debugger.settings[:autolist] = 1; debugger
  stories.flatten.reject { |story| story.linked? }
end

.yamlObject



6
7
8
# File 'lib/story.rb', line 6

def self.yaml
  YAML.load_file('slurper_config.yml')
end

Instance Method Details

#<=>(another_story) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/story.rb', line 67

def <=>(another_story)
  if self.epic_story? && another_story.epic_story?
    0
  elsif self.epic_story? && !another_story.epic_story?
    -1
  elsif !self.epic_story? && !another_story.epic_story?
    0
  else
    1
  end
end

#epic_story?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/story.rb', line 49

def epic_story?
  respond_to?(:labels) ? self.labels.split(',').include?("epic") : false
end

#feature_labelsObject



57
58
59
# File 'lib/story.rb', line 57

def feature_labels
  self.labels.split(',').find { |label| label != "epic" }
end

#link_storyObject



42
43
44
45
46
47
# File 'lib/story.rb', line 42

def link_story
  if epic_story? && !linked?
    self.description += "\n" + "Features Label Search\n" + label_search_url + "\n\n" + story_urls.join("\n") 
    self.labels += ",linked"
  end
end

#linked?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/story.rb', line 53

def linked?
  respond_to?(:labels) ? self.labels.split(',').include?("linked") : false
end

#prepareObject



35
36
37
38
39
40
# File 'lib/story.rb', line 35

def prepare
  scrub_description
  scrub_labels
  default_requested_by
  link_story
end

#saveObject



61
62
63
64
65
# File 'lib/story.rb', line 61

def save
  @config ||= Story.yaml
  self.prefix_options = {:project_id => @config['project_id']}
  super
end