raykit 0.0.385 → 0.0.388

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: 2628195892071cf9a584959d32d814ef059acaa7697b0a115c1ac67edd15f1a8
4
- data.tar.gz: d7e2b2dc2b8162d7003bfea9ec831d4b33240f851ba793adf905402ce4c7e48f
3
+ metadata.gz: 3b11546d1b5398f5248ef90d704add21b831f91ef7a79d38212086262aa3b9cc
4
+ data.tar.gz: 453b28fa4e041b94d05abd069ffdc3f4fa254ed476f2249f60a3865c8b1dac01
5
5
  SHA512:
6
- metadata.gz: b67eb6e9644e13778947a60730652034b23d6e66a4c165dff803da838da33de395e8c99b2def8d652dc41a085b750ea7c0539e5036e73fa15aedfdfbfd42b64d
7
- data.tar.gz: 4a6645a6870477ff37958778beaeecefa05c29f5393612476ea8b6e2e1bb589d8b4d47e1ca1659e07b570a944632e17fa900f6e260d4c07edcd3ecf0c09a6b0e
6
+ metadata.gz: a823d9b9b52e8fe70789b847521cf5ec368e58f555edf4843798bff487d8d5e4455062f0a083a097612ceb3cc4e2bdf6803417b266b0f4c51ae14bd7af27de80
7
+ data.tar.gz: 80beabddb4f3bba256d48db6f9f3358163a63ea36f3198f7e7f438e717865b8f4266587fa5f8ef67db02b31503d0eacdaba793fce5ae983d8273cbe4f521794b
data/README.md CHANGED
@@ -4,3 +4,5 @@ ruby gem supporting rake ci/cd tasks
4
4
 
5
5
  ## raykit console application
6
6
 
7
+ # TODO
8
+ - consider using https://github.com/tj/terminal-table to display name value pairs
@@ -63,6 +63,7 @@ module Raykit
63
63
  @output, @error, process_status = Open3.capture3(@command)
64
64
  @exitstatus = process_status.exitstatus
65
65
  else
66
+ # =================================================
66
67
  #puts "@timeout is #{@timeout}"
67
68
  Open3.popen3(@command, chdir: @directory) do |_stdin, stdout, stderr, thread|
68
69
  tick = 1
@@ -76,6 +77,12 @@ module Raykit
76
77
  rescue IO::WaitReadable
77
78
  rescue EOFError
78
79
  @exitstatus = thread.value.exitstatus
80
+ until stdout.eof?
81
+ @output << stdout.read_nonblock(BUFFER_SIZE)
82
+ end
83
+ until stderr.eof?
84
+ @error << stderr.read_nonblock(BUFFER_SIZE)
85
+ end
79
86
  break
80
87
  end
81
88
  end
@@ -92,6 +99,8 @@ module Raykit
92
99
  @exitstatus = thread.value.exitstatus
93
100
  end
94
101
  end
102
+
103
+ # =================================================
95
104
  end
96
105
  @elapsed = timer.elapsed
97
106
  if @logging_enabled
@@ -187,7 +196,7 @@ module Raykit
187
196
  symbol = Rainbow(error.encode("utf-8")).red if @exitstatus != 0
188
197
  cmd = "#{Rainbow(SECRETS.hide(@command)).yellow}"
189
198
  if show_directory
190
- puts "#{symbol} #{cmd} " + Rainbow("#{elapsed_str}").cyan #(#{@directory},#{elapsed_str})"
199
+ puts "#{symbol} #{cmd} " + Rainbow("#{elapsed_str}").cyan
191
200
  puts Rainbow(" #{@directory}").cyan
192
201
  else
193
202
  puts "#{symbol} #{Rainbow(SECRETS.hide(@command)).yellow} (#{elapsed_str})"
@@ -202,6 +211,7 @@ module Raykit
202
211
  end
203
212
 
204
213
  def details
214
+ puts " exit_code: " + @exitstatus.to_s
205
215
  if @output.length > 0
206
216
  @output.lines.each do |line|
207
217
  puts " " + line
@@ -214,6 +224,16 @@ module Raykit
214
224
  end
215
225
  end
216
226
 
227
+ def to_markdown
228
+ checkmark = "\u2713"
229
+ error = "\u0058"
230
+ symbol = checkmark.encode("utf-8")
231
+ symbol = error.encode("utf-8") if @exitstatus != 0
232
+ cmd = "#{SECRETS.hide(@command)}"
233
+ md = "#{symbol} #{SECRETS.hide(@command)} (#{elapsed_str})"
234
+ md
235
+ end
236
+
217
237
  def save
218
238
  filename = "#{Environment.get_dev_dir("log")}/Commands/#{SecureRandom.uuid}"
219
239
  log_dir = File.dirname(filename)
@@ -134,6 +134,20 @@ module Raykit
134
134
  run(cmd)
135
135
  end
136
136
  end
137
+
138
+ def self.make(url, commit_id, command)
139
+ repo = Raykit::Git::Repository.new(url)
140
+ make_dir = roam.get_dev_dir("make") + "/" + commit_id
141
+ FileUtils.mkdir_p(roam.get_dev_dir("make")) if !Dir.exists?(roam.get_dev_dir("make"))
142
+ run("git clone #{url} #{make_dir}") if (!Dir.exists?(make_dir))
143
+ cmd = 0
144
+ Dir.chdir(make_dir) do
145
+ run("git checkout #{commit_id}")
146
+ cmd = run(command)
147
+ end
148
+ FileUtils.rm_rf(make_dir) if (cmd.exitstatus == 0)
149
+ cmd
150
+ end
137
151
  end
138
152
  end
139
153
  end
data/lib/raykit/log.rb CHANGED
@@ -42,10 +42,12 @@ module Raykit
42
42
 
43
43
  def self.start_task(task_name)
44
44
  puts Rainbow(": #{task_name}").blue.bright
45
+ MARKDOWN.puts(": #{task_name}")
45
46
  end
46
47
 
47
48
  def self.show_value(name, value)
48
49
  puts " " + Rainbow(name).cyan + " " + Rainbow("#{value}").white.bold
50
+ MARKDOWN.puts("#{name} #{value}")
49
51
  end
50
52
  end
51
53
  end
@@ -0,0 +1,23 @@
1
+ module Raykit
2
+ class Markdown
3
+ attr_accessor :text
4
+
5
+ def initialize()
6
+ @text = ""
7
+ end
8
+
9
+ def puts(line)
10
+ @text = @text + "\n" + line
11
+ end
12
+
13
+ def to_s()
14
+ @text
15
+ end
16
+
17
+ def save_as(filename)
18
+ File.write("rake.md", @text)
19
+ end
20
+ end
21
+ end
22
+
23
+ MARKDOWN = Raykit::Markdown.new
@@ -14,6 +14,8 @@ module Raykit
14
14
  @repository
15
15
  @git_directory
16
16
  @timeout
17
+ @values
18
+ @commands
17
19
 
18
20
  # @log
19
21
  # @commit_message_filename
@@ -53,6 +55,8 @@ module Raykit
53
55
  end
54
56
  end
55
57
  @repository = Raykit::Git::Repository.new(@remote)
58
+ @values = Hash::new()
59
+ @commands = Array::new()
56
60
  end
57
61
 
58
62
  def get_dev_dir(subdir)
@@ -75,6 +79,10 @@ module Raykit
75
79
  @git_directory.branch
76
80
  end
77
81
 
82
+ def values
83
+ @values
84
+ end
85
+
78
86
  # latest local commit
79
87
  def latest_commit
80
88
  return "" if detached?
@@ -211,9 +219,28 @@ module Raykit
211
219
  self
212
220
  end
213
221
 
222
+ def to_markdown()
223
+ md = "# #{@name}"
224
+ md += get_markdown_nvp("Name", "Value", " ")
225
+ md += get_markdown_nvp("-", "-", "-")
226
+ md += get_markdown_nvp("Version", "#{@version}", " ")
227
+ md += get_markdown_nvp("Machine", "#{Raykit::Environment::machine}", " ")
228
+ md += get_markdown_nvp("User", "#{Raykit::Environment::user}", " ")
229
+ @values.each do |key, value|
230
+ md += get_markdown_nvp(key, value, " ")
231
+ end
232
+ @commands.each do |cmd|
233
+ md = md + "\n" + cmd.to_markdown
234
+ end
235
+ md
236
+ end
237
+
238
+ def get_markdown_nvp(key, value, pad_char)
239
+ "\n| " + key.to_s.ljust(36, pad_char) + "| " + value.to_s.ljust(36, pad_char)
240
+ end
241
+
214
242
  def summary
215
243
  info if @verbose
216
-
217
244
  puts "[#{elapsed}] #{Rainbow(@name).yellow.bright} #{Rainbow(version).yellow.bright}"
218
245
  end
219
246
 
@@ -294,13 +321,13 @@ module Raykit
294
321
  if !cmd.exitstatus.nil? && cmd.exitstatus.zero?
295
322
  else
296
323
  # display error details
297
- puts cmd.output
298
- $stderr.puts cmd.error
324
+ cmd.details
299
325
  if quit_on_failure
300
326
  abort
301
327
  end
302
328
  end
303
329
  cmd.save
330
+ @commands << cmd
304
331
  cmd
305
332
  end
306
333
  end
data/lib/raykit.rb CHANGED
@@ -10,6 +10,7 @@ lib_dir = File.dirname(__FILE__)
10
10
  Dir.glob("#{lib_dir}/raykit/**/*.rb").sort.each { |file| require file }
11
11
 
12
12
  PROJECT = Raykit::Project.new
13
+
13
14
  SECRETS = Raykit::Secrets.new
14
15
 
15
16
  REPOSITORIES = Raykit::Git::Repositories.new("#{Raykit::Environment.get_dev_dir("log")}/Raykit.Git.Repositories.json")
@@ -38,6 +39,7 @@ if defined?(RAYKIT_GLOBALS)
38
39
 
39
40
  def show_value(name, value)
40
41
  Raykit::Log.show_value(name, value)
42
+ PROJECT.values[name] = value
41
43
  end
42
44
 
43
45
  def copy_files(src_dir, target_dir, glob)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raykit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.385
4
+ version: 0.0.388
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lou Parslow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,6 +107,7 @@ files:
107
107
  - lib/raykit/log.rb
108
108
  - lib/raykit/logevent.rb
109
109
  - lib/raykit/logging.rb
110
+ - lib/raykit/markdown.rb
110
111
  - lib/raykit/msbuild.rb
111
112
  - lib/raykit/nugetpackage.rb
112
113
  - lib/raykit/nunit.rb