process_settings 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ace753f727c3aea91291d906951ff86da6750d6aa4b0db1022ad6155dce42dc
4
- data.tar.gz: 1081a5ba75c69f17f6ad308125a748751d381b7289b27e63a0e9130fd96db0bd
3
+ metadata.gz: 7639f6a88f14fbfc52dabbac2b771712cb7fda441683eabc23bdabdd2c9d5492
4
+ data.tar.gz: 5f8f41ad06f23db45c31a6c91246252a2a18b9055f1317dcf7e32f84cb6be6eb
5
5
  SHA512:
6
- metadata.gz: dbfbe4d945aa9d67b02862be7f5905afd36b0c0c1c5fd1f2054d6b263f6ccdaf878bbc6521361c4454183c9d00f882947572933aa6c52850a8c10e3b32839510
7
- data.tar.gz: 6e2341fca852024f9d0a518159c6367264376fb760d3efde1904546cc75a40042272ad1c0c9e075b7e68f23891c5812911253f98a66f514f72992aad2324dd7b
6
+ metadata.gz: df98267ef1e0c5da02c62a37ac953e12dd4f187aa822306fccce6c2654b6963641dc682d3fbd457455461d8237be7a4eb319f16f0393d399802773ce5ce16fc2
7
+ data.tar.gz: 67419019b84fca98837ef37f09d85554052f4ef1b9a2f59185017fb9f141834d28d86228dd7b1f461a00f079234541c02c12f955e760bc7686f55a4ce90b553e
@@ -68,7 +68,7 @@ end
68
68
  def add_warning_comment(yaml, root_folder, program_name, settings_folder)
69
69
  warning_comment = <<~EOS
70
70
  #
71
- # Don't edit this file directly! It was generated by #{program_name} from the files in #{root_folder.split('/').last}/#{settings_folder}/.
71
+ # Don't edit this file directly! It was generated by #{program_name} from the files in #{root_folder.rpartition('/').last}/#{settings_folder}/.
72
72
  #
73
73
  EOS
74
74
 
@@ -96,7 +96,7 @@ system("rm -f #{tmp_output_filename}")
96
96
  File.write(tmp_output_filename, yaml_with_warning_comment)
97
97
 
98
98
  system(<<~EOS)
99
- if cmp #{tmp_output_filename} #{output_filename} --silent; then
99
+ if bundle exec diff_process_settings --silent #{tmp_output_filename} #{output_filename} ; then
100
100
  #{"echo #{options.root_folder}: unchanged;" if options.verbose}
101
101
  rm -f #{tmp_output_filename};
102
102
  else
@@ -5,18 +5,31 @@
5
5
  # A filename of - means STDIN.
6
6
 
7
7
  require 'fileutils'
8
+ require 'optparse'
9
+ require 'ostruct'
8
10
 
9
11
  PROGRAM_NAME = File.basename($PROGRAM_NAME)
10
12
 
11
- unless ARGV.size == 2
12
- puts "usage: #{PROGRAM_NAME} <path-to-combined_process_settings-A.yml> <path-to-combined_process_settings-B.yml>"
13
- exit 1
13
+ def parse_options(argv)
14
+ options = OpenStruct.new
15
+ options.silent = false
16
+ option_parser = OptionParser.new(argv) do |opt|
17
+ opt.on('-s', '--silent', 'Silent mode.') { options.silent = true }
18
+ end
19
+
20
+ if option_parser.parse! && argv.size == 2
21
+ [options, argv]
22
+ else
23
+ warn "usage: #{PROGRAM_NAME} [--silent] <path-to-combined_process_settings-A.yml> <path-to-combined_process_settings-B.yml>"
24
+ option_parser.summarize(STDERR)
25
+ exit(1)
26
+ end
14
27
  end
15
28
 
16
- path_to_combine_process_settings = ARGV[0]
29
+ options, file_args = parse_options(ARGV)
17
30
 
18
31
  input_files =
19
- ARGV.map do |path|
32
+ file_args.map do |path|
20
33
  if path == '-'
21
34
  ''
22
35
  else
@@ -34,6 +47,13 @@ system("rm -f tmp/combined_process_settings-A.yml tmp/combined_process_settings-
34
47
  system("sed '/^- meta:$/,$d' #{input_files[0]} > tmp/combined_process_settings-A.yml")
35
48
  system("sed '/^- meta:$/,$d' #{input_files[1]} > tmp/combined_process_settings-B.yml")
36
49
 
37
- system("diff -c tmp/combined_process_settings-A.yml tmp/combined_process_settings-B.yml | sed '1,3d'")
50
+ if options.silent
51
+ system("cmp --silent tmp/combined_process_settings-A.yml tmp/combined_process_settings-B.yml")
52
+ else
53
+ system("diff -c tmp/combined_process_settings-A.yml tmp/combined_process_settings-B.yml | sed '1,3d'")
54
+ end
55
+ exit_code = $?.exitstatus
38
56
 
39
57
  system("rm -f tmp/combined_process_settings-A.yml tmp/combined_process_settings-B.yml")
58
+
59
+ exit(exit_code)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProcessSettings
4
- VERSION = '0.9.0'
4
+ VERSION = '0.10.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca