firespring_dev_commands 2.3.4 → 2.5.0.pre.alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/firespring_dev_commands/audit/report.rb +2 -9
  4. data/lib/firespring_dev_commands/aws/account.rb +1 -1
  5. data/lib/firespring_dev_commands/aws/cloudformation.rb +3 -10
  6. data/lib/firespring_dev_commands/aws/login.rb +11 -37
  7. data/lib/firespring_dev_commands/common.rb +2 -22
  8. data/lib/firespring_dev_commands/docker/compose.rb +1 -2
  9. data/lib/firespring_dev_commands/docker/status.rb +0 -20
  10. data/lib/firespring_dev_commands/docker.rb +16 -86
  11. data/lib/firespring_dev_commands/eol/aws.rb +2 -10
  12. data/lib/firespring_dev_commands/eol.rb +2 -22
  13. data/lib/firespring_dev_commands/git.rb +29 -44
  14. data/lib/firespring_dev_commands/jira/issue.rb +1 -3
  15. data/lib/firespring_dev_commands/node.rb +1 -1
  16. data/lib/firespring_dev_commands/php/audit.rb +0 -4
  17. data/lib/firespring_dev_commands/php.rb +12 -28
  18. data/lib/firespring_dev_commands/platform.rb +31 -38
  19. data/lib/firespring_dev_commands/ruby.rb +3 -6
  20. data/lib/firespring_dev_commands/target_process/query.rb +4 -30
  21. data/lib/firespring_dev_commands/target_process/release.rb +1 -1
  22. data/lib/firespring_dev_commands/target_process/team_assignment.rb +1 -1
  23. data/lib/firespring_dev_commands/target_process/user.rb +1 -13
  24. data/lib/firespring_dev_commands/target_process/user_story.rb +1 -1
  25. data/lib/firespring_dev_commands/target_process/user_story_history.rb +1 -1
  26. data/lib/firespring_dev_commands/target_process.rb +7 -24
  27. data/lib/firespring_dev_commands/templates/aws.rb +6 -33
  28. data/lib/firespring_dev_commands/templates/base_interface.rb +2 -2
  29. data/lib/firespring_dev_commands/templates/ci.rb +11 -16
  30. data/lib/firespring_dev_commands/templates/docker/application.rb +2 -2
  31. data/lib/firespring_dev_commands/templates/docker/node/application.rb +5 -55
  32. data/lib/firespring_dev_commands/templates/docker/php/application.rb +16 -58
  33. data/lib/firespring_dev_commands/templates/docker/ruby/application.rb +5 -54
  34. data/lib/firespring_dev_commands/templates/eol.rb +2 -9
  35. data/lib/firespring_dev_commands/templates/git.rb +4 -171
  36. data/lib/firespring_dev_commands/version.rb +1 -1
  37. data/lib/firespring_dev_commands.rb +1 -1
  38. metadata +37 -113
  39. data/lib/firespring_dev_commands/aws/route53.rb +0 -139
  40. data/lib/firespring_dev_commands/bloom_growth/rock.rb +0 -34
  41. data/lib/firespring_dev_commands/bloom_growth/seat.rb +0 -16
  42. data/lib/firespring_dev_commands/bloom_growth/user.rb +0 -43
  43. data/lib/firespring_dev_commands/bloom_growth.rb +0 -132
  44. data/lib/firespring_dev_commands/certificate.rb +0 -59
  45. data/lib/firespring_dev_commands/coverage/base.rb +0 -16
  46. data/lib/firespring_dev_commands/coverage/cobertura.rb +0 -86
  47. data/lib/firespring_dev_commands/coverage/none.rb +0 -21
  48. data/lib/firespring_dev_commands/dns/resource.rb +0 -83
  49. data/lib/firespring_dev_commands/docker/desktop.rb +0 -61
  50. data/lib/firespring_dev_commands/eol/node.rb +0 -42
  51. data/lib/firespring_dev_commands/eol/php.rb +0 -50
  52. data/lib/firespring_dev_commands/eol/ruby.rb +0 -42
  53. data/lib/firespring_dev_commands/jira/parent.rb +0 -19
  54. data/lib/firespring_dev_commands/os.rb +0 -35
  55. data/lib/firespring_dev_commands/port.rb +0 -24
  56. data/lib/firespring_dev_commands/target_process/time.rb +0 -32
  57. data/lib/firespring_dev_commands/templates/aws/services/route53.rb +0 -111
  58. data/lib/firespring_dev_commands/templates/certificate.rb +0 -41
@@ -1,6 +1,5 @@
1
1
  require 'fileutils'
2
2
  require 'git'
3
- require 'octokit'
4
3
 
5
4
  module Dev
6
5
  # Class for performing git functions
@@ -97,8 +96,7 @@ module Dev
97
96
  def branch_name(dir: default_project_dir)
98
97
  return unless File.exist?(dir)
99
98
 
100
- g = ::Git.open(dir)
101
- g.current_branch || "HEAD detached at #{g.object('HEAD').sha[0..7]}"
99
+ ::Git.open(dir).current_branch
102
100
  end
103
101
 
104
102
  # Returns true if the remote branch exists, false otherwise
@@ -115,10 +113,10 @@ module Dev
115
113
  next unless File.exist?(project_dir)
116
114
 
117
115
  repo_basename = File.basename(File.realpath(project_dir))
118
- header = "#{repo_basename} (#{original_branches[project_dir]})"
119
- puts Dev::Common.new.center_pad(header).light_green
116
+ header = " #{repo_basename} (#{original_branches[project_dir]}) "
117
+ puts center_pad(header).light_green
120
118
  @success &= status(dir: project_dir)
121
- puts Dev::Common.new.center_pad.light_green
119
+ puts center_pad.light_green
122
120
  end
123
121
  puts
124
122
 
@@ -167,10 +165,10 @@ module Dev
167
165
  next unless File.exist?(project_dir)
168
166
 
169
167
  repo_basename = File.basename(File.realpath(project_dir))
170
- header = "#{repo_basename} (#{original_branches[project_dir]})"
171
- puts Dev::Common.new.center_pad(header).light_green
168
+ header = " #{repo_basename} (#{original_branches[project_dir]}) "
169
+ puts center_pad(header).light_green
172
170
  reset(dir: project_dir)
173
- puts Dev::Common.new.center_pad.light_green
171
+ puts center_pad.light_green
174
172
  end
175
173
  puts
176
174
  end
@@ -185,7 +183,7 @@ module Dev
185
183
  end
186
184
 
187
185
  # Checks out the given branch in all repositories with some additional formatting
188
- def checkout_all(branch, default)
186
+ def checkout_all(branch)
189
187
  @success = true
190
188
  puts
191
189
  puts "Checking out #{branch} in each repo".light_yellow if project_dirs.length > 1
@@ -193,9 +191,10 @@ module Dev
193
191
  next unless File.exist?(project_dir)
194
192
 
195
193
  repo_basename = File.basename(File.realpath(project_dir))
196
- puts Dev::Common.new.center_pad(repo_basename).light_green
197
- @success &= checkout(branch, default, dir: project_dir)
198
- puts Dev::Common.new.center_pad.light_green
194
+ header = " #{repo_basename} "
195
+ puts center_pad(header).light_green
196
+ @success &= checkout(branch, dir: project_dir)
197
+ puts center_pad.light_green
199
198
  end
200
199
  puts
201
200
 
@@ -203,10 +202,9 @@ module Dev
203
202
  end
204
203
 
205
204
  # Checks out the given branch in the given repo
206
- # If the given branch isn't found, falls back to default branch, then staging, then main
207
205
  # Defaults to the current directory
208
206
  # optionally raise errors
209
- def checkout(branch, default, dir: default_project_dir, raise_errors: false)
207
+ def checkout(branch, dir: default_project_dir, raise_errors: false)
210
208
  raise 'branch is required' if branch.to_s.strip.empty?
211
209
  return unless File.exist?(dir)
212
210
 
@@ -216,11 +214,10 @@ module Dev
216
214
  g = ::Git.open(dir)
217
215
  g.fetch('origin', prune: true)
218
216
 
219
- # If the branch we are checking out doesn't exist,
220
- # check out either the default branch, staging branch, or the main branch
217
+ # If the branch we are checking out doesn't exist, check out either the staging branch or the main branch
221
218
  actual_branch = branch
222
219
  unless branch_exists?(dir, branch)
223
- actual_branch = [default, staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
220
+ actual_branch = [staging_branch, main_branch].uniq.find { |it| branch_exists?(dir, it) }
224
221
  puts "Branch #{branch} not found, checking out #{actual_branch} instead".light_yellow
225
222
  end
226
223
 
@@ -288,9 +285,10 @@ module Dev
288
285
  next unless File.exist?(project_dir)
289
286
 
290
287
  repo_basename = File.basename(File.realpath(project_dir))
291
- puts Dev::Common.new.center_pad(repo_basename).light_green
288
+ header = " #{repo_basename} "
289
+ puts center_pad(header).light_green
292
290
  @success &= merge(branch, dir: project_dir)
293
- puts Dev::Common.new.center_pad.light_green
291
+ puts center_pad.light_green
294
292
  end
295
293
  puts
296
294
 
@@ -336,9 +334,10 @@ module Dev
336
334
  next unless File.exist?(project_dir)
337
335
 
338
336
  repo_basename = File.basename(File.realpath(project_dir))
339
- puts Dev::Common.new.center_pad(repo_basename).light_green
337
+ header = " #{repo_basename} "
338
+ puts center_pad(header).light_green
340
339
  @success &= pull(dir: project_dir)
341
- puts Dev::Common.new.center_pad.light_green
340
+ puts center_pad.light_green
342
341
  end
343
342
  puts
344
343
 
@@ -374,9 +373,10 @@ module Dev
374
373
  next unless File.exist?(project_dir)
375
374
 
376
375
  repo_basename = File.basename(File.realpath(project_dir))
377
- puts Dev::Common.new.center_pad(repo_basename).light_green
376
+ header = " #{repo_basename} "
377
+ puts center_pad(header).light_green
378
378
  @success &= push(dir: project_dir)
379
- puts Dev::Common.new.center_pad.light_green
379
+ puts center_pad.light_green
380
380
  end
381
381
  puts
382
382
 
@@ -411,10 +411,7 @@ module Dev
411
411
  # Clones the repo_name into the dir
412
412
  # Optionally specify a repo_org
413
413
  # Optionally specify a branch to check out (defaults to the repository default branch)
414
- def clone_repo(dir:, repo_name:, repo_org: nil, branch: nil, depth: nil)
415
- # TODO: Split out the default of 'firespring' into a configuration variable
416
- repo_org = 'firespring' if repo_org.to_s.strip.empty?
417
-
414
+ def clone_repo(dir:, repo_name:, repo_org: 'firespring', branch: nil, depth: nil)
418
415
  if Dir.exist?("#{dir}/.git")
419
416
  puts "#{dir} already cloned".light_green
420
417
  return
@@ -431,19 +428,6 @@ module Dev
431
428
  g.fetch('origin', prune: true)
432
429
  end
433
430
 
434
- def commit_status(token:, repo_name:, commit_id:, status:, repo_org: nil, options: {})
435
- # TODO: Split out the default of 'firespring' into a configuration variable
436
- repo_org = 'firespring' if repo_org.to_s.strip.empty?
437
- repo = "#{repo_org}/#{repo_name}"
438
-
439
- # Set up the GitHub client
440
- client = Octokit::Client.new(access_token: token)
441
-
442
- # Create the commit status
443
- puts "Tagging commit #{commit_id} in #{repo} as #{status} for #{options[:context]}"
444
- client.create_status(repo, commit_id, status, options)
445
- end
446
-
447
431
  # Builds an ssh repo URL using the org and repo name given
448
432
  def ssh_repo_url(name, org)
449
433
  "git@github.com:#{org}/#{name}.git"
@@ -455,10 +439,11 @@ module Dev
455
439
  end
456
440
 
457
441
  # Center the string and pad on either side with the given padding character
458
- # @deprecated Please use {Dev::Common#center_pad} instead
459
442
  def center_pad(string = '', pad: '-', len: 80)
460
- warn '[DEPRECATION] `Dev::Git#center_pad` is deprecated. Please use `Dev::Common#center_pad` instead.'
461
- Dev::Common.new.center_pad(string, pad:, len:)
443
+ center_dash = len / 2
444
+ string = string.to_s
445
+ center_str = string.length / 2
446
+ string.rjust(center_dash + center_str - 1, pad).ljust(len - 1, pad)
462
447
  end
463
448
 
464
449
  # Exclude the command from the message and print all error lines
@@ -5,13 +5,11 @@ module Dev
5
5
  # Issue subtypes which do not map to a story type
6
6
  NON_STORY_TYPES = ['epic', 'review', 'sub-task', 'code review sub-task', 'pre-deploy sub-task', 'deploy sub-task', 'devops sub-task'].freeze
7
7
 
8
- attr_accessor :data, :project, :parent, :id, :title, :points, :assignee, :resolved_date, :histories,
9
- :last_in_progress_history, :first_in_review_history, :last_closed_history
8
+ attr_accessor :data, :project, :id, :title, :points, :assignee, :resolved_date, :histories, :last_in_progress_history, :first_in_review_history, :last_closed_history
10
9
 
11
10
  def initialize(data)
12
11
  @data = data
13
12
  @project = Jira::Project.new(data)
14
- @parent = Jira::Parent.new(data) if data.respond_to?(:parent)
15
13
  @id = data.key
16
14
  @title = data.summary
17
15
  @points = calculate_points(data)
@@ -96,7 +96,7 @@ module Dev
96
96
  test
97
97
  end
98
98
 
99
- # Build the node test command
99
+ # Build the node test (with coverage) command
100
100
  def test_coverage_command
101
101
  test = base_command
102
102
  test << 'run' << 'test:coverage'
@@ -16,10 +16,6 @@ module Dev
16
16
  def to_report
17
17
  Dev::Audit::Report.new(
18
18
  data['advisories'].map do |_, v|
19
- # If there are multiple advisories for the same package, v changes from an array into a hash
20
- v = v.values if v.is_a?(Hash)
21
-
22
- # Iterate over the advisories and turn them into report items
23
19
  v.map do |it|
24
20
  Dev::Audit::Report::Item.new(
25
21
  id: it['advisoryId'],
@@ -8,12 +8,11 @@ module Dev
8
8
  DEFAULT_PACKAGE_FILE = 'composer.json'.freeze
9
9
 
10
10
  # Config object for setting top level git config options
11
- Config = Struct.new(:container_path, :local_path, :package_file, :coverage) do
11
+ Config = Struct.new(:container_path, :local_path, :package_file) do
12
12
  def initialize
13
13
  self.container_path = DEFAULT_PATH
14
14
  self.local_path = DEV_COMMANDS_ROOT_DIR
15
15
  self.package_file = DEFAULT_PACKAGE_FILE
16
- self.coverage = nil
17
16
  end
18
17
  end
19
18
 
@@ -31,14 +30,12 @@ module Dev
31
30
  alias_method :configure, :config
32
31
  end
33
32
 
34
- attr_accessor :container_path, :local_path, :package_file, :coverage
33
+ attr_accessor :container_path, :local_path, :package_file
35
34
 
36
- def initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil)
35
+ def initialize(container_path: nil, local_path: nil, package_file: nil)
37
36
  @container_path = container_path || self.class.config.container_path
38
37
  @local_path = local_path || self.class.config.local_path
39
38
  @package_file = package_file || self.class.config.package_file
40
- @coverage = coverage || Dev::Coverage::None.new
41
- raise 'coverage must be an instance of the base class' unless @coverage.is_a?(Dev::Coverage::Base)
42
39
  end
43
40
 
44
41
  # The base npm command that is the starting point for all subsequent commands
@@ -61,12 +58,9 @@ module Dev
61
58
  end
62
59
 
63
60
  # Build the command to fix any security vulnerabilities that were found
64
- # def audit_fix_command
65
- # audit_fix = base_command
66
- # audit_fix << 'audit' << 'fix'
67
- # audit_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
68
- # audit_fix
69
- # end
61
+ def audit_fix_command
62
+ raise 'not implemented'
63
+ end
70
64
 
71
65
  # Build the php install command
72
66
  def install_command
@@ -79,7 +73,7 @@ module Dev
79
73
  # Build the php lint command
80
74
  def lint_command
81
75
  lint = base_command
82
- lint << 'lint'
76
+ lint << 'run' << 'lint'
83
77
  lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
84
78
  lint
85
79
  end
@@ -87,7 +81,7 @@ module Dev
87
81
  # Build the php lint fix command
88
82
  def lint_fix_command
89
83
  lint_fix = base_command
90
- lint_fix << 'lint-fix'
84
+ lint_fix << 'run' << 'lint-fix'
91
85
  lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
92
86
  lint_fix
93
87
  end
@@ -95,24 +89,14 @@ module Dev
95
89
  # Build the php test command
96
90
  def test_command
97
91
  test = []
98
- test << './vendor/bin/phpunit'
99
- test.concat(coverage.php_options) if coverage
92
+ lint_fix << 'run' << 'test'
100
93
  test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
101
94
  test
102
95
  end
103
96
 
104
- # Run the check to ensure code coverage meets the desired threshold
105
- def check_test_coverage(application:)
106
- coverage.check(application:)
107
- end
108
-
109
- # Build the php fast test command
110
- def test_fast_command(processes = 4)
111
- test = []
112
- test << './vendor/bin/paratest'
113
- test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
114
- test << "-p#{processes}" << '--runner=WrapperRunner'
115
- test
97
+ # Build the php test (with coverage) command
98
+ def test_coverage_command
99
+ raise 'not implemented'
116
100
  end
117
101
  end
118
102
  end
@@ -1,46 +1,39 @@
1
1
  module Dev
2
- # Class which returns information about the current platform
3
- class Platform
4
- # Constant containing all supported architectures
5
- ALLOWED_ARCHITECTURES = %w(linux/arm64 linux/amd64).freeze
6
-
7
- # If an architecture was specified in the ENV, use that. Otherwise auto-deted based of the OS reported architecture
8
- def architecture
9
- arch = env_architecture || os_architecture
10
- raise "Invalid DOCKER_ARCHITECTURE: #{arch} (allowed are #{ALLOWED_ARCHITECTURES.join(', ')})" unless ALLOWED_ARCHITECTURES.include?(arch)
11
-
12
- arch
13
- end
14
-
15
- # Check to see if a docker architecture has been specified in the ENV
16
- # If it has, verify the format and the value
17
- private def env_architecture
18
- arch = ENV['DOCKER_ARCHITECTURE'].to_s.strip.downcase
19
- return nil if arch.empty?
2
+ class Common
3
+ # Class which returns information about the current platform
4
+ class Platform
5
+ # Constant containing all supported architectures
6
+ ALLOWED_ARCHITECTURES = %w(arm64 amd64).freeze
20
7
 
21
- "linux/#{arch}" unless arch.start_with?('linux/')
22
- arch
23
- end
8
+ # Normalize the ruby platform to return a docker platform architecture format
9
+ def determine_compute_architecture
10
+ case RUBY_PLATFORM
11
+ when /x86_64|amd64/
12
+ 'linux/amd64' # 64-bit Intel/AMD architecture
13
+ when /arm|aarch64/
14
+ 'linux/arm64' # ARM architecture
15
+ else
16
+ raise 'Unknown or unsupported architecture'
17
+ end
18
+ end
24
19
 
25
- # Returns a valid docker architecture based off the RUBY_PLATFORM
26
- private def os_architecture
27
- return 'linux/amd64' if RUBY_PLATFORM.match?(/x86_64|amd64|x64-mingw/)
28
- return 'linux/arm64' if RUBY_PLATFORM.match?(/arm|aarch64/)
20
+ # Determine the platform architecture
21
+ # If one was specified in the DOCKER_ARCHITECTURE variable, use it
22
+ # Otherwise, use the RUBY_PLATFORM built-in to auto-detect and architecture
23
+ def architecture
24
+ docker_architecture = ENV['DOCKER_ARCHITECTURE'].to_s.strip.downcase
25
+ if docker_architecture.empty?
26
+ determine_compute_architecture
27
+ else
28
+ raise "Missing 'linux/' prefix in DOCKER_ARCHITECTURE: #{docker_architecture}" unless docker_architecture.start_with?('linux/')
29
29
 
30
- raise 'Unknown or unsupported architecture'
31
- end
32
- end
33
- end
30
+ architecture_name = docker_architecture.split('/')[1]
31
+ unless ALLOWED_ARCHITECTURES.include?(architecture_name)
32
+ raise "Invalid DOCKER_ARCHITECTURE: #{architecture_name}. Allowed architectures are #{ALLOWED_ARCHITECTURES.join(', ')}"
33
+ end
34
34
 
35
- module Dev
36
- class Common
37
- # Class which returns information about the current platform
38
- class Platform < Platform
39
- # Initializer for the deprecated class
40
- # @deprecated Please use {Dev::Platform#new} instead
41
- def initialize
42
- warn '[DEPRECATION] `Dev::Common::Platform#new` is deprecated. Please use `Dev::Platform#new` instead.'
43
- super
35
+ docker_architecture
36
+ end
44
37
  end
45
38
  end
46
39
  end
@@ -90,16 +90,14 @@ module Dev
90
90
 
91
91
  # Build the bundle lint command
92
92
  def lint_command
93
- lint = base_command
94
- lint << 'exec' << 'rubocop'
93
+ lint = ['rubocop']
95
94
  lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
96
95
  lint
97
96
  end
98
97
 
99
98
  # Build the bundle lint fix command
100
99
  def lint_fix_command
101
- lint_fix = base_command
102
- lint_fix << 'exec' << 'rubocop'
100
+ lint_fix = ['rubocop']
103
101
  lint_fix << '-A'
104
102
  lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
105
103
  lint_fix
@@ -107,8 +105,7 @@ module Dev
107
105
 
108
106
  # Build the bundle test command
109
107
  def test_command
110
- test = base_command
111
- test << 'exec' << 'rspec'
108
+ test = ['rspec']
112
109
  test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
113
110
  test
114
111
  end
@@ -2,13 +2,12 @@ module Dev
2
2
  class TargetProcess
3
3
  # Class for writing target process query statements
4
4
  class Query
5
- attr_accessor :where, :incl, :take, :empty
5
+ attr_accessor :where, :incl, :take
6
6
 
7
7
  def initialize
8
8
  @where = []
9
9
  @incl = []
10
10
  @take = 250
11
- @empty = false
12
11
  end
13
12
 
14
13
  # Add a new query clause
@@ -34,11 +33,6 @@ module Dev
34
33
  end
35
34
  end
36
35
 
37
- # Check if any of the "in" statements were empty. If so then we don't want to actually run the query
38
- def empty?
39
- @empty == true
40
- end
41
-
42
36
  # Generate the string representation for this query
43
37
  def generate
44
38
  {}.tap do |clause|
@@ -56,38 +50,22 @@ module Dev
56
50
  # TODO: Do these need moved to their associated entities?
57
51
  # Add a filter that looks for stories whose id is contained in the list of ids given
58
52
  def filter_by_user_story_ids(user_story_ids)
59
- if user_story_ids.nil? || user_story_ids.empty?
60
- @empty = true
61
- return
62
- end
63
53
  self << "(Id in ('#{user_story_ids.join("', '")}'))"
64
54
  end
65
55
 
66
56
  # Add a filter that looks for stories whose team id is contained in the list of ids given
67
57
  def filter_by_team_ids(team_ids)
68
- if team_ids.nil? || team_ids.empty?
69
- @empty = true
70
- return
71
- end
72
- self << "(Team.Id in ('#{team_ids.join("', '")}'))"
58
+ self << "(Team.Id in ('#{team_ids.join("', '")}'))" unless team_ids.nil? || team_ids.empty?
73
59
  end
74
60
 
75
61
  # Add a filter that looks for stories whose project id is contained in the list of ids given
76
62
  def filter_by_project(projects)
77
- if projects.nil? || projects.empty?
78
- @empty = true
79
- return
80
- end
81
63
  self << "(Project.Name in ('#{projects.join("', '")}'))"
82
64
  end
83
65
 
84
66
  # Add a filter that looks for stories whose state is contained in the list of states given
85
67
  def filter_by_states(states)
86
- if states.nil? || states.empty?
87
- @empty = true
88
- return
89
- end
90
- self << "(EntityState.Name in ('#{states.join("', '")}'))"
68
+ self << "(EntityState.Name in ('#{states.join("', '")}'))" unless states.nil? || states.empty?
91
69
  end
92
70
 
93
71
  # Add a filter that looks for stories whose state is set to final
@@ -136,11 +114,7 @@ module Dev
136
114
 
137
115
  # Add a filter that looks for assignable ids which are included in the given array
138
116
  def filter_by_entity_ids(entity_ids)
139
- if entity_ids.nil? || entity_ids.empty?
140
- @empty = true
141
- return
142
- end
143
- self << "(Assignable.Id in ('#{entity_ids.join("', '")}'))"
117
+ self << "(Assignable.Id in ('#{entity_ids.join("', '")}'))" unless entity_ids.nil? || entity_ids.empty?
144
118
  end
145
119
 
146
120
  # Add a filter that looks for a custom deploy date between the given dates`
@@ -24,7 +24,7 @@ module Dev
24
24
  def parse_time(string)
25
25
  return nil unless string && !string.empty?
26
26
 
27
- ::Time.at(string.slice(6, 10).to_i)
27
+ Time.at(string.slice(6, 10).to_i)
28
28
  end
29
29
  end
30
30
  end
@@ -24,7 +24,7 @@ module Dev
24
24
  def parse_time(string)
25
25
  return nil unless string && !string.empty?
26
26
 
27
- ::Time.at(string.slice(6, 10).to_i)
27
+ Time.at(string.slice(6, 10).to_i)
28
28
  end
29
29
 
30
30
  # Calculate the cycle time as the amount of time the story was open
@@ -2,13 +2,7 @@ module Dev
2
2
  class TargetProcess
3
3
  # Class containing user information
4
4
  class User
5
- # The resource type for the api endpoint
6
- RESOURCE_TYPE = 'User'.freeze
7
-
8
- # The api path for user requests
9
- PATH = '/User'.freeze
10
-
11
- attr_accessor :data, :id, :type, :name, :login, :email
5
+ attr_accessor :data, :id, :type, :name, :login
12
6
 
13
7
  def initialize(data)
14
8
  @data = data
@@ -16,12 +10,6 @@ module Dev
16
10
  @type = data['ResourceType']
17
11
  @name = data['FullName']
18
12
  @login = data['Login']
19
- @email = data['Email']
20
- end
21
-
22
- # Get the user with the given id and return that object
23
- def self.get(id)
24
- new(TargetProcess.new.get("#{User::PATH}/#{id}", Query.new))
25
13
  end
26
14
  end
27
15
  end
@@ -37,7 +37,7 @@ module Dev
37
37
  def parse_time(string)
38
38
  return nil unless string && !string.empty?
39
39
 
40
- ::Time.at(string.slice(6, 10).to_i)
40
+ Time.at(string.slice(6, 10).to_i)
41
41
  end
42
42
 
43
43
  # Calculate the cycle time as the amount of time the story was open
@@ -38,7 +38,7 @@ module Dev
38
38
  def parse_time(string)
39
39
  return nil unless string && !string.empty?
40
40
 
41
- ::Time.at(string.slice(6, 10).to_i)
41
+ Time.at(string.slice(6, 10).to_i)
42
42
  end
43
43
  end
44
44
  end
@@ -15,7 +15,7 @@ module Dev
15
15
  # The text of the url variable key
16
16
  TP_URL = 'TP_URL'.freeze
17
17
 
18
- # Config object for setting top level target process config options
18
+ # Config object for setting top level jira config options
19
19
  Config = Struct.new(:username, :password, :url, :http_debug) do
20
20
  def initialize
21
21
  Dotenv.load(CONFIG_FILE) if File.exist?(CONFIG_FILE)
@@ -72,8 +72,8 @@ module Dev
72
72
  [].tap do |ary|
73
73
  get(Release::PATH, query) do |result|
74
74
  ary << Release.new(result)
75
- yield ary.last if block_given?
76
75
  end
76
+ ary.each(&)
77
77
  end
78
78
  end
79
79
 
@@ -84,8 +84,8 @@ module Dev
84
84
  [].tap do |ary|
85
85
  get(UserStory::PATH, query) do |result|
86
86
  ary << UserStory.new(result)
87
- yield ary.last if block_given?
88
87
  end
88
+ ary.each(&)
89
89
  end
90
90
  end
91
91
 
@@ -96,8 +96,8 @@ module Dev
96
96
  [].tap do |ary|
97
97
  get(UserStoryHistory::PATH, query) do |result|
98
98
  ary << UserStoryHistory.new(result)
99
- yield ary.last if block_given?
100
99
  end
100
+ ary.each(&)
101
101
  end
102
102
  end
103
103
 
@@ -108,20 +108,8 @@ module Dev
108
108
  [].tap do |ary|
109
109
  get(TeamAssignment::PATH, query) do |result|
110
110
  ary << TeamAssignment.new(result)
111
- yield ary.last if block_given?
112
- end
113
- end
114
- end
115
-
116
- # Perform a query to the time api path
117
- # Call the given block (if present) with each time
118
- # Return all times
119
- def times(query, &)
120
- [].tap do |ary|
121
- get(Time::PATH, query) do |result|
122
- ary << Time.new(result)
123
- yield ary.last if block_given?
124
111
  end
112
+ ary.each(&)
125
113
  end
126
114
  end
127
115
 
@@ -129,8 +117,6 @@ module Dev
129
117
  # Call the given block (if present) with each piece of data
130
118
  # Return all pieces of data
131
119
  def get(path, query, &)
132
- return [] if query.empty?
133
-
134
120
  query_string = query.generate
135
121
  url = "/api/v1/#{path}"
136
122
  url << "?#{URI.encode_www_form(query_string)}" unless query_string.empty?
@@ -144,11 +130,8 @@ module Dev
144
130
  parsed_response['Items'].each(&)
145
131
 
146
132
  while parsed_response['Next']
147
- next_query_string = URI(parsed_response['Next']).query
148
- next_url = "/api/v1/#{path}"
149
- next_url << "?#{next_query_string}" unless query_string.empty?
150
- response = client.request_get(next_url, headers)
151
- raise "Error querying #{next_url} [#{next_query_string}]: #{response.inspect}" unless response.response.is_a?(Net::HTTPSuccess)
133
+ response = client.request_get(parsed_response['Next'], headers)
134
+ raise "Error querying #{parsed_response['Next']} [#{query_string}]: #{response.inspect}" unless response.response.is_a?(Net::HTTPSuccess)
152
135
 
153
136
  parsed_response = JSON.parse(response.body)
154
137
  return parsed_response unless parsed_response.key?('Items')