Class: Komplement::Base
- Inherits:
-
Object
- Object
- Komplement::Base
- Defined in:
- lib/komplement/base.rb
Instance Attribute Summary collapse
-
#dirs ⇒ Object
Returns the value of attribute dirs.
-
#files_of_interest ⇒ Object
readonly
Returns the value of attribute files_of_interest.
-
#filetypes ⇒ Object
Returns the value of attribute filetypes.
-
#ignored_elements ⇒ Object
Returns the value of attribute ignored_elements.
Instance Method Summary collapse
- #find_offenses ⇒ Object
-
#in_dirs(dirs_a) ⇒ Object
all the paths we should look into.
-
#in_filetypes(filetypes_a) ⇒ Object
filetypes to look into for html elements.
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#run ⇒ Object
returns 0 on no offenses, else 2.
-
#with_ignored(ignored_a) ⇒ Object
which html elements to ignore.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/komplement/base.rb', line 5 def initialize @ignored_elements = @filetypes = @dirs = [] end |
Instance Attribute Details
#dirs ⇒ Object
Returns the value of attribute dirs.
53 54 55 |
# File 'lib/komplement/base.rb', line 53 def dirs @dirs end |
#files_of_interest ⇒ Object (readonly)
Returns the value of attribute files_of_interest.
55 56 57 |
# File 'lib/komplement/base.rb', line 55 def files_of_interest @files_of_interest end |
#filetypes ⇒ Object
Returns the value of attribute filetypes.
52 53 54 |
# File 'lib/komplement/base.rb', line 52 def filetypes @filetypes end |
#ignored_elements ⇒ Object
Returns the value of attribute ignored_elements.
51 52 53 |
# File 'lib/komplement/base.rb', line 51 def ignored_elements @ignored_elements end |
Instance Method Details
#find_offenses ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/komplement/base.rb', line 32 def find_offenses [@ignored_elements, @filetypes, @dirs].map { |e| e.uniq! } paths = make_paths @files_of_interest = make_files(paths) unknown = Hash.new { |h, k| h[k] = [] } @files_of_interest.each do |file| contents = File.read(file) Nokogiri::HTML(contents).traverse do |node| unless @ignored_elements.include? nm = node.name unknown[file].push nm end end end unknown end |
#in_dirs(dirs_a) ⇒ Object
all the paths we should look into
22 23 24 25 |
# File 'lib/komplement/base.rb', line 22 def in_dirs(dirs_a) @dirs += dirs_a self end |
#in_filetypes(filetypes_a) ⇒ Object
filetypes to look into for html elements
16 17 18 19 |
# File 'lib/komplement/base.rb', line 16 def in_filetypes(filetypes_a) @filetypes = filetypes_a.map { |e| "*.#{e}" } self end |
#run ⇒ Object
returns 0 on no offenses, else 2
28 29 30 |
# File 'lib/komplement/base.rb', line 28 def run process_output(find_offenses) end |
#with_ignored(ignored_a) ⇒ Object
which html elements to ignore
10 11 12 13 |
# File 'lib/komplement/base.rb', line 10 def with_ignored(ignored_a) @ignored_elements += ignored_a self end |