Sha256: 92920ab84c4c2d7c7fdb813ec3ec92a66a73da1e28258f9e359a6258cab116d4

Contents?: true

Size: 524 Bytes

Versions: 46

Compression:

Stored size: 524 Bytes

Contents

# frozen_string_literal: true

module LicenseFinder
  class License
    Matcher = Struct.new(:regexp) do
      def self.from_template(template)
        from_text(template.content)
      end

      def self.from_text(text)
        from_regex(Text.compile_to_regex(text))
      end

      # an alias for Matcher.new, for uniformity of constructors
      def self.from_regex(regexp)
        new(regexp)
      end

      def matches_text?(text)
        !!(Text.normalize_punctuation(text) =~ regexp)
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
license_finder-7.1.0 lib/license_finder/license/matcher.rb
license_finder-7.0.1 lib/license_finder/license/matcher.rb
license_finder-7.0.0 lib/license_finder/license/matcher.rb
license_finder-6.15.0 lib/license_finder/license/matcher.rb
gitlab-license_finder-6.14.2.1 lib/license_finder/license/matcher.rb
license_finder-6.14.2 lib/license_finder/license/matcher.rb
license_finder-6.14.1 lib/license_finder/license/matcher.rb
license_finder-6.13.0 lib/license_finder/license/matcher.rb
license_finder-6.12.2 lib/license_finder/license/matcher.rb
license_finder-6.12.1 lib/license_finder/license/matcher.rb
license_finder-6.12.0 lib/license_finder/license/matcher.rb
license_finder-6.11.0 lib/license_finder/license/matcher.rb
license_finder-6.10.1 lib/license_finder/license/matcher.rb
license_finder-6.10.0 lib/license_finder/license/matcher.rb
license_finder-6.9.0 lib/license_finder/license/matcher.rb
license_finder-6.8.2 lib/license_finder/license/matcher.rb
license_finder-6.8.1 lib/license_finder/license/matcher.rb
license_finder-6.8.0 lib/license_finder/license/matcher.rb
license_finder-6.7.0 lib/license_finder/license/matcher.rb
license_finder-6.6.2 lib/license_finder/license/matcher.rb