Class: Story
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- Story
- Includes:
- Comparable
- Defined in:
- lib/story.rb
Class Method Summary collapse
- .config(project_id = 'project_id') ⇒ Object
- .find_unlinked_epics(story_query) ⇒ Object
- .yaml ⇒ Object
Instance Method Summary collapse
- #<=>(another_story) ⇒ Object
- #epic_story? ⇒ Boolean
- #feature_labels ⇒ Object
- #link_story ⇒ Object
- #linked? ⇒ Boolean
- #prepare ⇒ Object
- #save ⇒ Object
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. = { :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 |
.yaml ⇒ Object
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
49 50 51 |
# File 'lib/story.rb', line 49 def epic_story? respond_to?(:labels) ? self.labels.split(',').include?("epic") : false end |
#feature_labels ⇒ Object
57 58 59 |
# File 'lib/story.rb', line 57 def feature_labels self.labels.split(',').find { |label| label != "epic" } end |
#link_story ⇒ Object
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
53 54 55 |
# File 'lib/story.rb', line 53 def linked? respond_to?(:labels) ? self.labels.split(',').include?("linked") : false end |
#prepare ⇒ Object
35 36 37 38 39 40 |
# File 'lib/story.rb', line 35 def prepare scrub_description scrub_labels default_requested_by link_story end |