Class: FileContentRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/technologist/rules/file_content_rule.rb

Direct Known Subclasses

GemRule

Instance Attribute Summary collapse

Attributes inherited from Rule

#framework

Instance Method Summary collapse

Methods inherited from Rule

#initialize

Constructor Details

This class inherits a constructor from Rule

Instance Attribute Details

#file_content_patternObject

Returns the value of attribute file_content_pattern.



4
5
6
# File 'lib/technologist/rules/file_content_rule.rb', line 4

def file_content_pattern
  @file_content_pattern
end

#file_nameObject

Returns the value of attribute file_name.



4
5
6
# File 'lib/technologist/rules/file_content_rule.rb', line 4

def file_name
  @file_name
end

Instance Method Details

#matches?(repository) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
# File 'lib/technologist/rules/file_content_rule.rb', line 6

def matches?(repository)
  !!repository.file_with_content_exists?(file_name) do |content|
    content =~ /#{file_content_pattern}/
  end
end