Class: Mkbook::Utils
- Inherits:
-
Object
- Object
- Mkbook::Utils
- Defined in:
- lib/mkbook/utils.rb
Class Method Summary collapse
- .command_exists?(command) ⇒ Boolean
- .log(type, msg) ⇒ Object
- .log_debug(msg) ⇒ Object
- .log_error(msg) ⇒ Object
- .log_info(msg) ⇒ Object
- .post_pandoc(string) ⇒ Object
- .pre_pandoc(string) ⇒ Object
Class Method Details
.command_exists?(command) ⇒ Boolean
17 18 19 20 21 22 23 24 25 |
# File 'lib/mkbook/utils.rb', line 17 def self.command_exists?(command) if File.executable?(command) then return command end ENV['PATH'].split(File::PATH_SEPARATOR).map do |path| cmd = "#{path}/#{command}" File.executable?(cmd) || File.executable?("#{cmd}.exe") || File.executable?("#{cmd}.cmd") end.inject { |a, b| a || b } end |
.log(type, msg) ⇒ Object
27 28 29 |
# File 'lib/mkbook/utils.rb', line 27 def self.log(type, msg) print "[#{type}] #{Time.now} #{msg}" end |
.log_debug(msg) ⇒ Object
39 40 41 |
# File 'lib/mkbook/utils.rb', line 39 def self.log_debug(msg) log("DEBUG", msg) end |
.log_error(msg) ⇒ Object
35 36 37 |
# File 'lib/mkbook/utils.rb', line 35 def self.log_error(msg) log("ERROR", msg) end |
.log_info(msg) ⇒ Object
31 32 33 |
# File 'lib/mkbook/utils.rb', line 31 def self.log_info(msg) log("INFO", msg) end |
.post_pandoc(string) ⇒ Object
11 12 13 14 15 |
# File 'lib/mkbook/utils.rb', line 11 def self.post_pandoc(string) replace = Replace.new(string) replace.post_pandoc_for_latex replace.string end |
.pre_pandoc(string) ⇒ Object
5 6 7 8 9 |
# File 'lib/mkbook/utils.rb', line 5 def self.pre_pandoc(string) replace = Replace.new(string) replace.pre_pandoc_for_latex replace.string end |