raykit 0.0.543 → 0.0.545
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 +8 -8
- data/lib/raykit/default_content.txt +219 -219
- data/lib/raykit/dir.rb +127 -127
- data/lib/raykit/dotnet.rb +207 -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 +279 -279
- 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 +97 -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 +143 -140
- metadata +3 -3
@@ -1,219 +1,219 @@
|
|
1
|
-
# General
|
2
|
-
[Aa]rtifacts/
|
3
|
-
|
4
|
-
# Ruby
|
5
|
-
*.gem
|
6
|
-
*.rbc
|
7
|
-
/.config
|
8
|
-
/coverage/
|
9
|
-
/InstalledFiles
|
10
|
-
/pkg/
|
11
|
-
/spec/reports/
|
12
|
-
/spec/examples.txt
|
13
|
-
/test/tmp/
|
14
|
-
/test/version_tmp/
|
15
|
-
/tmp/
|
16
|
-
/.yardoc/
|
17
|
-
/_yardoc/
|
18
|
-
/doc/
|
19
|
-
/rdoc/
|
20
|
-
/.bundle/
|
21
|
-
/vendor/bundle
|
22
|
-
/lib/bundler/man/
|
23
|
-
.rvmrc
|
24
|
-
|
25
|
-
# Rust
|
26
|
-
/target/
|
27
|
-
Cargo.lock
|
28
|
-
**/*.rs.bk
|
29
|
-
/target
|
30
|
-
/Cargo.lock
|
31
|
-
|
32
|
-
# DotNet
|
33
|
-
*.rsuser
|
34
|
-
*.suo
|
35
|
-
*.user
|
36
|
-
*.userosscache
|
37
|
-
*.sln.docstates
|
38
|
-
*.txt
|
39
|
-
*.userprefs
|
40
|
-
BenchmarkDotNet.Artifacts/
|
41
|
-
[Dd]ebug/
|
42
|
-
[Dd]ebugPublic/
|
43
|
-
[Rr]elease/
|
44
|
-
[Rr]eleases/
|
45
|
-
x64/
|
46
|
-
x86/
|
47
|
-
[Aa][Rr][Mm]/
|
48
|
-
[Aa][Rr][Mm]64/
|
49
|
-
bld/
|
50
|
-
[Bb]in/
|
51
|
-
[Oo]bj/
|
52
|
-
[Ll]og/
|
53
|
-
[Aa]rtifacts/
|
54
|
-
.vs/
|
55
|
-
Generated\ Files/
|
56
|
-
[Tt]est[Rr]esult*/
|
57
|
-
[Bb]uild[Ll]og.*
|
58
|
-
*.VisualState.xml
|
59
|
-
TestResult.xml
|
60
|
-
[Dd]ebugPS/
|
61
|
-
[Rr]eleasePS/
|
62
|
-
dlldata.c
|
63
|
-
BenchmarkDotNet.Artifacts/
|
64
|
-
|
65
|
-
project.lock.json
|
66
|
-
project.fragment.lock.json
|
67
|
-
artifacts/
|
68
|
-
StyleCopReport.xml
|
69
|
-
*_i.c
|
70
|
-
*_p.c
|
71
|
-
*_h.h
|
72
|
-
*.ilk
|
73
|
-
*.meta
|
74
|
-
*.obj
|
75
|
-
*.iobj
|
76
|
-
*.pch
|
77
|
-
*.pdb
|
78
|
-
*.ipdb
|
79
|
-
*.pgc
|
80
|
-
*.pgd
|
81
|
-
*.rsp
|
82
|
-
*.sbr
|
83
|
-
*.tlb
|
84
|
-
*.tli
|
85
|
-
*.tlh
|
86
|
-
*.tmp
|
87
|
-
*.tmp_proj
|
88
|
-
*_wpftmp.csproj
|
89
|
-
*.log
|
90
|
-
*.vspscc
|
91
|
-
*.vssscc
|
92
|
-
.builds
|
93
|
-
*.pidb
|
94
|
-
*.svclog
|
95
|
-
*.scc
|
96
|
-
_Chutzpah*
|
97
|
-
ipch/
|
98
|
-
*.aps
|
99
|
-
*.ncb
|
100
|
-
*.opendb
|
101
|
-
*.opensdf
|
102
|
-
*.sdf
|
103
|
-
*.cachefile
|
104
|
-
*.VC.db
|
105
|
-
*.VC.VC.opendb
|
106
|
-
*.psess
|
107
|
-
*.vsp
|
108
|
-
*.vspx
|
109
|
-
*.sap
|
110
|
-
*.e2e
|
111
|
-
$tf/
|
112
|
-
*.gpState
|
113
|
-
_ReSharper*/
|
114
|
-
*.[Rr]e[Ss]harper
|
115
|
-
*.DotSettings.user
|
116
|
-
.JustCode
|
117
|
-
_TeamCity*
|
118
|
-
*.dotCover
|
119
|
-
.axoCover/*
|
120
|
-
!.axoCover/settings.json
|
121
|
-
*.coverage
|
122
|
-
*.coveragexml
|
123
|
-
_NCrunch_*
|
124
|
-
.*crunch*.local.xml
|
125
|
-
nCrunchTemp_*
|
126
|
-
*.mm.*
|
127
|
-
AutoTest.Net/
|
128
|
-
.sass-cache/
|
129
|
-
[Ee]xpress/
|
130
|
-
DocProject/buildhelp/
|
131
|
-
DocProject/Help/*.HxT
|
132
|
-
DocProject/Help/*.HxC
|
133
|
-
DocProject/Help/*.hhc
|
134
|
-
DocProject/Help/*.hhk
|
135
|
-
DocProject/Help/*.hhp
|
136
|
-
DocProject/Help/Html2
|
137
|
-
DocProject/Help/html
|
138
|
-
publish/
|
139
|
-
*.[Pp]ublish.xml
|
140
|
-
*.azurePubxml
|
141
|
-
*.pubxml
|
142
|
-
*.publishproj
|
143
|
-
PublishScripts/
|
144
|
-
*.nupkg
|
145
|
-
**/[Pp]ackages/*
|
146
|
-
!**/[Pp]ackages/build/
|
147
|
-
*.nuget.props
|
148
|
-
*.nuget.targets
|
149
|
-
csx/
|
150
|
-
*.build.csdef
|
151
|
-
ecf/
|
152
|
-
rcf/
|
153
|
-
AppPackages/
|
154
|
-
BundleArtifacts/
|
155
|
-
Package.StoreAssociation.xml
|
156
|
-
_pkginfo.txt
|
157
|
-
*.appx
|
158
|
-
*.[Cc]ache
|
159
|
-
# but keep track of directories ending in .cache
|
160
|
-
!*.[Cc]ache/
|
161
|
-
ClientBin/
|
162
|
-
~$*
|
163
|
-
*~
|
164
|
-
*.dbmdl
|
165
|
-
*.dbproj.schemaview
|
166
|
-
*.jfm
|
167
|
-
*.pfx
|
168
|
-
*.publishsettings
|
169
|
-
orleans.codegen.cs
|
170
|
-
**/wwwroot/lib/
|
171
|
-
Generated_Code/
|
172
|
-
_UpgradeReport_Files/
|
173
|
-
Backup*/
|
174
|
-
UpgradeLog*.XML
|
175
|
-
UpgradeLog*.htm
|
176
|
-
ServiceFabricBackup/
|
177
|
-
*.rptproj.bak
|
178
|
-
*.mdf
|
179
|
-
*.ldf
|
180
|
-
*.ndf
|
181
|
-
*.rdl.data
|
182
|
-
*.bim.layout
|
183
|
-
*.bim_*.settings
|
184
|
-
*.rptproj.rsuser
|
185
|
-
FakesAssemblies/
|
186
|
-
*.GhostDoc.xml
|
187
|
-
.ntvs_analysis.dat
|
188
|
-
node_modules/
|
189
|
-
*.plg
|
190
|
-
*.opt
|
191
|
-
*.vbw
|
192
|
-
**/*.HTMLClient/GeneratedArtifacts
|
193
|
-
**/*.DesktopClient/GeneratedArtifacts
|
194
|
-
**/*.DesktopClient/ModelManifest.xml
|
195
|
-
**/*.Server/GeneratedArtifacts
|
196
|
-
**/*.Server/ModelManifest.xml
|
197
|
-
_Pvt_Extensions
|
198
|
-
.paket/paket.exe
|
199
|
-
paket-files/
|
200
|
-
.fake/
|
201
|
-
.idea/
|
202
|
-
*.sln.iml
|
203
|
-
.cr/personal
|
204
|
-
__pycache__/
|
205
|
-
*.pyc
|
206
|
-
tools/**
|
207
|
-
!tools/packages.config
|
208
|
-
*.tss
|
209
|
-
*.jmconfig
|
210
|
-
*.btp.cs
|
211
|
-
*.btm.cs
|
212
|
-
*.odx.cs
|
213
|
-
*.xsd.cs
|
214
|
-
OpenCover/
|
215
|
-
ASALocalRun/
|
216
|
-
*.binlog
|
217
|
-
*.nvuser
|
218
|
-
.mfractor/
|
219
|
-
.localhistory/
|
1
|
+
# General
|
2
|
+
[Aa]rtifacts/
|
3
|
+
|
4
|
+
# Ruby
|
5
|
+
*.gem
|
6
|
+
*.rbc
|
7
|
+
/.config
|
8
|
+
/coverage/
|
9
|
+
/InstalledFiles
|
10
|
+
/pkg/
|
11
|
+
/spec/reports/
|
12
|
+
/spec/examples.txt
|
13
|
+
/test/tmp/
|
14
|
+
/test/version_tmp/
|
15
|
+
/tmp/
|
16
|
+
/.yardoc/
|
17
|
+
/_yardoc/
|
18
|
+
/doc/
|
19
|
+
/rdoc/
|
20
|
+
/.bundle/
|
21
|
+
/vendor/bundle
|
22
|
+
/lib/bundler/man/
|
23
|
+
.rvmrc
|
24
|
+
|
25
|
+
# Rust
|
26
|
+
/target/
|
27
|
+
Cargo.lock
|
28
|
+
**/*.rs.bk
|
29
|
+
/target
|
30
|
+
/Cargo.lock
|
31
|
+
|
32
|
+
# DotNet
|
33
|
+
*.rsuser
|
34
|
+
*.suo
|
35
|
+
*.user
|
36
|
+
*.userosscache
|
37
|
+
*.sln.docstates
|
38
|
+
*.txt
|
39
|
+
*.userprefs
|
40
|
+
BenchmarkDotNet.Artifacts/
|
41
|
+
[Dd]ebug/
|
42
|
+
[Dd]ebugPublic/
|
43
|
+
[Rr]elease/
|
44
|
+
[Rr]eleases/
|
45
|
+
x64/
|
46
|
+
x86/
|
47
|
+
[Aa][Rr][Mm]/
|
48
|
+
[Aa][Rr][Mm]64/
|
49
|
+
bld/
|
50
|
+
[Bb]in/
|
51
|
+
[Oo]bj/
|
52
|
+
[Ll]og/
|
53
|
+
[Aa]rtifacts/
|
54
|
+
.vs/
|
55
|
+
Generated\ Files/
|
56
|
+
[Tt]est[Rr]esult*/
|
57
|
+
[Bb]uild[Ll]og.*
|
58
|
+
*.VisualState.xml
|
59
|
+
TestResult.xml
|
60
|
+
[Dd]ebugPS/
|
61
|
+
[Rr]eleasePS/
|
62
|
+
dlldata.c
|
63
|
+
BenchmarkDotNet.Artifacts/
|
64
|
+
|
65
|
+
project.lock.json
|
66
|
+
project.fragment.lock.json
|
67
|
+
artifacts/
|
68
|
+
StyleCopReport.xml
|
69
|
+
*_i.c
|
70
|
+
*_p.c
|
71
|
+
*_h.h
|
72
|
+
*.ilk
|
73
|
+
*.meta
|
74
|
+
*.obj
|
75
|
+
*.iobj
|
76
|
+
*.pch
|
77
|
+
*.pdb
|
78
|
+
*.ipdb
|
79
|
+
*.pgc
|
80
|
+
*.pgd
|
81
|
+
*.rsp
|
82
|
+
*.sbr
|
83
|
+
*.tlb
|
84
|
+
*.tli
|
85
|
+
*.tlh
|
86
|
+
*.tmp
|
87
|
+
*.tmp_proj
|
88
|
+
*_wpftmp.csproj
|
89
|
+
*.log
|
90
|
+
*.vspscc
|
91
|
+
*.vssscc
|
92
|
+
.builds
|
93
|
+
*.pidb
|
94
|
+
*.svclog
|
95
|
+
*.scc
|
96
|
+
_Chutzpah*
|
97
|
+
ipch/
|
98
|
+
*.aps
|
99
|
+
*.ncb
|
100
|
+
*.opendb
|
101
|
+
*.opensdf
|
102
|
+
*.sdf
|
103
|
+
*.cachefile
|
104
|
+
*.VC.db
|
105
|
+
*.VC.VC.opendb
|
106
|
+
*.psess
|
107
|
+
*.vsp
|
108
|
+
*.vspx
|
109
|
+
*.sap
|
110
|
+
*.e2e
|
111
|
+
$tf/
|
112
|
+
*.gpState
|
113
|
+
_ReSharper*/
|
114
|
+
*.[Rr]e[Ss]harper
|
115
|
+
*.DotSettings.user
|
116
|
+
.JustCode
|
117
|
+
_TeamCity*
|
118
|
+
*.dotCover
|
119
|
+
.axoCover/*
|
120
|
+
!.axoCover/settings.json
|
121
|
+
*.coverage
|
122
|
+
*.coveragexml
|
123
|
+
_NCrunch_*
|
124
|
+
.*crunch*.local.xml
|
125
|
+
nCrunchTemp_*
|
126
|
+
*.mm.*
|
127
|
+
AutoTest.Net/
|
128
|
+
.sass-cache/
|
129
|
+
[Ee]xpress/
|
130
|
+
DocProject/buildhelp/
|
131
|
+
DocProject/Help/*.HxT
|
132
|
+
DocProject/Help/*.HxC
|
133
|
+
DocProject/Help/*.hhc
|
134
|
+
DocProject/Help/*.hhk
|
135
|
+
DocProject/Help/*.hhp
|
136
|
+
DocProject/Help/Html2
|
137
|
+
DocProject/Help/html
|
138
|
+
publish/
|
139
|
+
*.[Pp]ublish.xml
|
140
|
+
*.azurePubxml
|
141
|
+
*.pubxml
|
142
|
+
*.publishproj
|
143
|
+
PublishScripts/
|
144
|
+
*.nupkg
|
145
|
+
**/[Pp]ackages/*
|
146
|
+
!**/[Pp]ackages/build/
|
147
|
+
*.nuget.props
|
148
|
+
*.nuget.targets
|
149
|
+
csx/
|
150
|
+
*.build.csdef
|
151
|
+
ecf/
|
152
|
+
rcf/
|
153
|
+
AppPackages/
|
154
|
+
BundleArtifacts/
|
155
|
+
Package.StoreAssociation.xml
|
156
|
+
_pkginfo.txt
|
157
|
+
*.appx
|
158
|
+
*.[Cc]ache
|
159
|
+
# but keep track of directories ending in .cache
|
160
|
+
!*.[Cc]ache/
|
161
|
+
ClientBin/
|
162
|
+
~$*
|
163
|
+
*~
|
164
|
+
*.dbmdl
|
165
|
+
*.dbproj.schemaview
|
166
|
+
*.jfm
|
167
|
+
*.pfx
|
168
|
+
*.publishsettings
|
169
|
+
orleans.codegen.cs
|
170
|
+
**/wwwroot/lib/
|
171
|
+
Generated_Code/
|
172
|
+
_UpgradeReport_Files/
|
173
|
+
Backup*/
|
174
|
+
UpgradeLog*.XML
|
175
|
+
UpgradeLog*.htm
|
176
|
+
ServiceFabricBackup/
|
177
|
+
*.rptproj.bak
|
178
|
+
*.mdf
|
179
|
+
*.ldf
|
180
|
+
*.ndf
|
181
|
+
*.rdl.data
|
182
|
+
*.bim.layout
|
183
|
+
*.bim_*.settings
|
184
|
+
*.rptproj.rsuser
|
185
|
+
FakesAssemblies/
|
186
|
+
*.GhostDoc.xml
|
187
|
+
.ntvs_analysis.dat
|
188
|
+
node_modules/
|
189
|
+
*.plg
|
190
|
+
*.opt
|
191
|
+
*.vbw
|
192
|
+
**/*.HTMLClient/GeneratedArtifacts
|
193
|
+
**/*.DesktopClient/GeneratedArtifacts
|
194
|
+
**/*.DesktopClient/ModelManifest.xml
|
195
|
+
**/*.Server/GeneratedArtifacts
|
196
|
+
**/*.Server/ModelManifest.xml
|
197
|
+
_Pvt_Extensions
|
198
|
+
.paket/paket.exe
|
199
|
+
paket-files/
|
200
|
+
.fake/
|
201
|
+
.idea/
|
202
|
+
*.sln.iml
|
203
|
+
.cr/personal
|
204
|
+
__pycache__/
|
205
|
+
*.pyc
|
206
|
+
tools/**
|
207
|
+
!tools/packages.config
|
208
|
+
*.tss
|
209
|
+
*.jmconfig
|
210
|
+
*.btp.cs
|
211
|
+
*.btm.cs
|
212
|
+
*.odx.cs
|
213
|
+
*.xsd.cs
|
214
|
+
OpenCover/
|
215
|
+
ASALocalRun/
|
216
|
+
*.binlog
|
217
|
+
*.nvuser
|
218
|
+
.mfractor/
|
219
|
+
.localhistory/
|
data/lib/raykit/dir.rb
CHANGED
@@ -1,127 +1,127 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "tmpdir"
|
4
|
-
require "find"
|
5
|
-
require_relative "./environment"
|
6
|
-
|
7
|
-
class Dir
|
8
|
-
def self.get_text(dir, relative_name)
|
9
|
-
File.read("#{dir}/#{relative_name}")
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.set_text(dir, relative_name, text)
|
13
|
-
File.open("#{dir}/#{relative_name}", "w") { |f| f.write text }
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.directory_size(directory)
|
17
|
-
total_size = 0
|
18
|
-
Find.find(directory) do |path|
|
19
|
-
if File.file?(path)
|
20
|
-
total_size += File.size(path)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
total_size
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.humanize_size(size_in_bytes)
|
27
|
-
units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"]
|
28
|
-
|
29
|
-
return "0 Bytes" if size_in_bytes == 0
|
30
|
-
|
31
|
-
exponent = (Math.log(size_in_bytes) / Math.log(1024)).to_i
|
32
|
-
exponent = units.size - 1 if exponent > units.size - 1 # Cap at the largest known unit
|
33
|
-
|
34
|
-
size = size_in_bytes.to_f / (1024 ** exponent)
|
35
|
-
format("%.2f %s", size, units[exponent])
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.get_git_directories(dir)
|
39
|
-
git_dirs = []
|
40
|
-
Dir.chdir(dir) do
|
41
|
-
Dir.glob("**/.git/index") do |f|
|
42
|
-
git_dir = File.dirname(File.dirname(f))
|
43
|
-
git_dirs << git_dir
|
44
|
-
end
|
45
|
-
end
|
46
|
-
git_dirs
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.get_git_urls(dir)
|
50
|
-
urls = Set.new
|
51
|
-
Dir.chdir(dir) do
|
52
|
-
get_git_directories(dir).each do |git_dir|
|
53
|
-
Dir.chdir(git_dir) do
|
54
|
-
url = `git config --get remote.origin.url`.strip
|
55
|
-
urls.add(url)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
urls
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.get_data_dir
|
63
|
-
unless ENV["DATA_DIR"].nil?
|
64
|
-
data_dir = ENV["DATA_DIR"]
|
65
|
-
return data_dir if Dir.exist?(data_dir)
|
66
|
-
end
|
67
|
-
home_dir = Raykit::Environment.home_dir
|
68
|
-
return home_dir if Dir.exist?(home_dir)
|
69
|
-
|
70
|
-
Dir.tmpdir
|
71
|
-
end
|
72
|
-
|
73
|
-
require "fileutils"
|
74
|
-
|
75
|
-
def self.remove_empty_directories(dir)
|
76
|
-
# List all entries in the directory except for '.' and '..'
|
77
|
-
Dir.entries(dir).each do |entry|
|
78
|
-
next if entry == "." || entry == ".." # Skip the current and parent directory entries
|
79
|
-
|
80
|
-
path = File.join(dir, entry) # Construct the full path
|
81
|
-
|
82
|
-
if File.directory?(path)
|
83
|
-
begin
|
84
|
-
remove_empty_directories(path) # Recursively call the method if the entry is a directory
|
85
|
-
rescue Errno::ENAMETOOLONG
|
86
|
-
puts "Path too long: #{path}"
|
87
|
-
next # Skip this directory and continue with others
|
88
|
-
end
|
89
|
-
|
90
|
-
# Attempt to remove the directory if it's empty after processing its contents
|
91
|
-
begin
|
92
|
-
Dir.rmdir(path) if Dir.empty?(path)
|
93
|
-
rescue Errno::ENAMETOOLONG
|
94
|
-
puts "Path too long to remove: #{path}"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
rescue Errno::ENOENT
|
99
|
-
# Handle the case where the directory doesn't exist or is removed before rmdir is called
|
100
|
-
puts "Directory not found: #{dir}"
|
101
|
-
rescue Errno::ENAMETOOLONG
|
102
|
-
# Handle the case where the initial directory path is too long
|
103
|
-
puts "Initial path too long: #{dir}"
|
104
|
-
end
|
105
|
-
|
106
|
-
#def self.remove_empty_directories(dir)
|
107
|
-
# List all entries in the directory except for '.' and '..'
|
108
|
-
# Dir.entries(dir).each do |entry|
|
109
|
-
# next if entry == "." || entry == ".." # Skip the current and parent directory entries
|
110
|
-
|
111
|
-
# path = File.join(dir, entry) # Construct the full path
|
112
|
-
|
113
|
-
# if File.directory?(path)
|
114
|
-
# remove_empty_directories(path) # Recursively call the method if the entry is a directory
|
115
|
-
# Remove the directory if it's empty after processing its contents
|
116
|
-
# Dir.rmdir(path) if Dir.empty?(path)
|
117
|
-
# end
|
118
|
-
# end
|
119
|
-
#rescue Errno::ENOENT
|
120
|
-
# Handle the case where the directory doesn't exist or is removed before rmdir is called
|
121
|
-
# puts "Directory not found: #{dir}"
|
122
|
-
#end
|
123
|
-
|
124
|
-
# Example usage:
|
125
|
-
# remove_empty_directories('/path/to/directory')
|
126
|
-
|
127
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tmpdir"
|
4
|
+
require "find"
|
5
|
+
require_relative "./environment"
|
6
|
+
|
7
|
+
class Dir
|
8
|
+
def self.get_text(dir, relative_name)
|
9
|
+
File.read("#{dir}/#{relative_name}")
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.set_text(dir, relative_name, text)
|
13
|
+
File.open("#{dir}/#{relative_name}", "w") { |f| f.write text }
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.directory_size(directory)
|
17
|
+
total_size = 0
|
18
|
+
Find.find(directory) do |path|
|
19
|
+
if File.file?(path)
|
20
|
+
total_size += File.size(path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
total_size
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.humanize_size(size_in_bytes)
|
27
|
+
units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"]
|
28
|
+
|
29
|
+
return "0 Bytes" if size_in_bytes == 0
|
30
|
+
|
31
|
+
exponent = (Math.log(size_in_bytes) / Math.log(1024)).to_i
|
32
|
+
exponent = units.size - 1 if exponent > units.size - 1 # Cap at the largest known unit
|
33
|
+
|
34
|
+
size = size_in_bytes.to_f / (1024 ** exponent)
|
35
|
+
format("%.2f %s", size, units[exponent])
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.get_git_directories(dir)
|
39
|
+
git_dirs = []
|
40
|
+
Dir.chdir(dir) do
|
41
|
+
Dir.glob("**/.git/index") do |f|
|
42
|
+
git_dir = File.dirname(File.dirname(f))
|
43
|
+
git_dirs << git_dir
|
44
|
+
end
|
45
|
+
end
|
46
|
+
git_dirs
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.get_git_urls(dir)
|
50
|
+
urls = Set.new
|
51
|
+
Dir.chdir(dir) do
|
52
|
+
get_git_directories(dir).each do |git_dir|
|
53
|
+
Dir.chdir(git_dir) do
|
54
|
+
url = `git config --get remote.origin.url`.strip
|
55
|
+
urls.add(url)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
urls
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.get_data_dir
|
63
|
+
unless ENV["DATA_DIR"].nil?
|
64
|
+
data_dir = ENV["DATA_DIR"]
|
65
|
+
return data_dir if Dir.exist?(data_dir)
|
66
|
+
end
|
67
|
+
home_dir = Raykit::Environment.home_dir
|
68
|
+
return home_dir if Dir.exist?(home_dir)
|
69
|
+
|
70
|
+
Dir.tmpdir
|
71
|
+
end
|
72
|
+
|
73
|
+
require "fileutils"
|
74
|
+
|
75
|
+
def self.remove_empty_directories(dir)
|
76
|
+
# List all entries in the directory except for '.' and '..'
|
77
|
+
Dir.entries(dir).each do |entry|
|
78
|
+
next if entry == "." || entry == ".." # Skip the current and parent directory entries
|
79
|
+
|
80
|
+
path = File.join(dir, entry) # Construct the full path
|
81
|
+
|
82
|
+
if File.directory?(path)
|
83
|
+
begin
|
84
|
+
remove_empty_directories(path) # Recursively call the method if the entry is a directory
|
85
|
+
rescue Errno::ENAMETOOLONG
|
86
|
+
puts "Path too long: #{path}"
|
87
|
+
next # Skip this directory and continue with others
|
88
|
+
end
|
89
|
+
|
90
|
+
# Attempt to remove the directory if it's empty after processing its contents
|
91
|
+
begin
|
92
|
+
Dir.rmdir(path) if Dir.empty?(path)
|
93
|
+
rescue Errno::ENAMETOOLONG
|
94
|
+
puts "Path too long to remove: #{path}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
rescue Errno::ENOENT
|
99
|
+
# Handle the case where the directory doesn't exist or is removed before rmdir is called
|
100
|
+
puts "Directory not found: #{dir}"
|
101
|
+
rescue Errno::ENAMETOOLONG
|
102
|
+
# Handle the case where the initial directory path is too long
|
103
|
+
puts "Initial path too long: #{dir}"
|
104
|
+
end
|
105
|
+
|
106
|
+
#def self.remove_empty_directories(dir)
|
107
|
+
# List all entries in the directory except for '.' and '..'
|
108
|
+
# Dir.entries(dir).each do |entry|
|
109
|
+
# next if entry == "." || entry == ".." # Skip the current and parent directory entries
|
110
|
+
|
111
|
+
# path = File.join(dir, entry) # Construct the full path
|
112
|
+
|
113
|
+
# if File.directory?(path)
|
114
|
+
# remove_empty_directories(path) # Recursively call the method if the entry is a directory
|
115
|
+
# Remove the directory if it's empty after processing its contents
|
116
|
+
# Dir.rmdir(path) if Dir.empty?(path)
|
117
|
+
# end
|
118
|
+
# end
|
119
|
+
#rescue Errno::ENOENT
|
120
|
+
# Handle the case where the directory doesn't exist or is removed before rmdir is called
|
121
|
+
# puts "Directory not found: #{dir}"
|
122
|
+
#end
|
123
|
+
|
124
|
+
# Example usage:
|
125
|
+
# remove_empty_directories('/path/to/directory')
|
126
|
+
|
127
|
+
end
|