class Xcop::CLI

Command line interface.

Public Class Methods

new(files, license, nocolor = false) click to toggle source
# File lib/xcop.rb, line 33
def initialize(files, license, nocolor = false)
  @files = files
  @license = license
  @nocolor = nocolor
end

Public Instance Methods

fix() { |f| ... } click to toggle source

Fix them all.

# 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() { |f| ... } click to toggle source
# 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