process_settings 0.13.0 → 0.14.0.pre.1
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 +4 -4
- data/README.md +4 -4
- data/bin/combine_process_settings +13 -13
- data/lib/process_settings/testing/helpers.rb +54 -36
- data/lib/process_settings/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0f741a9ba0e6370251e742c613fe5dba63b4c53c7dfdec8c352d00f9d2938489
         | 
| 4 | 
            +
              data.tar.gz: 69b58c50ff369b61d95814cba575fad95d8eb3404443acfb2f5d4154aea392c4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d00a43c0beffc30ab1af86edebc98adb7dc99dcc21d334dc7ba13cb146b5595e04bb905c6ce346a057ea29f2483fa729e52cdaaacb45eb743f0740fb062fdcf9
         | 
| 7 | 
            +
              data.tar.gz: 97ebec348ff8d4220668b55148cb26aa5c3934317e91d114ecbeb5e2e2c7cc081bfa695595b09ee8b9ac984b1c58955346697eda2ef78b36e6ea7bab1a8e6491
         | 
    
        data/README.md
    CHANGED
    
    | @@ -169,8 +169,8 @@ The settings YAML files are always combined in alphabetical order by file path. | |
| 169 169 |  | 
| 170 170 | 
             
            ### Testing
         | 
| 171 171 | 
             
            For testing, it is often necessary to set a specific override hash for the process_settings values to use in
         | 
| 172 | 
            -
            that use case.  The `ProcessSettings::Testing::Helpers`  | 
| 173 | 
            -
            override a specific hash of process settings, while leaving the rest intact, and resetting back to the defaults
         | 
| 172 | 
            +
            that use case.  The `ProcessSettings::Testing::RSpec::Helpers` and `ProcessSettings::Testing::Minitest::Helpers` modules are provided for this purpose.
         | 
| 173 | 
            +
            They can be used to override a specific hash of process settings, while leaving the rest intact, and resetting back to the defaults
         | 
| 174 174 | 
             
            after the test case is over.  Here are some examples using various testing frameworks:
         | 
| 175 175 |  | 
| 176 176 | 
             
            #### RSpec
         | 
| @@ -181,7 +181,7 @@ require 'process_settings/testing/helpers' | |
| 181 181 | 
             
            RSpec.configure do |config|
         | 
| 182 182 | 
             
              # ...
         | 
| 183 183 |  | 
| 184 | 
            -
              include ProcessSettings::Testing::Helpers
         | 
| 184 | 
            +
              include ProcessSettings::Testing::RSpec::Helpers
         | 
| 185 185 |  | 
| 186 186 | 
             
              # Note: the include above will automatically register a global after block that will reset process_settings to their initial values.
         | 
| 187 187 | 
             
              # ...
         | 
| @@ -206,7 +206,7 @@ end | |
| 206 206 | 
             
            require 'process_settings/testing/helpers'
         | 
| 207 207 |  | 
| 208 208 | 
             
            context SomeClass do
         | 
| 209 | 
            -
              include ProcessSettings::Testing::Helpers
         | 
| 209 | 
            +
              include ProcessSettings::Testing::Minitest::Helpers
         | 
| 210 210 |  | 
| 211 211 | 
             
              # Note: the include above will automatically register a teardown block that will reset process_settings to their initial values.
         | 
| 212 212 |  | 
| @@ -10,7 +10,6 @@ require_relative '../lib/process_settings/targeted_settings' | |
| 10 10 |  | 
| 11 11 | 
             
            PROGRAM_NAME = File.basename($PROGRAM_NAME)
         | 
| 12 12 | 
             
            SETTINGS_FOLDER = 'settings'
         | 
| 13 | 
            -
            MINIMUM_LIBYAML_VERSION = Gem::Version.new('0.2.6') # So that null (nil) values don't have trailing spaces.
         | 
| 14 13 |  | 
| 15 14 | 
             
            def end_marker(version)
         | 
| 16 15 | 
             
              {
         | 
| @@ -76,20 +75,21 @@ def add_warning_comment(yaml, root_folder, program_name, settings_folder) | |
| 76 75 | 
             
              yaml.sub("\n", "\n" + warning_comment)
         | 
| 77 76 | 
             
            end
         | 
| 78 77 |  | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 78 | 
            +
            MINIMUM_LIBYAML_VERSION = '0.2.5' # So that null (nil) values don't have trailing spaces.
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            def warn_if_old_libyaml_version
         | 
| 81 | 
            +
              if Gem::Version.new(Psych::LIBYAML_VERSION) < Gem::Version.new(MINIMUM_LIBYAML_VERSION)
         | 
| 81 82 | 
             
                warn <<~EOS
         | 
| 82 83 |  | 
| 83 | 
            -
                  #{PROGRAM_NAME}  | 
| 84 | 
            -
             | 
| 85 | 
            -
                      brew update && upgrade libyaml
         | 
| 86 | 
            -
             | 
| 84 | 
            +
                  #{PROGRAM_NAME} warning: libyaml version #{Psych::LIBYAML_VERSION} is out of date; it should be at least #{MINIMUM_LIBYAML_VERSION}. On a Mac, try:
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                      brew update && brew upgrade libyaml
         | 
| 87 | 
            +
             | 
| 87 88 | 
             
                  You may also need:
         | 
| 88 | 
            -
             | 
| 89 | 
            +
             | 
| 89 90 | 
             
                      gem install psych -- --enable-bundled-libyaml
         | 
| 90 91 | 
             
                EOS
         | 
| 91 | 
            -
             | 
| 92 | 
            -
              exit(1)
         | 
| 92 | 
            +
              end
         | 
| 93 93 | 
             
            end
         | 
| 94 94 |  | 
| 95 95 |  | 
| @@ -97,16 +97,16 @@ end | |
| 97 97 | 
             
            # main
         | 
| 98 98 | 
             
            #
         | 
| 99 99 |  | 
| 100 | 
            -
            check_libyaml_version
         | 
| 101 | 
            -
             | 
| 102 100 | 
             
            options = parse_options(ARGV.dup)
         | 
| 103 101 |  | 
| 102 | 
            +
            warn_if_old_libyaml_version
         | 
| 103 | 
            +
             | 
| 104 104 | 
             
            combined_settings = read_and_combine_settings(Pathname.new(options.root_folder) + SETTINGS_FOLDER)
         | 
| 105 105 |  | 
| 106 106 | 
             
            version_number = options.version || default_version_number(options.initial_filename)
         | 
| 107 107 | 
             
            combined_settings << end_marker(version_number)
         | 
| 108 108 |  | 
| 109 | 
            -
            yaml = combined_settings.to_yaml
         | 
| 109 | 
            +
            yaml = combined_settings.to_yaml.gsub(/: $/, ':') # libyaml before 0.2.5 wrote trailing space for nil
         | 
| 110 110 | 
             
            yaml_with_warning_comment = add_warning_comment(yaml, options.root_folder, PROGRAM_NAME, SETTINGS_FOLDER)
         | 
| 111 111 |  | 
| 112 112 | 
             
            output_filename     = options.output_filename
         | 
| @@ -8,48 +8,66 @@ require 'process_settings/testing/monitor' | |
| 8 8 |  | 
| 9 9 | 
             
            module ProcessSettings
         | 
| 10 10 | 
             
              module Testing
         | 
| 11 | 
            -
                module  | 
| 12 | 
            -
                   | 
| 13 | 
            -
                     | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 11 | 
            +
                module Base
         | 
| 12 | 
            +
                  module Helpers
         | 
| 13 | 
            +
                    # Adds the given settings_hash as an override at the end of the process_settings array, with default targeting (true).
         | 
| 14 | 
            +
                    # Therefore this will override these settings while leaving others alone.
         | 
| 15 | 
            +
                    #
         | 
| 16 | 
            +
                    # @param [Hash] settings_hash
         | 
| 17 | 
            +
                    #
         | 
| 18 | 
            +
                    # @return none
         | 
| 19 | 
            +
                    def stub_process_settings(settings_hash)
         | 
| 20 | 
            +
                      new_target_and_settings = ProcessSettings::TargetAndSettings.new(
         | 
| 21 | 
            +
                        '<test_override>',
         | 
| 22 | 
            +
                        Target::true_target,
         | 
| 23 | 
            +
                        ProcessSettings::Settings.new(settings_hash.deep_stringify_keys)
         | 
| 24 | 
            +
                      )
         | 
| 20 25 |  | 
| 21 | 
            -
                       | 
| 22 | 
            -
                         | 
| 23 | 
            -
             | 
| 26 | 
            +
                      new_process_settings = [
         | 
| 27 | 
            +
                        *initial_instance.statically_targeted_settings,
         | 
| 28 | 
            +
                        new_target_and_settings
         | 
| 29 | 
            +
                      ]
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                      ProcessSettings.instance = ProcessSettings::Testing::Monitor.new(
         | 
| 32 | 
            +
                        new_process_settings,
         | 
| 33 | 
            +
                        logger: initial_instance.logger
         | 
| 34 | 
            +
                      )
         | 
| 35 | 
            +
                    end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    def initial_instance
         | 
| 38 | 
            +
                      @initial_instance ||= ProcessSettings.instance
         | 
| 24 39 | 
             
                    end
         | 
| 25 40 | 
             
                  end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
                   | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
                    new_process_settings = [
         | 
| 40 | 
            -
                      *initial_instance.statically_targeted_settings,
         | 
| 41 | 
            -
                      new_target_and_settings
         | 
| 42 | 
            -
                    ]
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                    ProcessSettings.instance = ProcessSettings::Testing::Monitor.new(
         | 
| 45 | 
            -
                      new_process_settings,
         | 
| 46 | 
            -
                      logger: initial_instance.logger
         | 
| 47 | 
            -
                    )
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                module RSpec
         | 
| 44 | 
            +
                  module Helpers
         | 
| 45 | 
            +
                    include Base::Helpers
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                    class << self
         | 
| 48 | 
            +
                      def included(including_klass)
         | 
| 49 | 
            +
                        including_klass.after do
         | 
| 50 | 
            +
                          ProcessSettings.instance = initial_instance
         | 
| 51 | 
            +
                        end
         | 
| 52 | 
            +
                      end
         | 
| 53 | 
            +
                    end
         | 
| 48 54 | 
             
                  end
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                module Minitest
         | 
| 58 | 
            +
                  module Helpers
         | 
| 59 | 
            +
                    include Base::Helpers
         | 
| 49 60 |  | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 61 | 
            +
                    class << self
         | 
| 62 | 
            +
                      def included(including_klass)
         | 
| 63 | 
            +
                        including_klass.define_method(:teardown) do
         | 
| 64 | 
            +
                          ProcessSettings.instance = initial_instance
         | 
| 65 | 
            +
                        end
         | 
| 66 | 
            +
                      end
         | 
| 67 | 
            +
                    end
         | 
| 52 68 | 
             
                  end
         | 
| 53 69 | 
             
                end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                Helpers = RSpec::Helpers  # for backward-compatibility
         | 
| 54 72 | 
             
              end
         | 
| 55 73 | 
             
            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. | 
| 4 | 
            +
              version: 0.14.0.pre.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Invoca
         | 
| @@ -122,9 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 122 122 | 
             
                  version: '0'
         | 
| 123 123 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 124 124 | 
             
              requirements:
         | 
| 125 | 
            -
              - - " | 
| 125 | 
            +
              - - ">"
         | 
| 126 126 | 
             
                - !ruby/object:Gem::Version
         | 
| 127 | 
            -
                  version:  | 
| 127 | 
            +
                  version: 1.3.1
         | 
| 128 128 | 
             
            requirements: []
         | 
| 129 129 | 
             
            rubygems_version: 3.0.3
         | 
| 130 130 | 
             
            signing_key:
         |