Class: Xcop::CLI
- Inherits:
-
Object
- Object
- Xcop::CLI
- Defined in:
- lib/xcop/cli.rb
Overview
Command line interface.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2017-2025 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#fix ⇒ Object
Fix them all.
-
#initialize(files, nocolor: false) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(files, nocolor: false) ⇒ CLI
Returns a new instance of CLI.
32 33 34 35 |
# File 'lib/xcop/cli.rb', line 32 def initialize(files, nocolor: false) @files = files @nocolor = nocolor end |
Instance Method Details
#fix ⇒ Object
Fix them all.
50 51 52 53 54 55 |
# File 'lib/xcop/cli.rb', line 50 def fix @files.each do |f| Xcop::Document.new(f).fix yield(f) if block_given? end end |
#run ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/xcop/cli.rb', line 37 def run @files.each do |f| doc = Xcop::Document.new(f) diff = doc.diff(nocolor: @nocolor) unless diff.empty? puts diff raise "Invalid XML formatting in #{f}" end yield(f) if block_given? end end |