patman 0.0.2 → 0.0.3

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/doc/_index.html CHANGED
@@ -125,7 +125,7 @@
125
125
  </div>
126
126
 
127
127
  <div id="footer">
128
- Generated on Sat Dec 23 16:47:41 2017 by
128
+ Generated on Tue Mar 20 20:43:44 2018 by
129
129
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
130
130
  0.8.7.6 (ruby-2.3.3).
131
131
  </div>
@@ -63,7 +63,10 @@
63
63
 
64
64
  <div id="content"><div id='filecontents'>
65
65
  <h1 id="label-Version+history">Version history</h1>
66
- <dl class="rdoc-list label-list"><dt>0.0.2
66
+ <dl class="rdoc-list label-list"><dt>0.0.3
67
+ <dd>
68
+ <p>Documentation improvements.</p>
69
+ </dd><dt>0.0.2
67
70
  <dd>
68
71
  <p>Fix: view_ln did not tolerate “%” char in the line.</p>
69
72
  </dd><dt>0.0.1
@@ -73,7 +76,7 @@
73
76
  </div></div>
74
77
 
75
78
  <div id="footer">
76
- Generated on Sat Dec 23 16:47:41 2017 by
79
+ Generated on Tue Mar 20 20:43:44 2018 by
77
80
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
78
81
  0.8.7.6 (ruby-2.3.3).
79
82
  </div>
data/doc/file.README.html CHANGED
@@ -64,21 +64,122 @@
64
64
  <div id="content"><div id='filecontents'>
65
65
  <h1 id="label-Patman">Patman</h1>
66
66
 
67
- <h2 id="label-Description">Description</h2>
68
-
69
- <p><span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> is library for text file patching. It can also be used to just
70
- extract information from files.</p>
67
+ <p><span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> (Patch Manipulator) is a library for text file patching. It can
68
+ also be used to extract information from files.</p>
71
69
 
72
70
  <h2 id="label-Documentation">Documentation</h2>
73
71
 
74
- <p>Main documentation is generated from source (See: <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span>).</p>
75
-
76
- <p>Test files in “test” directory includes multiple ways of how to use
72
+ <p>Here is a brief overview of <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span>. Please refer to API documentation for
73
+ complete view. Also refer to tests for multiple ways of how to use
77
74
  <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span>.</p>
75
+
76
+ <p>Typical <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> script opens files for editing. File is read into the
77
+ library as content line by line. User finds the place for editing either
78
+ with Regexp searches or with direct line numbers. The file content is
79
+ edited by adding, removing, or replacing lines. When all edits are done,
80
+ the updated file content is written to disk.</p>
81
+
82
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_r'>r</span> <span class='op'>=</span> <span class='const'>Patman</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>edit_me.txt</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span>
83
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_line'>line</span> <span class='int'>10</span>
84
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span>
85
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span>
86
+ </code></pre>
87
+
88
+ <p>All editing commands refer to the “current position”. Current position is
89
+ returned by “line” method. Positions refer to lines that have content. Line
90
+ numbers start from 1. If user wants append to the end of file, then user
91
+ should jump to last line, with “lastline” method, and then issue “append”.
92
+ It is also possible to jump to arbitrary lines, <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> does not prevent
93
+ this. The line positions are just used as an index to Array. For example
94
+ negative line number will refer from end towards beginning in content.</p>
95
+
96
+ <p>Position can be explicitly changed with “line”, “step”, “firstline”, or
97
+ “lastline” methods (commands). “find” changes position if the pattern is
98
+ found in selected direction. “append” changes position implicitly with
99
+ every call.</p>
100
+
101
+ <pre class="code ruby"><code class="ruby">curline = r.line
102
+ if curline &gt; 5
103
+ r.step -2
104
+ else
105
+ r.line 10</code></pre>
106
+
107
+ <p>Current line content is returned by “get” and it can be set with “set”
108
+ method. Current line content can be replaced with “sub”.</p>
109
+
110
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>...</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span>
111
+ </code></pre>
112
+
113
+ <p><span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> includes many query commands: line, lines, [], get, find,
114
+ get_range, get_for. They all return the queried item. All other methods
115
+ return <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> object itself, hence many <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> methods can be
116
+ “chained”.</p>
117
+
118
+ <pre class="code ruby"><code class="ruby"><span class='const'>Patman</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>edit_me.txt</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_line'>line</span><span class='lparen'>(</span> <span class='int'>2</span> <span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span>
119
+ </code></pre>
120
+
121
+ <p>Block commands perform commands over a range of lines. Block commands are:
122
+ do_all, do_range, and do_for. These retain the original position, but the
123
+ final position is stored (actually one after) and it can be activated by
124
+ calling “blockline” method, i.e. <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> jumps to that line.</p>
125
+
126
+ <p>Block commands take a pre-defined number of lines to process. Note that, if
127
+ user deletes lines in block action, the outcome is most likely not what the
128
+ user expects.</p>
129
+
130
+ <p>Mark feature can be used if user wants to return back to original position
131
+ after changes. Mark features includes a “default mark” and “named marks”.</p>
132
+
133
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_mark'>mark</span> <span class='symbol'>:origin</span>
134
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_step'>step</span> <span class='int'>10</span>
135
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span>
136
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_unmark'>unmark</span> <span class='symbol'>:origin</span>
137
+ </code></pre>
138
+
139
+ <p>For debugging purposes it is good to see line content. “view” and “view_ln”
140
+ can be used to view line content either without or with line numbers
141
+ respectively.</p>
142
+
143
+ <p>No changes are stored to disk unless “write” is called. If user want to
144
+ create a “backup” of the edited file, the “copy” method can be used before
145
+ any editing commands have been applied.</p>
146
+
147
+ <h2 id="label-Example+session">Example session</h2>
148
+
149
+ <pre class="code ruby"><code class="ruby"><span class='comment'># Open file for reading.
150
+ </span><span class='id identifier rubyid_r'>r</span> <span class='op'>=</span> <span class='const'>Patman</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>report.txt</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span>
151
+
152
+ <span class='comment'># Backup file and find next line with &quot;error&quot;, i.e. method chaining.
153
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_copy'>copy</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>report.txt.org</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>error</span><span class='regexp_end'>/</span></span> <span class='rparen'>)</span>
154
+
155
+ <span class='comment'># Collect some lines.
156
+ </span><span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='int'>4</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
157
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_ref'>ref</span><span class='lparen'>(</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_line'>line</span> <span class='op'>+</span> <span class='id identifier rubyid_i'>i</span> <span class='rparen'>)</span>
158
+ <span class='kw'>end</span>
159
+
160
+ <span class='comment'># Duplicate the lines collected.
161
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_insert'>insert</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span> <span class='rparen'>)</span>
162
+
163
+ <span class='comment'># Move to line 9.
164
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_line'>line</span> <span class='int'>9</span>
165
+
166
+ <span class='comment'># Append &quot; Hello&quot; to the end of current line.
167
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> Hello</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span>
168
+
169
+ <span class='comment'># Save changes.
170
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span>
171
+ </code></pre>
172
+
173
+ <h2 id="label-Testing+">Testing </h2>
174
+
175
+ <p>Tests are executed with:</p>
176
+
177
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_test'>test</span>
178
+ </code></pre>
78
179
  </div></div>
79
180
 
80
181
  <div id="footer">
81
- Generated on Sat Dec 23 16:47:41 2017 by
182
+ Generated on Tue Mar 20 20:43:44 2018 by
82
183
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
83
184
  0.8.7.6 (ruby-2.3.3).
84
185
  </div>
data/doc/index.html CHANGED
@@ -64,21 +64,122 @@
64
64
  <div id="content"><div id='filecontents'>
65
65
  <h1 id="label-Patman">Patman</h1>
66
66
 
67
- <h2 id="label-Description">Description</h2>
68
-
69
- <p><span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> is library for text file patching. It can also be used to just
70
- extract information from files.</p>
67
+ <p><span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> (Patch Manipulator) is a library for text file patching. It can
68
+ also be used to extract information from files.</p>
71
69
 
72
70
  <h2 id="label-Documentation">Documentation</h2>
73
71
 
74
- <p>Main documentation is generated from source (See: <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span>).</p>
75
-
76
- <p>Test files in “test” directory includes multiple ways of how to use
72
+ <p>Here is a brief overview of <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span>. Please refer to API documentation for
73
+ complete view. Also refer to tests for multiple ways of how to use
77
74
  <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span>.</p>
75
+
76
+ <p>Typical <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> script opens files for editing. File is read into the
77
+ library as content line by line. User finds the place for editing either
78
+ with Regexp searches or with direct line numbers. The file content is
79
+ edited by adding, removing, or replacing lines. When all edits are done,
80
+ the updated file content is written to disk.</p>
81
+
82
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_r'>r</span> <span class='op'>=</span> <span class='const'>Patman</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>edit_me.txt</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span>
83
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_line'>line</span> <span class='int'>10</span>
84
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span>
85
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span>
86
+ </code></pre>
87
+
88
+ <p>All editing commands refer to the “current position”. Current position is
89
+ returned by “line” method. Positions refer to lines that have content. Line
90
+ numbers start from 1. If user wants append to the end of file, then user
91
+ should jump to last line, with “lastline” method, and then issue “append”.
92
+ It is also possible to jump to arbitrary lines, <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> does not prevent
93
+ this. The line positions are just used as an index to Array. For example
94
+ negative line number will refer from end towards beginning in content.</p>
95
+
96
+ <p>Position can be explicitly changed with “line”, “step”, “firstline”, or
97
+ “lastline” methods (commands). “find” changes position if the pattern is
98
+ found in selected direction. “append” changes position implicitly with
99
+ every call.</p>
100
+
101
+ <pre class="code ruby"><code class="ruby">curline = r.line
102
+ if curline &gt; 5
103
+ r.step -2
104
+ else
105
+ r.line 10</code></pre>
106
+
107
+ <p>Current line content is returned by “get” and it can be set with “set”
108
+ method. Current line content can be replaced with “sub”.</p>
109
+
110
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>...</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span>
111
+ </code></pre>
112
+
113
+ <p><span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> includes many query commands: line, lines, [], get, find,
114
+ get_range, get_for. They all return the queried item. All other methods
115
+ return <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> object itself, hence many <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> methods can be
116
+ “chained”.</p>
117
+
118
+ <pre class="code ruby"><code class="ruby"><span class='const'>Patman</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>edit_me.txt</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_line'>line</span><span class='lparen'>(</span> <span class='int'>2</span> <span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span>
119
+ </code></pre>
120
+
121
+ <p>Block commands perform commands over a range of lines. Block commands are:
122
+ do_all, do_range, and do_for. These retain the original position, but the
123
+ final position is stored (actually one after) and it can be activated by
124
+ calling “blockline” method, i.e. <span class='object_link'><a href="Patman.html" title="Patman (class)">Patman</a></span> jumps to that line.</p>
125
+
126
+ <p>Block commands take a pre-defined number of lines to process. Note that, if
127
+ user deletes lines in block action, the outcome is most likely not what the
128
+ user expects.</p>
129
+
130
+ <p>Mark feature can be used if user wants to return back to original position
131
+ after changes. Mark features includes a “default mark” and “named marks”.</p>
132
+
133
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_mark'>mark</span> <span class='symbol'>:origin</span>
134
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_step'>step</span> <span class='int'>10</span>
135
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span>
136
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_unmark'>unmark</span> <span class='symbol'>:origin</span>
137
+ </code></pre>
138
+
139
+ <p>For debugging purposes it is good to see line content. “view” and “view_ln”
140
+ can be used to view line content either without or with line numbers
141
+ respectively.</p>
142
+
143
+ <p>No changes are stored to disk unless “write” is called. If user want to
144
+ create a “backup” of the edited file, the “copy” method can be used before
145
+ any editing commands have been applied.</p>
146
+
147
+ <h2 id="label-Example+session">Example session</h2>
148
+
149
+ <pre class="code ruby"><code class="ruby"><span class='comment'># Open file for reading.
150
+ </span><span class='id identifier rubyid_r'>r</span> <span class='op'>=</span> <span class='const'>Patman</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>report.txt</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span>
151
+
152
+ <span class='comment'># Backup file and find next line with &quot;error&quot;, i.e. method chaining.
153
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_copy'>copy</span><span class='lparen'>(</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>report.txt.org</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>error</span><span class='regexp_end'>/</span></span> <span class='rparen'>)</span>
154
+
155
+ <span class='comment'># Collect some lines.
156
+ </span><span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='int'>4</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
157
+ <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_ref'>ref</span><span class='lparen'>(</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_line'>line</span> <span class='op'>+</span> <span class='id identifier rubyid_i'>i</span> <span class='rparen'>)</span>
158
+ <span class='kw'>end</span>
159
+
160
+ <span class='comment'># Duplicate the lines collected.
161
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_insert'>insert</span><span class='lparen'>(</span> <span class='id identifier rubyid_data'>data</span> <span class='rparen'>)</span>
162
+
163
+ <span class='comment'># Move to line 9.
164
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_line'>line</span> <span class='int'>9</span>
165
+
166
+ <span class='comment'># Append &quot; Hello&quot; to the end of current line.
167
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> Hello</span><span class='tstring_end'>&quot;</span></span> <span class='rparen'>)</span>
168
+
169
+ <span class='comment'># Save changes.
170
+ </span><span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span>
171
+ </code></pre>
172
+
173
+ <h2 id="label-Testing+">Testing </h2>
174
+
175
+ <p>Tests are executed with:</p>
176
+
177
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_rake'>rake</span> <span class='id identifier rubyid_test'>test</span>
178
+ </code></pre>
78
179
  </div></div>
79
180
 
80
181
  <div id="footer">
81
- Generated on Sat Dec 23 16:47:41 2017 by
182
+ Generated on Tue Mar 20 20:43:44 2018 by
82
183
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
83
184
  0.8.7.6 (ruby-2.3.3).
84
185
  </div>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sat Dec 23 16:47:41 2017 by
106
+ Generated on Tue Mar 20 20:43:44 2018 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.6 (ruby-2.3.3).
109
109
  </div>
data/lib/patman.rb CHANGED
@@ -1,85 +1,5 @@
1
- # = Patman
2
- #
3
- # == Introduction
4
- #
5
1
  # {Patman} (Patch Manipulator) is a library for text file patching. It
6
2
  # can also be used to extract information from files.
7
- #
8
- # Typical {Patman} script opens a file for editing. The file is read
9
- # into the library. User finds the place for editing either with
10
- # Regexp searches or with direct line numbers. The file content is
11
- # edited by adding, removing, or replacing lines. When all edits are
12
- # done, the updated file content is written to disk.
13
- #
14
- # All editing commands refer to the "current position". Current
15
- # position is returned by "line" method. Positions refer to lines that
16
- # have content. If user wants append to the end of file, then user
17
- # should jump to last line, with "lastline" method, and then issue
18
- # "append". It is also possible to jump to arbitrary lines, {Patman}
19
- # does not prevent this. The line positions are just used as an index
20
- # to Array. For example negative line number will refer from end
21
- # towards beginning in content.
22
- #
23
- # Position can be explicitly changed with "step", "firstline", or
24
- # "lastline" methods (commands). "find" changes position if the
25
- # pattern is found in selected direction. "append" changes position
26
- # implicitly with every call.
27
- #
28
- # Current line content is returned by "get" and it can be set with
29
- # "set" method. Current line content can be replaced with "sub".
30
- #
31
- # {Patman} includes many query commands: line, lines, [], get, find,
32
- # get_range, get_for. They all return the queried item. All other
33
- # methods return {Patman} object itself, hence many {Patman} methods
34
- # can be "chained".
35
- #
36
- # Block commands perform commands over a range of lines. Block
37
- # commands are: do_all, do_range, and do_for. These retain the
38
- # original position, but the final position is stored (actually one
39
- # after) and it can be activated by calling "blockline" method.
40
- #
41
- # Block commands take a pre-defined number of lines to process. Note
42
- # that, if user deletes lines in block action, the outcome is most
43
- # likely not what the user expects.
44
- #
45
- # Mark feature can be used if user wants to return back to original
46
- # position after changes. Mark features includes a "default mark" and
47
- # "named marks".
48
- #
49
- # For debugging purposes it is good to see line content. "view" and
50
- # "view_ln" can be used to view line content either without or with
51
- # line numbers respectively.
52
- #
53
- # No changes are stored to disk unless "write" is called. If user want
54
- # to create a "backup" of the edited file, the "copy" method can be
55
- # used before any editing commands have been applied.
56
- #
57
- # == Example session
58
- #
59
- # # Open file for reading.
60
- # r = Patman.read( "report.txt" )
61
- #
62
- # # Backup file and find next line with "cpp", method chaining.
63
- # r.copy( "report.txt.org" ).find( /cpp/ )
64
- #
65
- # # Collect some lines.
66
- # data = 4.times.collect do |i|
67
- # r.ref( r.line + i )
68
- # end
69
- #
70
- # # Duplicate the lines collected.
71
- # r.insert( data )
72
- #
73
- # # Move to line 9.
74
- # r.line 9
75
- #
76
- # # Append " Hello" to the end of current line.
77
- # r.set( r.get + " Hello" )
78
- #
79
- # # Save changes.
80
- # r.write
81
- #
82
-
83
3
  class Patman
84
4
 
85
5
  # {Patman} exception base class.
@@ -465,7 +385,6 @@ class Patman
465
385
  if ln
466
386
  ln = first+1
467
387
  @lines[first...last].each do |line|
468
- # puts format( "%+4s ", "#{ln.to_s}:" ) + line.to_s
469
388
  puts "#{ln.to_s.rjust(3)}: #{line}"
470
389
  ln += 1
471
390
  end
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Patman
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  def Patman.version
4
4
  Patman::VERSION
5
5
  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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tero Isannainen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-23 00:00:00.000000000 Z
11
+ date: 2018-03-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