jirametrics 1.3 → 1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02be53200d02a09c1dd8829dba1a06147959d6fc7c14960e810497ab72c8c731
4
- data.tar.gz: b3f79887cc78af19ec5199140bb655cb161a21fc548d52b98fee04c287fdc100
3
+ metadata.gz: bc425ec4e1efcb78c2e12facdbfb0109383c379c1e08a83f46e3587dceabda7a
4
+ data.tar.gz: aa98dca9360bec6250a423790f7e1d54d5d3c102804b514468aad220c4913cad
5
5
  SHA512:
6
- metadata.gz: d05d5ea737475206c127b3e1bde806a5fb98493f4cd5d75dbc7d0ce1d89093fb5778ae276f1189a37096a6f800550f7f1bb86a2bbf1e9433f80caa90cc905ba8
7
- data.tar.gz: 82dd49447e33017bd5d0dfb527011d27ae018d32c60e310bb8cc30ca1bcc8265888264df7aa2387109d8fe822a75381e6687bd750923de0d742b28dfb153bdf6
6
+ metadata.gz: 7ad6615bf254963dabe4557e907f6bacb0340562d9120c9fc3d5ca722b88709531b3e58148d1957707931e88512950053be04c49ace5d531c2990e99cb6e4254
7
+ data.tar.gz: 06b0af0ce2512d028bb0d11771610c75d88246113a0bc3cb789a348f4d3e24c745d419802248f4ad25caebf845e682ecabd7aa24b1aa39a911164fe0332d111a
@@ -84,7 +84,7 @@ class Board
84
84
  end
85
85
 
86
86
  def project_id
87
- @raw['location']['id']
87
+ @raw['location']&.[]('id')
88
88
  end
89
89
 
90
90
  def name
@@ -51,15 +51,7 @@ class Issue
51
51
  def summary = @raw['fields']['summary']
52
52
 
53
53
  def status
54
- raw_status = @raw['fields']['status']
55
- raw_category = raw_status['statusCategory']
56
-
57
- Status.new(
58
- name: raw_status['name'],
59
- id: raw_status['id'].to_i,
60
- category_name: raw_category['name'],
61
- category_id: raw_category['id'].to_i
62
- )
54
+ Status.new raw: @raw['fields']['status']
63
55
  end
64
56
 
65
57
  def status_id
@@ -41,7 +41,7 @@ class ProjectConfig
41
41
  def run
42
42
  unless aggregated_project?
43
43
  load_all_boards
44
- @project_id = @all_boards.first.last.project_id
44
+ @project_id = @all_boards.first.last&.project_id
45
45
  load_status_category_mappings
46
46
  load_project_metadata
47
47
  load_sprints
@@ -101,7 +101,7 @@ class ProjectConfig
101
101
  return
102
102
  end
103
103
 
104
- add_possible_status Status.new(name: status, id: nil, category_name: category, category_id: nil)
104
+ add_possible_status Status.new(name: status, category_name: category)
105
105
  end
106
106
 
107
107
  def load_all_boards
@@ -172,15 +172,7 @@ class ProjectConfig
172
172
  end
173
173
 
174
174
  status_json_snippets.each do |snippet|
175
- category_config = snippet['statusCategory']
176
- status_name = snippet['name']
177
- add_possible_status Status.new(
178
- name: status_name,
179
- id: snippet['id'].to_i,
180
- category_name: category_config['name'],
181
- category_id: category_config['id'].to_i,
182
- project_id: snippet['scope']&.[]('project')&.[]('id') # May have a value if this is a NextGen project
183
- )
175
+ add_possible_status Status.new(raw: snippet)
184
176
  end
185
177
  end
186
178
 
@@ -202,7 +194,7 @@ class ProjectConfig
202
194
 
203
195
  def add_possible_status status
204
196
  # If it's project scoped and it's not this project, just ignore it.
205
- return if status.project_id && status.project_id != @project_id
197
+ return if status.project_id && (@project_id.nil? || status.project_id != @project_id)
206
198
 
207
199
  existing_status = find_status(name: status.name)
208
200
 
@@ -4,12 +4,27 @@ class Status
4
4
  attr_reader :id, :type, :category_name, :category_id, :project_id
5
5
  attr_accessor :name
6
6
 
7
- def initialize name:, id:, category_name:, category_id:, project_id: nil
7
+ def initialize name: nil, id: nil, category_name: nil, category_id: nil, project_id: nil, raw: nil
8
8
  @name = name
9
9
  @id = id
10
10
  @category_name = category_name
11
11
  @category_id = category_id
12
12
  @project_id = project_id
13
+
14
+ if raw
15
+ @raw = raw
16
+ @name = raw['name']
17
+ @id = raw['id'].to_i
18
+
19
+ category_config = raw['statusCategory']
20
+ @category_name = category_config['name']
21
+ @category_id = category_config['id'].to_i
22
+
23
+ # If this is a NextGen project then this status may be project specific. When this field is
24
+ # nil then the status is global.
25
+ @project_id = raw['scope']&.[]('project')&.[]('id')
26
+ end
27
+
13
28
  end
14
29
 
15
30
  def to_s
@@ -22,6 +37,8 @@ class Status
22
37
  end
23
38
 
24
39
  def state
25
- instance_variables.map { |variable| instance_variable_get variable }
40
+ instance_variables
41
+ .reject {|variable| variable == :@raw}
42
+ .map { |variable| instance_variable_get variable }
26
43
  end
27
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jirametrics
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Bowler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2024-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: random-word