clutil 2015.068.0 → 2015.262.0
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 +7 -0
- data/cl/util/file.rb +5 -93
- data/cl/util/test.rb +3 -3
- metadata +24 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8e17b10acccdbaafec79262f28b27412c43961bd
|
4
|
+
data.tar.gz: a5857912e0f9ac73f3652c7c5eb05daf6f8d0de7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: be996ef60f927990548ccb013e16b8b10513459b8de696624c07d0f4ef15e0d7cf376c0c0a8565a4ec7bbf016fb8851005fa82e904923ef0e52aee2139d54f7d
|
7
|
+
data.tar.gz: 0baa3559da6510e05420bf9f2602037a168dea8b91f8ab40a03498f9c5c70e898c929b1282b46fccefbb6848bcad02d95f94537fcb643c9503c4ab8cade33103
|
data/cl/util/file.rb
CHANGED
@@ -69,12 +69,12 @@ class << File
|
|
69
69
|
def backup(src, dst, bincompare=false)
|
70
70
|
installed = false
|
71
71
|
if (
|
72
|
-
File.
|
72
|
+
File.exist?(dst) &&
|
73
73
|
(
|
74
74
|
(File.stat(src).mtime != File.stat(dst).mtime) ||
|
75
75
|
(File.stat(src).size != File.stat(dst).size)
|
76
76
|
)
|
77
|
-
) || !File.
|
77
|
+
) || !File.exist?(dst) || bincompare
|
78
78
|
FileUtils.install src, dst, :verbose => true
|
79
79
|
installed = true
|
80
80
|
end
|
@@ -123,7 +123,7 @@ class ClUtilFile
|
|
123
123
|
raise 'Cannot delete root or empty?'
|
124
124
|
end
|
125
125
|
|
126
|
-
if !File.
|
126
|
+
if !File.exist?(rootDirName)
|
127
127
|
raise 'rootDirName does not exist'
|
128
128
|
end
|
129
129
|
|
@@ -161,7 +161,7 @@ class ClUtilFile
|
|
161
161
|
# usage: cp_r(from,to,file_param,permissions)
|
162
162
|
##################################################################
|
163
163
|
def cp_r(from,to,file_param=".*",permissions = 0644)
|
164
|
-
Dir.mkdir(to) unless FileTest.
|
164
|
+
Dir.mkdir(to) unless FileTest.exist?(to)
|
165
165
|
Dir.chdir(to)
|
166
166
|
|
167
167
|
dirContents = Dir["#{from}/*"]
|
@@ -169,7 +169,7 @@ class ClUtilFile
|
|
169
169
|
file = File.basename(entry)
|
170
170
|
|
171
171
|
if FileTest.directory?(entry)
|
172
|
-
Dir.mkdir(file) unless FileTest.
|
172
|
+
Dir.mkdir(file) unless FileTest.exist?(file)
|
173
173
|
cp_r(entry,file,file_param)
|
174
174
|
Dir.chdir("..") #get back to the dir we were working on
|
175
175
|
else
|
@@ -193,91 +193,3 @@ class ClUtilFile
|
|
193
193
|
end
|
194
194
|
=end
|
195
195
|
end
|
196
|
-
|
197
|
-
|
198
|
-
class Dir
|
199
|
-
# Dir.mktmpdir creates a temporary directory.
|
200
|
-
#
|
201
|
-
# [Copied from Ruby 1.9]
|
202
|
-
#
|
203
|
-
# The directory is created with 0700 permission.
|
204
|
-
#
|
205
|
-
# The prefix and suffix of the name of the directory is specified by
|
206
|
-
# the optional first argument, <i>prefix_suffix</i>.
|
207
|
-
# - If it is not specified or nil, "d" is used as the prefix and no suffix is used.
|
208
|
-
# - If it is a string, it is used as the prefix and no suffix is used.
|
209
|
-
# - If it is an array, first element is used as the prefix and second element is used as a suffix.
|
210
|
-
#
|
211
|
-
# Dir.mktmpdir {|dir| dir is ".../d..." }
|
212
|
-
# Dir.mktmpdir("foo") {|dir| dir is ".../foo..." }
|
213
|
-
# Dir.mktmpdir(["foo", "bar"]) {|dir| dir is ".../foo...bar" }
|
214
|
-
#
|
215
|
-
# The directory is created under Dir.tmpdir or
|
216
|
-
# the optional second argument <i>tmpdir</i> if non-nil value is given.
|
217
|
-
#
|
218
|
-
# Dir.mktmpdir {|dir| dir is "#{Dir.tmpdir}/d..." }
|
219
|
-
# Dir.mktmpdir(nil, "/var/tmp") {|dir| dir is "/var/tmp/d..." }
|
220
|
-
#
|
221
|
-
# If a block is given,
|
222
|
-
# it is yielded with the path of the directory.
|
223
|
-
# The directory and its contents are removed
|
224
|
-
# using FileUtils.remove_entry_secure before Dir.mktmpdir returns.
|
225
|
-
# The value of the block is returned.
|
226
|
-
#
|
227
|
-
# Dir.mktmpdir {|dir|
|
228
|
-
# # use the directory...
|
229
|
-
# open("#{dir}/foo", "w") { ... }
|
230
|
-
# }
|
231
|
-
#
|
232
|
-
# If a block is not given,
|
233
|
-
# The path of the directory is returned.
|
234
|
-
# In this case, Dir.mktmpdir doesn't remove the directory.
|
235
|
-
#
|
236
|
-
# dir = Dir.mktmpdir
|
237
|
-
# begin
|
238
|
-
# # use the directory...
|
239
|
-
# open("#{dir}/foo", "w") { ... }
|
240
|
-
# ensure
|
241
|
-
# # remove the directory.
|
242
|
-
# FileUtils.remove_entry_secure dir
|
243
|
-
# end
|
244
|
-
#
|
245
|
-
def Dir.mktmpdir(prefix_suffix=nil, tmpdir=nil)
|
246
|
-
case prefix_suffix
|
247
|
-
when nil
|
248
|
-
prefix = "d"
|
249
|
-
suffix = ""
|
250
|
-
when String
|
251
|
-
prefix = prefix_suffix
|
252
|
-
suffix = ""
|
253
|
-
when Array
|
254
|
-
prefix = prefix_suffix[0]
|
255
|
-
suffix = prefix_suffix[1]
|
256
|
-
else
|
257
|
-
raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
|
258
|
-
end
|
259
|
-
tmpdir ||= Dir.tmpdir
|
260
|
-
t = Time.now.strftime("%Y%m%d")
|
261
|
-
n = nil
|
262
|
-
begin
|
263
|
-
path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
|
264
|
-
path << "-#{n}" if n
|
265
|
-
path << suffix
|
266
|
-
Dir.mkdir(path, 0700)
|
267
|
-
rescue Errno::EEXIST
|
268
|
-
n ||= 0
|
269
|
-
n += 1
|
270
|
-
retry
|
271
|
-
end
|
272
|
-
|
273
|
-
if block_given?
|
274
|
-
begin
|
275
|
-
yield path
|
276
|
-
ensure
|
277
|
-
FileUtils.remove_entry_secure path
|
278
|
-
end
|
279
|
-
else
|
280
|
-
path
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
data/cl/util/test.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/file'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'tmpdir'
|
4
|
-
require '
|
4
|
+
require 'minitest'
|
5
5
|
|
6
|
-
class TempDirTest < Test
|
6
|
+
class TempDirTest < MiniTest::Test
|
7
7
|
def set_temp_dir
|
8
8
|
@temp_dir = Dir.mktmpdir
|
9
9
|
end
|
@@ -31,7 +31,7 @@ class TempDirTest < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def make_sample_text_file(dirname='', size=0)
|
34
|
-
crlf_length =
|
34
|
+
crlf_length = 1
|
35
35
|
|
36
36
|
if size == 0
|
37
37
|
content = 'this is a sample file'
|
metadata
CHANGED
@@ -1,30 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clutil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2015.
|
5
|
-
prerelease:
|
4
|
+
version: 2015.262.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- chrismo
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2015-
|
11
|
+
date: 2015-09-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
28
39
|
- !ruby/object:Gem::Version
|
29
40
|
version: '0'
|
30
41
|
description: a mish-mash of spare utility libs for Ruby.
|
@@ -51,32 +62,25 @@ files:
|
|
51
62
|
homepage: https://github.com/chrismo/clutil
|
52
63
|
licenses:
|
53
64
|
- MIT
|
65
|
+
metadata: {}
|
54
66
|
post_install_message:
|
55
67
|
rdoc_options: []
|
56
68
|
require_paths:
|
57
|
-
- .
|
69
|
+
- "."
|
58
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
71
|
requirements:
|
61
|
-
- -
|
72
|
+
- - ">="
|
62
73
|
- !ruby/object:Gem::Version
|
63
74
|
version: '0'
|
64
|
-
segments:
|
65
|
-
- 0
|
66
|
-
hash: 1319166832057909282
|
67
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
76
|
requirements:
|
70
|
-
- -
|
77
|
+
- - ">="
|
71
78
|
- !ruby/object:Gem::Version
|
72
79
|
version: '0'
|
73
|
-
segments:
|
74
|
-
- 0
|
75
|
-
hash: 1319166832057909282
|
76
80
|
requirements: []
|
77
81
|
rubyforge_project:
|
78
|
-
rubygems_version:
|
82
|
+
rubygems_version: 2.2.5
|
79
83
|
signing_key:
|
80
|
-
specification_version:
|
84
|
+
specification_version: 4
|
81
85
|
summary: cLabs Ruby Utilities
|
82
86
|
test_files: []
|