Module: PatternMatcher
- Defined in:
- lib/pattern_matcher.rb,
lib/pattern_matcher/match.rb,
lib/pattern_matcher/config.rb,
lib/pattern_matcher/matcher.rb,
lib/pattern_matcher/pattern.rb,
lib/pattern_matcher/version.rb,
lib/pattern_matcher/pattern_manager.rb
Defined Under Namespace
Classes: Config, Match, Matcher, Pattern, PatternManager
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
Class Method Details
.add_pattern_hash(hash) ⇒ Object
50
51
52
53
|
# File 'lib/pattern_matcher.rb', line 50
def self.add_pattern_hash(hash)
pattern = Pattern.new(hash)
@patterns.add_pattern pattern if pattern.is_valid?
end
|
.configuration ⇒ Object
20
21
22
|
# File 'lib/pattern_matcher.rb', line 20
def self.configuration
@configuration ||= PatternMatcher::Config.new
end
|
15
16
17
18
|
# File 'lib/pattern_matcher.rb', line 15
def self.configure
yield configuration if block_given?
@patterns = PatternManager.initialize_patterns
end
|
24
25
26
|
# File 'lib/pattern_matcher.rb', line 24
def self.configured?
!@configuration.nil?
end
|
.match_patterns_to_text(text) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/pattern_matcher.rb', line 28
def self.match_patterns_to_text(text)
matches = []
@patterns.to_a.each do |pattern|
regex_match = Matcher.match_pattern_in_text(pattern, text)
matches << Match.new({:name => pattern.name, :regex_match => regex_match}) if regex_match
end
matches
end
|
.patterns ⇒ Object
46
47
48
|
# File 'lib/pattern_matcher.rb', line 46
def self.patterns
@patterns
end
|
.proof_patterns ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/pattern_matcher.rb', line 37
def self.proof_patterns
pattern_errors = {}
@patterns.each do |pattern|
failures = pattern.validate_all_examples
pattern_errors[pattern.pattern_id] = failures if (pattern.is_valid? && failures.count > 0)
end
pattern_errors
end
|