regex_replace 1.0.0 → 1.0.1

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.
Files changed (5) hide show
  1. data/History.txt +10 -0
  2. data/README.txt +3 -1
  3. data/bin/rr +14 -4
  4. data/lib/rr.rb +1 -1
  5. metadata +5 -4
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ === 1.0.1 / 2008-06-29
2
+
3
+ * 1 minor enhancement
4
+
5
+ * I found that usage quite often has the empty string in the replace portion
6
+ so I added a special usage (for pipes) that defaults the replacement
7
+ to the empty string. Therefore if you're using TextMate or something, you
8
+ can filter the docment on a regex, stripping out whatever matches.
9
+
10
+
1
11
  === 1.0.0 / 2008-05-31
2
12
 
3
13
  * 1 major enhancement
data/README.txt CHANGED
@@ -12,7 +12,9 @@ to appear in the replacement text.
12
12
 
13
13
  <pre>usage: rr [options] find replace [filenames]
14
14
  rr [options] s/find/replace/ [filenames]
15
+ rr [options] find
15
16
  find - a regular expression to be run on the entire file as one string
17
+ the final usage defaults the replacement to the empty string
16
18
  replace - replacement text, \1-\9 and metachars (\n, etc.) are allowed
17
19
  filenames - names of the input files to be parsed, if blank uses STDIN
18
20
 
@@ -45,7 +47,7 @@ rr "(.)\n" "\1\1\n\n" file
45
47
 
46
48
  == INSTALL:
47
49
 
48
- * sudo gem install rr
50
+ * sudo gem install regex_replace
49
51
 
50
52
  == LICENSE:
51
53
 
data/bin/rr CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Start Date: Sunday December 2, 2007 (v0.9)
3
- # Most Recent Update: Saturday January 26, 2008
4
- # Current Version: 1.0
3
+ # Most Recent Update: Sunday June 29, 2008 (v1.1)
4
+ # Current Version: 1.1
5
5
  # Author: Joseph Pecoraro
6
6
  # Contact: joepeck02@gmail.com
7
7
  # Decription: Default behavior is a multi-line search and replace utility that
@@ -19,7 +19,10 @@ $program_name = $0.split(/\//).last
19
19
  usage = <<USAGE
20
20
  usage: #{$program_name} [options] find replace [filenames]
21
21
  #{$program_name} [options] s/find/replace/ [filenames]
22
+ #{$program_name} [options] find
23
+
22
24
  find - a regular expression to be run on the entire file as one string
25
+ the final usage defaults the replacement to the empty string
23
26
  replace - replacement text, \\1-\\9 and metachars (\\n, etc.) are allowed
24
27
  filenames - names of the input files to be parsed, if blank uses STDIN
25
28
 
@@ -79,14 +82,18 @@ if ARGV.first =~ /^s\/(.*)?\/(.*)?\/(\w*)?$/
79
82
  find_str = $1
80
83
  replace = $2
81
84
  first_filename = 1
82
- ARGV << nil if ARGV.size == 1
85
+
86
+ # Check for 3rd usage: rr [options] find
87
+ elsif ARGV.size == 1
88
+ find_str = ARGV[0]
89
+ replace = ''
90
+ first_filename = 1
83
91
 
84
92
  # Not Quick Mode, Arguments are seperate on the cmdline
85
93
  elsif ARGV.size >= 2
86
94
  find_str = ARGV[0]
87
95
  replace = ARGV[1].dup
88
96
  first_filename = 2
89
- ARGV << nil if ARGV.size == 2
90
97
 
91
98
  # User is allowed to wrap the find regex in /'s (this removes them)
92
99
  find_str = find_str[1..(find_str.length-2)] if find_str =~ /^\/.*?\/$/
@@ -97,6 +104,9 @@ else
97
104
  exit 1
98
105
  end
99
106
 
107
+ # If there are no "files" put a nil on the end of ARGV to mean STDIN
108
+ ARGV << nil if ARGV.size == first_filename
109
+
100
110
  # Make find_str into a Regexp object
101
111
  if case_sensitive
102
112
  find = Regexp.new( find_str )
data/lib/rr.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Rr
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regex_replace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Pecoraro
@@ -9,17 +9,18 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-31 00:00:00 -04:00
12
+ date: 2008-06-29 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hoe
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
20
21
  - - ">="
21
22
  - !ruby/object:Gem::Version
22
- version: 1.5.3
23
+ version: 1.6.0
23
24
  version:
24
25
  description: A multi-line search and replace utility that uses Ruby regular expressions for searching and allows back references to captured groups from the pattern to appear in the replacement text.
25
26
  email:
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  requirements: []
64
65
 
65
66
  rubyforge_project: bogojoker
66
- rubygems_version: 1.1.1
67
+ rubygems_version: 1.2.0
67
68
  signing_key:
68
69
  specification_version: 2
69
70
  summary: A multi-line search and replace utility that uses Ruby regular expressions for searching and allows back references to captured groups from the pattern to appear in the replacement text.