raykit 0.0.471 → 0.0.472
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +20 -20
- data/bin/raykit +6 -6
- data/lib/raykit/command.rb +341 -343
- data/lib/raykit/conan/buildinfo.rb +69 -69
- data/lib/raykit/conanpackage.rb +49 -49
- data/lib/raykit/console.rb +272 -274
- data/lib/raykit/dir.rb +49 -49
- data/lib/raykit/dotnet.rb +115 -115
- data/lib/raykit/environment.rb +109 -109
- data/lib/raykit/filesystem.rb +34 -34
- data/lib/raykit/git/commit.rb +16 -16
- data/lib/raykit/git/directory.rb +216 -186
- data/lib/raykit/git/files.rb +46 -46
- data/lib/raykit/git/repositories.rb +89 -89
- data/lib/raykit/git/repository.rb +244 -244
- data/lib/raykit/installer.rb +17 -17
- data/lib/raykit/log.rb +80 -80
- data/lib/raykit/logevent.rb +49 -49
- data/lib/raykit/logging.rb +57 -59
- data/lib/raykit/markdown.rb +21 -23
- 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 +339 -340
- 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 +74 -74
- data/lib/raykit/sourceImports.rb +43 -43
- data/lib/raykit/string.rb +18 -18
- data/lib/raykit/tasks.rb +105 -99
- data/lib/raykit/text.rb +32 -32
- data/lib/raykit/timer.rb +31 -31
- data/lib/raykit/version.rb +103 -103
- data/lib/raykit/vstest.rb +24 -24
- data/lib/raykit/wt.rb +28 -28
- data/lib/raykit/zip.rb +73 -73
- data/lib/raykit.rb +117 -103
- metadata +2 -2
data/lib/raykit/dotnet.rb
CHANGED
@@ -1,115 +1,115 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class DotNet
|
5
|
-
def self.init_new(name, template)
|
6
|
-
if (!File.exist?("#{name}/#{name}.csproj"))
|
7
|
-
puts " #{name}.csproj not found, creating..."
|
8
|
-
run("dotnet new #{template} --name #{name} --output #{name} --language C# ")
|
9
|
-
else
|
10
|
-
puts " #{name}.csproj already exists"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# initialize a C# library
|
15
|
-
def self.initialize_csharp_lib(name)
|
16
|
-
puts `dotnet new sln --name #{name}` unless File.exist?("#{name}.sln")
|
17
|
-
unless Dir.exist?(name)
|
18
|
-
FileUtils.mkdir(name)
|
19
|
-
Dir.chdir(name) do
|
20
|
-
puts `dotnet new classlib -lang C#`
|
21
|
-
end
|
22
|
-
# puts `dotnet new sln`
|
23
|
-
puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
|
24
|
-
|
25
|
-
FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
|
26
|
-
Dir.chdir("#{name}.Test") do
|
27
|
-
puts `dotnet new nunit -lang C#`
|
28
|
-
puts `dotnet add reference ../#{name}/#{name}.csproj`
|
29
|
-
end
|
30
|
-
|
31
|
-
puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.csproj`
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# initialize an F# library
|
36
|
-
def self.initialize_fsharp_lib(name)
|
37
|
-
puts `dotnet new sln --name #{name}` unless File.exist?("#{name}.sln")
|
38
|
-
unless Dir.exist?(name)
|
39
|
-
FileUtils.mkdir(name)
|
40
|
-
Dir.chdir(name) do
|
41
|
-
puts `dotnet new classlib -lang F#`
|
42
|
-
end
|
43
|
-
# puts `dotnet new sln`
|
44
|
-
puts `dotnet sln #{name}.sln add #{name}/#{name}.fsproj`
|
45
|
-
|
46
|
-
FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
|
47
|
-
Dir.chdir("#{name}.Test") do
|
48
|
-
puts `dotnet new nunit -lang F#`
|
49
|
-
puts `dotnet add reference ../#{name}/#{name}.fsproj`
|
50
|
-
end
|
51
|
-
|
52
|
-
puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.fsproj`
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# initialize a C# console application
|
57
|
-
def self.initialize_csharp_console(name)
|
58
|
-
unless Dir.exist?(name)
|
59
|
-
FileUtils.mkdir(name)
|
60
|
-
Dir.chdir(name) do
|
61
|
-
puts `dotnet new console -lang C#`
|
62
|
-
end
|
63
|
-
puts `dotnet new sln`
|
64
|
-
puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
|
65
|
-
|
66
|
-
FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
|
67
|
-
Dir.chdir("#{name}.Test") do
|
68
|
-
puts `dotnet new nunit -lang C#`
|
69
|
-
puts `dotnet add reference ../#{name}/#{name}.csproj`
|
70
|
-
end
|
71
|
-
|
72
|
-
puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.csproj`
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
# initialize a C# wpf application
|
77
|
-
def self.initialize_csharp_wpf_application(name)
|
78
|
-
puts `dotnet new sln --name #{name}`
|
79
|
-
unless Dir.exist?(name)
|
80
|
-
FileUtils.mkdir(name)
|
81
|
-
Dir.chdir(name) do
|
82
|
-
puts `dotnet new wpf -lang C#`
|
83
|
-
end
|
84
|
-
end
|
85
|
-
puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
|
86
|
-
initialize_csharp_lib("#{name}.Library")
|
87
|
-
puts `dotnet sln #{name}.sln add #{name}.Library/#{name}.Library.csproj`
|
88
|
-
puts `dotnet sln #{name}.sln add #{name}.Library.Test/#{name}.Library.Test.csproj`
|
89
|
-
end
|
90
|
-
|
91
|
-
# initialize a C# worker service
|
92
|
-
def self.initialize_csharp_service(name)
|
93
|
-
unless Dir.exist?(name)
|
94
|
-
FileUtils.mkdir(name)
|
95
|
-
Dir.chdir(name) do
|
96
|
-
puts `dotnet new worker -lang C#`
|
97
|
-
end
|
98
|
-
puts `dotnet new sln`
|
99
|
-
puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def self.get_package_names(filename)
|
104
|
-
package_names = []
|
105
|
-
if File.exist?(filename) && filename.include?(".csproj")
|
106
|
-
regex = /<PackageReference Include="([\w.-]+)"/
|
107
|
-
text = IO.read(filename)
|
108
|
-
text.scan(regex).each do |m|
|
109
|
-
package_names << m.first.to_s
|
110
|
-
end
|
111
|
-
end
|
112
|
-
package_names
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class DotNet
|
5
|
+
def self.init_new(name, template)
|
6
|
+
if (!File.exist?("#{name}/#{name}.csproj"))
|
7
|
+
puts " #{name}.csproj not found, creating..."
|
8
|
+
run("dotnet new #{template} --name #{name} --output #{name} --language C# ")
|
9
|
+
else
|
10
|
+
puts " #{name}.csproj already exists"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# initialize a C# library
|
15
|
+
def self.initialize_csharp_lib(name)
|
16
|
+
puts `dotnet new sln --name #{name}` unless File.exist?("#{name}.sln")
|
17
|
+
unless Dir.exist?(name)
|
18
|
+
FileUtils.mkdir(name)
|
19
|
+
Dir.chdir(name) do
|
20
|
+
puts `dotnet new classlib -lang C#`
|
21
|
+
end
|
22
|
+
# puts `dotnet new sln`
|
23
|
+
puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
|
24
|
+
|
25
|
+
FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
|
26
|
+
Dir.chdir("#{name}.Test") do
|
27
|
+
puts `dotnet new nunit -lang C#`
|
28
|
+
puts `dotnet add reference ../#{name}/#{name}.csproj`
|
29
|
+
end
|
30
|
+
|
31
|
+
puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.csproj`
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# initialize an F# library
|
36
|
+
def self.initialize_fsharp_lib(name)
|
37
|
+
puts `dotnet new sln --name #{name}` unless File.exist?("#{name}.sln")
|
38
|
+
unless Dir.exist?(name)
|
39
|
+
FileUtils.mkdir(name)
|
40
|
+
Dir.chdir(name) do
|
41
|
+
puts `dotnet new classlib -lang F#`
|
42
|
+
end
|
43
|
+
# puts `dotnet new sln`
|
44
|
+
puts `dotnet sln #{name}.sln add #{name}/#{name}.fsproj`
|
45
|
+
|
46
|
+
FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
|
47
|
+
Dir.chdir("#{name}.Test") do
|
48
|
+
puts `dotnet new nunit -lang F#`
|
49
|
+
puts `dotnet add reference ../#{name}/#{name}.fsproj`
|
50
|
+
end
|
51
|
+
|
52
|
+
puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.fsproj`
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# initialize a C# console application
|
57
|
+
def self.initialize_csharp_console(name)
|
58
|
+
unless Dir.exist?(name)
|
59
|
+
FileUtils.mkdir(name)
|
60
|
+
Dir.chdir(name) do
|
61
|
+
puts `dotnet new console -lang C#`
|
62
|
+
end
|
63
|
+
puts `dotnet new sln`
|
64
|
+
puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
|
65
|
+
|
66
|
+
FileUtils.mkdir("#{name}.Test") unless Dir.exist?("#{name}.Test")
|
67
|
+
Dir.chdir("#{name}.Test") do
|
68
|
+
puts `dotnet new nunit -lang C#`
|
69
|
+
puts `dotnet add reference ../#{name}/#{name}.csproj`
|
70
|
+
end
|
71
|
+
|
72
|
+
puts `dotnet sln #{name}.sln add #{name}.Test/#{name}.Test.csproj`
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# initialize a C# wpf application
|
77
|
+
def self.initialize_csharp_wpf_application(name)
|
78
|
+
puts `dotnet new sln --name #{name}`
|
79
|
+
unless Dir.exist?(name)
|
80
|
+
FileUtils.mkdir(name)
|
81
|
+
Dir.chdir(name) do
|
82
|
+
puts `dotnet new wpf -lang C#`
|
83
|
+
end
|
84
|
+
end
|
85
|
+
puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
|
86
|
+
initialize_csharp_lib("#{name}.Library")
|
87
|
+
puts `dotnet sln #{name}.sln add #{name}.Library/#{name}.Library.csproj`
|
88
|
+
puts `dotnet sln #{name}.sln add #{name}.Library.Test/#{name}.Library.Test.csproj`
|
89
|
+
end
|
90
|
+
|
91
|
+
# initialize a C# worker service
|
92
|
+
def self.initialize_csharp_service(name)
|
93
|
+
unless Dir.exist?(name)
|
94
|
+
FileUtils.mkdir(name)
|
95
|
+
Dir.chdir(name) do
|
96
|
+
puts `dotnet new worker -lang C#`
|
97
|
+
end
|
98
|
+
puts `dotnet new sln`
|
99
|
+
puts `dotnet sln #{name}.sln add #{name}/#{name}.csproj`
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.get_package_names(filename)
|
104
|
+
package_names = []
|
105
|
+
if File.exist?(filename) && filename.include?(".csproj")
|
106
|
+
regex = /<PackageReference Include="([\w.-]+)"/
|
107
|
+
text = IO.read(filename)
|
108
|
+
text.scan(regex).each do |m|
|
109
|
+
package_names << m.first.to_s
|
110
|
+
end
|
111
|
+
end
|
112
|
+
package_names
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
data/lib/raykit/environment.rb
CHANGED
@@ -1,109 +1,109 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "pathname"
|
4
|
-
|
5
|
-
module Raykit
|
6
|
-
# Provides functionality related to the development environment
|
7
|
-
class Environment
|
8
|
-
# Normalize a directory or filename to use forward slashes
|
9
|
-
def self.normalize_path(name)
|
10
|
-
if (windows?)
|
11
|
-
normalize_windows(name)
|
12
|
-
else
|
13
|
-
normalize_unix(name)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.normalize_unix(name)
|
18
|
-
name.gsub('\\', "/")
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.normalize_windows(name)
|
22
|
-
name.gsub("/", '\\')
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.windows?
|
26
|
-
Gem.win_platform?
|
27
|
-
end
|
28
|
-
|
29
|
-
# The root directory for the development environment.
|
30
|
-
# May be set using the environment variable DEV_ROOT,
|
31
|
-
# otherwise defaults to the user home directory
|
32
|
-
def self.root_dir
|
33
|
-
if ENV["DEV_ROOT"].nil?
|
34
|
-
Environment.home_dir
|
35
|
-
else
|
36
|
-
root = ENV["DEV_ROOT"].gsub("\\", "/").chomp("/")
|
37
|
-
normalize_path(root)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# The user home directory
|
42
|
-
def self.home_dir
|
43
|
-
return normalize_path(ENV["USERPROFILE"]) if ENV.include?("USERPROFILE")
|
44
|
-
normalize_path(ENV["HOME"])
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.log_dir
|
48
|
-
get_dev_dir("log")
|
49
|
-
end
|
50
|
-
|
51
|
-
# Get, and create if it does not exist, a specific development directory
|
52
|
-
def self.get_dev_dir(name)
|
53
|
-
dir = Pathname.new("#{Environment.root_dir}/#{name}")
|
54
|
-
dir.mkpath
|
55
|
-
if (dir.to_s.include?("https:") || dir.to_s.include?("http:"))
|
56
|
-
normalize_path(dir.to_s.gsub("https://", ".").gsub("http://", ".").gsub("//", "/"))
|
57
|
-
else
|
58
|
-
normalize_path(dir.to_s)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.get_work_dir(url)
|
63
|
-
"#{Raykit::Environment.get_dev_dir("work")}/#{url.gsub(".git", "").gsub("://", ".")}"
|
64
|
-
end
|
65
|
-
|
66
|
-
# Get the size of a directory and its contents
|
67
|
-
def self.get_dir_size(dir)
|
68
|
-
Dir.glob(File.join(dir, "**", "*"))
|
69
|
-
.map { |f| File.size(f) }
|
70
|
-
.inject(:+)
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.machine
|
74
|
-
return ENV["COMPUTERNAME"] unless ENV["COMPUTERNAME"].nil?
|
75
|
-
|
76
|
-
machine = `hostname`
|
77
|
-
machine = machine.split(".")[0] if machine.include?(".")
|
78
|
-
machine.strip
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.user
|
82
|
-
ENV["USERNAME"]
|
83
|
-
end
|
84
|
-
|
85
|
-
def self.local_application_data
|
86
|
-
"#{ENV["USERPROFILE"]}/AppData/Local".gsub('\\', "/")
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.admin?
|
90
|
-
rights = `whoami /priv`
|
91
|
-
rights.include?("SeCreateGlobalPrivilege")
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.which(name)
|
95
|
-
return name if File.exist?(name)
|
96
|
-
|
97
|
-
["", ".exe", ".bat", ".cmd"].each do |ext|
|
98
|
-
aname = name + ext
|
99
|
-
return aname if File.exist?(aname)
|
100
|
-
|
101
|
-
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
102
|
-
apath = "#{path.gsub('\\', "/")}/#{aname}".gsub("//", "/")
|
103
|
-
return apath if File.exist?(apath)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
""
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
|
5
|
+
module Raykit
|
6
|
+
# Provides functionality related to the development environment
|
7
|
+
class Environment
|
8
|
+
# Normalize a directory or filename to use forward slashes
|
9
|
+
def self.normalize_path(name)
|
10
|
+
if (windows?)
|
11
|
+
normalize_windows(name)
|
12
|
+
else
|
13
|
+
normalize_unix(name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.normalize_unix(name)
|
18
|
+
name.gsub('\\', "/")
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.normalize_windows(name)
|
22
|
+
name.gsub("/", '\\')
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.windows?
|
26
|
+
Gem.win_platform?
|
27
|
+
end
|
28
|
+
|
29
|
+
# The root directory for the development environment.
|
30
|
+
# May be set using the environment variable DEV_ROOT,
|
31
|
+
# otherwise defaults to the user home directory
|
32
|
+
def self.root_dir
|
33
|
+
if ENV["DEV_ROOT"].nil?
|
34
|
+
Environment.home_dir
|
35
|
+
else
|
36
|
+
root = ENV["DEV_ROOT"].gsub("\\", "/").chomp("/")
|
37
|
+
normalize_path(root)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# The user home directory
|
42
|
+
def self.home_dir
|
43
|
+
return normalize_path(ENV["USERPROFILE"]) if ENV.include?("USERPROFILE")
|
44
|
+
normalize_path(ENV["HOME"])
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.log_dir
|
48
|
+
get_dev_dir("log")
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get, and create if it does not exist, a specific development directory
|
52
|
+
def self.get_dev_dir(name)
|
53
|
+
dir = Pathname.new("#{Environment.root_dir}/#{name}")
|
54
|
+
dir.mkpath
|
55
|
+
if (dir.to_s.include?("https:") || dir.to_s.include?("http:"))
|
56
|
+
normalize_path(dir.to_s.gsub("https://", ".").gsub("http://", ".").gsub("//", "/"))
|
57
|
+
else
|
58
|
+
normalize_path(dir.to_s)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.get_work_dir(url)
|
63
|
+
"#{Raykit::Environment.get_dev_dir("work")}/#{url.gsub(".git", "").gsub("://", ".")}"
|
64
|
+
end
|
65
|
+
|
66
|
+
# Get the size of a directory and its contents
|
67
|
+
def self.get_dir_size(dir)
|
68
|
+
Dir.glob(File.join(dir, "**", "*"))
|
69
|
+
.map { |f| File.size(f) }
|
70
|
+
.inject(:+)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.machine
|
74
|
+
return ENV["COMPUTERNAME"] unless ENV["COMPUTERNAME"].nil?
|
75
|
+
|
76
|
+
machine = `hostname`
|
77
|
+
machine = machine.split(".")[0] if machine.include?(".")
|
78
|
+
machine.strip
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.user
|
82
|
+
ENV["USERNAME"]
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.local_application_data
|
86
|
+
"#{ENV["USERPROFILE"]}/AppData/Local".gsub('\\', "/")
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.admin?
|
90
|
+
rights = `whoami /priv`
|
91
|
+
rights.include?("SeCreateGlobalPrivilege")
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.which(name)
|
95
|
+
return name if File.exist?(name)
|
96
|
+
|
97
|
+
["", ".exe", ".bat", ".cmd"].each do |ext|
|
98
|
+
aname = name + ext
|
99
|
+
return aname if File.exist?(aname)
|
100
|
+
|
101
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
102
|
+
apath = "#{path.gsub('\\', "/")}/#{aname}".gsub("//", "/")
|
103
|
+
return apath if File.exist?(apath)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
""
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/raykit/filesystem.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
module Raykit
|
2
|
-
class FileSystem
|
3
|
-
def self.copy_files(source_dir, target_dir, glob_pattern)
|
4
|
-
FileUtils.mkdir_p(target_dir) if !Dir.exist?(target_dir)
|
5
|
-
#Dir.chdir(source_dir) do
|
6
|
-
file_count = 0
|
7
|
-
Dir.glob("#{source_dir}/#{glob_pattern}").each { |f|
|
8
|
-
rel = f.gsub("#{source_dir}/", "")
|
9
|
-
dest = "#{target_dir}/#{rel}"
|
10
|
-
FileUtils.mkdir_p(File.dirname(dest)) if (!Dir.exist?(File.dirname(dest)))
|
11
|
-
#puts " copying #{rel} to #{dest}"
|
12
|
-
FileUtils.cp(f, dest)
|
13
|
-
file_count = file_count + 1
|
14
|
-
}
|
15
|
-
#end
|
16
|
-
puts " copied " + file_count.to_s + " file(s) from #{source_dir} to #{target_dir}"
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.copy_file_to_dir(file, dir)
|
20
|
-
dest = "#{dir}/#{File.basename(file)}"
|
21
|
-
if (File.exist?(dest))
|
22
|
-
return "#{dest} already exists"
|
23
|
-
else
|
24
|
-
FileUtils.cp(file, dest)
|
25
|
-
return "#{dest} now exists"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.replace_invalid_chars(str)
|
30
|
-
#[\\/:"*?<>|]
|
31
|
-
str.gsub('\\', "_").gsub("/", "_").gsub(":", "_").gsub("*", "_").gsub("?", "_")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
module Raykit
|
2
|
+
class FileSystem
|
3
|
+
def self.copy_files(source_dir, target_dir, glob_pattern)
|
4
|
+
FileUtils.mkdir_p(target_dir) if !Dir.exist?(target_dir)
|
5
|
+
#Dir.chdir(source_dir) do
|
6
|
+
file_count = 0
|
7
|
+
Dir.glob("#{source_dir}/#{glob_pattern}").each { |f|
|
8
|
+
rel = f.gsub("#{source_dir}/", "")
|
9
|
+
dest = "#{target_dir}/#{rel}"
|
10
|
+
FileUtils.mkdir_p(File.dirname(dest)) if (!Dir.exist?(File.dirname(dest)))
|
11
|
+
#puts " copying #{rel} to #{dest}"
|
12
|
+
FileUtils.cp(f, dest)
|
13
|
+
file_count = file_count + 1
|
14
|
+
}
|
15
|
+
#end
|
16
|
+
puts " copied " + file_count.to_s + " file(s) from #{source_dir} to #{target_dir}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.copy_file_to_dir(file, dir)
|
20
|
+
dest = "#{dir}/#{File.basename(file)}"
|
21
|
+
if (File.exist?(dest))
|
22
|
+
return "#{dest} already exists"
|
23
|
+
else
|
24
|
+
FileUtils.cp(file, dest)
|
25
|
+
return "#{dest} now exists"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.replace_invalid_chars(str)
|
30
|
+
#[\\/:"*?<>|]
|
31
|
+
str.gsub('\\', "_").gsub("/", "_").gsub(":", "_").gsub("*", "_").gsub("?", "_")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/raykit/git/commit.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
module Git
|
5
|
-
# Functionality to manage a git commit
|
6
|
-
class Commit
|
7
|
-
attr_accessor :url, :branch, :commit_id
|
8
|
-
|
9
|
-
def initialize(url, branch, commit_id)
|
10
|
-
@url = url
|
11
|
-
@branch = branch
|
12
|
-
@commit_id = commit_id
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
module Git
|
5
|
+
# Functionality to manage a git commit
|
6
|
+
class Commit
|
7
|
+
attr_accessor :url, :branch, :commit_id
|
8
|
+
|
9
|
+
def initialize(url, branch, commit_id)
|
10
|
+
@url = url
|
11
|
+
@branch = branch
|
12
|
+
@commit_id = commit_id
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|