class AssistedWorkflow::Addons::Jira
Public Class Methods
new(output, options = {})
click to toggle source
Calls superclass method
AssistedWorkflow::Addons::Base::new
# File lib/assisted_workflow/addons/jira.rb, line 40 def initialize(output, options = {}) super Jiralicious.configure do |config| config.username = options["username"] config.password = options["password"] config.uri = options["uri"] config.api_version = "latest" config.auth_type = :basic end @project = options["project"] @username = options["username"] @unstarted = options["unstarted"] @started = options["started"] @finished = options["finished"] end
Public Instance Methods
find_story(story_id)
click to toggle source
# File lib/assisted_workflow/addons/jira.rb, line 56 def find_story(story_id) if !story_id.nil? log "loading story ##{story_id}" issue = Jiralicious::Issue.find(story_id) story = JiraStory.new(issue) if issue story end end
finish_story(story, options = {})
click to toggle source
# File lib/assisted_workflow/addons/jira.rb, line 70 def finish_story(story, options = {}) log "finishing story ##{story.id}" move_story! story, @finished story.comments.add(options[:note]) if options[:note] end
pending_stories(options = {})
click to toggle source
# File lib/assisted_workflow/addons/jira.rb, line 76 def pending_stories(options = {}) log "loading pending stories" states = [@unstarted] states << @started if options[:include_started] query = "project=#{@project} and assignee='#{@username}' and status in ('#{states.join("','")}')" response = Jiralicious.search(query, :max_results => 5) log "loading stories info" response.issues_raw.map do |issue| JiraStory.new(Jiralicious::Issue.new(issue)) end end
start_story(story, options = {})
click to toggle source
# File lib/assisted_workflow/addons/jira.rb, line 65 def start_story(story, options = {}) log "starting story ##{story.id}" move_story! story, @started end
valid?()
click to toggle source
# File lib/assisted_workflow/addons/jira.rb, line 88 def valid? !@project.nil? end
Private Instance Methods
move_story!(story, status)
click to toggle source
# File lib/assisted_workflow/addons/jira.rb, line 94 def move_story!(story, status) url = "#{Jiralicious.rest_path}/issue/#{story.id}/transitions" transitions = Jiralicious::Issue.get_transitions(url) transition = transitions.parsed_response["transitions"].find{|t| t["to"]["name"] == status} if transition Jiralicious::Issue.transition(url, {"transition" => transition["id"]}) else raise AssistedWorkflow::Error, "cannot find a valid transition to move the story to #{status}" end end