utils 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/path +2 -2
- data/bin/probe +8 -6
- data/bin/untest +3 -3
- data/lib/utils.rb +0 -1
- data/lib/utils/editor.rb +1 -1
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +9 -9
- metadata +28 -30
- data/lib/utils/lines_file.rb +0 -122
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.17
|
data/bin/path
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spruz/go'
|
4
4
|
include Spruz::GO
|
5
|
-
require 'spruz/xt/
|
5
|
+
require 'spruz/xt/secure_write'
|
6
6
|
require 'tempfile'
|
7
7
|
|
8
8
|
path_separator = RUBY_PLATFORM =~ /mswin32/ ? ';' : ':'
|
@@ -27,7 +27,7 @@ when 'edit'
|
|
27
27
|
path.map! { |part| File.expand_path(part) }
|
28
28
|
end
|
29
29
|
path_file = File.join(Dir.tmpdir, "path_temp.#$$")
|
30
|
-
File.
|
30
|
+
File.secure_write path_file, path * "\n"
|
31
31
|
system "edit -w #{path_file.inspect}"
|
32
32
|
path = File.read(path_file).split(/\n/)
|
33
33
|
path.map! { |part| File.expand_path(part) }
|
data/bin/probe
CHANGED
@@ -2,29 +2,31 @@
|
|
2
2
|
# encoding: UTF-8
|
3
3
|
|
4
4
|
require 'spruz/xt'
|
5
|
-
require 'spruz/
|
5
|
+
require 'spruz/lines_file'
|
6
6
|
include Spruz::GO
|
7
7
|
require 'utils'
|
8
8
|
include Utils
|
9
9
|
|
10
10
|
def cmd(*args)
|
11
11
|
puts args * ' '
|
12
|
-
|
12
|
+
exec *args
|
13
13
|
end
|
14
14
|
|
15
|
-
filename = ARGV.shift or fail "require filename or filename:
|
15
|
+
filename = ARGV.shift or fail "require filename or filename:line_number as first argument"
|
16
16
|
$opt = go 'n:'
|
17
17
|
if testname = $opt['n']
|
18
18
|
cmd "testrb", '-I', 'lib:test:ext', '-n', testname , filename
|
19
19
|
elsif filename =~ /^\s*([^:]+):(\d+)/
|
20
|
-
filename,
|
21
|
-
lf = LinesFile.for_filename filename,
|
20
|
+
filename, line_number = $1, $2
|
21
|
+
lf = Spruz::LinesFile.for_filename filename, line_number.to_i
|
22
22
|
if testname = lf.match_backward(/def\s+(\S+?)(?:\(|\s*$)/).full?(:first)
|
23
|
+
puts "Running test #{testname.inspect} at #{filename}:#{lf.line_number}"
|
23
24
|
cmd "testrb", '-I', 'lib:test:ext', '-n', testname , filename
|
24
25
|
else
|
25
|
-
warn "no test found before line #{
|
26
|
+
warn "no test found before line #{line_number}"
|
26
27
|
exit 1
|
27
28
|
end
|
28
29
|
else
|
30
|
+
puts "Running ALL tests in #{filename}"
|
29
31
|
cmd "testrb", '-Ilib:test:ext', filename
|
30
32
|
end
|
data/bin/untest
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'spruz/xt/
|
3
|
+
require 'spruz/xt/secure_write'
|
4
4
|
|
5
5
|
for filename in ARGV
|
6
6
|
File.open(filename) do |input|
|
7
|
-
|
7
|
+
File.secure_write(filename) do |output|
|
8
8
|
until input.eof?
|
9
9
|
line = input.readline
|
10
10
|
line.sub!(/^(\s*)test "(.+)" do\s*$/) do
|
11
11
|
"#$1def test_" << $2.downcase.gsub(/\A[^a-z]/, '').gsub(/[ -]/, '_').delete('^0-9a-z_')
|
12
12
|
end
|
13
|
-
output.
|
13
|
+
output.write line
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/utils.rb
CHANGED
data/lib/utils/editor.rb
CHANGED
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.17"
|
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-17}
|
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/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/
|
12
|
+
s.executables = [%q{untest}, %q{chroot-libs}, %q{edit_wait}, %q{chroot-exec}, %q{number_files}, %q{search}, %q{strip_spaces}, %q{path}, %q{edit}, %q{git-empty}, %q{classify}, %q{utils-install-config}, %q{xmp}, %q{discover}, %q{sshscreen}, %q{myex}, %q{probe}, %q{errf}, %q{same_files}, %q{unquarantine_apps}, %q{vacuum_firefox_sqlite}, %q{sedit}]
|
13
|
+
s.extra_rdoc_files = [%q{README.rdoc}, %q{lib/utils/finder.rb}, %q{lib/utils/version.rb}, %q{lib/utils/find.rb}, %q{lib/utils/config.rb}, %q{lib/utils/editor.rb}, %q{lib/utils/grepper.rb}, %q{lib/utils/file_xt.rb}, %q{lib/utils/md5.rb}, %q{lib/utils/patterns.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/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.7}
|
19
19
|
s.summary = %q{Some useful command line utilities}
|
20
20
|
|
21
21
|
if s.respond_to? :specification_version then
|
@@ -23,16 +23,16 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
25
|
s.add_development_dependency(%q<gem_hadar>, ["~> 0.0.11"])
|
26
|
-
s.add_runtime_dependency(%q<spruz>, ["~> 0.2.
|
26
|
+
s.add_runtime_dependency(%q<spruz>, ["~> 0.2.13"])
|
27
27
|
s.add_runtime_dependency(%q<term-ansicolor>, ["~> 1.0"])
|
28
28
|
else
|
29
29
|
s.add_dependency(%q<gem_hadar>, ["~> 0.0.11"])
|
30
|
-
s.add_dependency(%q<spruz>, ["~> 0.2.
|
30
|
+
s.add_dependency(%q<spruz>, ["~> 0.2.13"])
|
31
31
|
s.add_dependency(%q<term-ansicolor>, ["~> 1.0"])
|
32
32
|
end
|
33
33
|
else
|
34
34
|
s.add_dependency(%q<gem_hadar>, ["~> 0.0.11"])
|
35
|
-
s.add_dependency(%q<spruz>, ["~> 0.2.
|
35
|
+
s.add_dependency(%q<spruz>, ["~> 0.2.13"])
|
36
36
|
s.add_dependency(%q<term-ansicolor>, ["~> 1.0"])
|
37
37
|
end
|
38
38
|
end
|
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.17
|
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-18 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gem_hadar
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152966880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: 0.0.11
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152966880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: spruz
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152966340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.2.
|
32
|
+
version: 0.2.13
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152966340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: term-ansicolor
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152965800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,45 +43,44 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152965800
|
47
47
|
description: This ruby gem provides some useful command line utilities
|
48
48
|
email: flori@ping.de
|
49
49
|
executables:
|
50
|
-
-
|
50
|
+
- untest
|
51
51
|
- chroot-libs
|
52
|
-
- classify
|
53
|
-
- discover
|
54
|
-
- edit
|
55
52
|
- edit_wait
|
56
|
-
-
|
57
|
-
- git-empty
|
58
|
-
- myex
|
53
|
+
- chroot-exec
|
59
54
|
- number_files
|
55
|
+
- search
|
56
|
+
- strip_spaces
|
60
57
|
- path
|
58
|
+
- edit
|
59
|
+
- git-empty
|
60
|
+
- classify
|
61
|
+
- utils-install-config
|
62
|
+
- xmp
|
63
|
+
- discover
|
64
|
+
- sshscreen
|
65
|
+
- myex
|
61
66
|
- probe
|
67
|
+
- errf
|
62
68
|
- same_files
|
63
|
-
- search
|
64
|
-
- sedit
|
65
|
-
- sshscreen
|
66
|
-
- strip_spaces
|
67
69
|
- unquarantine_apps
|
68
|
-
- untest
|
69
|
-
- utils-install-config
|
70
70
|
- vacuum_firefox_sqlite
|
71
|
-
-
|
71
|
+
- sedit
|
72
72
|
extensions: []
|
73
73
|
extra_rdoc_files:
|
74
74
|
- README.rdoc
|
75
|
+
- lib/utils/finder.rb
|
76
|
+
- lib/utils/version.rb
|
77
|
+
- lib/utils/find.rb
|
75
78
|
- lib/utils/config.rb
|
76
79
|
- lib/utils/editor.rb
|
77
|
-
- lib/utils/file_xt.rb
|
78
|
-
- lib/utils/find.rb
|
79
|
-
- lib/utils/finder.rb
|
80
80
|
- lib/utils/grepper.rb
|
81
|
-
- lib/utils/
|
81
|
+
- lib/utils/file_xt.rb
|
82
82
|
- lib/utils/md5.rb
|
83
83
|
- lib/utils/patterns.rb
|
84
|
-
- lib/utils/version.rb
|
85
84
|
- lib/utils.rb
|
86
85
|
files:
|
87
86
|
- .gitignore
|
@@ -165,7 +164,6 @@ files:
|
|
165
164
|
- lib/utils/find.rb
|
166
165
|
- lib/utils/finder.rb
|
167
166
|
- lib/utils/grepper.rb
|
168
|
-
- lib/utils/lines_file.rb
|
169
167
|
- lib/utils/md5.rb
|
170
168
|
- lib/utils/patterns.rb
|
171
169
|
- lib/utils/version.rb
|
@@ -194,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
192
|
version: '0'
|
195
193
|
requirements: []
|
196
194
|
rubyforge_project:
|
197
|
-
rubygems_version: 1.8.
|
195
|
+
rubygems_version: 1.8.7
|
198
196
|
signing_key:
|
199
197
|
specification_version: 3
|
200
198
|
summary: Some useful command line utilities
|
data/lib/utils/lines_file.rb
DELETED
@@ -1,122 +0,0 @@
|
|
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
|