flipper-api 0.24.0 → 0.25.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/lib/flipper/api/v1/actions/feature.rb +2 -1
- data/lib/flipper/api/v1/actions/features.rb +2 -1
- data/lib/flipper/api/v1/decorators/feature.rb +11 -8
- data/lib/flipper/api.rb +3 -2
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/api/v1/decorators/feature_spec.rb +27 -0
- data/spec/flipper/api_spec.rb +1 -1
- metadata +11 -9
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 463722a6c76397e004716c02360817a52d22dafda409d5508ec93355783d2f87
         | 
| 4 | 
            +
              data.tar.gz: c2b457498c463653f8ca0fcf0baf0e118d4c0941316294d0bcf12cc91b90d958
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7faf36080060780258a8a979fc206a9cdb9ae69df3b3231b30f9b156cb12130f6d7a7ae82fb7d965a578a66d4415bbd649a2b3e67f93073df089c15dcf2548a3
         | 
| 7 | 
            +
              data.tar.gz: 24ea9e61bb8cda87d3efa602bfacfae9f9d63d9db7b75e7955d7ac8a5afed17a9694f4868c4dd9c7639c02b02928490dfdd67730e81a25fdc368e7eb17721ebc
         | 
| @@ -12,8 +12,9 @@ module Flipper | |
| 12 12 |  | 
| 13 13 | 
             
                      def get
         | 
| 14 14 | 
             
                        return json_error_response(:feature_not_found) unless feature_exists?(feature_name)
         | 
| 15 | 
            +
                        exclude_gates = params['exclude_gates']&.downcase == "true"
         | 
| 15 16 | 
             
                        feature = Decorators::Feature.new(flipper[feature_name])
         | 
| 16 | 
            -
                        json_response(feature.as_json)
         | 
| 17 | 
            +
                        json_response(feature.as_json(exclude_gates: exclude_gates))
         | 
| 17 18 | 
             
                      end
         | 
| 18 19 |  | 
| 19 20 | 
             
                      def delete
         | 
| @@ -10,6 +10,7 @@ module Flipper | |
| 10 10 |  | 
| 11 11 | 
             
                      def get
         | 
| 12 12 | 
             
                        keys = params['keys']
         | 
| 13 | 
            +
                        exclude_gates = params['exclude_gates']&.downcase == "true"
         | 
| 13 14 | 
             
                        features = if keys
         | 
| 14 15 | 
             
                          names = keys.split(',')
         | 
| 15 16 | 
             
                          if names.empty?
         | 
| @@ -26,7 +27,7 @@ module Flipper | |
| 26 27 | 
             
                        end
         | 
| 27 28 |  | 
| 28 29 | 
             
                        decorated_features = features.map do |feature|
         | 
| 29 | 
            -
                          Decorators::Feature.new(feature).as_json
         | 
| 30 | 
            +
                          Decorators::Feature.new(feature).as_json(exclude_gates: exclude_gates)
         | 
| 30 31 | 
             
                        end
         | 
| 31 32 |  | 
| 32 33 | 
             
                        json_response(features: decorated_features)
         | 
| @@ -10,17 +10,20 @@ module Flipper | |
| 10 10 | 
             
                      alias_method :feature, :__getobj__
         | 
| 11 11 |  | 
| 12 12 | 
             
                      # Public: Returns instance as hash that is ready to be json dumped.
         | 
| 13 | 
            -
                      def as_json
         | 
| 14 | 
            -
                         | 
| 15 | 
            -
                        gates_json = gates.map do |gate|
         | 
| 16 | 
            -
                          Decorators::Gate.new(gate, gate_values[gate.key]).as_json
         | 
| 17 | 
            -
                        end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                        {
         | 
| 13 | 
            +
                      def as_json(exclude_gates: false)
         | 
| 14 | 
            +
                        result = {
         | 
| 20 15 | 
             
                          'key' => key,
         | 
| 21 16 | 
             
                          'state' => state.to_s,
         | 
| 22 | 
            -
                          'gates' => gates_json,
         | 
| 23 17 | 
             
                        }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                        unless exclude_gates
         | 
| 20 | 
            +
                          gate_values = feature.adapter.get(self)
         | 
| 21 | 
            +
                          result['gates'] = gates.map do |gate|
         | 
| 22 | 
            +
                            Decorators::Gate.new(gate, gate_values[gate.key]).as_json
         | 
| 23 | 
            +
                          end
         | 
| 24 | 
            +
                        end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                        result
         | 
| 24 27 | 
             
                      end
         | 
| 25 28 | 
             
                    end
         | 
| 26 29 | 
             
                  end
         | 
    
        data/lib/flipper/api.rb
    CHANGED
    
    | @@ -17,8 +17,9 @@ module Flipper | |
| 17 17 | 
             
                  builder.use Flipper::Api::Middleware, env_key: env_key
         | 
| 18 18 | 
             
                  builder.run app
         | 
| 19 19 | 
             
                  klass = self
         | 
| 20 | 
            -
                   | 
| 21 | 
            -
                   | 
| 20 | 
            +
                  app = builder.to_app
         | 
| 21 | 
            +
                  app.define_singleton_method(:inspect) { klass.inspect } # pretty rake routes output
         | 
| 22 | 
            +
                  app
         | 
| 22 23 | 
             
                end
         | 
| 23 24 | 
             
              end
         | 
| 24 25 | 
             
            end
         | 
    
        data/lib/flipper/version.rb
    CHANGED
    
    
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            RSpec.describe Flipper::Api::V1::Decorators::Feature do
         | 
| 2 | 
            +
              describe "#as_json" do
         | 
| 3 | 
            +
                context "with exclude_gates set to true" do
         | 
| 4 | 
            +
                  subject { described_class.new(flipper[:my_feature]).as_json(exclude_gates: true) }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  it "returns json WITHOUT feature gate data" do
         | 
| 7 | 
            +
                    expect(subject.keys).to_not include("gates")
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                context "with exclude_gates set to false" do
         | 
| 12 | 
            +
                  subject { described_class.new(flipper[:my_feature]).as_json(exclude_gates: false) }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  it "returns json WITH feature gate data" do
         | 
| 15 | 
            +
                    expect(subject.keys).to include("gates")
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                context "without exclude_gates set" do
         | 
| 20 | 
            +
                  subject { described_class.new(flipper[:my_feature]).as_json }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  it "returns json WITH feature gate data" do
         | 
| 23 | 
            +
                    expect(subject.keys).to include("gates")
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
    
        data/spec/flipper/api_spec.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: flipper-api
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.25.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - John Nunemaker
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022- | 
| 11 | 
            +
            date: 2022-08-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rack
         | 
| @@ -36,15 +36,15 @@ dependencies: | |
| 36 36 | 
             
                requirements:
         | 
| 37 37 | 
             
                - - "~>"
         | 
| 38 38 | 
             
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            -
                    version: 0. | 
| 39 | 
            +
                    version: 0.25.1
         | 
| 40 40 | 
             
              type: :runtime
         | 
| 41 41 | 
             
              prerelease: false
         | 
| 42 42 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 43 | 
             
                requirements:
         | 
| 44 44 | 
             
                - - "~>"
         | 
| 45 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            -
                    version: 0. | 
| 47 | 
            -
            description: | 
| 46 | 
            +
                    version: 0.25.1
         | 
| 47 | 
            +
            description:
         | 
| 48 48 | 
             
            email:
         | 
| 49 49 | 
             
            - nunemaker@gmail.com
         | 
| 50 50 | 
             
            executables: []
         | 
| @@ -84,13 +84,14 @@ files: | |
| 84 84 | 
             
            - spec/flipper/api/v1/actions/groups_gate_spec.rb
         | 
| 85 85 | 
             
            - spec/flipper/api/v1/actions/percentage_of_actors_gate_spec.rb
         | 
| 86 86 | 
             
            - spec/flipper/api/v1/actions/percentage_of_time_gate_spec.rb
         | 
| 87 | 
            +
            - spec/flipper/api/v1/decorators/feature_spec.rb
         | 
| 87 88 | 
             
            - spec/flipper/api_spec.rb
         | 
| 88 89 | 
             
            homepage: https://github.com/jnunemaker/flipper
         | 
| 89 90 | 
             
            licenses:
         | 
| 90 91 | 
             
            - MIT
         | 
| 91 92 | 
             
            metadata:
         | 
| 92 93 | 
             
              changelog_uri: https://github.com/jnunemaker/flipper/blob/master/Changelog.md
         | 
| 93 | 
            -
            post_install_message: | 
| 94 | 
            +
            post_install_message:
         | 
| 94 95 | 
             
            rdoc_options: []
         | 
| 95 96 | 
             
            require_paths:
         | 
| 96 97 | 
             
            - lib
         | 
| @@ -105,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 105 106 | 
             
                - !ruby/object:Gem::Version
         | 
| 106 107 | 
             
                  version: '0'
         | 
| 107 108 | 
             
            requirements: []
         | 
| 108 | 
            -
            rubygems_version: 3. | 
| 109 | 
            -
            signing_key: | 
| 109 | 
            +
            rubygems_version: 3.3.7
         | 
| 110 | 
            +
            signing_key:
         | 
| 110 111 | 
             
            specification_version: 4
         | 
| 111 112 | 
             
            summary: API for the Flipper gem
         | 
| 112 113 | 
             
            test_files:
         | 
| @@ -121,4 +122,5 @@ test_files: | |
| 121 122 | 
             
            - spec/flipper/api/v1/actions/groups_gate_spec.rb
         | 
| 122 123 | 
             
            - spec/flipper/api/v1/actions/percentage_of_actors_gate_spec.rb
         | 
| 123 124 | 
             
            - spec/flipper/api/v1/actions/percentage_of_time_gate_spec.rb
         | 
| 125 | 
            +
            - spec/flipper/api/v1/decorators/feature_spec.rb
         | 
| 124 126 | 
             
            - spec/flipper/api_spec.rb
         |