dorian-sort-yaml 0.4.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/sort-yaml +9 -16
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96f2a0af5f86899f818b8087a8a6e25e5ac3edc6fe0d0d9488acb26916f6338f
4
- data.tar.gz: 732639d58d4653a083abb7b07327aaab847052ae8a31ca9ba868b392bf4d280d
3
+ metadata.gz: 1ff09d214a4ef91af00cbe29f0060e184929d0445807689747cda209d0dc2b0c
4
+ data.tar.gz: 9c7e55f68a02bddf194eb7d23b4a095f2c0e636965063f0f5b22f32cc683ccbb
5
5
  SHA512:
6
- metadata.gz: 7c9330d84458bf0c60c615b5a6159310e436865f61eec2905c2f1f65577222b6ce2f210adc8a1b4d4aa6992b308da8e2d0d46069308d4e061e74ad27fa3d27dd
7
- data.tar.gz: 8bb01a3871762e64fadeba88ad8eef33815ca0ccc743e6ce65fe2a4cc4eda274b86f4c89d761a6e47c5ba698a61f8576a63859dd2003c316dd5cdfb55a114246
6
+ metadata.gz: afc71443f61d6b15e4ef260c03676c6c91a0dbee8aef9e152ef1d84ba25f0f63c11ef78c80be4d4f2da2444154d6d596c8142413ed0a079359091c0afd8ed898
7
+ data.tar.gz: 50ebae0ce7d628d5b0fa86aa9bf7d885eabef86b7a8c9bec054f0af9110c399579a24d007231af6c117ead47afa72a5eba4ff6669fa4a31ea3c1995f263f9c49
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", __FILE__))
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-sort-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.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
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dorian-arguments
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: sorts yaml
28
42
  email: dorian@dorianmarie.com
29
43
  executables: