Module: GitFeats::Checker

Extended by:
Checker
Included in:
Checker
Defined in:
lib/git-feats/checker.rb

Instance Method Summary collapse

Instance Method Details

#check(args) ⇒ Object

Main interface for checking feats



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/git-feats/checker.rb', line 7

def check(args)

  # Load history and completed
  Completed.unserialize
  History.unserialize

  # request flag
  upload = false

  # Check for feats and update history
  Feats.all.each do |pattern, feats|
    if args.match?(pattern)
      History.add(pattern)

      feats.each do |feat, value|
        if History.count(pattern) >= value[:count]
          unless Completed.exists?(feat)
            Completed.add(feat) 
            Reporter.report(value)
            upload = true
          end
        end
      end
    end
  end

  # upload feats if the request flag is set
  upload_feats if upload

  # Write out history and completed feats
  Completed.serialize
  History.serialize
end