Module: Doxyparser::Util

Included in:
Node
Defined in:
lib/util.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.home_dirObject



5
6
7
# File 'lib/util.rb', line 5

def self.home_dir
	File.expand_path('..', File.dirname(__FILE__))
end

.read_file(file_name) ⇒ Object



33
34
35
36
37
38
# File 'lib/util.rb', line 33

def self.read_file file_name
	file = File.open(file_name, "r")
	data = file.read
	file.close
	return data
end

.write_file(file_name, data) ⇒ Object



40
41
42
43
44
45
# File 'lib/util.rb', line 40

def self.write_file file_name, data
	file = File.open(file_name, "w")
	count = file.write(data)
	file.close
	return count
end

Instance Method Details

#del_prefix(n) ⇒ Object



13
14
15
# File 'lib/util.rb', line 13

def del_prefix n
	n.gsub(%r{.*[:/]}, "")
end

#del_spaces(n) ⇒ Object



9
10
11
# File 'lib/util.rb', line 9

def del_spaces n
	n.gsub(/\s+/, "")
end

#do_filter(filter, lst, clazz) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/util.rb', line 47

def do_filter filter, lst, clazz
	if filter
		filtered_lst = []
		filter.each { |val|
			found = lst.select { |node| match(val, yield(node)) }
			raise "The object: #{val} #{clazz} could not be found while parsing" if found.nil? || found.empty?
			filtered_lst.push(*found)
		}
	else
	filtered_lst=lst
	end
	filtered_lst.map { |node| clazz.new(parent: self, node: node) }
end

#escape_class_name(filename) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/util.rb', line 25

def escape_class_name filename
	if filename.include? '::'
		return filename.gsub('::','_1_1')
	else
		return filename.gsub('_1_1','::')
	end
end

#escape_file_name(filename) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/util.rb', line 17

def escape_file_name filename
	if filename =~ %r{[\./]}
		return filename.gsub('.', '_8').gsub('/', '_2')
	else
		return filename.gsub('_8', '.').gsub('_2', '/')
	end
end

#match(val, aux_name) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/util.rb', line 61

def match val, aux_name
	if val.is_a? Regexp
	return aux_name =~ val
	else
	return aux_name == val
	end
end