utils 0.0.46 → 0.0.47
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.
- data/VERSION +1 -1
- data/lib/utils/find.rb +21 -22
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.47
|
data/lib/utils/find.rb
CHANGED
@@ -7,21 +7,8 @@ module Utils
|
|
7
7
|
attr_writer :finder
|
8
8
|
|
9
9
|
def file
|
10
|
-
tried = false
|
11
10
|
begin
|
12
|
-
|
13
|
-
if file
|
14
|
-
file.closed? and file.reopen(file.path, 'rb')
|
15
|
-
else
|
16
|
-
file = File.new(self, 'rb')
|
17
|
-
@finder.add_file self, file
|
18
|
-
end
|
19
|
-
return file
|
20
|
-
rescue Errno::EMFILE
|
21
|
-
tried and raise
|
22
|
-
@finder.close_files
|
23
|
-
tried = true
|
24
|
-
retry
|
11
|
+
@finder.open_file(self)
|
25
12
|
rescue Errno::ENOENT, Errno::EACCES
|
26
13
|
return
|
27
14
|
end
|
@@ -70,8 +57,22 @@ module Utils
|
|
70
57
|
path
|
71
58
|
end
|
72
59
|
|
73
|
-
def
|
74
|
-
|
60
|
+
def open_file(path, opts = {})
|
61
|
+
retried = false
|
62
|
+
mode = opts.fetch(:mode, 'rb')
|
63
|
+
if file = @files[path]
|
64
|
+
if file.closed?
|
65
|
+
file.reopen(file.path, mode)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
file = File.new(path, mode)
|
69
|
+
add_file path, file
|
70
|
+
end
|
71
|
+
file
|
72
|
+
rescue Errno::EMFILE
|
73
|
+
close_files
|
74
|
+
retried = true
|
75
|
+
retry
|
75
76
|
end
|
76
77
|
|
77
78
|
def add_file(path, file)
|
@@ -79,6 +80,10 @@ module Utils
|
|
79
80
|
self
|
80
81
|
end
|
81
82
|
|
83
|
+
def current_open_files
|
84
|
+
@files.inject(0) { |c, f| c + f.closed? ? 0 : 1 }
|
85
|
+
end
|
86
|
+
|
82
87
|
def close_files
|
83
88
|
@files.each_value do |f|
|
84
89
|
f.closed? or f.close
|
@@ -109,13 +114,7 @@ module Utils
|
|
109
114
|
end
|
110
115
|
if s.directory? then
|
111
116
|
begin
|
112
|
-
tried = false
|
113
117
|
fs = Dir.entries(file)
|
114
|
-
rescue Errno::EMFILE
|
115
|
-
tried and raise
|
116
|
-
close_files
|
117
|
-
tried = true
|
118
|
-
retry
|
119
118
|
rescue Errno::ENOENT, Errno::EACCES, Errno::ENOTDIR, Errno::ELOOP, Errno::ENAMETOOLONG
|
120
119
|
next
|
121
120
|
end
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "utils"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.47"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Florian Frank"]
|
9
|
-
s.date = "2012-
|
9
|
+
s.date = "2012-07-05"
|
10
10
|
s.description = "This ruby gem provides some useful command line utilities"
|
11
11
|
s.email = "flori@ping.de"
|
12
12
|
s.executables = ["chroot-exec", "chroot-libs", "classify", "discover", "edit", "edit_wait", "enum", "errf", "git-empty", "myex", "number_files", "path", "probe", "same_files", "search", "sedit", "sshscreen", "strip_spaces", "unquarantine_apps", "untest", "utils-install-config", "utils-utilsrc", "vacuum_firefox_sqlite", "xmp"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.47
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gem_hadar
|
@@ -243,7 +243,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
243
|
version: '0'
|
244
244
|
segments:
|
245
245
|
- 0
|
246
|
-
hash:
|
246
|
+
hash: 1507338635745314567
|
247
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
248
|
none: false
|
249
249
|
requirements:
|