raykit 0.0.319 → 0.0.323

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e800e87fe08181c989bb8babbce06be9fcae9f2eb8d1a9fe118bc6a47ff62999
4
- data.tar.gz: 41c106098a55e6499087cf420f23227eb1a4f601bae921571524f11dd45026ba
3
+ metadata.gz: efd74944a1f30ac6317bef794cc964e37e484cef50814f0702b61b7b17c1d4d2
4
+ data.tar.gz: 5eb12a1cafeb1dd6812d5747ea90046face2dfefffdc4c6008ec7d4593d26a4a
5
5
  SHA512:
6
- metadata.gz: 7def4aa9bb5c9fa527b86707438876f79aa2ff6ea21e9b15fb4e47ce5856bb070aee634a63d4b0194da3a6fb4ed9b31d7d3dfb34b16a72057d201026df356359
7
- data.tar.gz: 134460e58978f156f9e4e1b1a0ef41743b361b852c6206a3905659fb560ba5a317c93867cd48922229770dd450ded9f918413269eaa9e27abdc3295cdcf9d577
6
+ metadata.gz: 4848c9952dcc2853067c1e7ef54b275f1c08c4dd18dac99c5e692750bc2ce28d526bd7e74da7910e27577ae1251f2ba20fe0f6510c51a7ab5ea140a58722a8b0
7
+ data.tar.gz: 8390ef4a06b1c5c48217dda4e729647750757e03c15e3a0a4ebc5c90c9dfae214f9422aedc329f5346b39903ad27986dec94f6c0311877b7645f0d0ddc52fffa
@@ -1,13 +1,12 @@
1
- # frozen_string_literal: true
2
-
3
- require 'open3'
4
- require 'timeout'
5
- require 'json'
6
- require 'yaml'
7
- require 'logger'
8
- require 'securerandom'
1
+ require "open3"
2
+ require "timeout"
3
+ require "json"
4
+ require "yaml"
5
+ require "logger"
6
+ require "securerandom"
9
7
 
10
8
  BUFFER_SIZE = 1024 unless defined?(BUFFER_SIZE)
9
+
11
10
  module Raykit
12
11
  # Functionality to support executing and logging system commands
13
12
  class Command
@@ -25,39 +24,51 @@ module Raykit
25
24
  def init_defaults
26
25
  @timeout = 0
27
26
  @directory = Dir.pwd
28
- @output = ''
29
- @error = ''
27
+ @output = +""
28
+ @error = +""
30
29
  @exitstatus = 0
31
30
  @user = Environment.user
32
31
  @machine = Environment.machine
33
32
  @logging_enabled = true
34
33
  end
35
34
 
36
- def initialize(command, timeout = 0, success_log_level = Logger::DEBUG, logging_enabled = true)
35
+ def initialize(command)
36
+ #def initialize(command, timeout = 0, success_log_level = Logger::DEBUG, logging_enabled = true)
37
+ timeout = 0
38
+ success_log_level = nil
39
+ logging_enabled = false
37
40
  @@commands = []
38
41
  init_defaults
39
42
  @success_log_level = success_log_level
40
43
  @logging_enabled = logging_enabled
41
44
  @command = command
42
45
  @timeout = timeout
43
- run if @command.length.positive?
46
+ #t = Time.now
47
+ @elapsed = 0
48
+ #run if @command.length.positive?
49
+ self
50
+ end
51
+
52
+ def set_timeout(timeout)
53
+ @timeout = timeout
44
54
  self
45
55
  end
46
56
 
47
57
  def run
48
58
  # puts '---running---'
49
59
  @start_time = Time.now
60
+ @elapsed = 0
50
61
  timer = Timer.new
51
62
  if @timeout.zero?
52
63
  @output, @error, process_status = Open3.capture3(@command)
53
64
  @exitstatus = process_status.exitstatus
54
65
  else
66
+ puts "@timeout is #{@timeout}"
55
67
  Open3.popen3(@command, chdir: @directory) do |_stdin, stdout, stderr, thread|
56
- tick = 2
68
+ tick = 1
57
69
  pid = thread.pid
58
70
  start = Time.now
59
- elapsed = Time.now - start
60
- while ((elapsed) < @timeout) && thread.alive?
71
+ while ((Time.now - start) < @timeout) && thread.alive?
61
72
  Kernel.select([stdout, stderr], nil, nil, tick)
62
73
  begin
63
74
  @output << stdout.read_nonblock(BUFFER_SIZE)
@@ -67,16 +78,16 @@ module Raykit
67
78
  @exitstatus = thread.value.exitstatus
68
79
  break
69
80
  end
70
- elapsed = Time.now - start
71
81
  end
82
+ sleep 1
72
83
  if thread.alive?
73
84
  if Gem.win_platform?
74
85
  `taskkill /f /pid #{pid}`
75
86
  else
76
- Process.kill('TERM', pid)
87
+ Process.kill("TERM", pid)
77
88
  end
78
89
  @exitstatus = 5
79
- @error = 'timed out'
90
+ @error = +"timed out"
80
91
  else
81
92
  @exitstatus = thread.value.exitstatus
82
93
  end
@@ -91,68 +102,70 @@ module Raykit
91
102
  # puts '---logging---'
92
103
  unless @success_log_level.nil?
93
104
  e = to_log_event
94
- e['Level'] = 'Verbose' if @success_log_level == 'Verbose'
95
- e['Level'] = 'Debug' if @success_log_level == Logger::DEBUG
96
- e['Level'] = 'Information' if @success_log_level == Logger::INFO
97
- e['Level'] = 'Warning' if @elapsed > 60 * 2
105
+ e["Level"] = "Verbose" if @success_log_level == "Verbose"
106
+ e["Level"] = "Debug" if @success_log_level == Logger::DEBUG
107
+ e["Level"] = "Information" if @success_log_level == Logger::INFO
108
+ e["Level"] = "Warning" if @elapsed > 60 * 2
98
109
  e.to_seq
99
110
  end
100
111
  end
101
112
  end
113
+ self
102
114
  end
103
115
 
116
+
104
117
  def to_log_event
105
118
  secrets = Secrets.new
106
119
  msg = secrets.hide(@command)
107
- level = 'Verbose'
108
- level = 'Warning' if @exitstatus != 0
120
+ level = "Verbose"
121
+ level = "Warning" if @exitstatus != 0
109
122
  output = @output
110
123
  error = @error
111
124
  output = @output[-1000..-1] if @output.length > 1200
112
125
  error = @error[-1000..-1] if @error.length > 1200
113
126
  Raykit::LogEvent.new(level, msg, {
114
- 'SourceContext' => 'Raykit::Command',
115
- 'Category' => 'Command',
116
- 'Timeout' => @timeout,
117
- 'Directory' => @directory,
118
- 'Output' => output,
119
- 'Error' => error,
120
- 'ExitStatus' => @exitstatus,
121
- 'Elapsed' => elapsed_str,
122
- 'ElapsedSeconds' => @elapsed
123
- })
127
+ "SourceContext" => "Raykit::Command",
128
+ "Category" => "Command",
129
+ "Timeout" => @timeout,
130
+ "Directory" => @directory,
131
+ "Output" => output,
132
+ "Error" => error,
133
+ "ExitStatus" => @exitstatus,
134
+ "Elapsed" => elapsed_str,
135
+ "ElapsedSeconds" => @elapsed,
136
+ })
124
137
  end
125
138
 
126
139
  def log
127
140
  # --- Rolling File JSON -----
128
- log = Logger.new("#{Raykit::Environment.log_dir}/Raykit.Commands.txt", 'daily')
141
+ log = Logger.new("#{Raykit::Environment.log_dir}/Raykit.Commands.txt", "daily")
129
142
  log.formatter = proc do |_severity, _datetime, _progname, msg|
130
143
  "#{msg}\n"
131
144
  end
132
145
  secrets = Secrets.new
133
146
  msg = secrets.hide(@command) # "?"# self.summary(false)
134
- level = 'Verbose'
135
- level = 'Warning' if @exitstatus != 0
147
+ level = "Verbose"
148
+ level = "Warning" if @exitstatus != 0
136
149
  event = Raykit::LogEvent.new(level, msg, {
137
- 'Timeout' => @timeout,
138
- 'Directory' => @directory,
139
- 'Output' => @output,
140
- 'Error' => @error,
141
- 'ExitStatus' => @exitstatus,
142
- 'Elapsed' => elapsed_str
143
- })
150
+ "Timeout" => @timeout,
151
+ "Directory" => @directory,
152
+ "Output" => @output,
153
+ "Error" => @error,
154
+ "ExitStatus" => @exitstatus,
155
+ "Elapsed" => elapsed_str,
156
+ })
144
157
  log.info event.to_json
145
158
  # ---------------------------
146
159
  begin
147
160
  json = JSON.generate(to_hash)
148
- log_filename = "#{Environment.get_dev_dir('log')}/Raykit.Command/#{SecureRandom.uuid}.json"
161
+ log_filename = "#{Environment.get_dev_dir("log")}/Raykit.Command/#{SecureRandom.uuid}.json"
149
162
  log_dir = File.dirname(log_filename)
150
163
  FileUtils.mkdir_p(log_dir) unless Dir.exist?(log_dir)
151
- File.open(log_filename, 'w') { |f| f.write(json) }
152
- if @exitstatus.zero?
153
- LOG.log('Raykit.Command', Logger::Severity::INFO, json)
164
+ File.open(log_filename, "w") { |f| f.write(json) }
165
+ if !@exitstatus.nil? && @exitstatus.zero?
166
+ LOG.log("Raykit.Command", Logger::Severity::INFO, json)
154
167
  else
155
- LOG.log('Raykit.Command', Logger::Severity::ERROR, json)
168
+ LOG.log("Raykit.Command", Logger::Severity::ERROR, json)
156
169
  end
157
170
  rescue JSON::GeneratorError => e
158
171
  puts to_hash.to_s
@@ -164,36 +177,46 @@ module Raykit
164
177
  def elapsed_str
165
178
  if elapsed < 1.0
166
179
  end
167
- "#{format('%.0f', elapsed)}s"
180
+ "#{format("%.0f", elapsed)}s"
168
181
  end
169
182
 
170
- def summary(show_directory = false)
183
+ def summary(show_directory = true)
171
184
  checkmark = "\u2713"
172
185
  # warning="\u26A0"
173
186
  error = "\u0058"
174
- symbol = Rainbow(checkmark.encode('utf-8')).green
175
- symbol = Rainbow(error.encode('utf-8')).red if @exitstatus != 0
187
+ symbol = Rainbow(checkmark.encode("utf-8")).green
188
+ symbol = Rainbow(error.encode("utf-8")).red if @exitstatus != 0
176
189
  if show_directory
177
- puts "#{symbol} #{elapsed_str.rjust(4)} #{Rainbow(SECRETS.hide(@command)).yellow} (#{@directory})"
190
+ puts "#{symbol} #{Rainbow(SECRETS.hide(@command)).yellow} (#{@directory},#{elapsed_str})"
178
191
  else
179
- puts "#{symbol} #{elapsed_str.rjust(4)} #{Rainbow(SECRETS.hide(@command)).yellow}" # + " (#{@directory})"
192
+ puts "#{symbol} #{Rainbow(SECRETS.hide(@command)).yellow} (#{elapsed_str})"
180
193
  end
181
- # puts symbol + " " + elapsed_str.rjust(4) + " " + Rainbow(SECRETS.hide(@command)).yellow# + " (#{@directory})"
194
+ self
182
195
  end
183
196
 
184
197
  def details
198
+ if @output.length > 0
199
+ @output.lines.each do |line|
200
+ puts ' ' + line
201
+ end
202
+ end
203
+ if @error.length > 0
204
+ @error.lines.each do |line|
205
+ puts ' ' + line
206
+ end
207
+ end
185
208
  # summary
186
- puts @output
187
- puts @error
188
- puts
209
+ #puts @output
210
+ #puts @error
211
+ #puts
189
212
  end
190
213
 
191
214
  def save
192
- filename = "#{Environment.get_dev_dir('log')}/Commands/#{SecureRandom.uuid}"
215
+ filename = "#{Environment.get_dev_dir("log")}/Commands/#{SecureRandom.uuid}"
193
216
  log_dir = File.dirname(filename)
194
217
  FileUtils.mkdir_p(log_dir) unless Dir.exist?(log_dir)
195
218
 
196
- File.open(filename, 'w') do |f|
219
+ File.open(filename, "w") do |f|
197
220
  f.write(JSON.pretty_generate(to_hash))
198
221
  end
199
222
  self
@@ -206,30 +229,30 @@ module Raykit
206
229
  hash[:timeout] = @timeout
207
230
  hash[:start_time] = @start_time
208
231
  hash[:elapsed] = @elapsed
209
- hash[:output] = @output.force_encoding('ISO-8859-1').encode('UTF-8')
210
- hash[:error] = @error.force_encoding('ISO-8859-1').encode('UTF-8')
232
+ hash[:output] = @output.force_encoding("ISO-8859-1").encode("UTF-8")
233
+ hash[:error] = @error.force_encoding("ISO-8859-1").encode("UTF-8")
211
234
  hash[:exitstatus] = @exitstatus
212
235
  hash[:user] = @user
213
236
  hash[:machine] = @machine
214
- hash[:context] = 'Raykit.Command'
237
+ hash[:context] = "Raykit.Command"
215
238
  hash
216
239
  end
217
240
 
218
241
  def from_hash(hash)
219
- @command = hash['command']
220
- @directory = hash['directory']
221
- @timeout = hash['timeout']
222
- @start_time = hash['start_time']
223
- @elapsed = hash['elapsed']
224
- @output = hash['output']
225
- @error = hash['error']
226
- @exitstatus = hash['exitstatus']
227
- @user = hash['user'] if hash.include?('user')
228
- @machine = hash['machine'] if hash.include?('machine')
242
+ @command = hash["command"]
243
+ @directory = hash["directory"]
244
+ @timeout = hash["timeout"]
245
+ @start_time = hash["start_time"]
246
+ @elapsed = hash["elapsed"]
247
+ @output = hash["output"]
248
+ @error = hash["error"]
249
+ @exitstatus = hash["exitstatus"]
250
+ @user = hash["user"] if hash.include?("user")
251
+ @machine = hash["machine"] if hash.include?("machine")
229
252
  end
230
253
 
231
254
  def self.parse(json)
232
- cmd = Command.new('')
255
+ cmd = Command.new("")
233
256
  cmd.from_hash(JSON.parse(json))
234
257
  cmd
235
258
  end
@@ -242,8 +265,8 @@ module Raykit
242
265
 
243
266
  def self.get_script_commands(hash)
244
267
  commands = []
245
- if hash.key?('script')
246
- hash['script'].each do |cmd|
268
+ if hash.key?("script")
269
+ hash["script"].each do |cmd|
247
270
  commands << cmd
248
271
  end
249
272
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'optparse'
4
- require 'slop'
5
- require_relative('./logging')
3
+ require "optparse"
4
+ require "slop"
5
+ require_relative("./logging")
6
6
 
7
7
  module Raykit
8
8
  # The implementation for the raykit console application
@@ -11,10 +11,10 @@ module Raykit
11
11
 
12
12
  def initialize
13
13
  @opts = Slop.parse do |o|
14
- o.string '-t', '--task', 'rake task', default: 'default'
15
- o.bool '-v', '--verbose', 'print detailed output', default: false
16
- o.bool '-q', '--quiet', 'minimal output', default: false
17
- o.bool '-s', '--stop', 'stop on error', default: true
14
+ o.string "-t", "--task", "rake task", default: "default"
15
+ o.bool "-v", "--verbose", "print detailed output", default: false
16
+ o.bool "-q", "--quiet", "minimal output", default: false
17
+ o.bool "-s", "--stop", "stop on error", default: true
18
18
  end
19
19
 
20
20
  if opts.verbose?
@@ -24,28 +24,28 @@ module Raykit
24
24
  end
25
25
 
26
26
  def run
27
- verb = 'usage'
27
+ verb = "usage"
28
28
  verb = @opts.arguments[0] if @opts.arguments.length.positive?
29
29
  case verb
30
- when 'usage'
30
+ when "usage"
31
31
  usage
32
- when 'add'
32
+ when "add"
33
33
  add
34
- when 'remove'
34
+ when "remove"
35
35
  remove
36
- when 'show'
36
+ when "show"
37
37
  show
38
- when 'work'
38
+ when "work"
39
39
  work
40
- when 'import'
40
+ when "import"
41
41
  import
42
- when 'clean'
42
+ when "clean"
43
43
  clean
44
- when 'sync_version'
44
+ when "sync_version"
45
45
  sync_version
46
- when 'copy'
46
+ when "copy"
47
47
  copy
48
- when 'pull'
48
+ when "pull"
49
49
  pull
50
50
  else
51
51
  puts "unrecognized command #{verb}"
@@ -54,33 +54,33 @@ module Raykit
54
54
  end
55
55
 
56
56
  def verb_descriptions
57
- { 'add' => 'add a git url',
58
- 'remove' => 'remove one or more git urls',
59
- 'show' => 'show git urls matching a specific pattern',
60
- 'work' => 'clone and rake a git repository',
61
- 'import' => 'import git urls matching a specific pattern',
62
- 'clean' => 'clean one or more working directories',
63
- 'pull' => 'preform git pull on one or more working directories',
64
- 'sync_version' => 'synchronize the version number between two files',
65
- 'copy' => 'copy a file' }
57
+ { "add" => "add a git url",
58
+ "remove" => "remove one or more git urls",
59
+ "show" => "show git urls matching a specific pattern",
60
+ "work" => "clone and rake a git repository",
61
+ "import" => "import git urls matching a specific pattern",
62
+ "clean" => "clean one or more working directories",
63
+ "pull" => "preform git pull on one or more working directories",
64
+ "sync_version" => "synchronize the version number between two files",
65
+ "copy" => "copy a file" }
66
66
  end
67
67
 
68
68
  def verb_usage
69
- { 'add' => 'add GIT_URL',
70
- 'remove' => 'remove URL_PATTERN',
71
- 'show' => 'show URL_PATTERN',
72
- 'work' => 'work URL_PATTERN [--task RAKE_TASK]',
73
- 'import' => 'import URL_PATTERN',
74
- 'clean' => 'clean URL_PATTERN',
75
- 'pull' => 'pull URL_PATTERN',
76
- 'sync_version' => 'sync_version SOURCE_FILENAME DESTINATION_FILENAME',
77
- 'copy' => 'copy SOURCE DESTINATION' }
69
+ { "add" => "add GIT_URL",
70
+ "remove" => "remove URL_PATTERN",
71
+ "show" => "show URL_PATTERN",
72
+ "work" => "work URL_PATTERN [--task RAKE_TASK]",
73
+ "import" => "import URL_PATTERN",
74
+ "clean" => "clean URL_PATTERN",
75
+ "pull" => "pull URL_PATTERN",
76
+ "sync_version" => "sync_version SOURCE_FILENAME DESTINATION_FILENAME",
77
+ "copy" => "copy SOURCE DESTINATION" }
78
78
  end
79
79
 
80
80
  def usage
81
- puts 'Usage: raykit VERB [GIT_URL|PATTERN] [OPTIONS]'
81
+ puts "Usage: raykit VERB [GIT_URL|PATTERN] [OPTIONS]"
82
82
  verb_descriptions.each do |k, v|
83
- puts "#{k.ljust(15, ' ')} - #{v}"
83
+ puts "#{k.ljust(15, " ")} - #{v}"
84
84
  end
85
85
  # puts @opts
86
86
  # puts "verbs: " + verbs.to_s
@@ -89,7 +89,7 @@ module Raykit
89
89
 
90
90
  def add
91
91
  if @opts.arguments.length < 2
92
- puts 'add requires a url'
92
+ puts "add requires a url"
93
93
  return 1
94
94
  end
95
95
  url = @opts.arguments[1]
@@ -104,17 +104,16 @@ module Raykit
104
104
 
105
105
  def remove
106
106
  if @opts.arguments.length < 2
107
- puts 'remove requires a url or pattern'
107
+ puts "remove requires a url or pattern"
108
108
  return 1
109
109
  end
110
- pattern = ''
110
+ pattern = ""
111
111
  pattern = @opts.arguments[1] if @opts.arguments.length > 1
112
112
  remove_urls = REPOSITORIES.matches(pattern)
113
113
  if remove_urls.length.zero?
114
- puts 'no matching urls found.'
115
-
114
+ puts "no matching urls found."
116
115
  else
117
- remove_urls.each do |url|
116
+ remove_urls.each do |url|
118
117
  REPOSITORIES.delete(url)
119
118
  puts "url #{url} removed."
120
119
  end
@@ -123,7 +122,7 @@ module Raykit
123
122
  end
124
123
 
125
124
  def show
126
- pattern = ''
125
+ pattern = ""
127
126
  pattern = @opts.arguments[1] if @opts.arguments.length > 1
128
127
  REPOSITORIES.matches(pattern).each do |url|
129
128
  puts url
@@ -131,7 +130,7 @@ module Raykit
131
130
  end
132
131
 
133
132
  def work
134
- pattern = ''
133
+ pattern = ""
135
134
  pattern = @opts.arguments[1] if @opts.arguments.length > 1
136
135
 
137
136
  work_repositories = REPOSITORIES.matches(pattern)
@@ -139,18 +138,18 @@ module Raykit
139
138
  puts "work: found #{work_repositories.length} matching urls"
140
139
  work_repositories.each do |url|
141
140
  exitstatus = work_url(url)
142
- puts ' ' if @opts.verbose?
141
+ puts " " if @opts.verbose?
143
142
  return exitstatus if @opts[:stop] && exitstatus != 0
144
143
  end
145
144
  0
146
145
  end
147
146
 
148
147
  def work_url(url)
149
- return 0 if url == 'https://gitlab.com/lou-parslow/raykit.git'
148
+ return 0 if url == "https://gitlab.com/lou-parslow/raykit.git"
150
149
 
151
150
  puts Rainbow(url).yellow.bright if @opts.verbose?
152
151
  repo = Raykit::Git::Repository.new(url)
153
- work = Raykit::Git::Directory.new(repo.get_dev_dir('work'))
152
+ work = Raykit::Git::Directory.new(repo.get_dev_dir("work"))
154
153
  unless Dir.exist?(work.directory)
155
154
  clone = Command.new("git clone #{url} #{work.directory} --recursive")
156
155
  puts clone.summary unless @opts.quiet?
@@ -161,7 +160,7 @@ module Raykit
161
160
  end
162
161
  if Dir.exist?(work.directory)
163
162
  Dir.chdir(work.directory) do
164
- if File.exist?('rakefile.rb')
163
+ if File.exist?("rakefile.rb")
165
164
  rake = Raykit::Command.new("rake #{@opts[:task]}")
166
165
  rake.summary(true) if !@opts.quiet? || rake.exitstatus != 0
167
166
  if rake.exitstatus != 0
@@ -179,17 +178,17 @@ module Raykit
179
178
  end
180
179
 
181
180
  def pull
182
- pattern = ''
181
+ pattern = ""
183
182
  pattern = @opts.arguments[1] if @opts.arguments.length > 1
184
183
  REPOSITORIES.matches(pattern).each do |url|
185
184
  repo = Raykit::Git::Repository.new(url)
186
- work = Raykit::Git::Directory.new(repo.get_dev_dir('work'))
187
- if Dir.exist?(work.directory) && !work.directory == '.git'
185
+ work = Raykit::Git::Directory.new(repo.get_dev_dir("work"))
186
+ if Dir.exist?(work.directory) && !work.directory == ".git"
188
187
  Dir.chdir(work.directory) do
189
188
  diff = `git diff`.strip
190
189
  status = `git status`.strip
191
- if diff.length.zero? && status.include?('nothing to commit')
192
- cmd = Command.new('git pull')
190
+ if diff.length.zero? && status.include?("nothing to commit")
191
+ cmd = Command.new("git pull")
193
192
  cmd.summary if @opts.verbose?
194
193
 
195
194
  if cmd.exitstatus != 0
@@ -210,9 +209,9 @@ module Raykit
210
209
  end
211
210
 
212
211
  def import
213
- pattern = ''
212
+ pattern = ""
214
213
  pattern = @opts.arguments[1] if @opts.arguments.length > 1
215
- puts 'scanning...'
214
+ puts "scanning..."
216
215
  count = REPOSITORIES.length
217
216
  REPOSITORIES.import(pattern)
218
217
  new_count = REPOSITORIES.length - count
@@ -220,11 +219,11 @@ module Raykit
220
219
  end
221
220
 
222
221
  def clean
223
- pattern = ''
222
+ pattern = ""
224
223
  pattern = @opts.arguments[1] if @opts.arguments.length > 1
225
224
  REPOSITORIES.matches(pattern).each do |url|
226
225
  repo = Raykit::Git::Repository.new(url)
227
- work = Raykit::Git::Directory.new(repo.get_dev_dir('work'))
226
+ work = Raykit::Git::Directory.new(repo.get_dev_dir("work"))
228
227
  next unless Dir.exist?(work.directory)
229
228
 
230
229
  puts "removing #{work.directory}"
@@ -250,7 +249,7 @@ module Raykit
250
249
 
251
250
  def copy
252
251
  if @opts.arguments.length < 3
253
- puts 'source and destination arguments are required for copy'
252
+ puts "source and destination arguments are required for copy"
254
253
  return 1
255
254
  end
256
255
  source = @opts.arguments[1]
@@ -265,7 +264,7 @@ module Raykit
265
264
 
266
265
  begin
267
266
  puts "remote: #{remote}"
268
- cmd = Raykit::Rake.run(remote, 'master')
267
+ cmd = Raykit::Rake.run(remote, "master")
269
268
  elapsed_str = Timer.get_elapsed_str(cmd.elapsed)
270
269
  if cmd.exitstatus.zero?
271
270
  puts "#{elapsed_str} #{Rainbow(SECRETS.hide(cmd.command)).yellow.bright} (#{cmd.directory})"
@@ -273,11 +272,11 @@ module Raykit
273
272
  puts "\r\n#{cmd.command}\r\n"
274
273
  puts "\r\n#{cmd.output}\r\n"
275
274
  puts "\r\n#{cmd.error}\r\n"
276
- puts ''
275
+ puts ""
277
276
  puts "#{Rainbow(elapsed_str).red.bright} #{Rainbow(cmd.command).white}"
278
277
  end
279
278
  rescue StandardError
280
- puts 'rescued...'
279
+ puts "rescued..."
281
280
  end
282
281
  end
283
282
  end
data/lib/raykit/dir.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tmpdir'
4
- require_relative './environment'
3
+ require "tmpdir"
4
+ require_relative "./environment"
5
5
 
6
6
  class Dir
7
7
  def self.get_text(dir, relative_name)
@@ -9,13 +9,13 @@ class Dir
9
9
  end
10
10
 
11
11
  def self.set_text(dir, relative_name, text)
12
- File.open("#{dir}/#{relative_name}", 'w') { |f| f.write text }
12
+ File.open("#{dir}/#{relative_name}", "w") { |f| f.write text }
13
13
  end
14
14
 
15
15
  def self.get_git_directories(dir)
16
16
  git_dirs = []
17
17
  Dir.chdir(dir) do
18
- Dir.glob('**/.git/index') do |f|
18
+ Dir.glob("**/.git/index") do |f|
19
19
  git_dir = File.dirname(File.dirname(f))
20
20
  git_dirs << git_dir
21
21
  end
@@ -37,8 +37,8 @@ class Dir
37
37
  end
38
38
 
39
39
  def self.get_data_dir
40
- unless ENV['DATA_DIR'].nil?
41
- data_dir = ENV['DATA_DIR']
40
+ unless ENV["DATA_DIR"].nil?
41
+ data_dir = ENV["DATA_DIR"]
42
42
  return data_dir if Dir.exist?(data_dir)
43
43
  end
44
44
  home_dir = Raykit::Environment.home_dir
data/lib/raykit/dotnet.rb CHANGED
@@ -93,7 +93,7 @@ module Raykit
93
93
 
94
94
  def self.get_package_names(filename)
95
95
  package_names = []
96
- if File.exist?(filename) && filename.include?('.csproj')
96
+ if File.exist?(filename) && filename.include?(".csproj")
97
97
  regex = /<PackageReference Include="([\w.-]+)"/
98
98
  text = IO.read(filename)
99
99
  text.scan(regex).each do |m|