utils 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/bin/probe +30 -0
- data/bin/strip_spaces +3 -2
- data/lib/utils.rb +1 -0
- data/lib/utils/config/vimrc +1 -1
- data/lib/utils/lines_file.rb +122 -0
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +6 -6
- metadata +31 -27
data/README.rdoc
CHANGED
@@ -8,7 +8,7 @@ This ruby gem provides some useful command line utilities.
|
|
8
8
|
|
9
9
|
Florian Frank <mailto:flori@ping.de>
|
10
10
|
|
11
|
-
== License
|
11
|
+
== License
|
12
12
|
|
13
13
|
This is free software; you can redistribute it and/or modify it under the
|
14
14
|
terms of the GNU General Public License Version 2 as published by the Free
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.16
|
data/bin/probe
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require 'spruz/xt'
|
5
|
+
require 'spruz/go'
|
6
|
+
include Spruz::GO
|
7
|
+
require 'utils'
|
8
|
+
include Utils
|
9
|
+
|
10
|
+
def cmd(*args)
|
11
|
+
puts args * ' '
|
12
|
+
system *args
|
13
|
+
end
|
14
|
+
|
15
|
+
filename = ARGV.shift or fail "require filename or filename:linenumber as first argument"
|
16
|
+
$opt = go 'n:'
|
17
|
+
if testname = $opt['n']
|
18
|
+
cmd "testrb", '-I', 'lib:test:ext', '-n', testname , filename
|
19
|
+
elsif filename =~ /^\s*([^:]+):(\d+)/
|
20
|
+
filename, linenumber = $1, $2
|
21
|
+
lf = LinesFile.for_filename filename, linenumber
|
22
|
+
if testname = lf.match_backward(/def\s+(\S+?)(?:\(|\s*$)/).full?(:first)
|
23
|
+
cmd "testrb", '-I', 'lib:test:ext', '-n', testname , filename
|
24
|
+
else
|
25
|
+
warn "no test found before line #{linenumber}"
|
26
|
+
exit 1
|
27
|
+
end
|
28
|
+
else
|
29
|
+
cmd "testrb", '-Ilib:test:ext', filename
|
30
|
+
end
|
data/bin/strip_spaces
CHANGED
@@ -9,9 +9,10 @@ class ::File
|
|
9
9
|
include Utils::FileXt
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
pathes = ARGV.empty? ? %w[.] : ARGV
|
13
|
+
pathes = pathes.map { |p| File.expand_path(p) }
|
13
14
|
|
14
|
-
find(*
|
15
|
+
find(*pathes) do |path|
|
15
16
|
File.basename(path) =~ /\A\./ and prune
|
16
17
|
File.directory?(path) and next
|
17
18
|
File.ascii?(path) or next
|
data/lib/utils.rb
CHANGED
data/lib/utils/config/vimrc
CHANGED
@@ -0,0 +1,122 @@
|
|
1
|
+
class Utils::LinesFile
|
2
|
+
module LineExtension
|
3
|
+
attr_reader :line_number
|
4
|
+
|
5
|
+
def filename
|
6
|
+
lines_file.filename.dup
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
include Enumerable
|
11
|
+
|
12
|
+
def self.for_filename(filename, line_number = nil)
|
13
|
+
obj = new(File.readlines(filename), line_number)
|
14
|
+
obj.filename = filename
|
15
|
+
obj
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.for_file(file, line_number)
|
19
|
+
obj = new(file.readlines, line_number)
|
20
|
+
obj.filename = filename
|
21
|
+
obj
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.for_lines(lines, line_number = nil)
|
25
|
+
new(lines, line_number)
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(lines, line_number = nil)
|
29
|
+
@lines = lines
|
30
|
+
@lines.each_with_index do |line, i|
|
31
|
+
line.extend LineExtension
|
32
|
+
line.instance_variable_set :@line_number, i + 1
|
33
|
+
line.instance_variable_set :@lines_file, self
|
34
|
+
end
|
35
|
+
self.line_number = line_number || (@lines.empty? ? 0 : 1)
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_accessor :filename
|
39
|
+
|
40
|
+
attr_reader :line_number
|
41
|
+
|
42
|
+
def rewind
|
43
|
+
self.line_number = 1
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
def next!
|
48
|
+
self.line_number += 1
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def previous!
|
53
|
+
self.line_number -= 1
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
def line_number=(number)
|
58
|
+
number = number.to_i
|
59
|
+
if number > 0 && number <= last_line_number
|
60
|
+
@line_number = number
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def last_line_number
|
65
|
+
@lines.size
|
66
|
+
end
|
67
|
+
|
68
|
+
def empty?
|
69
|
+
@lines.empty?
|
70
|
+
end
|
71
|
+
|
72
|
+
def each(&block)
|
73
|
+
@lines.empty? and return
|
74
|
+
old_line_number = line_number
|
75
|
+
1.upto(last_line_number) do |number|
|
76
|
+
self.line_number = number
|
77
|
+
block.call(line)
|
78
|
+
end
|
79
|
+
self
|
80
|
+
ensure
|
81
|
+
self.line_number = old_line_number
|
82
|
+
end
|
83
|
+
|
84
|
+
def line
|
85
|
+
index = line_number - 1
|
86
|
+
@lines[index] if index >= 0
|
87
|
+
end
|
88
|
+
|
89
|
+
def file_linenumber
|
90
|
+
"#{filename}:#{line_number}"
|
91
|
+
end
|
92
|
+
|
93
|
+
def match_backward(regexp, previous_after_match = false)
|
94
|
+
empty? and return
|
95
|
+
while line_number >= 1
|
96
|
+
if line =~ regexp
|
97
|
+
previous_after_match and previous!
|
98
|
+
return $~.captures
|
99
|
+
end
|
100
|
+
previous!
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def match_forward(regexp, next_after_match = false)
|
105
|
+
empty? and return
|
106
|
+
begin
|
107
|
+
if line =~ regexp
|
108
|
+
next_after_match and next!
|
109
|
+
return $~.captures
|
110
|
+
end
|
111
|
+
next!
|
112
|
+
end while line_number < last_line_number
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_s
|
116
|
+
"#{line_number} #{line.chomp}"
|
117
|
+
end
|
118
|
+
|
119
|
+
def inspect
|
120
|
+
"#<#{self.class}: #{to_s.inspect}>"
|
121
|
+
end
|
122
|
+
end
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{utils}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.16"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [%q{Florian Frank}]
|
9
|
-
s.date = %q{2011-08-
|
9
|
+
s.date = %q{2011-08-10}
|
10
10
|
s.description = %q{This ruby gem provides some useful command line utilities}
|
11
11
|
s.email = %q{flori@ping.de}
|
12
|
-
s.executables = [%q{
|
13
|
-
s.extra_rdoc_files = [%q{README.rdoc}, %q{lib/utils/
|
14
|
-
s.files = [%q{.gitignore}, %q{.rvmrc}, %q{COPYING}, %q{Gemfile}, %q{README.rdoc}, %q{Rakefile}, %q{VERSION}, %q{bin/chroot-exec}, %q{bin/chroot-libs}, %q{bin/classify}, %q{bin/discover}, %q{bin/edit}, %q{bin/edit_wait}, %q{bin/errf}, %q{bin/git-empty}, %q{bin/myex}, %q{bin/number_files}, %q{bin/path}, %q{bin/same_files}, %q{bin/search}, %q{bin/sedit}, %q{bin/sshscreen}, %q{bin/strip_spaces}, %q{bin/unquarantine_apps}, %q{bin/untest}, %q{bin/utils-install-config}, %q{bin/vacuum_firefox_sqlite}, %q{bin/xmp}, %q{lib/utils.rb}, %q{lib/utils/config.rb}, %q{lib/utils/config/gdb/asm}, %q{lib/utils/config/gdb/ruby}, %q{lib/utils/config/gdbinit}, %q{lib/utils/config/irbrc}, %q{lib/utils/config/rdebugrc}, %q{lib/utils/config/screenrc}, %q{lib/utils/config/vim/autoload/Align.vim}, %q{lib/utils/config/vim/autoload/AlignMaps.vim}, %q{lib/utils/config/vim/autoload/rails.vim}, %q{lib/utils/config/vim/autoload/rubycomplete.vim}, %q{lib/utils/config/vim/autoload/sqlcomplete.vim}, %q{lib/utils/config/vim/autoload/vimball.vim}, %q{lib/utils/config/vim/colors/flori.vim}, %q{lib/utils/config/vim/compiler/eruby.vim}, %q{lib/utils/config/vim/compiler/ruby.vim}, %q{lib/utils/config/vim/compiler/rubyunit.vim}, %q{lib/utils/config/vim/ftdetect/ragel.vim}, %q{lib/utils/config/vim/ftdetect/ruby.vim}, %q{lib/utils/config/vim/ftplugin/eruby.vim}, %q{lib/utils/config/vim/ftplugin/ruby.vim}, %q{lib/utils/config/vim/ftplugin/xml.vim}, %q{lib/utils/config/vim/indent/IndentAnything_html.vim}, %q{lib/utils/config/vim/indent/eruby.vim}, %q{lib/utils/config/vim/indent/javascript.vim}, %q{lib/utils/config/vim/indent/ruby.vim}, %q{lib/utils/config/vim/plugin/AlignMapsPlugin.vim}, %q{lib/utils/config/vim/plugin/AlignPlugin.vim}, %q{lib/utils/config/vim/plugin/Decho.vim}, %q{lib/utils/config/vim/plugin/IndentAnything.vim}, %q{lib/utils/config/vim/plugin/bufexplorer.vim}, %q{lib/utils/config/vim/plugin/cecutil.vim}, %q{lib/utils/config/vim/plugin/fugitive.vim}, %q{lib/utils/config/vim/plugin/lusty-explorer.vim}, %q{lib/utils/config/vim/plugin/rails.vim}, %q{lib/utils/config/vim/plugin/rubyextra.vim}, %q{lib/utils/config/vim/plugin/surround.vim}, %q{lib/utils/config/vim/plugin/taglist.vim}, %q{lib/utils/config/vim/plugin/test/IndentAnything/test.js}, %q{lib/utils/config/vim/plugin/vimballPlugin.vim}, %q{lib/utils/config/vim/syntax/Decho.vim}, %q{lib/utils/config/vim/syntax/eruby.vim}, %q{lib/utils/config/vim/syntax/javascript.vim}, %q{lib/utils/config/vim/syntax/ragel.vim}, %q{lib/utils/config/vim/syntax/ruby.vim}, %q{lib/utils/config/vimrc}, %q{lib/utils/editor.rb}, %q{lib/utils/file_xt.rb}, %q{lib/utils/find.rb}, %q{lib/utils/finder.rb}, %q{lib/utils/grepper.rb}, %q{lib/utils/md5.rb}, %q{lib/utils/patterns.rb}, %q{lib/utils/version.rb}, %q{utils.gemspec}]
|
12
|
+
s.executables = [%q{chroot-exec}, %q{chroot-libs}, %q{classify}, %q{discover}, %q{edit}, %q{edit_wait}, %q{errf}, %q{git-empty}, %q{myex}, %q{number_files}, %q{path}, %q{probe}, %q{same_files}, %q{search}, %q{sedit}, %q{sshscreen}, %q{strip_spaces}, %q{unquarantine_apps}, %q{untest}, %q{utils-install-config}, %q{vacuum_firefox_sqlite}, %q{xmp}]
|
13
|
+
s.extra_rdoc_files = [%q{README.rdoc}, %q{lib/utils/config.rb}, %q{lib/utils/editor.rb}, %q{lib/utils/file_xt.rb}, %q{lib/utils/find.rb}, %q{lib/utils/finder.rb}, %q{lib/utils/grepper.rb}, %q{lib/utils/lines_file.rb}, %q{lib/utils/md5.rb}, %q{lib/utils/patterns.rb}, %q{lib/utils/version.rb}, %q{lib/utils.rb}]
|
14
|
+
s.files = [%q{.gitignore}, %q{.rvmrc}, %q{COPYING}, %q{Gemfile}, %q{README.rdoc}, %q{Rakefile}, %q{VERSION}, %q{bin/chroot-exec}, %q{bin/chroot-libs}, %q{bin/classify}, %q{bin/discover}, %q{bin/edit}, %q{bin/edit_wait}, %q{bin/errf}, %q{bin/git-empty}, %q{bin/myex}, %q{bin/number_files}, %q{bin/path}, %q{bin/probe}, %q{bin/same_files}, %q{bin/search}, %q{bin/sedit}, %q{bin/sshscreen}, %q{bin/strip_spaces}, %q{bin/unquarantine_apps}, %q{bin/untest}, %q{bin/utils-install-config}, %q{bin/vacuum_firefox_sqlite}, %q{bin/xmp}, %q{lib/utils.rb}, %q{lib/utils/config.rb}, %q{lib/utils/config/gdb/asm}, %q{lib/utils/config/gdb/ruby}, %q{lib/utils/config/gdbinit}, %q{lib/utils/config/irbrc}, %q{lib/utils/config/rdebugrc}, %q{lib/utils/config/screenrc}, %q{lib/utils/config/vim/autoload/Align.vim}, %q{lib/utils/config/vim/autoload/AlignMaps.vim}, %q{lib/utils/config/vim/autoload/rails.vim}, %q{lib/utils/config/vim/autoload/rubycomplete.vim}, %q{lib/utils/config/vim/autoload/sqlcomplete.vim}, %q{lib/utils/config/vim/autoload/vimball.vim}, %q{lib/utils/config/vim/colors/flori.vim}, %q{lib/utils/config/vim/compiler/eruby.vim}, %q{lib/utils/config/vim/compiler/ruby.vim}, %q{lib/utils/config/vim/compiler/rubyunit.vim}, %q{lib/utils/config/vim/ftdetect/ragel.vim}, %q{lib/utils/config/vim/ftdetect/ruby.vim}, %q{lib/utils/config/vim/ftplugin/eruby.vim}, %q{lib/utils/config/vim/ftplugin/ruby.vim}, %q{lib/utils/config/vim/ftplugin/xml.vim}, %q{lib/utils/config/vim/indent/IndentAnything_html.vim}, %q{lib/utils/config/vim/indent/eruby.vim}, %q{lib/utils/config/vim/indent/javascript.vim}, %q{lib/utils/config/vim/indent/ruby.vim}, %q{lib/utils/config/vim/plugin/AlignMapsPlugin.vim}, %q{lib/utils/config/vim/plugin/AlignPlugin.vim}, %q{lib/utils/config/vim/plugin/Decho.vim}, %q{lib/utils/config/vim/plugin/IndentAnything.vim}, %q{lib/utils/config/vim/plugin/bufexplorer.vim}, %q{lib/utils/config/vim/plugin/cecutil.vim}, %q{lib/utils/config/vim/plugin/fugitive.vim}, %q{lib/utils/config/vim/plugin/lusty-explorer.vim}, %q{lib/utils/config/vim/plugin/rails.vim}, %q{lib/utils/config/vim/plugin/rubyextra.vim}, %q{lib/utils/config/vim/plugin/surround.vim}, %q{lib/utils/config/vim/plugin/taglist.vim}, %q{lib/utils/config/vim/plugin/test/IndentAnything/test.js}, %q{lib/utils/config/vim/plugin/vimballPlugin.vim}, %q{lib/utils/config/vim/syntax/Decho.vim}, %q{lib/utils/config/vim/syntax/eruby.vim}, %q{lib/utils/config/vim/syntax/javascript.vim}, %q{lib/utils/config/vim/syntax/ragel.vim}, %q{lib/utils/config/vim/syntax/ruby.vim}, %q{lib/utils/config/vimrc}, %q{lib/utils/editor.rb}, %q{lib/utils/file_xt.rb}, %q{lib/utils/find.rb}, %q{lib/utils/finder.rb}, %q{lib/utils/grepper.rb}, %q{lib/utils/lines_file.rb}, %q{lib/utils/md5.rb}, %q{lib/utils/patterns.rb}, %q{lib/utils/version.rb}, %q{utils.gemspec}]
|
15
15
|
s.homepage = %q{http://github.com/flori/utils}
|
16
16
|
s.rdoc_options = [%q{--title}, %q{Utils - Some useful command line utilities}, %q{--main}, %q{README.rdoc}]
|
17
17
|
s.require_paths = [%q{lib}]
|
18
|
-
s.rubygems_version = %q{1.8.
|
18
|
+
s.rubygems_version = %q{1.8.6}
|
19
19
|
s.summary = %q{Some useful command line utilities}
|
20
20
|
|
21
21
|
if s.respond_to? :specification_version then
|
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.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-10 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gem_hadar
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153046640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.0.11
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153046640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: spruz
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153046080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.2.12
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153046080
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: term-ansicolor
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153045540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,43 +43,45 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153045540
|
47
47
|
description: This ruby gem provides some useful command line utilities
|
48
48
|
email: flori@ping.de
|
49
49
|
executables:
|
50
|
-
- untest
|
51
|
-
- chroot-libs
|
52
|
-
- edit_wait
|
53
50
|
- chroot-exec
|
54
|
-
-
|
55
|
-
- search
|
56
|
-
- strip_spaces
|
57
|
-
- path
|
58
|
-
- edit
|
59
|
-
- git-empty
|
51
|
+
- chroot-libs
|
60
52
|
- classify
|
61
|
-
- utils-install-config
|
62
|
-
- xmp
|
63
53
|
- discover
|
64
|
-
-
|
65
|
-
-
|
54
|
+
- edit
|
55
|
+
- edit_wait
|
66
56
|
- errf
|
57
|
+
- git-empty
|
58
|
+
- myex
|
59
|
+
- number_files
|
60
|
+
- path
|
61
|
+
- probe
|
67
62
|
- same_files
|
63
|
+
- search
|
64
|
+
- sedit
|
65
|
+
- sshscreen
|
66
|
+
- strip_spaces
|
68
67
|
- unquarantine_apps
|
68
|
+
- untest
|
69
|
+
- utils-install-config
|
69
70
|
- vacuum_firefox_sqlite
|
70
|
-
-
|
71
|
+
- xmp
|
71
72
|
extensions: []
|
72
73
|
extra_rdoc_files:
|
73
74
|
- README.rdoc
|
74
|
-
- lib/utils/finder.rb
|
75
|
-
- lib/utils/version.rb
|
76
|
-
- lib/utils/find.rb
|
77
75
|
- lib/utils/config.rb
|
78
76
|
- lib/utils/editor.rb
|
79
|
-
- lib/utils/grepper.rb
|
80
77
|
- lib/utils/file_xt.rb
|
78
|
+
- lib/utils/find.rb
|
79
|
+
- lib/utils/finder.rb
|
80
|
+
- lib/utils/grepper.rb
|
81
|
+
- lib/utils/lines_file.rb
|
81
82
|
- lib/utils/md5.rb
|
82
83
|
- lib/utils/patterns.rb
|
84
|
+
- lib/utils/version.rb
|
83
85
|
- lib/utils.rb
|
84
86
|
files:
|
85
87
|
- .gitignore
|
@@ -100,6 +102,7 @@ files:
|
|
100
102
|
- bin/myex
|
101
103
|
- bin/number_files
|
102
104
|
- bin/path
|
105
|
+
- bin/probe
|
103
106
|
- bin/same_files
|
104
107
|
- bin/search
|
105
108
|
- bin/sedit
|
@@ -162,6 +165,7 @@ files:
|
|
162
165
|
- lib/utils/find.rb
|
163
166
|
- lib/utils/finder.rb
|
164
167
|
- lib/utils/grepper.rb
|
168
|
+
- lib/utils/lines_file.rb
|
165
169
|
- lib/utils/md5.rb
|
166
170
|
- lib/utils/patterns.rb
|
167
171
|
- lib/utils/version.rb
|
@@ -190,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
194
|
version: '0'
|
191
195
|
requirements: []
|
192
196
|
rubyforge_project:
|
193
|
-
rubygems_version: 1.8.
|
197
|
+
rubygems_version: 1.8.6
|
194
198
|
signing_key:
|
195
199
|
specification_version: 3
|
196
200
|
summary: Some useful command line utilities
|