raykit 0.0.524 → 0.0.525
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 +4 -4
- data/LICENSE +21 -21
- data/README.md +25 -25
- data/bin/raykit +6 -6
- data/lib/raykit/auto_setup.rb +69 -69
- data/lib/raykit/command.rb +374 -374
- data/lib/raykit/conan/buildinfo.rb +69 -69
- data/lib/raykit/conanpackage.rb +49 -49
- data/lib/raykit/configuration.rb +53 -53
- data/lib/raykit/console.rb +310 -310
- data/lib/raykit/default_content.rb +227 -227
- data/lib/raykit/dir.rb +96 -96
- data/lib/raykit/dotnet.rb +174 -174
- data/lib/raykit/environment.rb +115 -115
- data/lib/raykit/filesystem.rb +34 -34
- data/lib/raykit/git/commit.rb +16 -16
- data/lib/raykit/git/directory.rb +216 -216
- data/lib/raykit/git/files.rb +46 -46
- data/lib/raykit/git/repositories.rb +89 -89
- data/lib/raykit/git/repository.rb +362 -362
- data/lib/raykit/installer.rb +17 -17
- data/lib/raykit/log.rb +80 -80
- data/lib/raykit/logevent.rb +29 -29
- data/lib/raykit/logger.rb +100 -100
- data/lib/raykit/logging.rb +57 -57
- data/lib/raykit/markdown.rb +21 -21
- data/lib/raykit/msbuild.rb +54 -54
- data/lib/raykit/nugetpackage.rb +54 -54
- data/lib/raykit/nunit.rb +13 -13
- data/lib/raykit/project.rb +343 -343
- data/lib/raykit/rake.rb +39 -39
- data/lib/raykit/runner.rb +42 -42
- data/lib/raykit/secrets.rb +38 -38
- data/lib/raykit/sourceImport.rb +76 -76
- data/lib/raykit/sourceImports.rb +43 -43
- data/lib/raykit/string.rb +18 -18
- data/lib/raykit/symbols.rb +115 -115
- data/lib/raykit/tasks.rb +91 -91
- data/lib/raykit/text.rb +32 -32
- data/lib/raykit/timer.rb +31 -31
- data/lib/raykit/version.rb +95 -95
- data/lib/raykit/vstest.rb +24 -24
- data/lib/raykit/wix.rb +61 -61
- data/lib/raykit/wt.rb +28 -28
- data/lib/raykit/zip.rb +73 -73
- data/lib/raykit.rb +129 -129
- metadata +2 -2
data/lib/raykit/symbols.rb
CHANGED
@@ -1,115 +1,115 @@
|
|
1
|
-
# https://symbl.cc/en/unicode/table/
|
2
|
-
module Raykit
|
3
|
-
class Symbols
|
4
|
-
def self.checkmark
|
5
|
-
Rainbow("\u2713").green
|
6
|
-
end
|
7
|
-
def self.success
|
8
|
-
Rainbow("\u2713").green
|
9
|
-
end
|
10
|
-
def self.error
|
11
|
-
Rainbow("\u0058").red
|
12
|
-
end
|
13
|
-
def self.warning
|
14
|
-
Rainbow("\u26A0").yellow
|
15
|
-
end
|
16
|
-
def self.debug
|
17
|
-
Rainbow("\u24D8").blue # Circle with "i"
|
18
|
-
end
|
19
|
-
def self.info
|
20
|
-
Rainbow("\u2139").blue # Information source
|
21
|
-
end
|
22
|
-
def self.fatal
|
23
|
-
Rainbow("\u25A0").bright.red # Filled square, indicating stop/critical
|
24
|
-
end
|
25
|
-
def self.warn
|
26
|
-
Rainbow("\u26A0").yellow # Warning sign
|
27
|
-
end
|
28
|
-
def self.star
|
29
|
-
Rainbow("\u2605").yellow # Star
|
30
|
-
end
|
31
|
-
def self.coffee
|
32
|
-
Rainbow("\u2615").yellow # Hot beverage
|
33
|
-
end
|
34
|
-
def self.heart
|
35
|
-
Rainbow("\u2764").red # Heavy black heart
|
36
|
-
end
|
37
|
-
def self.bug
|
38
|
-
Rainbow("\u1F41E").yellow # Bug
|
39
|
-
end
|
40
|
-
def self.gear
|
41
|
-
Rainbow("\u2699").yellow # Gear
|
42
|
-
end
|
43
|
-
def self.magnifying_glass
|
44
|
-
Rainbow("\u1F50D").yellow # Left-pointing magnifying glass
|
45
|
-
end
|
46
|
-
def self.question
|
47
|
-
Rainbow("\u003F").yellow # Question mark
|
48
|
-
end
|
49
|
-
def self.arrow_right
|
50
|
-
Rainbow("\u27A4").yellow # Arrow pointing rightwards then curving upwards
|
51
|
-
end
|
52
|
-
def self.arrow_left
|
53
|
-
Rainbow("\u2B05").yellow # Left arrow
|
54
|
-
end
|
55
|
-
def self.arrow_up
|
56
|
-
Rainbow("\u2B06").yellow # Up arrow
|
57
|
-
end
|
58
|
-
def self.arrow_down
|
59
|
-
Rainbow("\u2B07").yellow # Down arrow
|
60
|
-
end
|
61
|
-
def self.arrow_up_down
|
62
|
-
Rainbow("\u2195").yellow # Up/down arrow
|
63
|
-
end
|
64
|
-
def self.arrow_left_right
|
65
|
-
Rainbow("\u2194").yellow # Left/right arrow
|
66
|
-
end
|
67
|
-
def self.arrow_upper_right
|
68
|
-
Rainbow("\u2197").yellow # North east arrow
|
69
|
-
end
|
70
|
-
def self.arrow_lower_right
|
71
|
-
Rainbow("\u2198").yellow # South east arrow
|
72
|
-
end
|
73
|
-
def self.arrow_lower_left
|
74
|
-
Rainbow("\u2199").yellow # South west arrow
|
75
|
-
end
|
76
|
-
def self.arrow_upper_left
|
77
|
-
Rainbow("\u2196").yellow # North west arrow
|
78
|
-
end
|
79
|
-
def self.arrow_up_small
|
80
|
-
Rainbow("\u2B06").yellow # Up arrow
|
81
|
-
end
|
82
|
-
def self.arrow_down_small
|
83
|
-
Rainbow("\u2B07").yellow # Down arrow
|
84
|
-
end
|
85
|
-
def self.arrow_right_small
|
86
|
-
Rainbow("\u27A1").yellow # Black rightwards arrow
|
87
|
-
end
|
88
|
-
def self.arrow_left_small
|
89
|
-
Rainbow("\u2B05").yellow # Left arrow
|
90
|
-
end
|
91
|
-
def self.arrow_up_down_small
|
92
|
-
Rainbow("\u2195").yellow # Up/down arrow
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.music
|
96
|
-
Rainbow("\u266B").yellow # Beamed eighth notes
|
97
|
-
end
|
98
|
-
def self.get_severity_symbol(severity)
|
99
|
-
case severity
|
100
|
-
when "DEBUG"
|
101
|
-
question
|
102
|
-
#when "INFO"
|
103
|
-
# info
|
104
|
-
when "WARN"
|
105
|
-
warning
|
106
|
-
when "ERROR"
|
107
|
-
error
|
108
|
-
when "FATAL"
|
109
|
-
fatal
|
110
|
-
else
|
111
|
-
" "
|
112
|
-
end
|
113
|
-
end # def get_severity_symbol
|
114
|
-
end # class Symbols
|
115
|
-
end # module Raykit
|
1
|
+
# https://symbl.cc/en/unicode/table/
|
2
|
+
module Raykit
|
3
|
+
class Symbols
|
4
|
+
def self.checkmark
|
5
|
+
Rainbow("\u2713").green
|
6
|
+
end
|
7
|
+
def self.success
|
8
|
+
Rainbow("\u2713").green
|
9
|
+
end
|
10
|
+
def self.error
|
11
|
+
Rainbow("\u0058").red
|
12
|
+
end
|
13
|
+
def self.warning
|
14
|
+
Rainbow("\u26A0").yellow
|
15
|
+
end
|
16
|
+
def self.debug
|
17
|
+
Rainbow("\u24D8").blue # Circle with "i"
|
18
|
+
end
|
19
|
+
def self.info
|
20
|
+
Rainbow("\u2139").blue # Information source
|
21
|
+
end
|
22
|
+
def self.fatal
|
23
|
+
Rainbow("\u25A0").bright.red # Filled square, indicating stop/critical
|
24
|
+
end
|
25
|
+
def self.warn
|
26
|
+
Rainbow("\u26A0").yellow # Warning sign
|
27
|
+
end
|
28
|
+
def self.star
|
29
|
+
Rainbow("\u2605").yellow # Star
|
30
|
+
end
|
31
|
+
def self.coffee
|
32
|
+
Rainbow("\u2615").yellow # Hot beverage
|
33
|
+
end
|
34
|
+
def self.heart
|
35
|
+
Rainbow("\u2764").red # Heavy black heart
|
36
|
+
end
|
37
|
+
def self.bug
|
38
|
+
Rainbow("\u1F41E").yellow # Bug
|
39
|
+
end
|
40
|
+
def self.gear
|
41
|
+
Rainbow("\u2699").yellow # Gear
|
42
|
+
end
|
43
|
+
def self.magnifying_glass
|
44
|
+
Rainbow("\u1F50D").yellow # Left-pointing magnifying glass
|
45
|
+
end
|
46
|
+
def self.question
|
47
|
+
Rainbow("\u003F").yellow # Question mark
|
48
|
+
end
|
49
|
+
def self.arrow_right
|
50
|
+
Rainbow("\u27A4").yellow # Arrow pointing rightwards then curving upwards
|
51
|
+
end
|
52
|
+
def self.arrow_left
|
53
|
+
Rainbow("\u2B05").yellow # Left arrow
|
54
|
+
end
|
55
|
+
def self.arrow_up
|
56
|
+
Rainbow("\u2B06").yellow # Up arrow
|
57
|
+
end
|
58
|
+
def self.arrow_down
|
59
|
+
Rainbow("\u2B07").yellow # Down arrow
|
60
|
+
end
|
61
|
+
def self.arrow_up_down
|
62
|
+
Rainbow("\u2195").yellow # Up/down arrow
|
63
|
+
end
|
64
|
+
def self.arrow_left_right
|
65
|
+
Rainbow("\u2194").yellow # Left/right arrow
|
66
|
+
end
|
67
|
+
def self.arrow_upper_right
|
68
|
+
Rainbow("\u2197").yellow # North east arrow
|
69
|
+
end
|
70
|
+
def self.arrow_lower_right
|
71
|
+
Rainbow("\u2198").yellow # South east arrow
|
72
|
+
end
|
73
|
+
def self.arrow_lower_left
|
74
|
+
Rainbow("\u2199").yellow # South west arrow
|
75
|
+
end
|
76
|
+
def self.arrow_upper_left
|
77
|
+
Rainbow("\u2196").yellow # North west arrow
|
78
|
+
end
|
79
|
+
def self.arrow_up_small
|
80
|
+
Rainbow("\u2B06").yellow # Up arrow
|
81
|
+
end
|
82
|
+
def self.arrow_down_small
|
83
|
+
Rainbow("\u2B07").yellow # Down arrow
|
84
|
+
end
|
85
|
+
def self.arrow_right_small
|
86
|
+
Rainbow("\u27A1").yellow # Black rightwards arrow
|
87
|
+
end
|
88
|
+
def self.arrow_left_small
|
89
|
+
Rainbow("\u2B05").yellow # Left arrow
|
90
|
+
end
|
91
|
+
def self.arrow_up_down_small
|
92
|
+
Rainbow("\u2195").yellow # Up/down arrow
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.music
|
96
|
+
Rainbow("\u266B").yellow # Beamed eighth notes
|
97
|
+
end
|
98
|
+
def self.get_severity_symbol(severity)
|
99
|
+
case severity
|
100
|
+
when "DEBUG"
|
101
|
+
question
|
102
|
+
#when "INFO"
|
103
|
+
# info
|
104
|
+
when "WARN"
|
105
|
+
warning
|
106
|
+
when "ERROR"
|
107
|
+
error
|
108
|
+
when "FATAL"
|
109
|
+
fatal
|
110
|
+
else
|
111
|
+
" "
|
112
|
+
end
|
113
|
+
end # def get_severity_symbol
|
114
|
+
end # class Symbols
|
115
|
+
end # module Raykit
|
data/lib/raykit/tasks.rb
CHANGED
@@ -1,91 +1,91 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
desc "Display project information"
|
4
|
-
task :info do
|
5
|
-
PROJECT.info
|
6
|
-
end
|
7
|
-
|
8
|
-
desc "integrate changes into the git repository"
|
9
|
-
task :integrate do
|
10
|
-
puts Rainbow(": integrate").blue.bright
|
11
|
-
|
12
|
-
if PROJECT.read_only?
|
13
|
-
puts " read only state, skipping integrate operations"
|
14
|
-
else
|
15
|
-
git_dir = Raykit::Git::Directory.new(Rake.application.original_dir)
|
16
|
-
if git_dir.detached?
|
17
|
-
puts " detached head state, skipping integrate operations"
|
18
|
-
else
|
19
|
-
if PROJECT.outstanding_commit?
|
20
|
-
Rake::Task["test"].invoke if Rake::Task.task_defined?("test")
|
21
|
-
else
|
22
|
-
puts " no outstanding commits detected"
|
23
|
-
end
|
24
|
-
|
25
|
-
if !File.exist?(".gitignore")
|
26
|
-
puts "warning: .gitignore does not exist."
|
27
|
-
else
|
28
|
-
PROJECT.run("git add --all")
|
29
|
-
unless `git status`.include?("nothing to commit")
|
30
|
-
commit_message = "integrate"
|
31
|
-
PROJECT.run("git commit -m\"#{commit_message}\"") if PROJECT.outstanding_commit?
|
32
|
-
end
|
33
|
-
PROJECT.run("git pull", false)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "push changes including tags"
|
40
|
-
task :push do
|
41
|
-
puts Rainbow(": push").blue.bright
|
42
|
-
git_dir = Raykit::Git::Directory.new(Rake.application.original_dir)
|
43
|
-
if git_dir.detached?
|
44
|
-
puts "detached head state, skipping push operations"
|
45
|
-
else
|
46
|
-
PROJECT.run("git push") if (!PROJECT.read_only?)
|
47
|
-
PROJECT.run("git push --tags") if (!PROJECT.read_only?)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "clean files not tracked by git"
|
52
|
-
task :clean do
|
53
|
-
puts Rainbow(": clean").blue.bright
|
54
|
-
PROJECT.run("git clean -dXf", false)
|
55
|
-
end
|
56
|
-
|
57
|
-
desc "tag the git repository at the current version"
|
58
|
-
task :tag do
|
59
|
-
puts Rainbow(": tag").blue.bright
|
60
|
-
if PROJECT.read_only?
|
61
|
-
puts " read only state, skipping tag operation"
|
62
|
-
else
|
63
|
-
if (GIT_DIRECTORY.has_tag "v#{PROJECT.version}")
|
64
|
-
puts " tag #{PROJECT.latest_tag} already exists."
|
65
|
-
else
|
66
|
-
GIT_DIRECTORY.tag_version PROJECT.version
|
67
|
-
try "git push --tags"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
desc "update_source from sourceImports.json"
|
73
|
-
task :update_source do
|
74
|
-
if File.exist?("sourceImports.json")
|
75
|
-
puts Rainbow(":update_source").blue.bright
|
76
|
-
sourceImports = Raykit::SourceImports.load("sourceImports.json")
|
77
|
-
json = sourceImports.to_json
|
78
|
-
sourceImports.update
|
79
|
-
|
80
|
-
json2 = sourceImports.to_json
|
81
|
-
if json2 != json || !sourceImports.targets_exist?
|
82
|
-
sourceImports.save("sourceImports.json")
|
83
|
-
sourceImports.copy
|
84
|
-
else
|
85
|
-
puts " no update required."
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
desc "update source files"
|
91
|
-
task update: [:update_source]
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
desc "Display project information"
|
4
|
+
task :info do
|
5
|
+
PROJECT.info
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "integrate changes into the git repository"
|
9
|
+
task :integrate do
|
10
|
+
puts Rainbow(": integrate").blue.bright
|
11
|
+
|
12
|
+
if PROJECT.read_only?
|
13
|
+
puts " read only state, skipping integrate operations"
|
14
|
+
else
|
15
|
+
git_dir = Raykit::Git::Directory.new(Rake.application.original_dir)
|
16
|
+
if git_dir.detached?
|
17
|
+
puts " detached head state, skipping integrate operations"
|
18
|
+
else
|
19
|
+
if PROJECT.outstanding_commit?
|
20
|
+
Rake::Task["test"].invoke if Rake::Task.task_defined?("test")
|
21
|
+
else
|
22
|
+
puts " no outstanding commits detected"
|
23
|
+
end
|
24
|
+
|
25
|
+
if !File.exist?(".gitignore")
|
26
|
+
puts "warning: .gitignore does not exist."
|
27
|
+
else
|
28
|
+
PROJECT.run("git add --all")
|
29
|
+
unless `git status`.include?("nothing to commit")
|
30
|
+
commit_message = "integrate"
|
31
|
+
PROJECT.run("git commit -m\"#{commit_message}\"") if PROJECT.outstanding_commit?
|
32
|
+
end
|
33
|
+
PROJECT.run("git pull", false)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "push changes including tags"
|
40
|
+
task :push do
|
41
|
+
puts Rainbow(": push").blue.bright
|
42
|
+
git_dir = Raykit::Git::Directory.new(Rake.application.original_dir)
|
43
|
+
if git_dir.detached?
|
44
|
+
puts "detached head state, skipping push operations"
|
45
|
+
else
|
46
|
+
PROJECT.run("git push") if (!PROJECT.read_only?)
|
47
|
+
PROJECT.run("git push --tags") if (!PROJECT.read_only?)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "clean files not tracked by git"
|
52
|
+
task :clean do
|
53
|
+
puts Rainbow(": clean").blue.bright
|
54
|
+
PROJECT.run("git clean -dXf", false)
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "tag the git repository at the current version"
|
58
|
+
task :tag do
|
59
|
+
puts Rainbow(": tag").blue.bright
|
60
|
+
if PROJECT.read_only?
|
61
|
+
puts " read only state, skipping tag operation"
|
62
|
+
else
|
63
|
+
if (GIT_DIRECTORY.has_tag "v#{PROJECT.version}")
|
64
|
+
puts " tag #{PROJECT.latest_tag} already exists."
|
65
|
+
else
|
66
|
+
GIT_DIRECTORY.tag_version PROJECT.version
|
67
|
+
try "git push --tags"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "update_source from sourceImports.json"
|
73
|
+
task :update_source do
|
74
|
+
if File.exist?("sourceImports.json")
|
75
|
+
puts Rainbow(":update_source").blue.bright
|
76
|
+
sourceImports = Raykit::SourceImports.load("sourceImports.json")
|
77
|
+
json = sourceImports.to_json
|
78
|
+
sourceImports.update
|
79
|
+
|
80
|
+
json2 = sourceImports.to_json
|
81
|
+
if json2 != json || !sourceImports.targets_exist?
|
82
|
+
sourceImports.save("sourceImports.json")
|
83
|
+
sourceImports.copy
|
84
|
+
else
|
85
|
+
puts " no update required."
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "update source files"
|
91
|
+
task update: [:update_source]
|
data/lib/raykit/text.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class Text
|
5
|
-
def self.replace_in_glob(glob, search, replace)
|
6
|
-
Dir.glob(glob).each { |f| replace_in_file(f, search, replace) }
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.replace_in_file(filename, search, replace)
|
10
|
-
text1 = IO.read(filename)
|
11
|
-
text2 = text1.gsub(search) { |_str| str = replace }
|
12
|
-
unless text1 == text2
|
13
|
-
File.open(filename, "w") { |f| f.puts text2 }
|
14
|
-
return true
|
15
|
-
end
|
16
|
-
false
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.copy_if_different(source, destination)
|
20
|
-
if !File.exist?(destination)
|
21
|
-
FileUtils.cp source, destination
|
22
|
-
else
|
23
|
-
source_text = IO.read(source)
|
24
|
-
destination_text = IO.read(destination)
|
25
|
-
if source_text != destination_text
|
26
|
-
FileUtils.rm destination
|
27
|
-
FileUtils.cp source, destination
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class Text
|
5
|
+
def self.replace_in_glob(glob, search, replace)
|
6
|
+
Dir.glob(glob).each { |f| replace_in_file(f, search, replace) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.replace_in_file(filename, search, replace)
|
10
|
+
text1 = IO.read(filename)
|
11
|
+
text2 = text1.gsub(search) { |_str| str = replace }
|
12
|
+
unless text1 == text2
|
13
|
+
File.open(filename, "w") { |f| f.puts text2 }
|
14
|
+
return true
|
15
|
+
end
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.copy_if_different(source, destination)
|
20
|
+
if !File.exist?(destination)
|
21
|
+
FileUtils.cp source, destination
|
22
|
+
else
|
23
|
+
source_text = IO.read(source)
|
24
|
+
destination_text = IO.read(destination)
|
25
|
+
if source_text != destination_text
|
26
|
+
FileUtils.rm destination
|
27
|
+
FileUtils.cp source, destination
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/raykit/timer.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "time"
|
4
|
-
|
5
|
-
module Raykit
|
6
|
-
# Provides functionality to record the time execution times
|
7
|
-
class Timer
|
8
|
-
# The time at which start occurred
|
9
|
-
attr_accessor :start_time
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@start_time = Time.now
|
13
|
-
end
|
14
|
-
|
15
|
-
# The elapsed time, in seconds, since the timer started
|
16
|
-
def elapsed
|
17
|
-
Time.now - @start_time
|
18
|
-
end
|
19
|
-
|
20
|
-
# The elapsed time, in seconds, as a formatted string
|
21
|
-
def elapsed_str(pad = 0)
|
22
|
-
Timer.get_elapsed_str(elapsed, pad)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Converts a time span in seconds to a formatted string
|
26
|
-
def self.get_elapsed_str(elapsed, pad = 0)
|
27
|
-
# "[" + "%.0f" % (elapsed) + "s]".ljust(pad)
|
28
|
-
format("%.0f", elapsed) + "s".ljust(pad)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
module Raykit
|
6
|
+
# Provides functionality to record the time execution times
|
7
|
+
class Timer
|
8
|
+
# The time at which start occurred
|
9
|
+
attr_accessor :start_time
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@start_time = Time.now
|
13
|
+
end
|
14
|
+
|
15
|
+
# The elapsed time, in seconds, since the timer started
|
16
|
+
def elapsed
|
17
|
+
Time.now - @start_time
|
18
|
+
end
|
19
|
+
|
20
|
+
# The elapsed time, in seconds, as a formatted string
|
21
|
+
def elapsed_str(pad = 0)
|
22
|
+
Timer.get_elapsed_str(elapsed, pad)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Converts a time span in seconds to a formatted string
|
26
|
+
def self.get_elapsed_str(elapsed, pad = 0)
|
27
|
+
# "[" + "%.0f" % (elapsed) + "s]".ljust(pad)
|
28
|
+
format("%.0f", elapsed) + "s".ljust(pad)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|