raykit 0.0.505 → 0.0.506
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/raykit/console.rb +27 -0
- data/lib/raykit/dir.rb +24 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ea32fa36258ad6f45bb896087791ea0fc57b4394425c96149583b4438f86b24
|
4
|
+
data.tar.gz: 2c15951203504dd796c9efdc86ebee03c44ff627a0422d5124bcb65b7dc2f1fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85ce77ab49484e3f4427b2df31f9520a5a2668d61b00f569ff2b6019cc8165f26fde35dba85f7b920be433dc9c09053621344beba051401d3308cc1d1d9d0112
|
7
|
+
data.tar.gz: 309bed182a7449d81aba70b1d63ba3e5268ba06a2bd8808c66c701acd3fc8665aa01288ef08e359f5da7aed3b3c89eb96783dee2a2abe911bdf340541d053ae9
|
data/lib/raykit/console.rb
CHANGED
@@ -57,6 +57,8 @@ module Raykit
|
|
57
57
|
import
|
58
58
|
when "clean"
|
59
59
|
clean
|
60
|
+
when "clobber"
|
61
|
+
clobber
|
60
62
|
when "sync_version"
|
61
63
|
sync_version
|
62
64
|
when "copy"
|
@@ -77,6 +79,7 @@ module Raykit
|
|
77
79
|
"work" => "clone and rake a git repository",
|
78
80
|
"import" => "import git urls matching a specific pattern",
|
79
81
|
"clean" => "clean one or more working directories",
|
82
|
+
"clobber" => "clobber one or more working directories",
|
80
83
|
"pull" => "preform git pull on one or more working directories",
|
81
84
|
"sync_version" => "synchronize the version number between two files",
|
82
85
|
"copy" => "copy a file" }
|
@@ -89,6 +92,7 @@ module Raykit
|
|
89
92
|
"work" => "work URL_PATTERN [--task RAKE_TASK]",
|
90
93
|
"import" => "import URL_PATTERN",
|
91
94
|
"clean" => "clean URL_PATTERN",
|
95
|
+
"clobber" => "clobber URL_PATTERN",
|
92
96
|
"pull" => "pull URL_PATTERN",
|
93
97
|
"sync_version" => "sync_version SOURCE_FILENAME DESTINATION_FILENAME",
|
94
98
|
"copy" => "copy SOURCE DESTINATION" }
|
@@ -265,6 +269,28 @@ module Raykit
|
|
265
269
|
end
|
266
270
|
|
267
271
|
def clean
|
272
|
+
pattern = ""
|
273
|
+
pattern = @opts.arguments[1] if @opts.arguments.length > 1
|
274
|
+
REPOSITORIES.matches(pattern).each do |url|
|
275
|
+
repo = Raykit::Git::Repository.new(url)
|
276
|
+
work = Raykit::Git::Directory.new(repo.get_dev_dir("work"))
|
277
|
+
next unless Dir.exist?(work.directory)
|
278
|
+
|
279
|
+
# TODO: run a git clean command in the directory
|
280
|
+
puts "cleaning #{work.directory}"
|
281
|
+
Dir.chdir(work.directory) do
|
282
|
+
cmd = Command.new("git clean -xdf")
|
283
|
+
cmd.summary if @opts.verbose?
|
284
|
+
if cmd.exitstatus != 0
|
285
|
+
cmd.details
|
286
|
+
abort Rainbow(cmd.summary).blue.bright if @opts.quit?
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
Dir::remove_empty_directories(Raykit::Environment.get_dev_dir("work"))
|
291
|
+
end
|
292
|
+
|
293
|
+
def clobber
|
268
294
|
pattern = ""
|
269
295
|
pattern = @opts.arguments[1] if @opts.arguments.length > 1
|
270
296
|
REPOSITORIES.matches(pattern).each do |url|
|
@@ -279,6 +305,7 @@ module Raykit
|
|
279
305
|
puts "error removing #{work.directory}"
|
280
306
|
end
|
281
307
|
end
|
308
|
+
Dir::remove_empty_directories(Raykit::Environment.get_dev_dir("work"))
|
282
309
|
end
|
283
310
|
|
284
311
|
def copy
|
data/lib/raykit/dir.rb
CHANGED
@@ -46,4 +46,28 @@ class Dir
|
|
46
46
|
|
47
47
|
Dir.tmpdir
|
48
48
|
end
|
49
|
+
|
50
|
+
require "fileutils"
|
51
|
+
|
52
|
+
def self.remove_empty_directories(dir)
|
53
|
+
# List all entries in the directory except for '.' and '..'
|
54
|
+
Dir.entries(dir).each do |entry|
|
55
|
+
next if entry == "." || entry == ".." # Skip the current and parent directory entries
|
56
|
+
|
57
|
+
path = File.join(dir, entry) # Construct the full path
|
58
|
+
|
59
|
+
if File.directory?(path)
|
60
|
+
remove_empty_directories(path) # Recursively call the method if the entry is a directory
|
61
|
+
# Remove the directory if it's empty after processing its contents
|
62
|
+
Dir.rmdir(path) if Dir.empty?(path)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
rescue Errno::ENOENT
|
66
|
+
# Handle the case where the directory doesn't exist or is removed before rmdir is called
|
67
|
+
puts "Directory not found: #{dir}"
|
68
|
+
end
|
69
|
+
|
70
|
+
# Example usage:
|
71
|
+
# remove_empty_directories('/path/to/directory')
|
72
|
+
|
49
73
|
end
|