lazylead 0.6.2 → 0.7.0

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: 669da4d2f993894e78fcd42508429667cb29afe9082012c8dadee88e77dc0518
4
- data.tar.gz: '0976452e6d5aaf5e282f468f05620915e73ee5cb2566ff9e4441d094d4f3dc3f'
3
+ metadata.gz: e5a5b0412fc9cb5796b066940c57e50785b64920718a09ecd4ef8794fc8b3908
4
+ data.tar.gz: 148b21d628c91d27abee8fb1bb86aeaf78cfdc96b01f9cbed16c9f4f8b5c7ef3
5
5
  SHA512:
6
- metadata.gz: ec9719d37253c81db0d59d6d3f216e8d677a8d3a4543776409782236c01428fe97a07e3c58e95150c031506d894a8188b2ce551a2ffa79c4b364edf60774ad8a
7
- data.tar.gz: 57662e5ba79d877e4b7310f0ff20fa767e6b4246ba46f7ffd30afeee86215f311dffeb2e947a86c867b3554ac20b1711b1d69edbd493e971c01d170fccd85aed
6
+ metadata.gz: 58539cbff1ccdc9c392aaa67af4e6dc0ade92311cbf2118202392b069de15f3872f833d2081b59d97439029901b569fe72e6a54e22ddfe011c06cddef576b6e2
7
+ data.tar.gz: 658f24b1dde5272d17c6cdd77f570f71de818f83a7acda9c5b3cdebf497f514e7f890862963caa49e577f2c566829be7d247bee1e236ec1248cdf0fbc4a58de2
@@ -16,10 +16,13 @@ Layout/LineLength:
16
16
  - "test/**/*"
17
17
 
18
18
  Metrics/AbcSize:
19
- Max: 20
19
+ Max: 21
20
20
  Exclude:
21
21
  - "test/**/*"
22
22
 
23
+ Metrics/CyclomaticComplexity:
24
+ Max: 8
25
+
23
26
  Metrics/BlockLength:
24
27
  Exclude:
25
28
  - "*.gemspec"
@@ -91,3 +94,48 @@ Lint/StructNewOverride:
91
94
 
92
95
  # @todo #/DEV Add violation regarding methods without documentation using RDoc
93
96
  # https://stackoverflow.com/questions/1681467/how-to-document-ruby-code
97
+
98
+ Layout/SpaceBeforeBrackets: # (new in 1.7)
99
+ Enabled: true
100
+ Lint/AmbiguousAssignment: # (new in 1.7)
101
+ Enabled: true
102
+ Lint/DeprecatedConstants: # (new in 1.8)
103
+ Enabled: true
104
+ Lint/DuplicateBranch: # (new in 1.3)
105
+ Enabled: true
106
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
107
+ Enabled: true
108
+ Lint/EmptyBlock: # (new in 1.1)
109
+ Enabled: true
110
+ Lint/EmptyClass: # (new in 1.3)
111
+ Enabled: true
112
+ Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
113
+ Enabled: true
114
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
115
+ Enabled: true
116
+ Lint/RedundantDirGlobSort: # (new in 1.8)
117
+ Enabled: true
118
+ Lint/ToEnumArguments: # (new in 1.1)
119
+ Enabled: true
120
+ Lint/UnexpectedBlockArity: # (new in 1.5)
121
+ Enabled: true
122
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
123
+ Enabled: true
124
+ Style/ArgumentsForwarding: # (new in 1.1)
125
+ Enabled: true
126
+ Style/CollectionCompact: # (new in 1.2)
127
+ Enabled: true
128
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
129
+ Enabled: true
130
+ Style/EndlessMethod: # (new in 1.8)
131
+ Enabled: true
132
+ Style/HashExcept: # (new in 1.7)
133
+ Enabled: true
134
+ Style/NegatedIfElseCondition: # (new in 1.2)
135
+ Enabled: true
136
+ Style/NilLambda: # (new in 1.3)
137
+ Enabled: true
138
+ Style/RedundantArgument: # (new in 1.4)
139
+ Enabled: true
140
+ Style/SwapValues: # (new in 1.1)
141
+ Enabled: true
data/.simplecov CHANGED
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
4
4
  [SimpleCov::Formatter::HTMLFormatter]
data/Guardfile CHANGED
@@ -25,7 +25,7 @@
25
25
  # Guardfile for Lazylead
26
26
  guard :minitest, all_after_pass: false, all_on_start: false do
27
27
  # with Minitest::Unit
28
- watch(%r{^test/(.*)\/?test_(.*)\.rb$})
28
+ watch(%r{^test/(.*)/?test_(.*)\.rb$})
29
29
  watch(%r{^test/test\.rb$}) { "test" }
30
30
  watch(%r{^lib/lazylead/(.*/)?([^/]+)\.rb$}) do |m|
31
31
  "test/#{m[1]}test_#{m[2]}.rb"
@@ -25,11 +25,12 @@
25
25
 
26
26
  # When sync mode is true, all output is immediately flushed
27
27
  # to the underlying operating system and is not buffered internally.
28
- STDOUT.sync = true
28
+ $stdout.sync = true
29
29
 
30
30
  require "slop"
31
31
  require "sqlite3"
32
32
  require "colorize"
33
+ require "inifile"
33
34
  require "logging"
34
35
  require "backtrace"
35
36
  require "memory_profiler"
@@ -81,6 +82,7 @@ log.debug "Version: #{Lazylead::VERSION.colorize(:green)}"
81
82
  log.debug "Memory footprint at start is " \
82
83
  "#{Lazylead::Allocated.new.to_s.colorize(:light_blue)}."
83
84
  cmd = lambda do
85
+ IniFile.new(filename: "lazylead.ini").each { |_, k, v| ENV[k] = v }
84
86
  Lazylead::CLI::App.new(
85
87
  log,
86
88
  Lazylead::Schedule.new(log: log),
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.rubygems_version = "2.2"
33
33
  s.required_ruby_version = ">=2.6.5"
34
34
  s.name = "lazylead"
35
- s.version = "0.6.2"
35
+ s.version = "0.7.0"
36
36
  s.license = "MIT"
37
37
  s.summary = "Eliminate the annoying work within bug-trackers."
38
38
  s.description = "Ticketing systems (Github, Jira, etc.) are strongly
@@ -45,7 +45,7 @@ tasks instead of solving technical problems."
45
45
  s.authors = ["Yurii Dubinka"]
46
46
  s.email = "yurii.dubinka@gmail.com"
47
47
  s.homepage = "http://github.com/dgroup/lazylead"
48
- s.post_install_message = "Thanks for installing Lazylead v0.6.2!
48
+ s.post_install_message = "Thanks for installing Lazylead v0.7.0!
49
49
  Read our blog posts: https://lazylead.org
50
50
  Stay in touch with the community in Telegram: https://t.me/lazylead
51
51
  Follow us on Twitter: https://twitter.com/lazylead
@@ -55,42 +55,46 @@ tasks instead of solving technical problems."
55
55
  s.test_files = s.files.grep(%r{^(test|features)/})
56
56
  s.rdoc_options = ["--charset=UTF-8"]
57
57
  s.extra_rdoc_files = %w[readme.md license.txt]
58
- s.add_runtime_dependency "activerecord", "6.0.3"
58
+ s.add_runtime_dependency "activerecord", "6.1.1"
59
59
  s.add_runtime_dependency "backtrace", "0.3"
60
60
  s.add_runtime_dependency "colorize", "0.8.1"
61
61
  s.add_runtime_dependency "faraday", "1.0.1"
62
- s.add_runtime_dependency "get_process_mem", "0.2.5"
62
+ s.add_runtime_dependency "get_process_mem", "0.2.7"
63
+ s.add_runtime_dependency "inifile", "3.0.0"
63
64
  s.add_runtime_dependency "jira-ruby", "1.7.1"
64
- s.add_runtime_dependency "json", "2.3.0"
65
- s.add_runtime_dependency "logging", "2.2.2"
65
+ s.add_runtime_dependency "json", "2.5.1"
66
+ s.add_runtime_dependency "logging", "2.3.0"
66
67
  s.add_runtime_dependency "mail", "2.7.1"
67
68
  s.add_runtime_dependency "memory_profiler", "0.9.13"
68
69
  s.add_runtime_dependency "openssl", "2.1.2"
70
+ s.add_runtime_dependency "railties", "6.1.1"
69
71
  s.add_runtime_dependency "require_all", "3.0.0"
70
72
  s.add_runtime_dependency "rufus-scheduler", "3.6.0"
71
73
  s.add_runtime_dependency "slop", "4.4"
72
74
  s.add_runtime_dependency "sqlite3", "1.4.2"
73
75
  s.add_runtime_dependency "tempfile", "0.1.0"
74
76
  s.add_runtime_dependency "tilt", "2.0.10"
75
- s.add_runtime_dependency "tzinfo", "1.1"
76
- s.add_runtime_dependency "tzinfo-data", "1.2019.3"
77
- s.add_runtime_dependency "vcs4sql", "0.1.0"
77
+ s.add_runtime_dependency "tzinfo", "2.0.4"
78
+ s.add_runtime_dependency "tzinfo-data", "1.2020.6"
79
+ s.add_runtime_dependency "vcs4sql", "0.1.1"
78
80
  s.add_runtime_dependency "viewpoint", "1.1.0"
79
- s.add_development_dependency "codecov", "0.2.3"
81
+ s.add_development_dependency "codecov", "0.2.15"
80
82
  s.add_development_dependency "guard", "2.15.0"
81
83
  s.add_development_dependency "guard-minitest", "2.4.6"
82
- s.add_development_dependency "minitest", "5.11.3"
84
+ s.add_development_dependency "minitest", "5.14.3"
83
85
  s.add_development_dependency "minitest-fail-fast", "0.1.0"
84
86
  s.add_development_dependency "minitest-hooks", "1.5.0"
85
87
  s.add_development_dependency "minitest-reporters", "1.3.6"
86
88
  s.add_development_dependency "net-ping", "2.0.8"
87
89
  s.add_development_dependency "rake", "12.3.3"
88
90
  s.add_development_dependency "random-port", "0.3.1"
89
- s.add_development_dependency "rdoc", "6.1.1"
90
- s.add_development_dependency "rubocop", "0.82"
91
+ s.add_development_dependency "rdoc", "6.3.0"
92
+ s.add_development_dependency "rubocop", "1.8.1"
91
93
  s.add_development_dependency "rubocop-minitest", "0.5.1"
92
94
  s.add_development_dependency "rubocop-performance", "1.5.2"
95
+ s.add_development_dependency "rubocop-rake", "0.5.1"
93
96
  s.add_development_dependency "rubocop-rspec", "1.33.0"
94
97
  s.add_development_dependency "sqlint", "0.1.10"
95
- s.add_development_dependency "xcop", "0.6"
98
+ s.add_development_dependency "tempfile", "0.1.0"
99
+ s.add_development_dependency "xcop", "0.6.2"
96
100
  end
@@ -81,12 +81,12 @@ module Lazylead
81
81
 
82
82
  def cc
83
83
  @cc ||= begin
84
- if @text.include? ","
85
- @text.split(",").map(&:strip).select { |e| e[@regxp] }
86
- elsif @text[@regxp]
87
- [@text.strip]
88
- end
89
- end
84
+ if @text.include? ","
85
+ @text.split(",").map(&:strip).select { |e| e[@regxp] }
86
+ elsif @text[@regxp]
87
+ [@text.strip]
88
+ end
89
+ end
90
90
  end
91
91
 
92
92
  def each(&block)
@@ -126,14 +126,14 @@ module Lazylead
126
126
 
127
127
  def to_h
128
128
  @to_h ||= begin
129
- if @orig.is_a? Hash
130
- @orig.each_with_object({}) do |i, o|
131
- o[i.first] = Lazylead::PlainCC.new(i.last).cc
132
- end
133
- else
134
- {}
135
- end
136
- end
129
+ if @orig.is_a? Hash
130
+ @orig.each_with_object({}) do |i, o|
131
+ o[i.first] = Lazylead::PlainCC.new(i.last).cc
132
+ end
133
+ else
134
+ {}
135
+ end
136
+ end
137
137
  end
138
138
  end
139
139
 
@@ -145,18 +145,19 @@ module Lazylead
145
145
  # License:: MIT
146
146
  class ComponentCC < Lazylead::PredefinedCC
147
147
  def initialize(prj, jira)
148
+ super({})
148
149
  @prj = prj
149
150
  @jira = jira
150
151
  end
151
152
 
152
153
  def to_h
153
154
  @to_h ||= begin
154
- components.each_with_object({}) do |c, h|
155
- email = lead(c.attrs["id"])
156
- next if email.nil? || email.blank?
157
- h[c.attrs["name"]] = email
158
- end
159
- end
155
+ components.each_with_object({}) do |c, h|
156
+ email = lead(c.attrs["id"])
157
+ next if email.nil? || email.blank?
158
+ h[c.attrs["name"]] = email
159
+ end
160
+ end
160
161
  end
161
162
 
162
163
  private
@@ -57,8 +57,8 @@ module Lazylead
57
57
  private
58
58
 
59
59
  def apply_vcs_migration(opts)
60
- @db = File.expand_path(opts[:home]) + "/" + opts[:sqlite]
61
- vcs = File.expand_path(opts[:home]) + "/" + opts[:vcs4sql]
60
+ @db = "#{File.expand_path(opts[:home])}/#{opts[:sqlite]}"
61
+ vcs = "#{File.expand_path(opts[:home])}/#{opts[:vcs4sql]}"
62
62
  @log.debug "Database: '#{@db.colorize(:light_blue)}', "\
63
63
  "sql migration dir: '#{vcs.colorize(:light_blue)}'"
64
64
  Vcs4sql::Sqlite::Migration.new(@db).upgrade vcs, opts[:testdata]
@@ -104,16 +104,23 @@ module Lazylead
104
104
  end
105
105
 
106
106
  # Detect links mentioned in ticket comments
107
+ # @todo #/DEV Refactor this method in order to make it more human-readable and remove the
108
+ # suppresion below
109
+ #
110
+ # rubocop:disable Metrics/CyclomaticComplexity
111
+ # rubocop:disable Metrics/PerceivedComplexity
107
112
  def mentioned_links(ticket)
108
113
  ticket.comments
109
114
  .map { |cmnt| cmnt.attrs["body"] }
110
115
  .select { |cmnt| @confl.any? { |c| cmnt.include? c.url } }
111
- .flat_map { |cmnt| cmnt.split " " }
116
+ .flat_map(&:split)
112
117
  .select { |cmnt| @confl.any? { |c| cmnt.start_with? c.url } }
113
118
  .map(&method(:to_page_id))
114
119
  .reject(&:blank?)
115
120
  .uniq
116
121
  end
122
+ # rubocop:enable Metrics/CyclomaticComplexity
123
+ # rubocop:enable Metrics/PerceivedComplexity
117
124
 
118
125
  # Convert confluence page url to the following format:
119
126
  # http://confluence.com/pages/viewpage.action?pageId=xxxxx
@@ -68,9 +68,7 @@ module Lazylead
68
68
  opts.each_with_object({}) do |e, o|
69
69
  k = e[0]
70
70
  v = e[1]
71
- if v.respond_to? :start_with?
72
- v = ENV[v.slice(2, v.length - 3)] if v.start_with? "${"
73
- end
71
+ v = ENV[v.slice(2, v.length - 3)] if v.respond_to?(:start_with?) && v.start_with?("${")
74
72
  o[k] = v
75
73
  end
76
74
  end
@@ -106,6 +104,7 @@ module Lazylead
106
104
  sys = system.connect
107
105
  opts = props
108
106
  opts = detect_cc(sys) if opts.key? "cc"
107
+ opts["system"] = second_sys if opts.numeric? "system"
109
108
  action.constantize.new.run(sys, postman, opts)
110
109
  end
111
110
 
@@ -137,12 +136,12 @@ module Lazylead
137
136
 
138
137
  def props
139
138
  @props ||= begin
140
- if team.nil?
141
- Opts.new(env(to_hash))
142
- else
143
- Opts.new(env(team.to_hash.merge(to_hash)))
144
- end
145
- end
139
+ if team.nil?
140
+ Opts.new(env(to_hash))
141
+ else
142
+ Opts.new(env(team.to_hash.merge(to_hash)))
143
+ end
144
+ end
146
145
  end
147
146
 
148
147
  def postman
@@ -153,17 +152,21 @@ module Lazylead
153
152
  end
154
153
  end
155
154
 
155
+ def second_sys
156
+ sys = System.find(props["system"])
157
+ raise "ll-014: No ticketing system found for #{self}" if sys.nil?
158
+ sys.connect
159
+ end
160
+
156
161
  private
157
162
 
158
163
  # Parse scheduling #type and #unit
159
164
  def trigger
160
165
  @trigger ||= begin
161
- trg = schedule.split(":")
162
- unless trg.size == 2
163
- raise "ll-007: illegal schedule format '#{schedule}'"
164
- end
165
- trg.map(&:strip).map(&:chomp)
166
- end
166
+ trg = schedule.split(":")
167
+ raise "ll-007: illegal schedule format '#{schedule}'" unless trg.size == 2
168
+ trg.map(&:strip).map(&:chomp)
169
+ end
167
170
  end
168
171
  end
169
172
 
@@ -179,6 +182,10 @@ module Lazylead
179
182
  @log = log
180
183
  end
181
184
 
185
+ # @todo #/DEV Remove the suppression during next refactoring (or enhancements)
186
+ # for the method below
187
+ #
188
+ # rubocop:disable Metrics/AbcSize
182
189
  def exec
183
190
  Logging.mdc["tid"] = "task #{id}"
184
191
  @log.debug "'#{name}' is started."
@@ -189,12 +196,13 @@ module Lazylead
189
196
  rescue StandardError => e
190
197
  msg = <<~MSG
191
198
  ll-006: Task ##{id} #{e} (#{e.class}) at #{self}
192
- #{Backtrace.new(e) if ARGV.include? '--trace'}"
199
+ #{Backtrace.new(e) if ARGV.include? '--trace'}
193
200
  MSG
194
201
  @log.error msg
195
202
  ensure
196
203
  Logging.mdc["tid"] = ""
197
204
  end
205
+ # rubocop:enable Metrics/AbcSize
198
206
  end
199
207
 
200
208
  # Ticketing systems to monitor.
@@ -44,7 +44,13 @@ module Lazylead
44
44
  # Split text value by delimiter, trim all spaces and reject blank items
45
45
  def slice(key, delim)
46
46
  return [] unless to_h.key? key
47
- to_h[key].split(delim).map(&:chomp).map(&:strip).reject(&:blank?)
47
+ trim to_h[key].split(delim)
48
+ end
49
+
50
+ # Trim all spaces and reject blank items in array
51
+ def trim(arr)
52
+ return [] if arr.nil?
53
+ arr.map(&:chomp).map(&:strip).reject(&:blank?)
48
54
  end
49
55
 
50
56
  def blank?(key)
@@ -124,5 +130,14 @@ module Lazylead
124
130
  return [val] unless val.include? delim
125
131
  slice key, delim
126
132
  end
133
+
134
+ # Ensure that particular key from options is a positive numer
135
+ # Opts.new("key" => "1").numeric? "key" => true
136
+ # Opts.new("key" => "0").numeric? "key" => false
137
+ # Opts.new("key" => ".").numeric? "key" => false
138
+ # Opts.new("key" => "nil").numeric? "key" => false
139
+ def numeric?(key)
140
+ to_h[key].to_i.positive?
141
+ end
127
142
  end
128
143
  end
@@ -39,6 +39,7 @@ module Lazylead
39
39
  #
40
40
  class Salt
41
41
  attr_reader :id
42
+
42
43
  #
43
44
  # Each salt should be defined as a environment variable with id, like
44
45
  # salt1=E1F53135E559C253
@@ -177,7 +177,7 @@ module Lazylead
177
177
  end
178
178
 
179
179
  def url
180
- @issue.attrs["self"].split("/rest/api/").first + "/browse/" + key
180
+ "#{@issue.attrs['self'].split('/rest/api/').first}/browse/#{key}"
181
181
  end
182
182
 
183
183
  def duedate
@@ -257,13 +257,20 @@ module Lazylead
257
257
  lbl = [] if lbl.nil?
258
258
  lbl << label
259
259
  lbl += more if more.size.positive?
260
- save!("fields" => { "labels" => lbl.uniq })
260
+ labels! lbl
261
261
  end
262
262
 
263
+ # Get the labels for a particular issue
263
264
  def labels
264
265
  fields["labels"]
265
266
  end
266
267
 
268
+ # Update the labels for a particular issue
269
+ def labels!(lbl)
270
+ return if lbl.nil? || lbl.empty?
271
+ save!("fields" => { "labels" => lbl.uniq })
272
+ end
273
+
267
274
  def save!(opts)
268
275
  @issue.save(opts)
269
276
  end