utils 0.0.54 → 0.0.55
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/bin/discover +3 -2
- data/bin/probe +1 -1
- data/bin/search +3 -2
- data/bin/strip_spaces +1 -1
- data/lib/utils/config/config_file.rb +26 -10
- data/lib/utils/finder.rb +3 -3
- data/lib/utils/grepper.rb +4 -4
- data/lib/utils/irb.rb +20 -8
- 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.55
|
data/bin/discover
CHANGED
@@ -30,6 +30,7 @@ Options are
|
|
30
30
|
-a CSET use only character set CSET from PATTERN
|
31
31
|
-I SUFFIX only include files with suffix SUFFIX during finding
|
32
32
|
-b match also binary files
|
33
|
+
-v be verbose
|
33
34
|
-h display this help
|
34
35
|
|
35
36
|
Version is #{File.basename($0)} #{Utils::VERSION}.
|
@@ -37,7 +38,7 @@ Version is #{File.basename($0)} #{Utils::VERSION}.
|
|
37
38
|
exit 1
|
38
39
|
end
|
39
40
|
|
40
|
-
args = go 'I:a:
|
41
|
+
args = go 'I:a:rdDciebvh'
|
41
42
|
args['h'] and usage
|
42
43
|
pattern = ARGV.shift or usage
|
43
44
|
roots = (ARGV.empty? ? [ Dir.pwd ] : ARGV).map { |f| File.expand_path(f) }
|
@@ -45,7 +46,7 @@ roots = (ARGV.empty? ? [ Dir.pwd ] : ARGV).map { |f| File.expand_path(f) }
|
|
45
46
|
Term::ANSIColor.coloring = (STDIN.tty? && ENV['TERM'] !~ /dumb/) && !args['c']
|
46
47
|
STDOUT.sync = true
|
47
48
|
config = Utils::Config::ConfigFile.new
|
48
|
-
config.
|
49
|
+
config.configure_from_paths
|
49
50
|
args['b'] ||= config.discover.binary
|
50
51
|
finder = Finder.new(
|
51
52
|
:pattern => pattern,
|
data/bin/probe
CHANGED
data/bin/search
CHANGED
@@ -49,6 +49,7 @@ Options are
|
|
49
49
|
-I SUFFIX only include files with suffix SUFFIX in search
|
50
50
|
-e open the matching files with edit command
|
51
51
|
-a CSET use only character set CSET from PATTERN
|
52
|
+
-v be verbose
|
52
53
|
-h display this help
|
53
54
|
|
54
55
|
Version is #{File.basename($0)} #{Utils::VERSION}.
|
@@ -56,7 +57,7 @@ Version is #{File.basename($0)} #{Utils::VERSION}.
|
|
56
57
|
exit 1
|
57
58
|
end
|
58
59
|
|
59
|
-
args = go 'I:A:B:C:s:S:n:N:a:
|
60
|
+
args = go 'I:A:B:C:s:S:n:N:a:RciflLevh'
|
60
61
|
args['h'] and usage
|
61
62
|
pattern = ARGV.shift or usage
|
62
63
|
roots = (ARGV.empty? ? [ Dir.pwd ] : ARGV).map { |f| File.expand_path(f) }
|
@@ -64,7 +65,7 @@ roots = (ARGV.empty? ? [ Dir.pwd ] : ARGV).map { |f| File.expand_path(f) }
|
|
64
65
|
Term::ANSIColor.coloring = (STDIN.tty? && ENV['TERM'] !~ /dumb/) && !args['c']
|
65
66
|
STDOUT.sync = true
|
66
67
|
config = Utils::Config::ConfigFile.new
|
67
|
-
config.
|
68
|
+
config.configure_from_paths
|
68
69
|
grepper = Grepper.new(
|
69
70
|
:pattern => pattern,
|
70
71
|
:args => args,
|
data/bin/strip_spaces
CHANGED
@@ -38,7 +38,7 @@ paths = paths.map { |p| File.expand_path(p) }
|
|
38
38
|
suffix = args['I'].ask_and_send(:split, /[\s,]+/).to_a
|
39
39
|
|
40
40
|
config = Utils::Config::ConfigFile.new
|
41
|
-
config.
|
41
|
+
config.configure_from_paths
|
42
42
|
|
43
43
|
find(*(paths + [ { :suffix => suffix} ])) do |filename|
|
44
44
|
bn, s = File.basename(filename), File.stat(filename)
|
@@ -2,6 +2,15 @@ require 'dslkit/polite'
|
|
2
2
|
require 'tins/xt/string'
|
3
3
|
|
4
4
|
class Utils::Config::ConfigFile
|
5
|
+
class << self
|
6
|
+
attr_accessor :config_file_paths
|
7
|
+
end
|
8
|
+
self.config_file_paths = [
|
9
|
+
'/etc/utilsrc',
|
10
|
+
'~/.utilsrc',
|
11
|
+
'./.utilsrc',
|
12
|
+
]
|
13
|
+
|
5
14
|
include DSLKit::Interpreter
|
6
15
|
|
7
16
|
class ConfigFileError < StandardError; end
|
@@ -9,14 +18,21 @@ class Utils::Config::ConfigFile
|
|
9
18
|
def initialize
|
10
19
|
end
|
11
20
|
|
12
|
-
def
|
13
|
-
|
21
|
+
def configure_from_paths(paths = self.class.config_file_paths)
|
22
|
+
for config_file_path in paths
|
23
|
+
parse_config_file config_file_path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_config_file(config_file_path)
|
28
|
+
config_file_path = File.expand_path(config_file_path)
|
29
|
+
File.open(config_file_path) do |cf|
|
14
30
|
parse cf.read
|
15
31
|
end
|
16
32
|
self
|
17
33
|
rescue SystemCallError => e
|
18
34
|
$DEBUG and warn "Couldn't read config file "\
|
19
|
-
"#{
|
35
|
+
"#{config_file_path.inspect}: #{e.class} #{e}"
|
20
36
|
return nil
|
21
37
|
end
|
22
38
|
|
@@ -48,7 +64,7 @@ class Utils::Config::ConfigFile
|
|
48
64
|
|
49
65
|
def to_ruby
|
50
66
|
result = ''
|
51
|
-
result << "#{self.class.name[/::([^:]+)\
|
67
|
+
result << "#{self.class.name[/::([^:]+)\z/, 1].underscore} do\n"
|
52
68
|
for da in self.class.dsl_attributes
|
53
69
|
result << " #{da} #{Array(__send__(da)).map(&:inspect) * ', '}\n"
|
54
70
|
end
|
@@ -92,9 +108,9 @@ class Utils::Config::ConfigFile
|
|
92
108
|
end
|
93
109
|
|
94
110
|
class Search < FileFinder
|
95
|
-
config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\
|
111
|
+
config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\z/
|
96
112
|
|
97
|
-
config :skip_files, /(\A\.|\.sw[pon]\
|
113
|
+
config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
|
98
114
|
end
|
99
115
|
|
100
116
|
def search(&block)
|
@@ -105,9 +121,9 @@ class Utils::Config::ConfigFile
|
|
105
121
|
end
|
106
122
|
|
107
123
|
class Discover < FileFinder
|
108
|
-
config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\
|
124
|
+
config :prune_dirs, /\A(\.svn|\.git|CVS|tmp)\z/
|
109
125
|
|
110
|
-
config :skip_files, /(\A\.|\.sw[pon]\
|
126
|
+
config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
|
111
127
|
|
112
128
|
config :binary, false
|
113
129
|
end
|
@@ -120,9 +136,9 @@ class Utils::Config::ConfigFile
|
|
120
136
|
end
|
121
137
|
|
122
138
|
class StripSpaces < FileFinder
|
123
|
-
config :prune_dirs, /\A(\..*|CVS)\
|
139
|
+
config :prune_dirs, /\A(\..*|CVS)\z/
|
124
140
|
|
125
|
-
config :skip_files, /(\A\.|\.sw[pon]\
|
141
|
+
config :skip_files, /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
|
126
142
|
end
|
127
143
|
|
128
144
|
def strip_spaces(&block)
|
data/lib/utils/finder.rb
CHANGED
@@ -57,11 +57,11 @@ class Utils::Finder
|
|
57
57
|
begin
|
58
58
|
bn, s = filename.pathname.basename, filename.stat
|
59
59
|
if !s || s.directory? && @config.discover.prune?(bn)
|
60
|
-
|
60
|
+
@args['v'] and warn "Pruning #{filename.inspect}."
|
61
61
|
prune
|
62
62
|
end
|
63
63
|
if s.file? && @config.discover.skip?(bn)
|
64
|
-
|
64
|
+
@args['v'] and warn "Skipping #{filename.inspect}."
|
65
65
|
next
|
66
66
|
end
|
67
67
|
paths << filename
|
@@ -70,7 +70,7 @@ class Utils::Finder
|
|
70
70
|
paths.uniq!
|
71
71
|
paths.map! { |p| a = File.split(p) ; a.unshift(p) ; a }
|
72
72
|
paths = paths.map! do |path, dir, file|
|
73
|
-
if do_match = attempt_match?(path) and
|
73
|
+
if do_match = attempt_match?(path) and @args['v']
|
74
74
|
warn "Attempt match of #{path.inspect}"
|
75
75
|
end
|
76
76
|
if do_match and match = @pattern.match(file)
|
data/lib/utils/grepper.rb
CHANGED
@@ -71,7 +71,7 @@ class Utils::Grepper
|
|
71
71
|
@output = []
|
72
72
|
bn, s = File.basename(filename), File.stat(filename)
|
73
73
|
if !s || s.directory? && @config.search.prune?(bn)
|
74
|
-
|
74
|
+
@args['v'] and warn "Pruning #{filename.inspect}."
|
75
75
|
prune
|
76
76
|
end
|
77
77
|
if s.file? && !@config.search.skip?(bn) &&
|
@@ -79,18 +79,18 @@ class Utils::Grepper
|
|
79
79
|
then
|
80
80
|
File.open(filename, 'rb') do |file|
|
81
81
|
if file.binary? != true
|
82
|
-
|
82
|
+
@args['v'] and warn "Matching #{filename.inspect}."
|
83
83
|
if @args['f']
|
84
84
|
@output << filename
|
85
85
|
else
|
86
86
|
match_lines file
|
87
87
|
end
|
88
88
|
else
|
89
|
-
|
89
|
+
@args['v'] and warn "Skipping binary file #{filename.inspect}."
|
90
90
|
end
|
91
91
|
end
|
92
92
|
else
|
93
|
-
|
93
|
+
@args['v'] and warn "Skipping #{filename.inspect}."
|
94
94
|
end
|
95
95
|
unless @output.empty?
|
96
96
|
case
|
data/lib/utils/irb.rb
CHANGED
@@ -112,7 +112,7 @@ module Utils
|
|
112
112
|
|
113
113
|
attr_reader :description
|
114
114
|
|
115
|
-
alias to_str
|
115
|
+
alias to_str description
|
116
116
|
|
117
117
|
alias inspect description
|
118
118
|
|
@@ -136,15 +136,27 @@ module Utils
|
|
136
136
|
class MethodWrapper < WrapperBase
|
137
137
|
def initialize(obj, name, modul)
|
138
138
|
super(name)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
@method = modul ? obj.instance_method(name) : obj.method(name)
|
140
|
+
@description = "#{owner}##@name(#{arity})"
|
141
|
+
end
|
142
|
+
|
143
|
+
attr_reader :method
|
144
|
+
|
145
|
+
def owner
|
146
|
+
method.respond_to?(:owner) ? method.owner : nil
|
145
147
|
end
|
146
148
|
|
147
|
-
|
149
|
+
def arity
|
150
|
+
method.arity
|
151
|
+
end
|
152
|
+
|
153
|
+
def source_location
|
154
|
+
method.source_location
|
155
|
+
end
|
156
|
+
|
157
|
+
def <=>(other)
|
158
|
+
@description <=> other.description
|
159
|
+
end
|
148
160
|
end
|
149
161
|
|
150
162
|
class ConstantWrapper < WrapperBase
|
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.55"
|
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-09-
|
9
|
+
s.date = "2012-09-25"
|
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", "create_tags", "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.55
|
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-09-
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gem_hadar
|
@@ -256,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
256
256
|
version: '0'
|
257
257
|
segments:
|
258
258
|
- 0
|
259
|
-
hash:
|
259
|
+
hash: 147024533922954409
|
260
260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
261
|
none: false
|
262
262
|
requirements:
|