Module: Hoygancop

Defined in:
lib/hoygancop.rb,
lib/hoygancop/support.rb,
lib/hoygancop/version.rb,
lib/hoygancop/rules/ayudenme.rb,
lib/hoygancop/rules/simple_rule.rb,
lib/hoygancop/rules/too_much_caps.rb,
lib/hoygancop/rules/too_much_marks.rb,
lib/hoygancop/rules/starts_with_hoygan.rb

Defined Under Namespace

Modules: Rules, Support

Constant Summary collapse

VERSION =
"0.0.1.2"

Class Method Summary collapse

Class Method Details

.correct(text, options = {}) ⇒ Object



21
22
23
24
# File 'lib/hoygancop.rb', line 21

def self.correct(text, options = {})
  rules = (options[:rules] || default_rules)
  ruleset(rules).inject(text){ |text, rule| rule.new(text).correct }
end

.default_rulesObject



6
7
8
# File 'lib/hoygancop.rb', line 6

def self.default_rules
  %w{starts_with_hoygan ayudenme too_much_marks too_much_caps}
end

.hoygan?(text, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/hoygancop.rb', line 16

def self.hoygan?(text, options = {})
  rules = (options[:rules] || default_rules)
  ruleset(rules).any?{ |rule| rule.new(text).hoygan? }
end

.report(text, options = {}) ⇒ Object



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

def self.report(text, options = {})
  rules = (options[:rules] || default_rules)
  ruleset(rules).inject(Set.new) do |report, rule|
    report + rule.new(text).report
  end.to_a
end

.ruleset(rules) ⇒ Object



10
11
12
13
14
# File 'lib/hoygancop.rb', line 10

def self.ruleset(rules)
  rules.map do |rule|
    Hoygancop::Rules.const_get(Hoygancop::Support.camelize(rule).to_sym)
  end
end