/
util.rb
38 lines (30 loc) · 869 Bytes
/
util.rb
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
29
30
31
32
33
34
35
36
37
38
module Borg
# General purpose utilities to be mixed in
module Util
def self.included(base)
base.class_eval <<-EVAL
def self.borg(key)
BorgConfig[key]
end
EVAL
end
def borg(key)
BorgConfig[key]
end
# prepends the repository location to a relative path
def root(path, base_folder)
base_folder + path.join("/").chomp("/")
end
def relative(rpath, base_folder)
path = rpath.clone
path = path.sub(Regexp.new('^' + base_folder), '')
return path.split('/').reject { |token| token.blank? }
end
def prune(rpaths)
return rpaths.reject { |rpath| rpath =~ /toolbar\.html$/ || rpath =~ /sidebar\.html$/ }
end
def is_content?(path)
path.length > 0 && path.last.downcase =~ /\.html$/
end
end
end