Module: Jazor
- Defined in:
- lib/jazor.rb,
lib/jazor/app_info.rb
Defined Under Namespace
Classes: RestClient
Constant Summary collapse
- LOG =
Logger.new(STDOUT)
- HAS_ORDERED_HASH =
(RUBY_VERSION.split(".").map(&:to_i) <=> [1, 9, 1]) >= 0
- NAME =
"jazor"
- VERSION =
"0.1.8"
- AUTHOR =
"Michael Paul Thomas Conigliaro"
- AUTHOR_EMAIL =
"mike [at] conigliaro [dot] org"
- DESCRIPTION =
"Jazor (JSON razor) is a simple command line JSON parsing tool."
- URL =
"http://github.com/mconigliaro/jazor"
Class Method Summary collapse
- .colorize(input) ⇒ Object
- .evaluate(obj, expression) ⇒ Object
- .parse(input = nil, options = {}) ⇒ Object
Class Method Details
.colorize(input) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/jazor.rb', line 31 def self.colorize(input) input = input.gsub(/"(.*)":/, "\\1:".bold) # Key input = input.gsub(/"(#{URI::regexp})"/i, "\\1".magenta.underline) # URL input = input.gsub(/"(.*)"/, "\"\\1\"".green) # String input = input.gsub(/(\s+[-+]?\d*\.?\d+)(,?)$/, "\\1".cyan + "\\2") # Numeric input = input.gsub(/(\s+(true|false))(,?)$/, "\\1".blue + "\\3") # Boolean input = input.gsub(/(\s+null)(,?)$/, "\\1".red + "\\2") # Null end |
.evaluate(obj, expression) ⇒ Object
27 28 29 |
# File 'lib/jazor.rb', line 27 def self.evaluate(obj, expression) expression.nil? ? obj : obj.instance_eval(expression) end |