dorian-replace 0.3.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/replace +15 -2
- metadata +3 -4
- data/lib/dorian/replace.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a72f20d8ea3001659ea384a2c204c516f066c1a5bbea0b25df947e10213cc4d9
|
4
|
+
data.tar.gz: 8be646866b17591e8d85bd6be8f42ab9337a4f555cfee687153deae86aaf1183
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99389435694049e7e983a600f66875fe5f9f573ffbe69f79e7f57eb370e6649be5ef94da22be40e529b420643908b6bea3128ca6a2dcd85431e3310eb70531d8
|
7
|
+
data.tar.gz: 91131d84a61f34ad2906f2fd9073f95b40e620511d6fa2a7e0de42ff2834ac1d6c6e4f63b7d804764e3c19c0eb230879a781eb888237007938cec33b74525022
|
data/bin/replace
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
if ARGV.size < 2 || ARGV[0] == "--help" || ARGV[0] == "-h"
|
5
|
+
puts "USAGE: replace FROM TO FILES..."
|
6
|
+
puts "USAGE: ... | replace FROM TO"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
from = ARGV[0]
|
11
|
+
to = ARGV[1]
|
12
|
+
files = (ARGV.size > 2) ? ARGV[2..] : $stdin.each_line.to_a.map(&:strip)
|
13
|
+
|
14
|
+
files.each do |file|
|
15
|
+
next if File.directory?(file)
|
16
|
+
|
17
|
+
File.write(file, File.read(file).gsub(from, to))
|
18
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorian-replace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Replace some string with some other string from the files provided
|
15
15
|
|
16
16
|
e.g. `replace "cool" "coolest" *.md`
|
17
|
-
email: dorian@dorianmarie.
|
17
|
+
email: dorian@dorianmarie.com
|
18
18
|
executables:
|
19
19
|
- replace
|
20
20
|
extensions: []
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
23
|
- bin/replace
|
24
|
-
- lib/dorian/replace.rb
|
25
24
|
homepage: https://github.com/dorianmariecom/replace
|
26
25
|
licenses:
|
27
26
|
- MIT
|
data/lib/dorian/replace.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Dorian
|
4
|
-
class Replace
|
5
|
-
def self.run
|
6
|
-
if ARGV.size < 2 || ARGV[0] == "--help" || ARGV[0] == "-h"
|
7
|
-
puts "USAGE: replace FROM TO FILES..."
|
8
|
-
puts "USAGE: ... | replace FROM TO"
|
9
|
-
exit
|
10
|
-
end
|
11
|
-
|
12
|
-
from = ARGV[0]
|
13
|
-
to = ARGV[1]
|
14
|
-
files = (ARGV.size > 2) ? ARGV[2..] : $stdin.each_line.to_a.map(&:strip)
|
15
|
-
|
16
|
-
files.each do |file|
|
17
|
-
next if File.directory?(file)
|
18
|
-
|
19
|
-
File.write(file, File.read(file).gsub(from, to))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|