Class: Fdlint::CLI::Runner
- Includes:
- Helper::Logger
- Defined in:
- lib/fdlint/cli.rb
Constant Summary
Constants included from Helper::Logger
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #list_rules ⇒ Object
- #run ⇒ Object
Methods included from Helper::Logger
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fdlint/cli.rb', line 29 def initialize( ={} ) @options = @files = [:files] # 默认不检查已经被压缩的文件 @checkmin = [:checkmin] # Windows 下默认是ANSI编码 # 我们需要使用 UTF-8 编码输出 IO.popen "chcp 65001" if ENV['OS'] =~ /windows/i $logger = Logger.new(STDOUT).tap do |l| l.level = [:debug] ? Logger::DEBUG : Logger::FATAL end end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
27 28 29 |
# File 'lib/fdlint/cli.rb', line 27 def files @files end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
27 28 29 |
# File 'lib/fdlint/cli.rb', line 27 def @options end |
Instance Method Details
#list_rules ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fdlint/cli.rb', line 56 def list_rules ::Fdlint::Rule.rules.each do |syntax, rules| puts "----> #{syntax} (#{rules.size})\n\n" rules.each do |rule| print " " * 6 print rule print "\n" end print "\n" end end |
#run ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fdlint/cli.rb', line 45 def run trap("SIGINT") { puts "\nGoodbye!"; exit! } if text = @options[:text] validate_content elsif !@files.empty? validate_files end end |