Module: Colora
- Defined in:
- lib/colora.rb,
lib/colora/data.rb,
lib/colora/lines.rb,
lib/colora/configure.rb,
lib/colora/plugs/diff.rb,
lib/colora/plugs/markdown.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.2.240119'
- Config =
OpenStruct.new
- FILTERS =
Filter keys:
%i[quiet green red code comment dupcode dupcomment]
Class Method Summary collapse
- .configure(options) ⇒ Object
-
.run(options = nil) ⇒ Object
Colora.run(options).
Class Method Details
.configure(options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/colora/configure.rb', line 26 def self.configure() # FILE: Config.file = .file if .file # Options: Config.theme = .theme if .theme? Config.lang = .lang if .lang? Config.git = .git? Config.tab = .tab? # Filters: # Config.quiet=options.quiet? ... FILTERS.each{Config[_1]=.send("#{_1}?")} end |
.run(options = nil) ⇒ Object
Colora.run(options)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/colora.rb', line 6 def self.run(=nil) # Standard libraries: require 'ostruct' # Gems: require 'fuzzystringmatch' require 'paint' require 'rouge' # Colora: require_relative 'colora/configure' require_relative 'colora/data' require_relative 'colora/lines' # Plugs: require_relative 'colora/plugs/diff' require_relative 'colora/plugs/markdown' # Configure Colora: Colora.configure() if # By default, run git-diff: Config.git = true if $stdin.tty? && !Config.file # Puts Colora::Lines Lines.new.each do |line| line.gsub!("\t", '⇥') if Config.tab puts line end end |