From 22c25e42847d41924d43d31f3ef67be1ae4a155e Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 25 Mar 2011 12:37:59 +0000 Subject: include json gem (for tests to pass) --- vendor/gems/json-1.5.1/bin/prettify_json.rb | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 vendor/gems/json-1.5.1/bin/prettify_json.rb (limited to 'vendor/gems/json-1.5.1/bin/prettify_json.rb') diff --git a/vendor/gems/json-1.5.1/bin/prettify_json.rb b/vendor/gems/json-1.5.1/bin/prettify_json.rb new file mode 100755 index 000000000..5e1f8062d --- /dev/null +++ b/vendor/gems/json-1.5.1/bin/prettify_json.rb @@ -0,0 +1,75 @@ +#!/usr/bin/env ruby + +require 'json' +require 'fileutils' +include FileUtils + +# Parses the argument array _args_, according to the pattern _s_, to +# retrieve the single character command line options from it. If _s_ is +# 'xy:' an option '-x' without an option argument is searched, and an +# option '-y foo' with an option argument ('foo'). +# +# An option hash is returned with all found options set to true or the +# found option argument. +def go(s, args = ARGV) + b, v = s.scan(/(.)(:?)/).inject([{},{}]) { |t,(o,a)| + t[a.empty? ? 0 : 1][o] = a.empty? ? false : nil + t + } + while a = args.shift + a !~ /\A-(.+)/ and args.unshift a and break + p = $1 + until p == '' + o = p.slice!(0, 1) + if v.key?(o) + v[o] = if p == '' then args.shift or break 1 else p end + break + elsif b.key?(o) + b[o] = true + else + args.unshift a + break 1 + end + end and break + end + b.merge(v) +end + +opts = go 'slhi:', args = ARGV.dup +if opts['h'] || opts['l'] && opts['s'] + puts <