Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/taglob/extensions/file.rb

Class Method Summary collapse

Class Method Details

.parse_tags(line) ⇒ Object



10
11
12
# File 'lib/taglob/extensions/file.rb', line 10

def self.parse_tags(line)
  line =~ /^# ?tags:\s+(.*)/ ? $1.split(',').map {|tag| tag.strip} : []
end

.tags(file) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/taglob/extensions/file.rb', line 2

def self.tags(file)
  parsed_tags = []
  File.readlines(file).each do |line|
    parsed_tags = parsed_tags | self.parse_tags(line)
  end
  parsed_tags
end