Class: Codesake::Engine::Text

Inherits:
Object
  • Object
show all
Includes:
Core, Utils::Files, Utils::Secrets
Defined in:
lib/codesake/engine/text.rb

Constant Summary

Constants included from Utils::Secrets

Utils::Secrets::DEFAULT_SECRETS

Instance Attribute Summary collapse

Attributes included from Utils::Secrets

#secrets

Attributes included from Utils::Files

#file_content, #filename

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::Secrets

#add, #find_reserved_keywords, #load_secrets, #reserved?

Methods included from Utils::Files

#lines, #lines_of_comment, #loc, #read_file

Constructor Details

#initialize(filename) ⇒ Text

Returns a new instance of Text.



12
13
14
15
16
17
18
# File 'lib/codesake/engine/text.rb', line 12

def initialize(filename)
  @filename = filename
  @raw_results = nil
  
  read_file
  load_secrets
end

Instance Attribute Details

#reserved_keywordsObject (readonly)

Returns the value of attribute reserved_keywords.



10
11
12
# File 'lib/codesake/engine/text.rb', line 10

def reserved_keywords
  @reserved_keywords
end

Class Method Details

.is_txt?(filename) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/codesake/engine/text.rb', line 30

def self.is_txt?(filename)
  (File.extname(filename).empty? or File.extname(filename) == ".txt" or File.extname(filename) == ".conf" or File.extname(filename) == ".rc" or File.extname(filename) == ".bak" or File.extname(filename) == ".old" )
end

Instance Method Details

#analyseObject



20
21
22
23
24
25
26
27
28
# File 'lib/codesake/engine/text.rb', line 20

def analyse
  ret =  []
  @reserved_keywords = find_reserved_keywords
  @reserved_keywords.each do |secret|
    ret << "reserved keyword found: \"#{secret[:matcher]}\" (#{@filename}@#{secret[:line]})"
  end
   
  ret
end