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, nocolor = false) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(files, license, nocolor = false) ⇒ CLI
Returns a new instance of CLI.
33 34 35 36 37 |
# File 'lib/xcop.rb', line 33 def initialize(files, license, nocolor = false) @files = files @license = license @nocolor = nocolor end |
Instance Method Details
#fix ⇒ Object
Fix them all.
59 60 61 62 63 64 |
# File 'lib/xcop.rb', line 59 def fix @files.each do |f| Document.new(f).fix(@license) yield(f) if block_given? end end |
#run ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/xcop.rb', line 39 def run @files.each do |f| doc = Document.new(f) diff = doc.diff(@nocolor) 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 |