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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/replace +10 -8
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 295c5cd5b64c9e8ecd93f80ee8342e6a84a10aa8f7d73cfde6cc0efe6d0af74f
4
- data.tar.gz: cfa405f0067b3149921b96f1cefc496bece9d1d3e1e361394fb1b3934d1251c5
3
+ metadata.gz: 1d904cf09301e987c840243017a5631ac6c8cc7d2eec2dad5680f58c3c011164
4
+ data.tar.gz: 9d8025f2bbc88ad4b583175cc331209ad4bbcbf4d60833a6ba469e312ed28398
5
5
  SHA512:
6
- metadata.gz: 9eda7d5f9f6281e12ff5b37fe44e7b2473a5f547c0d53bbc161e14294a9e82d0e28097b3c7f7105e6ade77a7a09b13ce4f1d4ff947af540075918d00a6cc2915
7
- data.tar.gz: 16eee391e0e74a8fbcc2a34ff7f76b6e32272cc18da6b6635bb9497a83b53cb1e3e5d531d8b4d26b6fa1382314fea9dc02b35ec3364faeda35829a7d0709a0aa
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
- 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
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 = ARGV[0]
11
- to = ARGV[1]
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.5.2
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-18 00:00:00.000000000 Z
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: