patman 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +2 -2
- data/doc/Patman.html +539 -431
- data/doc/Patman/PatmanError.html +44 -43
- data/doc/Patman/PatmanFileError.html +44 -43
- data/doc/Patman/PatmanSearchError.html +44 -43
- data/doc/_index.html +28 -31
- data/doc/class_list.html +24 -31
- data/doc/css/full_list.css +32 -31
- data/doc/css/style.css +250 -93
- data/doc/file.CHANGELOG.html +33 -32
- data/doc/file.README.html +34 -36
- data/doc/file_list.html +29 -31
- data/doc/frames.html +7 -16
- data/doc/index.html +34 -36
- data/doc/js/app.js +147 -74
- data/doc/js/full_list.js +170 -135
- data/doc/method_list.html +241 -155
- data/doc/top-level-namespace.html +34 -36
- data/lib/patman.rb +32 -5
- data/lib/version.rb +1 -1
- data/test/test_patman.rb +24 -10
- metadata +3 -4
@@ -1,12 +1,12 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
4
3
|
<head>
|
5
|
-
<meta
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
6
|
<title>
|
7
7
|
Top Level Namespace
|
8
8
|
|
9
|
-
— Documentation by YARD 0.
|
9
|
+
— Documentation by YARD 0.9.16
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -15,9 +15,8 @@
|
|
15
15
|
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
16
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
|
-
|
18
|
+
pathId = "";
|
19
19
|
relpath = '';
|
20
|
-
framesUrl = "frames.html#!top-level-namespace.html";
|
21
20
|
</script>
|
22
21
|
|
23
22
|
|
@@ -28,58 +27,56 @@
|
|
28
27
|
|
29
28
|
</head>
|
30
29
|
<body>
|
31
|
-
<div
|
32
|
-
<
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
33
38
|
|
34
39
|
<a href="_index.html">Index</a> »
|
35
40
|
|
36
41
|
|
37
42
|
<span class="title">Top Level Namespace</span>
|
38
43
|
|
39
|
-
|
40
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
44
|
</div>
|
42
45
|
|
43
|
-
|
46
|
+
<div id="search">
|
44
47
|
|
45
48
|
<a class="full_list_link" id="class_list_link"
|
46
49
|
href="class_list.html">
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
</a>
|
54
|
-
|
55
|
-
<a class="full_list_link" id="file_list_link"
|
56
|
-
href="file_list.html">
|
57
|
-
File List
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
58
56
|
</a>
|
59
57
|
|
60
58
|
</div>
|
61
|
-
|
62
|
-
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
<div id="content"><h1>Top Level Namespace
|
62
|
+
<div id="content"><h1>Top Level Namespace
|
67
63
|
|
68
64
|
|
69
65
|
|
70
66
|
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
71
69
|
|
72
|
-
<dl class="box">
|
73
70
|
|
74
71
|
|
75
|
-
|
76
72
|
|
77
|
-
|
78
73
|
|
79
74
|
|
75
|
+
|
80
76
|
|
81
|
-
|
82
|
-
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
83
80
|
|
84
81
|
<h2>Defined Under Namespace</h2>
|
85
82
|
<p class="children">
|
@@ -102,11 +99,12 @@
|
|
102
99
|
|
103
100
|
</div>
|
104
101
|
|
105
|
-
|
106
|
-
Generated on
|
102
|
+
<div id="footer">
|
103
|
+
Generated on Sat Oct 20 17:33:29 2018 by
|
107
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
|
-
0.
|
105
|
+
0.9.16 (ruby-2.5.1).
|
109
106
|
</div>
|
110
107
|
|
108
|
+
</div>
|
111
109
|
</body>
|
112
110
|
</html>
|
data/lib/patman.rb
CHANGED
@@ -22,6 +22,25 @@ class Patman
|
|
22
22
|
p
|
23
23
|
end
|
24
24
|
|
25
|
+
|
26
|
+
# Edit file and also create it if it does not exist.
|
27
|
+
#
|
28
|
+
# If block is given, a file will be opened and block with Patman
|
29
|
+
# commands will be executed for it. Otherwise a Patman object is
|
30
|
+
# returned for further use.
|
31
|
+
def Patman.edit( file, &blk )
|
32
|
+
p = Patman.new( file )
|
33
|
+
if File.exist?( file )
|
34
|
+
p.send( :read, file )
|
35
|
+
end
|
36
|
+
if block_given?
|
37
|
+
p.instance_exec( &blk )
|
38
|
+
p.send( :write )
|
39
|
+
else
|
40
|
+
p
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
25
44
|
# Create {Patman} object.
|
26
45
|
def initialize( file )
|
27
46
|
@file = file
|
@@ -34,9 +53,9 @@ class Patman
|
|
34
53
|
end
|
35
54
|
|
36
55
|
# Read file in.
|
37
|
-
def read
|
38
|
-
if File.exist?(
|
39
|
-
@lines = read_clean(
|
56
|
+
def read( file = @file )
|
57
|
+
if File.exist?( file )
|
58
|
+
@lines = read_clean( file )
|
40
59
|
else
|
41
60
|
raise PatmanFileError
|
42
61
|
end
|
@@ -45,7 +64,15 @@ class Patman
|
|
45
64
|
# Write {Patman} content to disk.
|
46
65
|
def write( file = @file )
|
47
66
|
return unless @edited
|
67
|
+
|
68
|
+
file_dir = File.dirname( file )
|
69
|
+
unless File.exist?( file_dir )
|
70
|
+
require 'fileutils'
|
71
|
+
FileUtils.mkdir_p( file_dir )
|
72
|
+
end
|
73
|
+
|
48
74
|
fh = File.open( file, 'w' )
|
75
|
+
|
49
76
|
@lines.each do |line|
|
50
77
|
if line
|
51
78
|
fh.puts line
|
@@ -168,7 +195,7 @@ class Patman
|
|
168
195
|
@edited = true
|
169
196
|
if text.kind_of? Array
|
170
197
|
line = @line
|
171
|
-
step -1
|
198
|
+
step( -1 )
|
172
199
|
text.each do |txt|
|
173
200
|
append( txt )
|
174
201
|
end
|
@@ -205,7 +232,7 @@ class Patman
|
|
205
232
|
# Insert file to current position.
|
206
233
|
def insertfile( file )
|
207
234
|
@edited = true
|
208
|
-
step -1
|
235
|
+
step( -1 )
|
209
236
|
read_clean( file ).each do |line|
|
210
237
|
append line
|
211
238
|
end
|
data/lib/version.rb
CHANGED
data/test/test_patman.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test/unit'
|
|
2
2
|
require 'patman'
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
|
5
|
+
require 'byebug'
|
6
6
|
|
7
7
|
|
8
8
|
class PatmanTest < Test::Unit::TestCase
|
@@ -22,9 +22,9 @@ class PatmanTest < Test::Unit::TestCase
|
|
22
22
|
# ------------------------------------------------------------
|
23
23
|
# Test diff jumping commands and their return values:
|
24
24
|
r.step; assert_equal( r.line, 2 )
|
25
|
-
r.step -1;
|
26
|
-
|
27
|
-
|
25
|
+
r.step( -1); assert_equal( r.line, 1 )
|
26
|
+
assert_equal( r.step.line, 2 )
|
27
|
+
assert_equal( r.step(-1).line, 1 )
|
28
28
|
r.line( 5 ); assert_equal( r.line, 5 )
|
29
29
|
r.firstline; assert_equal( r.line, 1 )
|
30
30
|
r.lastline; assert_equal( r.line, 10 )
|
@@ -122,20 +122,20 @@ class PatmanTest < Test::Unit::TestCase
|
|
122
122
|
assert_equal( r.firstline.insertfile( ifile ).length, 2*len )
|
123
123
|
assert_equal( r.lastline.step.insertfile( ifile ).length, 3*len )
|
124
124
|
|
125
|
-
r.do_all do |
|
126
|
-
|
125
|
+
r.do_all do |p|
|
126
|
+
p.sub( /Line/, 'foobar' )
|
127
127
|
end
|
128
128
|
assert_equal( r.get_range(5,6), [ 'foobar 5', 'foobar 6' ] )
|
129
129
|
r.blockline
|
130
130
|
assert_equal( r.line, 30 )
|
131
131
|
|
132
|
-
r.do_range( 1, r.length-1 ) do |
|
133
|
-
|
132
|
+
r.do_range( 1, r.length-1 ) do |p|
|
133
|
+
p.sub( /foobar/, 'Line' )
|
134
134
|
end
|
135
135
|
assert_equal( r.get_range(5,6), [ 'Line 5', 'Line 6' ] )
|
136
136
|
|
137
|
-
r.do_for( 1, r.length-1 ) do |
|
138
|
-
|
137
|
+
r.do_for( 1, r.length-1 ) do |p|
|
138
|
+
p.sub( /Line/, 'foobar' )
|
139
139
|
end
|
140
140
|
assert_equal( r.get_range(5,6), [ 'foobar 5', 'foobar 6' ] )
|
141
141
|
|
@@ -170,6 +170,20 @@ class PatmanTest < Test::Unit::TestCase
|
|
170
170
|
|
171
171
|
FileUtils.rm_f ofile
|
172
172
|
|
173
|
+
|
174
|
+
# ------------------------------------------------------------
|
175
|
+
# Test Patman.edit:
|
176
|
+
|
177
|
+
ofile = 'test/output/test_file1.txt'
|
178
|
+
Patman.edit( ofile ) do
|
179
|
+
insert 'foobar'
|
180
|
+
end
|
181
|
+
|
182
|
+
p = Patman.edit( ofile )
|
183
|
+
assert_equal( p.get, 'foobar' )
|
184
|
+
|
185
|
+
FileUtils.rm_f ofile
|
186
|
+
|
173
187
|
end
|
174
188
|
|
175
189
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tero Isannainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Patman (Patch Manipulator) is a library for text file patching.
|
14
14
|
email: tero.isannainen@gmail.com
|
@@ -64,9 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
66
|
rubyforge_project:
|
67
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.7.6
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Patman is used to patch text files.
|
71
71
|
test_files: []
|
72
|
-
has_rdoc:
|