Sha256: c505c17a39e2f1bc3aaf3c40f0406bc2d9fe03f247b037b3512c83d501664e4a

Contents?: true

Size: 427 Bytes

Versions: 5

Compression:

Stored size: 427 Bytes

Contents

require 'markdo/command'

module Markdo
  class QueryCommand < Command
    def run(string)
      regexp = Regexp.new(string, Regexp::IGNORECASE)

      matches = Dir.
        glob(markdown_glob).
        map { |path| File.readlines(path, encoding: 'UTF-8') }.
        flatten.
        grep(regexp)

      @stdout.puts(matches)
    end

    protected

    def markdown_glob
      "#{@env['MARKDO_ROOT']}/*.md"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
markdo-0.1.6 lib/markdo/query_command.rb
markdo-0.1.5 lib/markdo/query_command.rb
markdo-0.1.4 lib/markdo/query_command.rb
markdo-0.1.3 lib/markdo/query_command.rb
markdo-0.1.2 lib/markdo/query_command.rb