Sha256: b48c66258098c72fb4eed1e4ec73ad9414a8003d49e1c43bf81b351e9831b02c

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

require 'singleton'

class SourceValidator
    attr_accessor :private_specs
    attr_accessor :private_sources
    def initialize(private_specs, private_sources)
        @private_specs = private_specs
        @private_sources = private_sources
    end

    # Filters the valids specifications for a given pod
    # Params:
    # +pod+:: podname to be validated
    # +specifications+:: potencial unsecure specs
    # @returs valid specs
    def filter_dependency(pod, specifications)
        return specifications.select { |spec| spec_is_valid(pod, spec) }  
    end

    def spec_is_valid(pod, spec)
        # Allow external dependencies (using :git or :path), which create a local podspec
        return true if !spec.defined_in_file.nil? && spec.defined_in_file.to_s.include?('/Pods/Local Podspecs')
        
        # Allow every dependency that comes from our privates sources
        return true if @private_sources.include? spec.spec_source.url

        # NO dependency that comes from a public source should be in our private specs
        return true if !@private_specs.include? spec.name

        return false
    end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cocoapods-whitelist-0.5.5 lib/cocoapods-whitelist/validator/source_validator.rb
cocoapods-whitelist-0.5.4 lib/cocoapods-whitelist/validator/source_validator.rb
cocoapods-whitelist-0.5.3 lib/cocoapods-whitelist/validator/source_validator.rb
cocoapods-whitelist-0.4.0 lib/cocoapods-whitelist/validator/source_validator.rb
cocoapods-whitelist-0.3.0 lib/cocoapods-whitelist/validator/source_validator.rb
cocoapods-whitelist-0.2.1 lib/cocoapods-whitelist/validator/source_validator.rb
cocoapods-whitelist-0.2.0 lib/cocoapods-whitelist/validator/source_validator.rb