File: implementation.rb

package info (click to toggle)
ruby-github-markup 1.5.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 336 kB
  • ctags: 118
  • sloc: ruby: 373; python: 113; sh: 21; makefile: 15
file content (28 lines) | stat: -rw-r--r-- 526 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module GitHub
  module Markup
    class Implementation
      attr_reader :regexp

      def initialize(regexp)
        @regexp = regexp
      end

      def load
        # no-op by default
      end

      def render(content)
        raise NotImplementedError, "subclasses of GitHub::Markup::Implementation must define #render"
      end

      def match?(filename)
        file_ext_regexp =~ filename
      end

    private
      def file_ext_regexp
        @file_ext_regexp ||= /\.(#{regexp})\z/
      end
    end
  end
end