Class: Lazylead::Issue
- Inherits:
-
Object
- Object
- Lazylead::Issue
- Defined in:
- lib/lazylead/system/jira.rb
Overview
An issue from Jira
- Author
-
Yurii Dubinka ([email protected])
- Copyright
-
Copyright © 2019-2020 Yurii Dubinka
- License
-
MIT
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add_label(label, *more) ⇒ Object
- #assignee ⇒ Object
- #attachments ⇒ Object
- #comments ⇒ Object
- #components ⇒ Object
- #description ⇒ Object
- #duedate ⇒ Object
- #fields ⇒ Object
- #history ⇒ Object
- #id ⇒ Object
-
#initialize(issue, jira) ⇒ Issue
constructor
A new instance of Issue.
- #inspect ⇒ Object
- #key ⇒ Object
- #labels ⇒ Object
- #post(markdown) ⇒ Object
- #priority ⇒ Object
- #remote_links ⇒ Object
- #reporter ⇒ Object
- #save!(opts) ⇒ Object
- #status ⇒ Object
- #summary ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(issue, jira) ⇒ Issue
Returns a new instance of Issue.
157 158 159 160 |
# File 'lib/lazylead/system/jira.rb', line 157 def initialize(issue, jira) @issue = issue @jira = jira end |
Instance Method Details
#[](name) ⇒ Object
207 208 209 210 |
# File 'lib/lazylead/system/jira.rb', line 207 def [](name) return "" if fields[name].nil? || fields[name].blank? fields[name] end |
#add_label(label, *more) ⇒ Object
255 256 257 258 259 260 261 |
# File 'lib/lazylead/system/jira.rb', line 255 def add_label(label, *more) lbl = labels lbl = [] if lbl.nil? lbl << label lbl += more if more.size.positive? save!("fields" => { "labels" => lbl.uniq }) end |
#assignee ⇒ Object
195 196 197 |
# File 'lib/lazylead/system/jira.rb', line 195 def assignee Lazylead::User.new(@issue.assignee.attrs) end |
#attachments ⇒ Object
251 252 253 |
# File 'lib/lazylead/system/jira.rb', line 251 def @issue. end |
#comments ⇒ Object
224 225 226 227 228 229 |
# File 'lib/lazylead/system/jira.rb', line 224 def comments return @comments if defined? @comments @comments = @jira.Issue.find(@issue.id, expand: "comments", fields: "") .comments .map { |c| Comment.new(c) } end |
#components ⇒ Object
212 213 214 215 216 |
# File 'lib/lazylead/system/jira.rb', line 212 def components return [] unless @issue.respond_to? :components return [] if @issue.components.nil? @issue.components.map(&:name) end |
#description ⇒ Object
170 171 172 173 |
# File 'lib/lazylead/system/jira.rb', line 170 def description return "" if @issue.description.nil? @issue.description end |
#duedate ⇒ Object
183 184 185 |
# File 'lib/lazylead/system/jira.rb', line 183 def duedate @issue.fields["duedate"] end |
#fields ⇒ Object
199 200 201 202 203 204 205 |
# File 'lib/lazylead/system/jira.rb', line 199 def fields return {} if @issue.nil? return {} unless @issue.respond_to? :fields return {} if @issue.fields.nil? return {} unless @issue.fields.respond_to? :[] @issue.fields end |
#history ⇒ Object
218 219 220 221 222 |
# File 'lib/lazylead/system/jira.rb', line 218 def history return [] unless @issue.respond_to? :changelog return [] if @issue.changelog == nil? || @issue.changelog.empty? @issue.changelog["histories"] end |
#id ⇒ Object
162 163 164 |
# File 'lib/lazylead/system/jira.rb', line 162 def id @issue.id end |
#inspect ⇒ Object
235 236 237 |
# File 'lib/lazylead/system/jira.rb', line 235 def inspect to_s end |
#key ⇒ Object
166 167 168 |
# File 'lib/lazylead/system/jira.rb', line 166 def key @issue.key end |
#labels ⇒ Object
263 264 265 |
# File 'lib/lazylead/system/jira.rb', line 263 def labels fields["labels"] end |
#post(markdown) ⇒ Object
243 244 245 |
# File 'lib/lazylead/system/jira.rb', line 243 def post(markdown) @issue.comments.build.save!(body: markdown) end |
#priority ⇒ Object
187 188 189 |
# File 'lib/lazylead/system/jira.rb', line 187 def priority fields["priority"]["name"] end |
#remote_links ⇒ Object
247 248 249 |
# File 'lib/lazylead/system/jira.rb', line 247 def remote_links @issue.remotelink.all end |
#reporter ⇒ Object
191 192 193 |
# File 'lib/lazylead/system/jira.rb', line 191 def reporter Lazylead::User.new(fields["reporter"]) end |
#save!(opts) ⇒ Object
267 268 269 |
# File 'lib/lazylead/system/jira.rb', line 267 def save!(opts) @issue.save(opts) end |
#status ⇒ Object
239 240 241 |
# File 'lib/lazylead/system/jira.rb', line 239 def status @issue.status.attrs["name"] end |
#summary ⇒ Object
175 176 177 |
# File 'lib/lazylead/system/jira.rb', line 175 def summary fields["summary"] end |
#to_s ⇒ Object
231 232 233 |
# File 'lib/lazylead/system/jira.rb', line 231 def to_s "#{key} #{summary}" end |
#url ⇒ Object
179 180 181 |
# File 'lib/lazylead/system/jira.rb', line 179 def url @issue.attrs["self"].split("/rest/api/").first + "/browse/" + key end |