jirametrics 2.7.1 → 2.7.3

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: d5bb71d8f3c6ab4cf1fa17ad93ad1c00ba1b8381c196bc15a054095a5a91917a
4
- data.tar.gz: 790abb0404719d6b55d833ad76d34121875997f3ec3967f69f5d467fae203752
3
+ metadata.gz: ed5733b75d3ab3091973a5919269c467e6657a1a7699a6e5e4acb4139f9a292b
4
+ data.tar.gz: 3e750fe3a053fe9d8b5c30099afc42d1c50187c1d749f922d29bd91eb2f60241
5
5
  SHA512:
6
- metadata.gz: f71c2ae123a13435a1147ceaadf7f10364a6cdf1421b4f8491633936189e3744e58da4d99be6c43c6e8034d5f27afc470498532157ac15a7d4459a0399f6fc12
7
- data.tar.gz: f33eb0ea450d6002b09d84311823fc20847327bb78dca5fa218c3f724a23f02d49f4ef0183e9dc02499e0eea1f5916147396538751192974926e1c197f4f0bb5
6
+ metadata.gz: 9f97b93668b57a3f5876979daa14631c1f75f6d6294b49ae58f57b2d60e21b36020c64aef8d7affa59e03796e8c7b3e5480546e3a540372d20c3152764d8a6a0
7
+ data.tar.gz: ed479b302392340ca02a7f58d4ac0e5f27178ff23fc35956ebeb8659af91454ca8d7e752aacbcad3bef942c49bc24f03dca332760b582b23c782cb5824681651
@@ -6,14 +6,18 @@ class FileSystem
6
6
  attr_accessor :logfile, :logfile_name
7
7
 
8
8
  # Effectively the same as File.read except it forces the encoding to UTF-8
9
- def load filename
9
+ def load filename, supress_deprecation: false
10
+ if filename.end_with?('.json') && !supress_deprecation
11
+ deprecated(message: 'call load_json instead', date: '2024-11-13')
12
+ end
13
+
10
14
  File.read filename, encoding: 'UTF-8'
11
15
  end
12
16
 
13
17
  def load_json filename, fail_on_error: true
14
18
  return nil if fail_on_error == false && File.exist?(filename) == false
15
19
 
16
- JSON.parse load(filename)
20
+ JSON.parse load(filename, supress_deprecation: true)
17
21
  end
18
22
 
19
23
  def save_json json:, filename:
@@ -43,4 +47,8 @@ class FileSystem
43
47
  end
44
48
  node
45
49
  end
50
+
51
+ def foreach root, &block
52
+ Dir.foreach root, &block
53
+ end
46
54
  end
@@ -31,6 +31,10 @@ class ProjectConfig
31
31
  instance_eval(&@block) if @block
32
32
  end
33
33
 
34
+ def data_downloaded?
35
+ File.exist? File.join(@target_path, "#{file_prefix}_meta.json")
36
+ end
37
+
34
38
  def load_data
35
39
  return if @has_loaded_data
36
40
 
@@ -43,6 +47,8 @@ class ProjectConfig
43
47
  end
44
48
 
45
49
  def run load_only: false
50
+ return if @exporter.downloading?
51
+
46
52
  load_data unless aggregated_project?
47
53
  anonymize_data if @anonymizer_needed
48
54
 
@@ -57,7 +63,8 @@ class ProjectConfig
57
63
  end
58
64
 
59
65
  def load_settings
60
- JSON.parse(file_system.load(File.join(__dir__, 'settings.json')))
66
+ # This is the wierd exception that we don't ever want mocked out so we skip FileSystem entirely.
67
+ JSON.parse(File.read(File.join(__dir__, 'settings.json'), encoding: 'UTF-8'))
61
68
  end
62
69
 
63
70
  def guess_project_id
@@ -130,7 +137,7 @@ class ProjectConfig
130
137
 
131
138
  def load_board board_id:, filename:
132
139
  board = Board.new(
133
- raw: JSON.parse(file_system.load(filename)), possible_statuses: @possible_statuses
140
+ raw: file_system.load_json(filename), possible_statuses: @possible_statuses
134
141
  )
135
142
  board.project_config = self
136
143
  @all_boards[board_id] = board
@@ -172,7 +179,7 @@ class ProjectConfig
172
179
  # We may not always have this file. Load it if we can.
173
180
  return unless File.exist? filename
174
181
 
175
- statuses = JSON.parse(file_system.load(filename))
182
+ statuses = file_system.load_json(filename)
176
183
  .map { |snippet| Status.new(raw: snippet) }
177
184
  statuses
178
185
  .find_all { |status| status.global? }
@@ -183,13 +190,22 @@ class ProjectConfig
183
190
  end
184
191
 
185
192
  def load_sprints
186
- Dir.foreach(@target_path) do |file|
187
- next unless file =~ /#{file_prefix}_board_(\d+)_sprints_\d+/
193
+ file_system.foreach(@target_path) do |file|
194
+ next unless file =~ /^#{file_prefix}_board_(\d+)_sprints_\d+.json$/
195
+
196
+ file_path = File.join(@target_path, file)
197
+ board = @all_boards[$1.to_i]
198
+ unless board
199
+ @exporter.file_system.log(
200
+ 'Found sprint data but can\'t find a matching board in config. ' \
201
+ "File: #{file_path}, Boards: #{@all_boards.keys.sort}"
202
+ )
203
+ next
204
+ end
188
205
 
189
- board_id = $1.to_i
190
206
  timezone_offset = exporter.timezone_offset
191
- JSON.parse(file_system.load("#{target_path}#{file}"))['values']&.each do |json|
192
- @all_boards[board_id].sprints << Sprint.new(raw: json, timezone_offset: timezone_offset)
207
+ file_system.load_json(file_path)['values']&.each do |json|
208
+ board.sprints << Sprint.new(raw: json, timezone_offset: timezone_offset)
193
209
  end
194
210
  end
195
211
 
@@ -241,7 +257,7 @@ class ProjectConfig
241
257
 
242
258
  def load_project_metadata
243
259
  filename = File.join @target_path, "#{file_prefix}_meta.json"
244
- json = JSON.parse(file_system.load(filename))
260
+ json = file_system.load_json(filename)
245
261
 
246
262
  @data_version = json['version'] || 1
247
263
 
@@ -304,6 +320,10 @@ class ProjectConfig
304
320
  raise 'This is an aggregated project and issues should have been included with the include_issues_from ' \
305
321
  'declaration but none are here. Check your config.'
306
322
  end
323
+
324
+ return @issues = [] if @exporter.downloading?
325
+ raise 'No data found. Must do a download before an export' unless data_downloaded?
326
+
307
327
  load_data if all_boards.empty?
308
328
 
309
329
  timezone_offset = exporter.timezone_offset
@@ -370,7 +390,7 @@ class ProjectConfig
370
390
  default_board = nil
371
391
 
372
392
  group_filenames_and_board_ids(path: path).each do |filename, board_ids|
373
- content = file_system.load(File.join(path, filename))
393
+ content = file_system.load_json(File.join(path, filename))
374
394
  if board_ids == :unknown
375
395
  boards = [(default_board ||= find_default_board)]
376
396
  else
@@ -378,7 +398,7 @@ class ProjectConfig
378
398
  end
379
399
 
380
400
  boards.each do |board|
381
- issues << Issue.new(raw: JSON.parse(content), timezone_offset: timezone_offset, board: board)
401
+ issues << Issue.new(raw: content, timezone_offset: timezone_offset, board: board)
382
402
  end
383
403
  end
384
404
 
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: 2.7.1
4
+ version: 2.7.3
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-11-06 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: random-word