Class: Xcop::CLI
- Inherits:
-
Object
- Object
- Xcop::CLI
- Defined in:
- lib/xcop.rb
Overview
Command line interface.
Instance Method Summary collapse
-
#fix ⇒ Object
Fix them all.
-
#initialize(files, license) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(files, license) ⇒ CLI
Returns a new instance of CLI.
33 34 35 36 |
# File 'lib/xcop.rb', line 33 def initialize(files, license) @files = files @license = license end |
Instance Method Details
#fix ⇒ Object
Fix them all.
58 59 60 61 62 63 |
# File 'lib/xcop.rb', line 58 def fix @files.each do |f| Document.new(f).fix(@license) yield(f) if block_given? end end |
#run ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/xcop.rb', line 38 def run @files.each do |f| doc = Document.new(f) diff = doc.diff unless diff.empty? puts diff raise "Invalid XML formatting in #{f}" end unless @license.empty? ldiff = doc.ldiff(@license) unless ldiff.empty? puts ldiff raise "Broken license in #{f}" end end yield(f) if block_given? end end |