trailblazer-context 0.1.4 → 0.3.3
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/.gitignore +1 -0
- data/.travis.yml +9 -5
- data/CHANGES.md +31 -0
- data/LICENSE +1 -1
- data/Rakefile +5 -2
- data/lib/trailblazer-context.rb +1 -0
- data/lib/trailblazer/container_chain.rb +0 -2
- data/lib/trailblazer/context.rb +13 -72
- data/lib/trailblazer/context/container.rb +100 -0
- data/lib/trailblazer/context/container/with_aliases.rb +102 -0
- data/lib/trailblazer/context/store/indifferent_access.rb +36 -0
- data/lib/trailblazer/context/version.rb +2 -2
- data/lib/trailblazer/option.rb +18 -19
- data/test/benchmark/benchmark_helper.rb +32 -0
- data/test/benchmark/indifferent_access_test.rb +89 -0
- data/test/benchmark/indifferent_access_with_aliasing_test.rb +73 -0
- data/test/context_test.rb +239 -41
- data/test/option_test.rb +6 -6
- data/test/test_helper.rb +0 -1
- data/trailblazer-context.gemspec +3 -2
- metadata +20 -15
- data/.rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml +0 -136
- data/.rubocop.yml +0 -40
- data/lib/trailblazer/context/indifferent_access.rb +0 -18
    
        data/test/option_test.rb
    CHANGED
    
    | @@ -2,10 +2,10 @@ require "test_helper" | |
| 2 2 |  | 
| 3 3 | 
             
            class OptionTest < Minitest::Spec
         | 
| 4 4 | 
             
              def assert_result(result, block = nil)
         | 
| 5 | 
            -
                result.must_equal([{a: 1}, 2, {b: 3}, block])
         | 
| 5 | 
            +
                _(result).must_equal([{a: 1}, 2, {b: 3}, block])
         | 
| 6 6 |  | 
| 7 | 
            -
                positional.inspect.must_equal %({:a=>1})
         | 
| 8 | 
            -
                keywords.inspect.must_equal %({:a=>2, :b=>3})
         | 
| 7 | 
            +
                _(positional.inspect).must_equal %({:a=>1})
         | 
| 8 | 
            +
                _(keywords.inspect).must_equal %({:a=>2, :b=>3})
         | 
| 9 9 | 
             
              end
         | 
| 10 10 |  | 
| 11 11 | 
             
              describe "positional and kws" do
         | 
| @@ -79,8 +79,8 @@ class OptionTest < Minitest::Spec | |
| 79 79 |  | 
| 80 80 | 
             
              describe "positionals" do
         | 
| 81 81 | 
             
                def assert_result_pos(result)
         | 
| 82 | 
            -
                  result.must_equal([1, 2, [3, 4]])
         | 
| 83 | 
            -
                  positionals.must_equal [1, 2, 3, 4]
         | 
| 82 | 
            +
                  _(result).must_equal([1, 2, [3, 4]])
         | 
| 83 | 
            +
                  _(positionals).must_equal [1, 2, 3, 4]
         | 
| 84 84 | 
             
                end
         | 
| 85 85 |  | 
| 86 86 | 
             
                class Step
         | 
| @@ -124,7 +124,7 @@ class OptionTest < Minitest::Spec | |
| 124 124 |  | 
| 125 125 | 
             
              describe "Option::KW" do
         | 
| 126 126 | 
             
                def assert_result_kws(result)
         | 
| 127 | 
            -
                  result.must_equal([{a: 1, b: 2, c: 3}, 1, 2, {c: 3}])
         | 
| 127 | 
            +
                  _(result).must_equal([{a: 1, b: 2, c: 3}, 1, 2, {c: 3}])
         | 
| 128 128 | 
             
                end
         | 
| 129 129 |  | 
| 130 130 | 
             
                class Step
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        data/trailblazer-context.gemspec
    CHANGED
    
    | @@ -20,11 +20,12 @@ Gem::Specification.new do |spec| | |
| 20 20 |  | 
| 21 21 | 
             
              spec.require_paths = ["lib"]
         | 
| 22 22 |  | 
| 23 | 
            +
              spec.add_dependency "hashie", ">= 3.0.0"
         | 
| 24 | 
            +
             | 
| 23 25 | 
             
              spec.add_development_dependency "bundler"
         | 
| 24 26 | 
             
              spec.add_development_dependency "minitest"
         | 
| 25 27 | 
             
              spec.add_development_dependency "rake"
         | 
| 26 | 
            -
              spec.add_development_dependency "rubocop"
         | 
| 27 28 |  | 
| 28 29 | 
             
              # maybe we could remove this?
         | 
| 29 | 
            -
              spec.required_ruby_version = ">= 2. | 
| 30 | 
            +
              spec.required_ruby_version = ">= 2.1.0"
         | 
| 30 31 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,31 +1,31 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: trailblazer-context
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Nick Sutterer
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2021-02-23 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            -
              name:  | 
| 14 | 
            +
              name: hashie
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 20 | 
            -
              type: : | 
| 19 | 
            +
                    version: 3.0.0
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - ">="
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version:  | 
| 26 | 
            +
                    version: 3.0.0
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            -
              name:  | 
| 28 | 
            +
              name: bundler
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 31 | 
             
                - - ">="
         | 
| @@ -39,7 +39,7 @@ dependencies: | |
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: '0'
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            -
              name:  | 
| 42 | 
            +
              name: minitest
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 45 | 
             
                - - ">="
         | 
| @@ -53,7 +53,7 @@ dependencies: | |
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 54 | 
             
                    version: '0'
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            -
              name:  | 
| 56 | 
            +
              name: rake
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 58 | 
             
                requirements:
         | 
| 59 59 | 
             
                - - ">="
         | 
| @@ -75,8 +75,6 @@ extensions: [] | |
| 75 75 | 
             
            extra_rdoc_files: []
         | 
| 76 76 | 
             
            files:
         | 
| 77 77 | 
             
            - ".gitignore"
         | 
| 78 | 
            -
            - ".rubocop-https---raw-githubusercontent-com-trailblazer-meta-master-rubocop-yml"
         | 
| 79 | 
            -
            - ".rubocop.yml"
         | 
| 80 78 | 
             
            - ".travis.yml"
         | 
| 81 79 | 
             
            - CHANGES.md
         | 
| 82 80 | 
             
            - Gemfile
         | 
| @@ -86,9 +84,14 @@ files: | |
| 86 84 | 
             
            - lib/trailblazer-context.rb
         | 
| 87 85 | 
             
            - lib/trailblazer/container_chain.rb
         | 
| 88 86 | 
             
            - lib/trailblazer/context.rb
         | 
| 89 | 
            -
            - lib/trailblazer/context/ | 
| 87 | 
            +
            - lib/trailblazer/context/container.rb
         | 
| 88 | 
            +
            - lib/trailblazer/context/container/with_aliases.rb
         | 
| 89 | 
            +
            - lib/trailblazer/context/store/indifferent_access.rb
         | 
| 90 90 | 
             
            - lib/trailblazer/context/version.rb
         | 
| 91 91 | 
             
            - lib/trailblazer/option.rb
         | 
| 92 | 
            +
            - test/benchmark/benchmark_helper.rb
         | 
| 93 | 
            +
            - test/benchmark/indifferent_access_test.rb
         | 
| 94 | 
            +
            - test/benchmark/indifferent_access_with_aliasing_test.rb
         | 
| 92 95 | 
             
            - test/context_test.rb
         | 
| 93 96 | 
             
            - test/option_test.rb
         | 
| 94 97 | 
             
            - test/test_helper.rb
         | 
| @@ -105,19 +108,21 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 105 108 | 
             
              requirements:
         | 
| 106 109 | 
             
              - - ">="
         | 
| 107 110 | 
             
                - !ruby/object:Gem::Version
         | 
| 108 | 
            -
                  version: 2. | 
| 111 | 
            +
                  version: 2.1.0
         | 
| 109 112 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 110 113 | 
             
              requirements:
         | 
| 111 114 | 
             
              - - ">="
         | 
| 112 115 | 
             
                - !ruby/object:Gem::Version
         | 
| 113 116 | 
             
                  version: '0'
         | 
| 114 117 | 
             
            requirements: []
         | 
| 115 | 
            -
             | 
| 116 | 
            -
            rubygems_version: 2.7.3
         | 
| 118 | 
            +
            rubygems_version: 3.0.8
         | 
| 117 119 | 
             
            signing_key: 
         | 
| 118 120 | 
             
            specification_version: 4
         | 
| 119 121 | 
             
            summary: Argument-specific data structures for Trailblazer.
         | 
| 120 122 | 
             
            test_files:
         | 
| 123 | 
            +
            - test/benchmark/benchmark_helper.rb
         | 
| 124 | 
            +
            - test/benchmark/indifferent_access_test.rb
         | 
| 125 | 
            +
            - test/benchmark/indifferent_access_with_aliasing_test.rb
         | 
| 121 126 | 
             
            - test/context_test.rb
         | 
| 122 127 | 
             
            - test/option_test.rb
         | 
| 123 128 | 
             
            - test/test_helper.rb
         | 
| @@ -1,136 +0,0 @@ | |
| 1 | 
            -
            AllCops:
         | 
| 2 | 
            -
              TargetRubyVersion: 2.5.0
         | 
| 3 | 
            -
              DisplayCopNames: true
         | 
| 4 | 
            -
            Layout/CaseIndentation:
         | 
| 5 | 
            -
              IndentOneStep: true
         | 
| 6 | 
            -
            Layout/FirstArrayElementLineBreak:
         | 
| 7 | 
            -
              Enabled: true
         | 
| 8 | 
            -
            Layout/FirstHashElementLineBreak:
         | 
| 9 | 
            -
              Enabled: true
         | 
| 10 | 
            -
            Layout/FirstMethodArgumentLineBreak:
         | 
| 11 | 
            -
              Enabled: true
         | 
| 12 | 
            -
            Layout/FirstMethodParameterLineBreak:
         | 
| 13 | 
            -
              Enabled: true
         | 
| 14 | 
            -
            Layout/MultilineAssignmentLayout:
         | 
| 15 | 
            -
              Enabled: true
         | 
| 16 | 
            -
              EnforcedStyle: same_line
         | 
| 17 | 
            -
            Layout/SpaceInsideHashLiteralBraces:
         | 
| 18 | 
            -
              EnforcedStyle: no_space
         | 
| 19 | 
            -
            Metrics/LineLength:
         | 
| 20 | 
            -
              Max: 130
         | 
| 21 | 
            -
            Metrics/ParameterLists:
         | 
| 22 | 
            -
              Max: 5
         | 
| 23 | 
            -
            Naming/VariableNumber:
         | 
| 24 | 
            -
              EnforcedStyle: snake_case
         | 
| 25 | 
            -
            Style/AndOr:
         | 
| 26 | 
            -
              EnforcedStyle: conditionals
         | 
| 27 | 
            -
            Style/AutoResourceCleanup:
         | 
| 28 | 
            -
              Enabled: true
         | 
| 29 | 
            -
            Style/CollectionMethods:
         | 
| 30 | 
            -
              Enabled: true
         | 
| 31 | 
            -
            Style/Documentation:
         | 
| 32 | 
            -
              Enabled: false
         | 
| 33 | 
            -
            Style/EmptyLiteral:
         | 
| 34 | 
            -
              Enabled: false
         | 
| 35 | 
            -
            Style/EmptyMethod:
         | 
| 36 | 
            -
              EnforcedStyle: expanded
         | 
| 37 | 
            -
            Style/FormatStringToken:
         | 
| 38 | 
            -
              EnforcedStyle: template
         | 
| 39 | 
            -
            Style/ImplicitRuntimeError:
         | 
| 40 | 
            -
              Enabled: true
         | 
| 41 | 
            -
            Style/MethodCalledOnDoEndBlock:
         | 
| 42 | 
            -
              Enabled: true
         | 
| 43 | 
            -
            Style/MethodDefParentheses:
         | 
| 44 | 
            -
              EnforcedStyle: require_parentheses
         | 
| 45 | 
            -
            Style/MissingElse:
         | 
| 46 | 
            -
              Enabled: true
         | 
| 47 | 
            -
              EnforcedStyle: case
         | 
| 48 | 
            -
            Style/NumericLiterals:
         | 
| 49 | 
            -
              Enabled: false
         | 
| 50 | 
            -
            Style/OptionHash:
         | 
| 51 | 
            -
              Enabled: true
         | 
| 52 | 
            -
            Style/PercentLiteralDelimiters:
         | 
| 53 | 
            -
              PreferredDelimiters:
         | 
| 54 | 
            -
                "%w": "[]"
         | 
| 55 | 
            -
                "%W": "[]"
         | 
| 56 | 
            -
                "%i": "[]"
         | 
| 57 | 
            -
                "%I": "[]"
         | 
| 58 | 
            -
                "%r": "()"
         | 
| 59 | 
            -
            Style/ReturnNil:
         | 
| 60 | 
            -
              Enabled: true
         | 
| 61 | 
            -
            Style/SafeNavigation:
         | 
| 62 | 
            -
              Enabled: false
         | 
| 63 | 
            -
            Style/Send:
         | 
| 64 | 
            -
              Enabled: true
         | 
| 65 | 
            -
            Style/SignalException:
         | 
| 66 | 
            -
              EnforcedStyle: semantic
         | 
| 67 | 
            -
            Style/StringLiterals:
         | 
| 68 | 
            -
              EnforcedStyle: double_quotes
         | 
| 69 | 
            -
            Style/StringLiteralsInInterpolation:
         | 
| 70 | 
            -
              EnforcedStyle: double_quotes
         | 
| 71 | 
            -
            Style/StringMethods:
         | 
| 72 | 
            -
              Enabled: true
         | 
| 73 | 
            -
            Style/SymbolArray:
         | 
| 74 | 
            -
              Enabled: true
         | 
| 75 | 
            -
            # this allows in rspec to have expect { } with multiple lines
         | 
| 76 | 
            -
            Style/BlockDelimiters:
         | 
| 77 | 
            -
              EnforcedStyle: braces_for_chaining
         | 
| 78 | 
            -
            Layout/EndOfLine:
         | 
| 79 | 
            -
              Enabled: false
         | 
| 80 | 
            -
            # don't need these checks in test folders
         | 
| 81 | 
            -
            Metrics/ModuleLength:
         | 
| 82 | 
            -
              Exclude:
         | 
| 83 | 
            -
                - "spec/**/*"
         | 
| 84 | 
            -
                - "test/**/*"
         | 
| 85 | 
            -
            Metrics/BlockLength:
         | 
| 86 | 
            -
              Exclude:
         | 
| 87 | 
            -
                - "spec/**/*"
         | 
| 88 | 
            -
                - "test/**/*"
         | 
| 89 | 
            -
                - "*.gemspec" # definitely not in the gemspec
         | 
| 90 | 
            -
            Metrics/MethodLength:
         | 
| 91 | 
            -
              Max: 20
         | 
| 92 | 
            -
            Lint/UnreachableCode:
         | 
| 93 | 
            -
              Description: 'Unreachable code.'
         | 
| 94 | 
            -
              Enabled: false
         | 
| 95 | 
            -
            Lint/Void:
         | 
| 96 | 
            -
              Enabled: false
         | 
| 97 | 
            -
            Layout/AlignHash:
         | 
| 98 | 
            -
              EnforcedLastArgumentHashStyle: ignore_implicit
         | 
| 99 | 
            -
            Metrics/AbcSize:
         | 
| 100 | 
            -
              Max: 25
         | 
| 101 | 
            -
            Style/LambdaCall:
         | 
| 102 | 
            -
              Enabled: false
         | 
| 103 | 
            -
            Style/Semicolon:
         | 
| 104 | 
            -
              Enabled: false
         | 
| 105 | 
            -
            Naming/UncommunicativeMethodParamName:
         | 
| 106 | 
            -
              Enabled: false
         | 
| 107 | 
            -
            Style/ClassAndModuleChildren:
         | 
| 108 | 
            -
              Enabled: false
         | 
| 109 | 
            -
            Layout/LeadingCommentSpace:
         | 
| 110 | 
            -
              Exclude:
         | 
| 111 | 
            -
                - 'test/docs/**/*'
         | 
| 112 | 
            -
            Layout/AlignHash:
         | 
| 113 | 
            -
              EnforcedHashRocketStyle: table
         | 
| 114 | 
            -
            Style/FrozenStringLiteralComment:
         | 
| 115 | 
            -
              Enabled: false
         | 
| 116 | 
            -
            Layout/AlignHash:
         | 
| 117 | 
            -
              EnforcedColonStyle: table
         | 
| 118 | 
            -
            SingleLineMethods:
         | 
| 119 | 
            -
              Enabled: false
         | 
| 120 | 
            -
            Style/Lambda:
         | 
| 121 | 
            -
              EnforcedStyle: literal
         | 
| 122 | 
            -
            Style/AsciiComments:
         | 
| 123 | 
            -
              Enabled: false
         | 
| 124 | 
            -
            Style/CollectionMethods:
         | 
| 125 | 
            -
              Enabled: false
         | 
| 126 | 
            -
            Style/RedundantReturn:
         | 
| 127 | 
            -
              Enabled: false
         | 
| 128 | 
            -
            Style/PercentLiteralDelimiters:
         | 
| 129 | 
            -
              PreferredDelimiters:
         | 
| 130 | 
            -
                default: {}
         | 
| 131 | 
            -
                "%q": '()'
         | 
| 132 | 
            -
                "%r": '{}'
         | 
| 133 | 
            -
                "%w": '[]'
         | 
| 134 | 
            -
                "%": '{}'
         | 
| 135 | 
            -
            Style/HashSyntax:
         | 
| 136 | 
            -
              Enabled: false
         | 
    
        data/.rubocop.yml
    DELETED
    
    | @@ -1,40 +0,0 @@ | |
| 1 | 
            -
            AllCops:
         | 
| 2 | 
            -
              TargetRubyVersion: 2.2
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            inherit_from:
         | 
| 5 | 
            -
              - https://raw.githubusercontent.com/trailblazer/meta/master/rubocop.yml
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            Lint/UnusedMethodArgument:
         | 
| 8 | 
            -
              Exclude:
         | 
| 9 | 
            -
                - 'lib/trailblazer/option.rb'
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            Metrics/ClassLength:
         | 
| 12 | 
            -
              Exclude:
         | 
| 13 | 
            -
                - 'test/**'
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            Style/ImplicitRuntimeError:
         | 
| 16 | 
            -
              Exclude:
         | 
| 17 | 
            -
                - 'lib/trailblazer/option.rb'
         | 
| 18 | 
            -
             | 
| 19 | 
            -
            Naming/UncommunicativeMethodParamName:
         | 
| 20 | 
            -
              Exclude:
         | 
| 21 | 
            -
                - 'test/option_test.rb'
         | 
| 22 | 
            -
             | 
| 23 | 
            -
            Style/ClassAndModuleChildren:
         | 
| 24 | 
            -
              Enabled: false
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            # wants to use map instead of collect
         | 
| 27 | 
            -
            Style/CollectionMethods:
         | 
| 28 | 
            -
              Enabled: false
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            # wants to use fail instea of raise
         | 
| 31 | 
            -
            Style/SignalException:
         | 
| 32 | 
            -
              Enabled: false
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            # because in gemspec we say >= 2.0.0 wants to have 2.0 as target ruby version here but
         | 
| 35 | 
            -
            # it's not supported anymore from rubocop
         | 
| 36 | 
            -
            Gemspec/RequiredRubyVersion:
         | 
| 37 | 
            -
              Enabled: false
         | 
| 38 | 
            -
             | 
| 39 | 
            -
            Style/Lambda:
         | 
| 40 | 
            -
              EnforcedStyle: literal
         | 
| @@ -1,18 +0,0 @@ | |
| 1 | 
            -
            module Trailblazer
         | 
| 2 | 
            -
              class Context
         | 
| 3 | 
            -
                class IndifferentAccess < Context
         | 
| 4 | 
            -
                  def [](name)
         | 
| 5 | 
            -
                    # TODO: well...
         | 
| 6 | 
            -
                    @mutable_options.key?(name.to_sym) and return @mutable_options[name.to_sym]
         | 
| 7 | 
            -
                    @mutable_options.key?(name.to_s) and return @mutable_options[name.to_s]
         | 
| 8 | 
            -
                    @wrapped_options.key?(name.to_sym) and return @wrapped_options[name.to_sym]
         | 
| 9 | 
            -
                    @wrapped_options[name.to_s]
         | 
| 10 | 
            -
                  end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  def key?(name)
         | 
| 13 | 
            -
                    super(name.to_sym) || super(name.to_s)
         | 
| 14 | 
            -
                  end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                end
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
            end
         |