subtxt 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/subtxt.rb +20 -18
- data/lib/subtxt/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d6b3f5586203d5fff3aabc5fe4f96924ecbb12c6a074aa85d98e3dfdfd9e1b5
|
4
|
+
data.tar.gz: 39d19a2cd6dbd85d431cb07dc07b8f4f30d3de3d20e62aa70b218eb05ae62778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ccae6e0c113b355468421e69963c1219b157733a1244c41a0fec26969c0b349103f58c3dcf439a21f3715e54e5f57bdec9244919b4b29e902810d5211da46c9
|
7
|
+
data.tar.gz: cef008ada7bf46741b163094986b5578d4e0f620d7e4bd0f542b0381b88eae08f809d9dc8cf014c619cba4a03ced5e2de4d8471c87f44ff0c202108c72dff042
|
data/lib/subtxt.rb
CHANGED
@@ -19,22 +19,24 @@ require 'yaml'
|
|
19
19
|
"#{severity}: #{msg}\n"
|
20
20
|
end
|
21
21
|
|
22
|
-
def load_patterns
|
22
|
+
def load_patterns pfiles
|
23
|
+
files = pfiles.split(",")
|
23
24
|
records = []
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
files.each do |pfile|
|
26
|
+
File.open(pfile, "r") do |pats|
|
27
|
+
pair = {}
|
28
|
+
pats.each_line do |row|
|
29
|
+
break if row.chomp.downcase == "eof"
|
30
|
+
unless pair['fnd'] and pair['rep']
|
31
|
+
unless pair['fnd']
|
32
|
+
pair['fnd'] = row.chomp
|
33
|
+
else
|
34
|
+
pair['rep'] = row.chomp
|
35
|
+
end
|
32
36
|
else
|
33
|
-
|
37
|
+
records << pair
|
38
|
+
pair = {}
|
34
39
|
end
|
35
|
-
else
|
36
|
-
records << pair
|
37
|
-
pair = {}
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -125,7 +127,7 @@ parser = OptionParser.new do|opts|
|
|
125
127
|
\treplace pattern
|
126
128
|
\t
|
127
129
|
\t(pattern|string|content)-(to)-(find)
|
128
|
-
\t
|
130
|
+
\t\1 \2 replace
|
129
131
|
\t
|
130
132
|
\tregular expression pattern
|
131
133
|
\ttokenized substitute output
|
@@ -146,14 +148,14 @@ parser = OptionParser.new do|opts|
|
|
146
148
|
end
|
147
149
|
|
148
150
|
if ARGV[0].split("").first == "-"
|
149
|
-
opts.on('-p
|
151
|
+
opts.on('-p', '--patterns PATH[,PATH]', "Full (relative or absolute) path to a text file containing","find & replace patterns in the designated format.","REQUIRED. Ex: -p path/to/patterns.rgxp,path/to/secondary-patterns.txt") do |n|
|
150
152
|
@options[:patterns] = n;
|
151
153
|
end
|
152
154
|
else # the first arg has no leading - or --, it must be our path
|
153
155
|
@options[:patterns] = ARGV[0]
|
154
156
|
end
|
155
157
|
|
156
|
-
opts.on('-s PATH', '--source PATH', "Ingest files from this directory. Defaults to current directory
|
158
|
+
opts.on('-s PATH', '--source PATH', "Ingest files from this directory. Defaults to current directory.","\tSuperceded if a path is passed as the first argument","\t(subtxt path/to/files -p patterns.rgx). Ex: -i path/to/ingest/dir") do |n|
|
157
159
|
@options[:ingestdir] = n;
|
158
160
|
end
|
159
161
|
|
@@ -162,7 +164,7 @@ parser = OptionParser.new do|opts|
|
|
162
164
|
# @options[:recursive] = true
|
163
165
|
# end
|
164
166
|
|
165
|
-
opts.on('-f STRING', '--filext STRING', "Restrict ingested files to this extension. The first dot (.) is implied
|
167
|
+
opts.on('-f STRING', '--filext STRING', "Restrict ingested files to this extension. The first dot (.) is implied.","\tEx: -f htm") do |n|
|
166
168
|
@options[:filext] = n;
|
167
169
|
end
|
168
170
|
|
@@ -170,7 +172,7 @@ parser = OptionParser.new do|opts|
|
|
170
172
|
@options[:expath] = n;
|
171
173
|
end
|
172
174
|
|
173
|
-
opts.on('--expext STRING', "The export file\'s extension to reassign for all files. The first dot (.)
|
175
|
+
opts.on('--expext STRING', "The export file\'s extension to reassign for all files. The first dot (.)","is implied. Defaults to same extension as original. Ex: --expext htm") do |n|
|
174
176
|
@options[:expext] = n;
|
175
177
|
end
|
176
178
|
|
data/lib/subtxt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subtxt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Dominick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
description: A simple text conversion utility using regular expressions for searching
|
42
42
|
and replacing multiple strings across multiple files, for conversion projects.
|
43
43
|
email:
|
@@ -69,8 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
|
73
|
-
rubygems_version: 2.4.8
|
72
|
+
rubygems_version: 3.0.3
|
74
73
|
signing_key:
|
75
74
|
specification_version: 4
|
76
75
|
summary: A simple utility for converting multiple strings across multiple files, for
|