raykit 0.0.540 → 0.0.542
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 +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 +8 -8
- data/lib/raykit/default_content.txt +219 -219
- data/lib/raykit/dir.rb +127 -127
- 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 +280 -273
- 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 +140 -140
- metadata +2 -2
data/lib/raykit/version.rb
CHANGED
@@ -1,95 +1,95 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# warn "[DEPRECATION] Raykit::VersionHelper is deprecated. Use bump gem for better transparency."
|
4
|
-
|
5
|
-
module Raykit
|
6
|
-
# Version functionality
|
7
|
-
class Version
|
8
|
-
attr_accessor :start_time
|
9
|
-
|
10
|
-
# detect a version number based on the NAME variable, if defined
|
11
|
-
def self.detect(name)
|
12
|
-
version = detect_from_file("#{name}/#{name}.csproj", /<Version>([-\w\d.]+)</)
|
13
|
-
return version if version.length.positive?
|
14
|
-
|
15
|
-
version = detect_from_file("#{name}/Properties/AssemblyInfo.cs", /^\[assembly: AssemblyVersion\("([.\w]+)/)
|
16
|
-
return version if version.length.positive?
|
17
|
-
|
18
|
-
version = detect_from_file("Cargo.toml", /version\s+=\s+['"]([\w.]+)['"]/)
|
19
|
-
return version if version.length.positive?
|
20
|
-
|
21
|
-
version = detect_from_file("#{name}.gemspec", /version\s+=\s+['"]([\w.]+)['"]/)
|
22
|
-
return version if version.length.positive?
|
23
|
-
|
24
|
-
version = detect_from_file("#{name}.gemspec", /version\s?=\s?['|"]([.\d]+)['|"]/)
|
25
|
-
return version if version.length.positive?
|
26
|
-
|
27
|
-
version = detect_from_file("#{name}.nuspec", /<[Vv]ersion>([\d.]+)</)
|
28
|
-
return version if version.length.positive?
|
29
|
-
""
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.detect_from_file(filename, regex)
|
33
|
-
version = ""
|
34
|
-
if File.exist?(filename)
|
35
|
-
match = IO.read(filename).match(regex)
|
36
|
-
version = match.captures[0] if !match.nil? && match.captures.length.positive?
|
37
|
-
else
|
38
|
-
return ""
|
39
|
-
end
|
40
|
-
version
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.set_version_in_glob(glob_pattern, version)
|
44
|
-
Dir.glob(glob_pattern).each { |f|
|
45
|
-
Raykit::Version::set_version_in_file(f, version)
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.set_version_in_file(filename, version)
|
50
|
-
text = IO.read(filename)
|
51
|
-
new_text = text
|
52
|
-
new_text = text.gsub(/version\s?=\s?['|"]([.\d]+)['|"]/, "version='#{version}'") if filename.include?(".gemspec")
|
53
|
-
new_text = text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<") if filename.include?(".csproj")
|
54
|
-
new_text = text.gsub(/<version>([-\w\d.]+)</, "<version>#{version}<") if filename.include?(".nuspec")
|
55
|
-
new_text = text.gsub(/ Version="([\d\.]+)"/, " Version=\"#{version}\"") if filename.include?(".wxs")
|
56
|
-
|
57
|
-
new_text = text.gsub(/version\s+=\s+['"]([\w.]+)['"]/, "version=\"#{version}\"") if filename.include?(".toml")
|
58
|
-
|
59
|
-
# new_text=text.gsub(/<Version>([-\w\d.]+)</,"<Version>#{version}<")
|
60
|
-
# new_text=new_text.gsub(/version[\s]+=\s?['|"]([.\d]+)['|"]/,"version='#{version}'")
|
61
|
-
# new_text=new_text.gsub(/Version="([.\d]+)"/,"Version=\"#{version}\"")
|
62
|
-
File.open(filename, "w") { |f| f.write(new_text) } if new_text != text
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.sync_file_versions(source_filename, destination_filename)
|
66
|
-
version = Version.detect_from_file(source_filename, /<Version>([-\w\d.]+)</, false)
|
67
|
-
Version.set_version_in_file(destination_filename, version)
|
68
|
-
end
|
69
|
-
|
70
|
-
# increment to last digit of a version string
|
71
|
-
def self.bump(version)
|
72
|
-
# major.minor[.build[.revision]] (example: 1.2.12.102)
|
73
|
-
version_ints = version.split(".").map(&:to_i)
|
74
|
-
version_ints[-1] = version_ints.last + 1
|
75
|
-
version_ints.map(&:to_s).join(".")
|
76
|
-
end
|
77
|
-
|
78
|
-
def self.bump_file(filename)
|
79
|
-
warn "Raykit::Version.bump_file filename '#{filename}' does not exist." unless File.exist?(filename)
|
80
|
-
|
81
|
-
old_version = ""
|
82
|
-
if filename.include?(".gemspec")
|
83
|
-
old_version = detect_from_file(filename, /version\s?=\s?['|"]([.\d]+)['|"]/)
|
84
|
-
end
|
85
|
-
old_version = detect_from_file(filename, /<Version>([-\w\d.]+)</) if filename.include?(".csproj")
|
86
|
-
|
87
|
-
if old_version.length.positive?
|
88
|
-
new_version = bump(old_version)
|
89
|
-
set_version_in_file(filename, new_version)
|
90
|
-
end
|
91
|
-
|
92
|
-
new_version
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# warn "[DEPRECATION] Raykit::VersionHelper is deprecated. Use bump gem for better transparency."
|
4
|
+
|
5
|
+
module Raykit
|
6
|
+
# Version functionality
|
7
|
+
class Version
|
8
|
+
attr_accessor :start_time
|
9
|
+
|
10
|
+
# detect a version number based on the NAME variable, if defined
|
11
|
+
def self.detect(name)
|
12
|
+
version = detect_from_file("#{name}/#{name}.csproj", /<Version>([-\w\d.]+)</)
|
13
|
+
return version if version.length.positive?
|
14
|
+
|
15
|
+
version = detect_from_file("#{name}/Properties/AssemblyInfo.cs", /^\[assembly: AssemblyVersion\("([.\w]+)/)
|
16
|
+
return version if version.length.positive?
|
17
|
+
|
18
|
+
version = detect_from_file("Cargo.toml", /version\s+=\s+['"]([\w.]+)['"]/)
|
19
|
+
return version if version.length.positive?
|
20
|
+
|
21
|
+
version = detect_from_file("#{name}.gemspec", /version\s+=\s+['"]([\w.]+)['"]/)
|
22
|
+
return version if version.length.positive?
|
23
|
+
|
24
|
+
version = detect_from_file("#{name}.gemspec", /version\s?=\s?['|"]([.\d]+)['|"]/)
|
25
|
+
return version if version.length.positive?
|
26
|
+
|
27
|
+
version = detect_from_file("#{name}.nuspec", /<[Vv]ersion>([\d.]+)</)
|
28
|
+
return version if version.length.positive?
|
29
|
+
""
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.detect_from_file(filename, regex)
|
33
|
+
version = ""
|
34
|
+
if File.exist?(filename)
|
35
|
+
match = IO.read(filename).match(regex)
|
36
|
+
version = match.captures[0] if !match.nil? && match.captures.length.positive?
|
37
|
+
else
|
38
|
+
return ""
|
39
|
+
end
|
40
|
+
version
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.set_version_in_glob(glob_pattern, version)
|
44
|
+
Dir.glob(glob_pattern).each { |f|
|
45
|
+
Raykit::Version::set_version_in_file(f, version)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.set_version_in_file(filename, version)
|
50
|
+
text = IO.read(filename)
|
51
|
+
new_text = text
|
52
|
+
new_text = text.gsub(/version\s?=\s?['|"]([.\d]+)['|"]/, "version='#{version}'") if filename.include?(".gemspec")
|
53
|
+
new_text = text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<") if filename.include?(".csproj")
|
54
|
+
new_text = text.gsub(/<version>([-\w\d.]+)</, "<version>#{version}<") if filename.include?(".nuspec")
|
55
|
+
new_text = text.gsub(/ Version="([\d\.]+)"/, " Version=\"#{version}\"") if filename.include?(".wxs")
|
56
|
+
|
57
|
+
new_text = text.gsub(/version\s+=\s+['"]([\w.]+)['"]/, "version=\"#{version}\"") if filename.include?(".toml")
|
58
|
+
|
59
|
+
# new_text=text.gsub(/<Version>([-\w\d.]+)</,"<Version>#{version}<")
|
60
|
+
# new_text=new_text.gsub(/version[\s]+=\s?['|"]([.\d]+)['|"]/,"version='#{version}'")
|
61
|
+
# new_text=new_text.gsub(/Version="([.\d]+)"/,"Version=\"#{version}\"")
|
62
|
+
File.open(filename, "w") { |f| f.write(new_text) } if new_text != text
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.sync_file_versions(source_filename, destination_filename)
|
66
|
+
version = Version.detect_from_file(source_filename, /<Version>([-\w\d.]+)</, false)
|
67
|
+
Version.set_version_in_file(destination_filename, version)
|
68
|
+
end
|
69
|
+
|
70
|
+
# increment to last digit of a version string
|
71
|
+
def self.bump(version)
|
72
|
+
# major.minor[.build[.revision]] (example: 1.2.12.102)
|
73
|
+
version_ints = version.split(".").map(&:to_i)
|
74
|
+
version_ints[-1] = version_ints.last + 1
|
75
|
+
version_ints.map(&:to_s).join(".")
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.bump_file(filename)
|
79
|
+
warn "Raykit::Version.bump_file filename '#{filename}' does not exist." unless File.exist?(filename)
|
80
|
+
|
81
|
+
old_version = ""
|
82
|
+
if filename.include?(".gemspec")
|
83
|
+
old_version = detect_from_file(filename, /version\s?=\s?['|"]([.\d]+)['|"]/)
|
84
|
+
end
|
85
|
+
old_version = detect_from_file(filename, /<Version>([-\w\d.]+)</) if filename.include?(".csproj")
|
86
|
+
|
87
|
+
if old_version.length.positive?
|
88
|
+
new_version = bump(old_version)
|
89
|
+
set_version_in_file(filename, new_version)
|
90
|
+
end
|
91
|
+
|
92
|
+
new_version
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/lib/raykit/vstest.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class VsTest
|
5
|
-
def self.vstest_path
|
6
|
-
["2022/Community/Common7/IDE/CommonExtensions/Microsoft/TestWindow",
|
7
|
-
"2022/Professional/Common7/IDE/CommonExtensions/Microsoft/TestWindow",
|
8
|
-
"2022/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TestWindow",
|
9
|
-
"2019/Community/Common7/IDE/CommonExtensions/Microsoft",
|
10
|
-
"2019/Professional/Common7/IDE/Extensions/TestPlatform",
|
11
|
-
"2019/Community/Common7/IDE/Extensions",
|
12
|
-
"2019/Community/Common7/IDE/Extensions/TestPlatform",
|
13
|
-
"2022/Preview/Common7/IDE/Extensions/TestPlatform"].each do |relative_path|
|
14
|
-
["C:/Program Files (x86)/Microsoft Visual Studio/",
|
15
|
-
"C:/Program Files/Microsoft Visual Studio/"].each do |root_path|
|
16
|
-
path = root_path + relative_path
|
17
|
-
exe_path = "#{path}/vstest.console.exe"
|
18
|
-
return path if Dir.exist?(path) && File.exist?(exe_path)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
"vstest_path not found"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class VsTest
|
5
|
+
def self.vstest_path
|
6
|
+
["2022/Community/Common7/IDE/CommonExtensions/Microsoft/TestWindow",
|
7
|
+
"2022/Professional/Common7/IDE/CommonExtensions/Microsoft/TestWindow",
|
8
|
+
"2022/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TestWindow",
|
9
|
+
"2019/Community/Common7/IDE/CommonExtensions/Microsoft",
|
10
|
+
"2019/Professional/Common7/IDE/Extensions/TestPlatform",
|
11
|
+
"2019/Community/Common7/IDE/Extensions",
|
12
|
+
"2019/Community/Common7/IDE/Extensions/TestPlatform",
|
13
|
+
"2022/Preview/Common7/IDE/Extensions/TestPlatform"].each do |relative_path|
|
14
|
+
["C:/Program Files (x86)/Microsoft Visual Studio/",
|
15
|
+
"C:/Program Files/Microsoft Visual Studio/"].each do |root_path|
|
16
|
+
path = root_path + relative_path
|
17
|
+
exe_path = "#{path}/vstest.console.exe"
|
18
|
+
return path if Dir.exist?(path) && File.exist?(exe_path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
"vstest_path not found"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/raykit/wix.rb
CHANGED
@@ -1,61 +1,61 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class Wix
|
5
|
-
def self.harvest_directory_elements(directory)
|
6
|
-
get_nested_directory_element("", directory)
|
7
|
-
end
|
8
|
-
def self.get_nested_directory_element(id_prefix, directory)
|
9
|
-
Dir.chdir(directory) do
|
10
|
-
results = Array::new
|
11
|
-
Dir.glob("*").reject { |f| !File.directory? f }.each { |d|
|
12
|
-
directoryId = "#{d.upcase.gsub("/", "_").gsub("-", "_")}DIR"
|
13
|
-
directoryId = "#{id_prefix}#{directoryId}"
|
14
|
-
child_elements = get_nested_directory_element("#{directoryId[0...-3]}_", d)
|
15
|
-
if (child_elements.length > 0)
|
16
|
-
results.push("<Directory Id=\"#{directoryId}\" Name=\"#{d}\">")
|
17
|
-
child_elements.each { |child_element|
|
18
|
-
results.push("\t#{child_element}")
|
19
|
-
}
|
20
|
-
results.push("</Directory>")
|
21
|
-
else
|
22
|
-
results.push("<Directory Id=\"#{directoryId}\" Name=\"#{d}\"/>")
|
23
|
-
end
|
24
|
-
}
|
25
|
-
results
|
26
|
-
end
|
27
|
-
end
|
28
|
-
# given a directory, return an array of string the represent wix components for each file in the directory
|
29
|
-
# each string should look like this:
|
30
|
-
# <Component Id="IndexHtmlComponent" Directory="WWWDIR" Guid="*">
|
31
|
-
# <File Id="IndexHtmlFile" Source="path\to\index.html" KeyPath="yes"/>
|
32
|
-
# </Component>
|
33
|
-
def self.harvest_file_components(directory)
|
34
|
-
components = Array::new
|
35
|
-
Dir.chdir(directory) do
|
36
|
-
index = 0
|
37
|
-
Dir.glob("**/*").reject { |f| File.directory? f }.each { |f|
|
38
|
-
index += 1
|
39
|
-
component = get_indexed_file_component(f, index)
|
40
|
-
components.push(component)
|
41
|
-
}
|
42
|
-
components
|
43
|
-
end
|
44
|
-
end
|
45
|
-
# given a file and an index, return a string that represents a wix component
|
46
|
-
def self.get_indexed_file_component(file, index)
|
47
|
-
componentId = "c#{index}"
|
48
|
-
guid = SecureRandom.uuid
|
49
|
-
fileId = "f#{index}"
|
50
|
-
directory = File.dirname(file)
|
51
|
-
directory = directory.split(/[\/\\]/).last if File.dirname(file).include?("\\") || File.dirname(file).include?("/")
|
52
|
-
directory = "" if directory == "."
|
53
|
-
directoryId = "#{File.dirname(file).upcase.gsub("/", "_").gsub("-", "_")}DIR"
|
54
|
-
component = "<Component Id=\"#{componentId}\" Guid=\"#{guid}\"><File Id=\"#{fileId}\" Source=\"#{file}\" /></Component>"
|
55
|
-
if (directory.length > 0)
|
56
|
-
component = "<Component Id=\"#{componentId}\" Guid=\"#{guid}\" Directory=\"#{directoryId}\"><File Id=\"#{fileId}\" Source=\"#{file}\" /></Component>"
|
57
|
-
end
|
58
|
-
component
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class Wix
|
5
|
+
def self.harvest_directory_elements(directory)
|
6
|
+
get_nested_directory_element("", directory)
|
7
|
+
end
|
8
|
+
def self.get_nested_directory_element(id_prefix, directory)
|
9
|
+
Dir.chdir(directory) do
|
10
|
+
results = Array::new
|
11
|
+
Dir.glob("*").reject { |f| !File.directory? f }.each { |d|
|
12
|
+
directoryId = "#{d.upcase.gsub("/", "_").gsub("-", "_")}DIR"
|
13
|
+
directoryId = "#{id_prefix}#{directoryId}"
|
14
|
+
child_elements = get_nested_directory_element("#{directoryId[0...-3]}_", d)
|
15
|
+
if (child_elements.length > 0)
|
16
|
+
results.push("<Directory Id=\"#{directoryId}\" Name=\"#{d}\">")
|
17
|
+
child_elements.each { |child_element|
|
18
|
+
results.push("\t#{child_element}")
|
19
|
+
}
|
20
|
+
results.push("</Directory>")
|
21
|
+
else
|
22
|
+
results.push("<Directory Id=\"#{directoryId}\" Name=\"#{d}\"/>")
|
23
|
+
end
|
24
|
+
}
|
25
|
+
results
|
26
|
+
end
|
27
|
+
end
|
28
|
+
# given a directory, return an array of string the represent wix components for each file in the directory
|
29
|
+
# each string should look like this:
|
30
|
+
# <Component Id="IndexHtmlComponent" Directory="WWWDIR" Guid="*">
|
31
|
+
# <File Id="IndexHtmlFile" Source="path\to\index.html" KeyPath="yes"/>
|
32
|
+
# </Component>
|
33
|
+
def self.harvest_file_components(directory)
|
34
|
+
components = Array::new
|
35
|
+
Dir.chdir(directory) do
|
36
|
+
index = 0
|
37
|
+
Dir.glob("**/*").reject { |f| File.directory? f }.each { |f|
|
38
|
+
index += 1
|
39
|
+
component = get_indexed_file_component(f, index)
|
40
|
+
components.push(component)
|
41
|
+
}
|
42
|
+
components
|
43
|
+
end
|
44
|
+
end
|
45
|
+
# given a file and an index, return a string that represents a wix component
|
46
|
+
def self.get_indexed_file_component(file, index)
|
47
|
+
componentId = "c#{index}"
|
48
|
+
guid = SecureRandom.uuid
|
49
|
+
fileId = "f#{index}"
|
50
|
+
directory = File.dirname(file)
|
51
|
+
directory = directory.split(/[\/\\]/).last if File.dirname(file).include?("\\") || File.dirname(file).include?("/")
|
52
|
+
directory = "" if directory == "."
|
53
|
+
directoryId = "#{File.dirname(file).upcase.gsub("/", "_").gsub("-", "_")}DIR"
|
54
|
+
component = "<Component Id=\"#{componentId}\" Guid=\"#{guid}\"><File Id=\"#{fileId}\" Source=\"#{file}\" /></Component>"
|
55
|
+
if (directory.length > 0)
|
56
|
+
component = "<Component Id=\"#{componentId}\" Guid=\"#{guid}\" Directory=\"#{directoryId}\"><File Id=\"#{fileId}\" Source=\"#{file}\" /></Component>"
|
57
|
+
end
|
58
|
+
component
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/raykit/wt.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
module Raykit
|
2
|
-
class Wt
|
3
|
-
def self.open(names)
|
4
|
-
if names.is_a? String
|
5
|
-
cmd = Raykit::Command.new("wt --maximized #{get_tab_arg(names)}").run
|
6
|
-
end
|
7
|
-
if names.is_a?(Array)
|
8
|
-
cmd = "wt --maximized "
|
9
|
-
index = 0
|
10
|
-
names.each { |url|
|
11
|
-
if index <= 0
|
12
|
-
cmd += get_tab_arg(url)
|
13
|
-
else
|
14
|
-
cmd += ";new-tab " + get_tab_arg(url)
|
15
|
-
end
|
16
|
-
index = index + 1
|
17
|
-
}
|
18
|
-
Raykit::Command.new(cmd).run
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.get_tab_arg(url)
|
23
|
-
dir = Raykit::Git::Repository.new(url).get_dev_dir("work")
|
24
|
-
name = File.basename(dir)
|
25
|
-
"-d #{dir} --title #{name}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
1
|
+
module Raykit
|
2
|
+
class Wt
|
3
|
+
def self.open(names)
|
4
|
+
if names.is_a? String
|
5
|
+
cmd = Raykit::Command.new("wt --maximized #{get_tab_arg(names)}").run
|
6
|
+
end
|
7
|
+
if names.is_a?(Array)
|
8
|
+
cmd = "wt --maximized "
|
9
|
+
index = 0
|
10
|
+
names.each { |url|
|
11
|
+
if index <= 0
|
12
|
+
cmd += get_tab_arg(url)
|
13
|
+
else
|
14
|
+
cmd += ";new-tab " + get_tab_arg(url)
|
15
|
+
end
|
16
|
+
index = index + 1
|
17
|
+
}
|
18
|
+
Raykit::Command.new(cmd).run
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_tab_arg(url)
|
23
|
+
dir = Raykit::Git::Repository.new(url).get_dev_dir("work")
|
24
|
+
name = File.basename(dir)
|
25
|
+
"-d #{dir} --title #{name}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/raykit/zip.rb
CHANGED
@@ -1,73 +1,73 @@
|
|
1
|
-
require "zip"
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class Zip
|
5
|
-
@filename
|
6
|
-
@source_dir
|
7
|
-
@include_globs
|
8
|
-
@exclude_globs
|
9
|
-
|
10
|
-
def initialize(filename)
|
11
|
-
@filename = filename
|
12
|
-
@source_dir = Dir.pwd
|
13
|
-
@include_globs = []
|
14
|
-
@exclude_globs = []
|
15
|
-
self
|
16
|
-
end
|
17
|
-
|
18
|
-
def source_dir(dir)
|
19
|
-
@source_dir = dir
|
20
|
-
self
|
21
|
-
end
|
22
|
-
|
23
|
-
def include_glob(glob)
|
24
|
-
@include_globs << glob
|
25
|
-
self
|
26
|
-
end
|
27
|
-
|
28
|
-
def exclude_glob(glob)
|
29
|
-
@exclude_globs << glob
|
30
|
-
self
|
31
|
-
end
|
32
|
-
|
33
|
-
def zip
|
34
|
-
path = File.dirname(@filename)
|
35
|
-
FileUtils.mkdir_p(path) unless Dir.exist?(path)
|
36
|
-
|
37
|
-
files_to_archive = Array::new()
|
38
|
-
Dir.chdir(@source_dir) do
|
39
|
-
#include_files = []
|
40
|
-
@include_globs.each do |include_glob|
|
41
|
-
Dir.glob(include_glob) { |f|
|
42
|
-
#puts "\n" + f
|
43
|
-
files_to_archive << f
|
44
|
-
}
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
::Zip::File::open(@filename, ::Zip::File::CREATE) { |zipfile|
|
49
|
-
count = 0
|
50
|
-
files_to_archive.each do |file|
|
51
|
-
zipfile.get_output_stream(file) { |f|
|
52
|
-
fr = ::File.open("#{@source_dir}/#{file}", "rb")
|
53
|
-
f.puts(fr.read)
|
54
|
-
fr.close()
|
55
|
-
f.close()
|
56
|
-
count = count + 1
|
57
|
-
}
|
58
|
-
end
|
59
|
-
zipfile.close
|
60
|
-
puts " added " << count.to_s << " files to " << @filename
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.zip_directory(directory, zipfile_name, overwrite = true)
|
65
|
-
File.delete(zipfile_name) if File.exist?(zipfile_name) && overwrite
|
66
|
-
::Zip::File.open(zipfile_name, ::Zip::File::CREATE) do |zipfile|
|
67
|
-
Dir[File.join(directory, "**", "**")].each do |file|
|
68
|
-
zipfile.add(file.sub(directory + "/", ""), file)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
1
|
+
require "zip"
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class Zip
|
5
|
+
@filename
|
6
|
+
@source_dir
|
7
|
+
@include_globs
|
8
|
+
@exclude_globs
|
9
|
+
|
10
|
+
def initialize(filename)
|
11
|
+
@filename = filename
|
12
|
+
@source_dir = Dir.pwd
|
13
|
+
@include_globs = []
|
14
|
+
@exclude_globs = []
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def source_dir(dir)
|
19
|
+
@source_dir = dir
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def include_glob(glob)
|
24
|
+
@include_globs << glob
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def exclude_glob(glob)
|
29
|
+
@exclude_globs << glob
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def zip
|
34
|
+
path = File.dirname(@filename)
|
35
|
+
FileUtils.mkdir_p(path) unless Dir.exist?(path)
|
36
|
+
|
37
|
+
files_to_archive = Array::new()
|
38
|
+
Dir.chdir(@source_dir) do
|
39
|
+
#include_files = []
|
40
|
+
@include_globs.each do |include_glob|
|
41
|
+
Dir.glob(include_glob) { |f|
|
42
|
+
#puts "\n" + f
|
43
|
+
files_to_archive << f
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
::Zip::File::open(@filename, ::Zip::File::CREATE) { |zipfile|
|
49
|
+
count = 0
|
50
|
+
files_to_archive.each do |file|
|
51
|
+
zipfile.get_output_stream(file) { |f|
|
52
|
+
fr = ::File.open("#{@source_dir}/#{file}", "rb")
|
53
|
+
f.puts(fr.read)
|
54
|
+
fr.close()
|
55
|
+
f.close()
|
56
|
+
count = count + 1
|
57
|
+
}
|
58
|
+
end
|
59
|
+
zipfile.close
|
60
|
+
puts " added " << count.to_s << " files to " << @filename
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.zip_directory(directory, zipfile_name, overwrite = true)
|
65
|
+
File.delete(zipfile_name) if File.exist?(zipfile_name) && overwrite
|
66
|
+
::Zip::File.open(zipfile_name, ::Zip::File::CREATE) do |zipfile|
|
67
|
+
Dir[File.join(directory, "**", "**")].each do |file|
|
68
|
+
zipfile.add(file.sub(directory + "/", ""), file)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|