Sha256: 9896e30baba94be8225f938513d4c07f6a6704c6d76d19a4b437facf1ef1e4b7

Contents?: true

Size: 461 Bytes

Versions: 2

Compression:

Stored size: 461 Bytes

Contents

class Taglob
  VERSION = '0.0.1'
end

class Dir
  
  def self.taglob(pattern,*tags)
    tagged_files = []
    Dir.glob(pattern).each do |file|
      parsed_tags = []
      File.readlines(file).each do |line|
        parsed_tags = parsed_tags | self.parse_tags(line)
      end
      tagged_files << file unless (parsed_tags & tags).empty?
    end
    tagged_files
  end
  
  def self.parse_tags(line)
    line =~ /^#tags:\s+(.*)/ ?$1.split(',') : []
  end
  
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
scudco-taglob-0.0.1 lib/taglob.rb
taglob-0.0.1 lib/taglob.rb