dorian-sort-yaml 0.4.3 → 1.1.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/sort-yaml +9 -16
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d501bc7eb807f62c20d8bca1bf810a597835881383a8b34cd1495ffa904d2d6
4
- data.tar.gz: 49ba17b0700c3dff246e972a477c49f4e98ff70a1b1b6043065f7c080a9437c3
3
+ metadata.gz: ecd620fda18c13f5259de5b888fd7e8bd915075a9fa6ffd9db735ce194ebabf7
4
+ data.tar.gz: 7bfaa23e7988fe684afd5377b6b43086e0513623e270dd86526454a3ae7a0433
5
5
  SHA512:
6
- metadata.gz: '034208e4ab6e7d5ef8ec1ba1cdfbb59c65127fc6e57aa966c87ff2318db0b395fee52bf67f187ddd24aa45bbbc6eb927617bd9a6f75f1f4d590b3b50b0f01299'
7
- data.tar.gz: f29540b3d52b9cbc6065ff1b38fd39083a27ab0f2eec6ded316a5c95b42ba3fda9c7d3888923b577e1f8eefade6062c6e8031d7412b613df4fb9144d2d3781c3
6
+ metadata.gz: aefd685a76575de475d3ef2184a3dd556aada6630f7370e1aeb849d2fae449b4e3e5aa77c9f776622c4d3be5ff3018312eb0997545713a7bbb11c9f9227f59a3
7
+ data.tar.gz: 0baaa88381aef2c2b9f8a7d218a0dde24190dd8ea3e5a52a2b395262da27d34af74470eccc9bade54699459c9972f5658437fbd711d4c3688e0c459024622874
data/bin/sort-yaml CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "dorian/arguments"
4
5
  require "yaml"
5
6
 
6
7
  def sort_yaml(data)
@@ -16,23 +17,15 @@ def sort_yaml(data)
16
17
  end
17
18
  end
18
19
 
19
- if ARGV[0] == "--help" || ARGV[0] == "-h"
20
- puts "USAGE: sort-yaml FILES..."
21
- puts "USAGE: ... | sort-yaml"
22
- exit
23
- end
24
-
25
- inputs = ARGV
20
+ parsed = Dorian::Arguments.parse(version: { alias: :v }, help: { alias: :h })
26
21
 
27
- if inputs.empty?
28
- inputs = $stdin.each_line.to_a
22
+ abort parsed.help if parsed.options.help
29
23
 
30
- inputs =
31
- (File.exist?(inputs.first.strip) ? inputs.map(&:strip) : [inputs.join])
24
+ if parsed.options.version
25
+ abort File.read(File.expand_path("../VERSION", __dir__))
32
26
  end
33
27
 
34
- inputs.each do |input|
35
- content = File.exist?(input) ? File.read(input) : input
36
- yaml = sort_yaml(YAML.safe_load(content)).to_yaml
37
- File.exist?(input) ? File.write(input, yaml) : puts(yaml)
38
- end
28
+ inputs = parsed.arguments + parsed.files.map { |file| File.read(file) }
29
+ inputs = [$stdin.each_line.to_a.map(&:strip).join("\n")] if inputs.empty?
30
+
31
+ inputs.each { |input| puts sort_yaml(YAML.safe_load(input)).to_yaml }
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-sort-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 1.1.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-22 00:00:00.000000000 Z
11
+ date: 2024-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: yaml
14
+ name: dorian-arguments
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dorian-arguments
28
+ name: yaml
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -57,9 +57,9 @@ require_paths:
57
57
  - lib
58
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '='
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: 3.3.4
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="