colorful_json 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/README.md +3 -1
  2. data/bin/cjson +17 -5
  3. data/colorful_json.gemspec +2 -2
  4. metadata +1 -17
data/README.md CHANGED
@@ -8,7 +8,9 @@ JSON](http://f.cl.ly/items/2J1E3C2W1c0K2B1C0p2o/colorful_json.png)
8
8
 
9
9
  ## Install
10
10
 
11
- `sudo gem install colorful_json`
11
+ ```
12
+ gem install colorful_json
13
+ ```
12
14
 
13
15
  ## Usage
14
16
 
data/bin/cjson CHANGED
@@ -1,19 +1,31 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "yajl"
3
+ begin
4
+ require "yajl/json_gem"
5
+ rescue LoadError
6
+ require "json"
7
+ end
4
8
  require "pygments.rb"
5
9
 
6
10
  def parse_json(input)
7
- parsed_input = Yajl::Parser.parse(input)
8
- json = Yajl::Encoder.encode(parsed_input, :pretty => true)
9
- puts Pygments.highlight(json, :formatter => 'terminal', :lexer => 'javascript', :options => {:encoding => 'utf-8'})
10
- exit 0
11
+ begin
12
+ json_parsed = JSON.parse(input)
13
+ rescue JSON::ParserError
14
+ puts "Error parsing the JSON"
15
+ exit 1
11
16
  rescue Yajl::ParseError
12
17
  puts input
13
18
  exit 1
19
+ end
20
+ json = JSON.pretty_generate(json_parsed)
21
+ puts Pygments.highlight(json, :formatter => 'terminal', :lexer => 'javascript', :options => {:encoding => 'utf-8'})
22
+ exit 0
14
23
  end
15
24
 
16
25
  begin
17
26
  lines = ARGF.readlines.join
18
27
  parse_json lines
28
+ rescue Errno::ENOENT
29
+ puts "Error opening the input"
30
+ exit 1
19
31
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "colorful_json"
5
- s.version = '0.9.2'
5
+ s.version = '0.9.3'
6
6
  s.authors = ["Simon Gate"]
7
7
  s.email = ["simon@smgt.me"]
8
8
  s.summary = %q{Colorize and pretty parse JSON and get colored acsii output}
@@ -14,6 +14,6 @@ Gem::Specification.new do |s|
14
14
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
15
  # s.require_paths = ["lib"]
16
16
 
17
- s.add_runtime_dependency "yajl-ruby"
17
+ # s.add_runtime_dependency "yajl-ruby"
18
18
  s.add_runtime_dependency "pygments.rb"
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorful_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,22 +11,6 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: yajl-ruby
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
14
  - !ruby/object:Gem::Dependency
31
15
  name: pygments.rb
32
16
  requirement: !ruby/object:Gem::Requirement