dorian-replace 0.5.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/replace +10 -8
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d904cf09301e987c840243017a5631ac6c8cc7d2eec2dad5680f58c3c011164
|
4
|
+
data.tar.gz: 9d8025f2bbc88ad4b583175cc331209ad4bbcbf4d60833a6ba469e312ed28398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aade7c1848c4607cd93925aaa12bcc01082a1a732c5ea8cd78d3857c400b883bd173132d1aca12df5a124beaffaab421729b6a0c09749a2c257e9607d22826f5
|
7
|
+
data.tar.gz: 4f9170f518037280bc7b5033a1b43faf2271d659c406c6b6e67779bc2c5739ccc5e5720ab8fe3b8466dc4c3454e8842e39230d38b7123164578e04fbdf60d3f2
|
data/bin/replace
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
require "dorian/arguments"
|
5
|
+
|
6
|
+
parsed = Dorian::Arguments.parse(version: { alias: :v }, help: { alias: :h })
|
7
|
+
|
8
|
+
abort parsed.help if parsed.options.help
|
9
|
+
|
10
|
+
if parsed.options.version
|
11
|
+
abort File.read(File.expand_path("../../VERSION", __FILE__))
|
8
12
|
end
|
9
13
|
|
10
|
-
from =
|
11
|
-
|
12
|
-
files = ARGV.size > 2 ? ARGV[2..] : $stdin.each_line.to_a.map(&:strip)
|
14
|
+
from, to = parsed.arguments
|
15
|
+
files = parsed.files.any? ? parsed.files : $stdin.each_line.to_a.map(&:strip)
|
13
16
|
|
14
17
|
files.each do |file|
|
15
18
|
next if File.directory?(file)
|
16
|
-
|
17
19
|
File.write(file, File.read(file).gsub(from, to))
|
18
20
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorian-replace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
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-08-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dorian-arguments
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: replaces string with other string from files
|
14
28
|
email: dorian@dorianmarie.com
|
15
29
|
executables:
|