raykit 0.0.319 → 0.0.320

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.
@@ -1,89 +1,89 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pathname'
3
+ require "pathname"
4
4
 
5
5
  module Raykit
6
6
  # Provides functionality related to the development environment
7
7
  class Environment
8
8
  # Normalize a directory or filename to use forward slashes
9
9
  def self.normalize_path(name)
10
- name.gsub('\\', '/')
10
+ name.gsub('\\', "/")
11
11
  end
12
12
 
13
13
  # The root directory for the development environment.
14
14
  # May be set using the environment variable DEV_ROOT,
15
15
  # otherwise defaults to the user home directory
16
16
  def self.root_dir
17
- if ENV['DEV_ROOT'].nil?
17
+ if ENV["DEV_ROOT"].nil?
18
18
  Environment.home_dir
19
19
  else
20
- normalize_path(ENV['DEV_ROOT'])
20
+ normalize_path(ENV["DEV_ROOT"])
21
21
  end
22
22
  end
23
23
 
24
24
  # The user home directory
25
25
  def self.home_dir
26
- return normalize_path(ENV['USERPROFILE']) if ENV.include?('USERPROFILE')
26
+ return normalize_path(ENV["USERPROFILE"]) if ENV.include?("USERPROFILE")
27
27
 
28
- normalize_path(ENV['HOME'])
28
+ normalize_path(ENV["HOME"])
29
29
  end
30
30
 
31
31
  def self.log_dir
32
- get_dev_dir('log')
32
+ get_dev_dir("log")
33
33
  end
34
34
 
35
35
  # Get, and create if it does not exist, a specific development directory
36
36
  def self.get_dev_dir(name)
37
37
  dir = Pathname.new("#{Environment.root_dir}/#{name}")
38
38
  dir.mkpath
39
- dir.to_s.gsub('//', '/')
39
+ dir.to_s.gsub("//", "/")
40
40
  end
41
41
 
42
42
  def self.get_work_dir(url)
43
- "#{Raykit::Environment.get_dev_dir('work')}/#{url.gsub('://', '/').gsub('.git', '')}"
43
+ "#{Raykit::Environment.get_dev_dir("work")}/#{url.gsub("://", "/").gsub(".git", "")}"
44
44
  end
45
45
 
46
46
  # Get the size of a directory and its contents
47
47
  def self.get_dir_size(dir)
48
- Dir.glob(File.join(dir, '**', '*'))
48
+ Dir.glob(File.join(dir, "**", "*"))
49
49
  .map { |f| File.size(f) }
50
50
  .inject(:+)
51
51
  end
52
52
 
53
53
  def self.machine
54
- return ENV['COMPUTERNAME'] unless ENV['COMPUTERNAME'].nil?
54
+ return ENV["COMPUTERNAME"] unless ENV["COMPUTERNAME"].nil?
55
55
 
56
56
  machine = `hostname`
57
- machine = machine.split('.')[0] if machine.include?('.')
57
+ machine = machine.split(".")[0] if machine.include?(".")
58
58
  machine.strip
59
59
  end
60
60
 
61
61
  def self.user
62
- ENV['USERNAME']
62
+ ENV["USERNAME"]
63
63
  end
64
64
 
65
65
  def self.local_application_data
66
- "#{ENV['USERPROFILE']}/AppData/Local".gsub('\\', '/')
66
+ "#{ENV["USERPROFILE"]}/AppData/Local".gsub('\\', "/")
67
67
  end
68
68
 
69
69
  def self.admin?
70
70
  rights = `whoami /priv`
71
- rights.include?('SeCreateGlobalPrivilege')
71
+ rights.include?("SeCreateGlobalPrivilege")
72
72
  end
73
73
 
74
74
  def self.which(name)
75
75
  return name if File.exist?(name)
76
76
 
77
- ['', '.exe', '.bat', '.cmd'].each do |ext|
77
+ ["", ".exe", ".bat", ".cmd"].each do |ext|
78
78
  aname = name + ext
79
79
  return aname if File.exist?(aname)
80
80
 
81
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
82
- apath = "#{path.gsub('\\', '/')}/#{aname}".gsub('//', '/')
81
+ ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
82
+ apath = "#{path.gsub('\\', "/")}/#{aname}".gsub("//", "/")
83
83
  return apath if File.exist?(apath)
84
84
  end
85
85
  end
86
- ''
86
+ ""
87
87
  end
88
88
  end
89
89
  end
@@ -16,7 +16,7 @@ module Raykit
16
16
  def outstanding_commit?
17
17
  Dir.chdir(directory) do
18
18
  if user_can_commit
19
- return !`git status`.include?('nothing to commit,')
19
+ return !`git status`.include?("nothing to commit,")
20
20
  else
21
21
  return false
22
22
  end
@@ -26,7 +26,7 @@ module Raykit
26
26
  def detached?
27
27
  Dir.chdir(directory) do
28
28
  status = `git status`.strip
29
- if status.include?('detached')
29
+ if status.include?("detached")
30
30
  true
31
31
  else
32
32
  false
@@ -38,43 +38,43 @@ module Raykit
38
38
  Dir.chdir(directory) do
39
39
  diff = `git diff`.strip
40
40
  status = `git status`.strip
41
- PROJECT.run('git pull', false) if diff.length.zero? && status.include?('nothing to commit')
41
+ PROJECT.run("git pull", false) if diff.length.zero? && status.include?("nothing to commit")
42
42
  end
43
43
  end
44
44
 
45
45
  def rake(task)
46
46
  unless Dir.exist?(@directory)
47
- puts 'directory not found.'
47
+ puts "directory not found."
48
48
  return 1
49
49
  end
50
50
  debug = false
51
- sub_dir = 'work'
52
- sub_dir = 'make' if @directory.include?('/make/')
53
- rake_log = repository.get_dev_dir('log') + "/#{sub_dir}.rake.#{task}.json"
51
+ sub_dir = "work"
52
+ sub_dir = "make" if @directory.include?("/make/")
53
+ rake_log = repository.get_dev_dir("log") + "/#{sub_dir}.rake.#{task}.json"
54
54
 
55
55
  puts "log filename #{rake_log}" if debug
56
56
  if File.exist?(rake_log) && (File.mtime(rake_log) > last_modified_time)
57
- puts 'using logged data' if debug
57
+ puts "using logged data" if debug
58
58
  cmd = Raykit::Command.parse(File.read(rake_log))
59
59
  cmd.summary
60
60
  return
61
61
  end
62
62
 
63
63
  Dir.chdir(@directory) do
64
- if File.exist?('rakefile.rb')
64
+ if File.exist?("rakefile.rb")
65
65
  cmd = Raykit::Command.new("rake #{task}")
66
66
  cmd.summary
67
67
  FileUtils.mkdir_p(File.dirname(rake_log))
68
- File.open(rake_log, 'w') { |f| f.write(JSON.generate(cmd.to_hash)) }
68
+ File.open(rake_log, "w") { |f| f.write(JSON.generate(cmd.to_hash)) }
69
69
  else
70
- puts 'rakefile.rb not found'
70
+ puts "rakefile.rb not found"
71
71
  end
72
72
  end
73
73
  end
74
74
 
75
75
  def last_modified_time
76
76
  Dir.chdir(@directory) do
77
- File.mtime(Dir.glob('**/*.*').select { |f| File.file?(f) }.max_by { |f| File.mtime(f) })
77
+ File.mtime(Dir.glob("**/*.*").select { |f| File.file?(f) }.max_by { |f| File.mtime(f) })
78
78
  end
79
79
  end
80
80
 
@@ -83,15 +83,15 @@ module Raykit
83
83
  Dir.chdir(directory) do
84
84
  return `git describe --abbrev=0`.strip
85
85
  end
86
- ''
86
+ ""
87
87
  end
88
88
 
89
89
  def get_tag_commit_id(name)
90
90
  cmd = Raykit::Command.new("git rev-parse \"#{name}\"", 0, nil, false)
91
- if !cmd.output.include?('fatal') && !cmd.error.include?('fatal')
91
+ if !cmd.output.include?("fatal") && !cmd.error.include?("fatal")
92
92
  cmd.output.strip
93
93
  else
94
- ''
94
+ ""
95
95
  end
96
96
  end
97
97
 
@@ -133,7 +133,7 @@ module Raykit
133
133
  scan = `git branch`.scan(/\*\s([\w.-]+)/)
134
134
  return scan[0][0].to_s if !scan.nil? && scan.length.positive? && scan[0].length.positive?
135
135
  end
136
- 'master'
136
+ "master"
137
137
  end
138
138
 
139
139
  def repository
@@ -144,10 +144,10 @@ module Raykit
144
144
  def remote
145
145
  if Dir.exist?(directory)
146
146
  Dir.chdir(directory) do
147
- return Command.new('git config --get remote.origin.url').output.strip if Dir.exist?('.git')
147
+ return Command.new("git config --get remote.origin.url").output.strip if Dir.exist?(".git")
148
148
  end
149
149
  end
150
- ''
150
+ ""
151
151
  end
152
152
  end
153
153
  end
@@ -6,6 +6,7 @@ module Raykit
6
6
  class Files
7
7
  @url
8
8
  @commit_id
9
+
9
10
  def initialize(url, commit_id)
10
11
  @url = url
11
12
  @commit_id = commit_id
@@ -18,7 +19,7 @@ module Raykit
18
19
  def get(name)
19
20
  puts "commit_path(): #{commit_path}"
20
21
  unless Dir.exist?(commit_path)
21
- puts 'cloning commit path...'
22
+ puts "cloning commit path..."
22
23
  clone = Raykit::Command.new("git clone #{@url} #{commit_path}")
23
24
  puts clone.output
24
25
  puts clone.error
@@ -29,12 +30,12 @@ module Raykit
29
30
 
30
31
  return filename(name) if File.exist?(filename(name))
31
32
 
32
- ''
33
+ ""
33
34
  end
34
35
 
35
36
  def commit_path
36
- Dir.tmpdir + File::SEPARATOR + 'Raykit.Git.Files' + File::SEPARATOR + @url.gsub('://',
37
- '.') + File::SEPARATOR + @commit_id
37
+ Dir.tmpdir + File::SEPARATOR + "Raykit.Git.Files" + File::SEPARATOR + @url.gsub("://",
38
+ ".") + File::SEPARATOR + @commit_id
38
39
  end
39
40
 
40
41
  def filename(name)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('./directory')
3
+ require_relative("./directory")
4
4
 
5
5
  module Raykit
6
6
  module Git
@@ -24,7 +24,7 @@ module Raykit
24
24
  end
25
25
 
26
26
  def save(_filename)
27
- File.open(@filename, 'w') do |f|
27
+ File.open(@filename, "w") do |f|
28
28
  # json = JSON.pretty_generate(self)
29
29
  f.write(JSON.pretty_generate(self))
30
30
  # f.write(self.to_json)
@@ -32,12 +32,12 @@ module Raykit
32
32
  end
33
33
 
34
34
  def work_dir
35
- Environment.get_dev_dir('work')
35
+ Environment.get_dev_dir("work")
36
36
  end
37
37
 
38
38
  def is_remote_url(pattern)
39
- return true if pattern.include?('http://')
40
- return true if pattern.include?('https://')
39
+ return true if pattern.include?("http://")
40
+ return true if pattern.include?("https://")
41
41
 
42
42
  false
43
43
  end
@@ -60,8 +60,8 @@ module Raykit
60
60
  else
61
61
  git_dirs = []
62
62
  Dir.chdir(work_dir) do
63
- Dir.glob('**/.git') do |git_dir|
64
- dir = File.expand_path('..', git_dir)
63
+ Dir.glob("**/.git") do |git_dir|
64
+ dir = File.expand_path("..", git_dir)
65
65
  git_dirs.insert(0, dir) if dir.length.positive?
66
66
  end
67
67
  end
@@ -10,22 +10,22 @@ module Raykit
10
10
 
11
11
  def initialize(url)
12
12
  @url = url
13
- @clone_directory = Raykit::Git::Directory.new(get_dev_dir('clone'))
14
- @work_directory = Raykit::Git::Directory.new(get_dev_dir('work'))
13
+ @clone_directory = Raykit::Git::Directory.new(get_dev_dir("clone"))
14
+ @work_directory = Raykit::Git::Directory.new(get_dev_dir("work"))
15
15
  end
16
16
 
17
17
  def to_json(*_args)
18
- JSON.generate({ 'url' => @url })
18
+ JSON.generate({ "url" => @url })
19
19
  end
20
20
 
21
21
  def self.parse(json)
22
22
  hash = JSON.parse(json)
23
- Repository.new(hash['url'])
23
+ Repository.new(hash["url"])
24
24
  end
25
25
 
26
26
  # The relative path is a valid local path name derived from the url
27
27
  def relative_path
28
- @url.gsub('https://', '').gsub('.git', '').gsub('http://', '')
28
+ @url.gsub("https://", "").gsub(".git", "").gsub("http://", "")
29
29
  end
30
30
 
31
31
  def get_dev_dir(dir)
@@ -49,7 +49,7 @@ module Raykit
49
49
  if Dir.exist?(local_clone_directory)
50
50
  Dir.chdir(local_clone_directory) do
51
51
  `git branch`.split('\n').each do |line|
52
- branch = line.gsub('*', '').strip
52
+ branch = line.gsub("*", "").strip
53
53
  results.insert(-1, branch) if branch.length.positive?
54
54
  end
55
55
  end
@@ -64,24 +64,24 @@ module Raykit
64
64
  scan = text.scan(/commit (\w+)\s/)
65
65
  return scan[0][0].to_s
66
66
  end
67
- ''
67
+ ""
68
68
  end
69
69
 
70
70
  # The latest tag for a branch of the repository
71
71
  def latest_tag(branch)
72
72
  return `git describe --abbrev=0`.strip if checkout_local_clone_directory_branch(branch)
73
73
 
74
- ''
74
+ ""
75
75
  end
76
76
 
77
77
  private def local_clone_directory
78
- clone_dir = "#{Environment.get_dev_dir('clone')}/#{relative_path}"
78
+ clone_dir = "#{Environment.get_dev_dir("clone")}/#{relative_path}"
79
79
  end
80
80
 
81
81
  private def update_local_clone_directory
82
82
  if Dir.exist?(local_clone_directory)
83
83
  Dir.chdir(local_clone_directory) do
84
- Raykit::Command.new('git pull')
84
+ Raykit::Command.new("git pull")
85
85
  # t = `git pull`
86
86
  end
87
87
  else
data/lib/raykit/log.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
3
+ require "json"
4
+
4
5
  module Raykit
5
6
  class Log < Hash
6
7
  @filename
8
+
7
9
  def initialize(filename)
8
10
  @filename = filename
9
11
  dir = File.dirname(@filename)
@@ -20,21 +22,21 @@ module Raykit
20
22
  end
21
23
 
22
24
  def save
23
- File.open(@filename, 'w') { |f| f.write(JSON.generate(self)) }
25
+ File.open(@filename, "w") { |f| f.write(JSON.generate(self)) }
24
26
  end
25
27
 
26
28
  def update_command_time(command, timestamp)
27
29
  command_times = {}
28
- command_times = self['command_times'] if key?('command_times')
30
+ command_times = self["command_times"] if key?("command_times")
29
31
  command_times.delete(command) if command_times.key?(command)
30
32
  command_times[command] = timestamp.iso8601
31
- self['command_times'] = command_times
33
+ self["command_times"] = command_times
32
34
  save
33
35
  end
34
36
 
35
37
  def get_command_time(command)
36
- if key?('command_times')
37
- command_times = self['command_times']
38
+ if key?("command_times")
39
+ command_times = self["command_times"]
38
40
  return DateTime.parse(command_times[command]) if command_times.key?(command)
39
41
  end
40
42
  nil
@@ -1,26 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
3
+ require "json"
4
+
4
5
  module Raykit
5
6
  # :verbose, :debug, :information, :error, :fatal
6
7
  class LogEvent < Hash
7
8
  def initialize(level, messageTemplate, properties)
8
- self['Timestamp'] = DateTime.now.iso8601
9
- self['Level'] = level
10
- self['Message'] = messageTemplate
11
- self['MessageTemplate'] = messageTemplate
12
- properties['MachineName'] = Raykit::Environment.machine unless properties.key?('MachineName')
13
- properties['UserName'] = Raykit::Environment.user unless properties.key?('UserName')
14
- properties['RakeDirectory'] = ::Rake.application.original_dir
15
- self['Properties'] = properties
9
+ self["Timestamp"] = DateTime.now.iso8601
10
+ self["Level"] = level
11
+ self["Message"] = messageTemplate
12
+ self["MessageTemplate"] = messageTemplate
13
+ properties["MachineName"] = Raykit::Environment.machine unless properties.key?("MachineName")
14
+ properties["UserName"] = Raykit::Environment.user unless properties.key?("UserName")
15
+ properties["RakeDirectory"] = ::Rake.application.original_dir
16
+ self["Properties"] = properties
16
17
  end
17
18
 
18
19
  def to_seq
19
20
  # puts '---to_seq---'
20
21
  # puts self['Message']
21
- unless ENV['SEQ_SERVER'].nil?
22
- cmd_str = "seqcli log -m \"#{self['Message'].gsub('"', '')}\" -l #{self['Level']} -s #{ENV['SEQ_SERVER']}"
23
- self['Properties'].each do |k, v|
22
+ unless ENV["SEQ_SERVER"].nil?
23
+ cmd_str = "seqcli log -m \"#{self["Message"].gsub('"', "")}\" -l #{self["Level"]} -s #{ENV["SEQ_SERVER"]}"
24
+ self["Properties"].each do |k, v|
24
25
  cmd_str += " -p \"#{k}=#{v}\""
25
26
  end
26
27
  # puts '---executing---'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
4
- require 'logger'
3
+ require "json"
4
+ require "logger"
5
5
 
6
6
  module Raykit
7
7
  class Logging
@@ -18,15 +18,15 @@ module Raykit
18
18
  end
19
19
 
20
20
  def set_severity_as_string(severity)
21
- @severity = Logger::Severity::DEBUG if severity == 'debug'
22
- @severity = Logger::Severity::INFO if severity == 'info'
23
- @severity = Logger::Severity::WARN if severity == 'warn'
24
- @severity = Logger::Severity::ERROR if severity == 'error'
21
+ @severity = Logger::Severity::DEBUG if severity == "debug"
22
+ @severity = Logger::Severity::INFO if severity == "info"
23
+ @severity = Logger::Severity::WARN if severity == "warn"
24
+ @severity = Logger::Severity::ERROR if severity == "error"
25
25
  end
26
26
 
27
27
  def get_logger(context)
28
28
  unless loggers.key?(context)
29
- Dir.chdir(Environment.get_dev_dir('log')) do
29
+ Dir.chdir(Environment.get_dev_dir("log")) do
30
30
  # start the log over whenever the log exceeds 100 megabytes in size
31
31
  loggers[context] = Logger.new("#{context}.log", 0, 100 * 1024 * 1024)
32
32
  end
@@ -2,15 +2,22 @@
2
2
 
3
3
  module Raykit
4
4
  class MsBuild
5
+ # C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin
5
6
  def self.msbuild_path
6
- ['2019/Enterprise/MSBuild/Current/Bin',
7
- '2019/Professional/MSBuild/Current/Bin',
8
- '2019/Community/MSBuild/Current/Bin',
9
- '2017/BuildTools/MSBuild/15.0/Bin'].each do |relative_path|
10
- path = "C:/Program Files (x86)/Microsoft Visual Studio/#{relative_path}"
11
- return path if Dir.exist?(path)
7
+ ["2022/Community/Msbuild/Current/Bin",
8
+ "2019/Enterprise/MSBuild/Current/Bin",
9
+ "2019/Professional/MSBuild/Current/Bin",
10
+ "2019/Community/MSBuild/Current/Bin",
11
+ "2017/BuildTools/MSBuild/15.0/Bin"].each do |relative_path|
12
+ ["C:/Program Files/Microsoft Visual Studio/",
13
+ "C:/Program Files (x86)/Microsoft Visual Studio/"].each do |prog_path|
14
+ path = "#{prog_path}#{relative_path}"
15
+ return path if Dir.exist?(path)
16
+ end
17
+ #path = "C:/Program Files (x86)/Microsoft Visual Studio/#{relative_path}"
18
+ #return path if Dir.exist?(path)
12
19
  end
13
- ''
20
+ ""
14
21
  end
15
22
  end
16
23
  end
@@ -68,11 +68,13 @@ module Raykit
68
68
  end
69
69
 
70
70
  def branch
71
+ return "main" if @git_directory.nil?
71
72
  @git_directory.branch
72
73
  end
73
74
 
74
75
  # latest local commit
75
76
  def latest_commit
77
+ return "" if detached?
76
78
  Dir.chdir(@directory) do
77
79
  text = `git log -n 1`
78
80
  scan = text.scan(/commit (\w+)\s/)
@@ -95,7 +97,7 @@ module Raykit
95
97
  end
96
98
 
97
99
  def detached?
98
- return true if @git_directory.nil?
100
+ return true if @git_directory.nil?
99
101
  @git_directory.detached?
100
102
  end
101
103
 
@@ -185,23 +187,20 @@ module Raykit
185
187
  puts 'PROJECT.name'.ljust(ljust) + Rainbow(PROJECT.name).yellow.bright
186
188
  puts 'PROJECT.version'.ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
187
189
  puts 'PROJECT.remote'.ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
190
+ puts 'PROJECT.branch'.ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright
188
191
  puts 'PROJECT.detached?'.ljust(ljust) + Rainbow(PROJECT.detached?).yellow.bright
189
- if !PROJECT.detached?
190
- puts 'PROJECT.branch'.ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright if !branch.nil?
191
-
192
- # puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
193
- # puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
194
- puts 'PROJECT.latest_tag'.ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
195
- puts 'PROJECT.latest_tag_commit'.ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
196
- puts 'PROJECT.latest_tag_md5'.ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
197
- puts 'PROJECT.latest_commit'.ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
198
- puts 'PROJECT.last_modified_filename'.ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
199
- # puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
200
- puts 'PROJECT.size'.ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
201
- puts 'PROJECT.size_pack'.ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
202
- puts 'PROJECT.outstanding_commit?'.ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
203
- puts 'PROJECT.outstanding_tag?'.ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
204
- end
192
+ # puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
193
+ # puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
194
+ puts 'PROJECT.latest_tag'.ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
195
+ puts 'PROJECT.latest_tag_commit'.ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
196
+ puts 'PROJECT.latest_tag_md5'.ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
197
+ puts 'PROJECT.latest_commit'.ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
198
+ puts 'PROJECT.last_modified_filename'.ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
199
+ # puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
200
+ puts 'PROJECT.size'.ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
201
+ puts 'PROJECT.size_pack'.ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
202
+ puts 'PROJECT.outstanding_commit?'.ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
203
+ puts 'PROJECT.outstanding_tag?'.ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
205
204
  puts ''
206
205
  self
207
206
  end
data/lib/raykit/rake.rb CHANGED
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'time'
3
+ require "time"
4
4
 
5
5
  module Raykit
6
6
  class Rake
7
- def self.run(remote, branch, task = 'default')
7
+ def self.run(remote, branch, task = "default")
8
8
  repo = Raykit::Git::Repository.new(remote)
9
9
  rel_dir = repo.relative_path
10
10
  commit = repo.latest_commit(branch)
11
- log_filename = "#{Environment.get_dev_dir('log')}/RayKit.Runner/#{rel_dir}/#{branch}/#{commit}.json"
11
+ log_filename = "#{Environment.get_dev_dir("log")}/RayKit.Runner/#{rel_dir}/#{branch}/#{commit}.json"
12
12
  if File.exist?(log_filename)
13
13
  Command.parse(File.read(log_filename))
14
14
  else
15
- run_dir = "#{Environment.get_dev_dir('tmp')}/#{rel_dir}.#{branch}.#{commit}"
15
+ run_dir = "#{Environment.get_dev_dir("tmp")}/#{rel_dir}.#{branch}.#{commit}"
16
16
  unless Dir.exist?(run_dir)
17
- parent_dir = File.expand_path('..', run_dir)
17
+ parent_dir = File.expand_path("..", run_dir)
18
18
  FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
19
19
  cmd = Command.new("git clone #{remote} #{run_dir}")
20
20
  end
@@ -22,7 +22,7 @@ module Raykit
22
22
  cmd = Command.new("rake #{task}")
23
23
  parent_dir = File.dirname(log_filename)
24
24
  FileUtils.mkdir_p(parent_dir) unless Dir.exist?(parent_dir)
25
- File.open(log_filename, 'w') do |f|
25
+ File.open(log_filename, "w") do |f|
26
26
  f.write(JSON.generate(cmd.to_hash))
27
27
  end
28
28
  return cmd
data/lib/raykit/runner.rb CHANGED
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'yaml'
3
+ require "yaml"
4
4
 
5
5
  module Raykit
6
6
  class Runner
7
7
  def self.run(git_url)
8
8
  commands = []
9
- local_dir = Dir.mktmpdir('runner')
9
+ local_dir = Dir.mktmpdir("runner")
10
10
  puts "local_dir : #{local_dir}"
11
11
  commands << Raykit::Command.new("git clone #{git_url} #{local_dir}")
12
12
  Dir.chdir(local_dir) do
13
- commands << Raykit::Command.new('git log -n 1')
13
+ commands << Raykit::Command.new("git log -n 1")
14
14
  yaml = get_build_yaml(local_dir)
15
15
  build_hash = YAML.safe_load(yaml)
16
16
  build_commands = Raykit::Command.parse_yaml_commands(yaml)
17
- if build_hash.key?('image')
18
- image = build_hash['image']
19
- build_commands.insert(0, 'cd home')
17
+ if build_hash.key?("image")
18
+ image = build_hash["image"]
19
+ build_commands.insert(0, "cd home")
20
20
  build_commands.insert(1, "git clone #{git_url} build")
21
- build_commands.insert(2, 'cd build')
22
- build_commands_string = build_commands.join(';')
21
+ build_commands.insert(2, "cd build")
22
+ build_commands_string = build_commands.join(";")
23
23
  commands << Raykit::Command.new("docker run #{image} sh -c \"#{build_commands_string}\"")
24
24
  else
25
25
  build_commands.each do |cmd_string|
@@ -32,9 +32,9 @@ module Raykit
32
32
  end
33
33
 
34
34
  def self.get_build_yaml(directory)
35
- yaml = ''
35
+ yaml = ""
36
36
  Dir.chdir(directory) do
37
- yaml = File.open('.gitlab-ci.yml').read if File.exist?('.gitlab-ci.yml')
37
+ yaml = File.open(".gitlab-ci.yml").read if File.exist?(".gitlab-ci.yml")
38
38
  end
39
39
  yaml
40
40
  end