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-5.4.1 lib/license_finder/license/matcher.rb
license_finder-5.4.0 lib/license_finder/license/matcher.rb
license_finder-5.3.0 lib/license_finder/license/matcher.rb
license_finder-5.2.3 lib/license_finder/license/matcher.rb
license_finder-5.2.1 lib/license_finder/license/matcher.rb
license_finder-5.2.0 lib/license_finder/license/matcher.rb
license_finder-5.1.1 lib/license_finder/license/matcher.rb
license_finder-5.1.0 lib/license_finder/license/matcher.rb
license_finder-5.0.3 lib/license_finder/license/matcher.rb
license_finder-5.0.2 lib/license_finder/license/matcher.rb
license_finder-5.0.0 lib/license_finder/license/matcher.rb
license_finder-4.0.2 lib/license_finder/license/matcher.rb
license_finder-4.0.1 lib/license_finder/license/matcher.rb
license_finder-3.1.1 lib/license_finder/license/matcher.rb
license_finder-3.0.4 lib/license_finder/license/matcher.rb
license_finder-3.0.2 lib/license_finder/license/matcher.rb
license_finder-3.0.1 lib/license_finder/license/matcher.rb
license_finder-3.0.0 lib/license_finder/license/matcher.rb
license_finder-2.1.2 lib/license_finder/license/matcher.rb
license_finder-2.1.1 lib/license_finder/license/matcher.rb