Sha256: 69331ca1c51da1b9a35b8f6a7671804e06321839cb7317bad95b8507fe399ce1

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

module Capistrano
  module Jira
    class IssueTransiter
      attr_reader :issue

      def initialize(issue)
        @issue = issue
      end

      def transit
        validate_transition
        execute
      end

      private

      def transition
        @transition ||= issue.transitions.all.find do |t|
          t.attrs['name'].casecmp(fetch(:jira_transition_name)).zero?
        end
      end

      def validate_transition
        unless transition
          raise TransitionError,
                "Transition #{fetch(:jira_transition_name)} not available"
        end
      end

      def execute
        issue.transitions.build.save!(transition: { id: transition.id })
      rescue JIRA::HTTPError => e
        r = e.response
        raise TransitionError,
              "#{r.class.name}; #{r.code}: #{r.message} \n #{r.body}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-jira-0.1.0 lib/capistrano/jira/issue_transiter.rb