Sha256: 8eae1c0bdce400e9eaa678423d90542fe3a80072cd4b820839ef0f40cce7b6a3

Contents?: true

Size: 493 Bytes

Versions: 43

Compression:

Stored size: 493 Bytes

Contents

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

43 entries across 43 versions & 1 rubygems

Version Path
license_finder-1.1.0 lib/license_finder/license/matcher.rb
license_finder-1.0.1 lib/license_finder/license/matcher.rb
license_finder-1.0.0.1 lib/license_finder/license/matcher.rb