sinclair 1.6.3 → 1.6.4
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 +1 -1
- data/config/yardstick.yml +1 -0
- data/lib/sinclair/options.rb +15 -18
- data/lib/sinclair/version.rb +1 -1
- data/spec/lib/sinclair/options_spec.rb +69 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7c4239fce273eaf2a9dd2f62219833a2dc035230ba115f1369bc881fac00da9a
         | 
| 4 | 
            +
              data.tar.gz: 45b56a8e12244c9adcf3c328d7d794d0036ded1dcf040d21401406294c139f30
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cfb6141258f4d0a62cde59dcfddfa69ad7c875a78c11a080fc2d0b5d6a688fd62fe39c71f3c30229ff01f1c95c12a595c1f35799799c21007f7b518e8f794955
         | 
| 7 | 
            +
              data.tar.gz: 99ac196abb1272d7c0224e358a90540eb81e8fca869abd36b371e21157b734779914a29946f5bcb951f3b1d12d6638eeda34591f3eac1a1ede08fbc09ea7426e
         | 
    
        data/README.md
    CHANGED
    
    | @@ -15,7 +15,7 @@ methods | |
| 15 15 |  | 
| 16 16 | 
             
            Yard Documentation
         | 
| 17 17 | 
             
            -------------------
         | 
| 18 | 
            -
            [https://www.rubydoc.info/gems/sinclair/1.6. | 
| 18 | 
            +
            [https://www.rubydoc.info/gems/sinclair/1.6.4](https://www.rubydoc.info/gems/sinclair/1.6.4)
         | 
| 19 19 |  | 
| 20 20 | 
             
            Installation
         | 
| 21 21 | 
             
            ---------------
         | 
    
        data/config/yardstick.yml
    CHANGED
    
    
    
        data/lib/sinclair/options.rb
    CHANGED
    
    | @@ -45,8 +45,6 @@ class Sinclair | |
| 45 45 | 
             
                    allowed_options << name.to_sym
         | 
| 46 46 | 
             
                  end
         | 
| 47 47 |  | 
| 48 | 
            -
                  private
         | 
| 49 | 
            -
             | 
| 50 48 | 
             
                  # @api private
         | 
| 51 49 | 
             
                  # @private
         | 
| 52 50 | 
             
                  #
         | 
| @@ -54,24 +52,10 @@ class Sinclair | |
| 54 52 | 
             
                  #
         | 
| 55 53 | 
             
                  # @return [Set<Symbol>]
         | 
| 56 54 | 
             
                  def allowed_options
         | 
| 57 | 
            -
                    @allowed_options ||=  | 
| 55 | 
            +
                    @allowed_options ||= superclass.try(:allowed_options).dup || Set.new
         | 
| 58 56 | 
             
                  end
         | 
| 59 57 |  | 
| 60 | 
            -
                   | 
| 61 | 
            -
                  # @private
         | 
| 62 | 
            -
                  #
         | 
| 63 | 
            -
                  # Build set of allowed options
         | 
| 64 | 
            -
                  #
         | 
| 65 | 
            -
                  # When class is descendent of {Options}
         | 
| 66 | 
            -
                  # a duplication of it's parents allowed_options is
         | 
| 67 | 
            -
                  # returned
         | 
| 68 | 
            -
                  #
         | 
| 69 | 
            -
                  # @return (see allowed_options)
         | 
| 70 | 
            -
                  def build_allowed_options
         | 
| 71 | 
            -
                    superclass.send(:allowed_options).dup
         | 
| 72 | 
            -
                  rescue NoMethodError
         | 
| 73 | 
            -
                    Set.new
         | 
| 74 | 
            -
                  end
         | 
| 58 | 
            +
                  private
         | 
| 75 59 |  | 
| 76 60 | 
             
                  # @api public
         | 
| 77 61 | 
             
                  # @!visibility public
         | 
| @@ -105,6 +89,19 @@ class Sinclair | |
| 105 89 | 
             
                  end
         | 
| 106 90 | 
             
                end
         | 
| 107 91 |  | 
| 92 | 
            +
                # returns if other equals to self
         | 
| 93 | 
            +
                #
         | 
| 94 | 
            +
                # @param other [Object] object to be compared
         | 
| 95 | 
            +
                #
         | 
| 96 | 
            +
                # @return [TrueClass,FalseClass]
         | 
| 97 | 
            +
                def ==(other)
         | 
| 98 | 
            +
                  return false unless self.class == other.class
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                  self.class.allowed_options.all? do |name|
         | 
| 101 | 
            +
                    public_send(name) == other.public_send(name)
         | 
| 102 | 
            +
                  end
         | 
| 103 | 
            +
                end
         | 
| 104 | 
            +
             | 
| 108 105 | 
             
                private
         | 
| 109 106 |  | 
| 110 107 | 
             
                # @private
         | 
    
        data/lib/sinclair/version.rb
    CHANGED
    
    
| @@ -197,6 +197,51 @@ describe Sinclair::Options do | |
| 197 197 | 
             
                end
         | 
| 198 198 | 
             
              end
         | 
| 199 199 |  | 
| 200 | 
            +
              describe '.allowed_options' do
         | 
| 201 | 
            +
                let(:klass) { Class.new(described_class) }
         | 
| 202 | 
            +
             | 
| 203 | 
            +
                context 'when class has not been changed' do
         | 
| 204 | 
            +
                  it { expect(klass.allowed_options).to be_a(Set) }
         | 
| 205 | 
            +
                end
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                context 'when initializing with with options' do
         | 
| 208 | 
            +
                  let(:expected) do
         | 
| 209 | 
            +
                    Set.new %i[timeout retries port protocol]
         | 
| 210 | 
            +
                  end
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                  before do
         | 
| 213 | 
            +
                    klass.send(
         | 
| 214 | 
            +
                      :with_options,
         | 
| 215 | 
            +
                      :timeout, :retries, port: 443, protocol: 'https'
         | 
| 216 | 
            +
                    )
         | 
| 217 | 
            +
                  end
         | 
| 218 | 
            +
             | 
| 219 | 
            +
                  it do
         | 
| 220 | 
            +
                    expect(klass.allowed_options)
         | 
| 221 | 
            +
                      .to eq(expected)
         | 
| 222 | 
            +
                  end
         | 
| 223 | 
            +
             | 
| 224 | 
            +
                  context 'when class is descendent' do
         | 
| 225 | 
            +
                    let(:descendent_class) { Class.new(klass) }
         | 
| 226 | 
            +
                    let(:expected) do
         | 
| 227 | 
            +
                      Set.new %i[timeout retries port protocol name]
         | 
| 228 | 
            +
                    end
         | 
| 229 | 
            +
             | 
| 230 | 
            +
                    before do
         | 
| 231 | 
            +
                      descendent_class.send(
         | 
| 232 | 
            +
                        :with_options,
         | 
| 233 | 
            +
                        :name
         | 
| 234 | 
            +
                      )
         | 
| 235 | 
            +
                    end
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                    it do
         | 
| 238 | 
            +
                      expect(descendent_class.allowed_options)
         | 
| 239 | 
            +
                        .to eq(expected)
         | 
| 240 | 
            +
                    end
         | 
| 241 | 
            +
                  end
         | 
| 242 | 
            +
                end
         | 
| 243 | 
            +
              end
         | 
| 244 | 
            +
             | 
| 200 245 | 
             
              describe '#initialize' do
         | 
| 201 246 | 
             
                let(:klass) { ConnectionOptions }
         | 
| 202 247 |  | 
| @@ -309,4 +354,28 @@ describe Sinclair::Options do | |
| 309 354 | 
             
                  it { expect(options.protocol).to eq(false) }
         | 
| 310 355 | 
             
                end
         | 
| 311 356 | 
             
              end
         | 
| 357 | 
            +
             | 
| 358 | 
            +
              describe '#==' do
         | 
| 359 | 
            +
                let(:klass) { ConnectionOptions }
         | 
| 360 | 
            +
             | 
| 361 | 
            +
                context 'with black initialization' do
         | 
| 362 | 
            +
                  it do
         | 
| 363 | 
            +
                    expect(klass.new).to eq(klass.new)
         | 
| 364 | 
            +
                  end
         | 
| 365 | 
            +
                end
         | 
| 366 | 
            +
             | 
| 367 | 
            +
                context 'when initializing with same values' do
         | 
| 368 | 
            +
                  let(:first_option) { klass.new(protocol: nil) }
         | 
| 369 | 
            +
                  let(:second_option) { klass.new(protocol: nil) }
         | 
| 370 | 
            +
             | 
| 371 | 
            +
                  it { expect(first_option).to eq(second_option) }
         | 
| 372 | 
            +
                end
         | 
| 373 | 
            +
             | 
| 374 | 
            +
                context 'when initializing with different values' do
         | 
| 375 | 
            +
                  let(:first_option) { klass.new(protocol: nil) }
         | 
| 376 | 
            +
                  let(:second_option) { klass.new }
         | 
| 377 | 
            +
             | 
| 378 | 
            +
                  it { expect(first_option).not_to eq(second_option) }
         | 
| 379 | 
            +
                end
         | 
| 380 | 
            +
              end
         | 
| 312 381 | 
             
            end
         |