colorful_json 0.9.0 → 0.9.1

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.
data/README.md CHANGED
@@ -3,6 +3,15 @@
3
3
  Pipe your curl output to cjson and make it both sexier and easier to
4
4
  read.
5
5
 
6
+ ![Colorful
7
+ JSON](http://f.cl.ly/items/2J1E3C2W1c0K2B1C0p2o/colorful_json.png)
8
+
9
+ ## Install
10
+
11
+ `sudo gem install colorful_json`
12
+
13
+ ## Usage
14
+
6
15
  ```
7
16
  curl -s https://api.flattr.com/rest/v2/users/smgt/things | cjson
8
17
  ```
data/bin/cjson CHANGED
@@ -1,11 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "colorful_json"
3
+ require "yajl"
4
+ require "pygments.rb"
4
5
 
5
- if ARGV.empty?
6
- lines = STDIN.readlines.join
7
- else
8
- lines = File.open(ARGV[0]).readlines.join
6
+ 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')
10
+ exit 0
11
+ rescue Yajl::ParseError
12
+ puts input
13
+ exit 1
9
14
  end
10
15
 
11
- puts ColorfulJson.parse(lines)
16
+ begin
17
+ lines = ARGF.readlines.join
18
+ parse_json lines
19
+ end
@@ -1,10 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "colorful_json/version"
4
2
 
5
3
  Gem::Specification.new do |s|
6
4
  s.name = "colorful_json"
7
- s.version = ColorfulJson::VERSION
5
+ s.version = '0.9.1'
8
6
  s.authors = ["Simon Gate"]
9
7
  s.email = ["simon@smgt.me"]
10
8
  s.summary = %q{Colorize and pretty parse JSON and get colored acsii output}
@@ -14,8 +12,8 @@ Gem::Specification.new do |s|
14
12
  s.files = `git ls-files`.split("\n")
15
13
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
14
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
- s.require_paths = ["lib"]
15
+ # s.require_paths = ["lib"]
18
16
 
19
- s.add_runtime_dependency "json"
17
+ s.add_runtime_dependency "yajl-ruby"
20
18
  s.add_runtime_dependency "pygments.rb"
21
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.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-11 00:00:00.000000000Z
12
+ date: 2011-12-18 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: json
16
- requirement: &70205821657600 !ruby/object:Gem::Requirement
15
+ name: yajl-ruby
16
+ requirement: &70233353946180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70205821657600
24
+ version_requirements: *70233353946180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: pygments.rb
27
- requirement: &70205821657180 !ruby/object:Gem::Requirement
27
+ requirement: &70233353945740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70205821657180
35
+ version_requirements: *70233353945740
36
36
  description:
37
37
  email:
38
38
  - simon@smgt.me
@@ -48,9 +48,6 @@ files:
48
48
  - Rakefile
49
49
  - bin/cjson
50
50
  - colorful_json.gemspec
51
- - lib/colorful_json.rb
52
- - lib/colorful_json/version.rb
53
- - test
54
51
  homepage:
55
52
  licenses: []
56
53
  post_install_message:
@@ -1,3 +0,0 @@
1
- class ColorfulJson
2
- VERSION = "0.9.0"
3
- end
data/lib/colorful_json.rb DELETED
@@ -1,15 +0,0 @@
1
- require "colorful_json/version"
2
- require "json"
3
- require "pygments.rb"
4
-
5
- class ColorfulJson
6
-
7
- class << self
8
- def parse(input)
9
- parsed_input = JSON.parse(input)
10
- json = JSON.pretty_generate(parsed_input)
11
- return Pygments.highlight(json, :formatter => 'terminal', :lexer => 'javascript')
12
- end
13
- end
14
-
15
- end
data/test DELETED
@@ -1 +0,0 @@
1
- [{"id":"en_GB","text":"English"},{"id":"sq_AL","text":"Albanian"},{"id":"ar_DZ","text":"Arabic"},{"id":"be_BY","text":"Belarusian"},{"id":"bg_BG","text":"Bulgarian"},{"id":"ca_ES","text":"Catalan"},{"id":"zh_CN","text":"Chinese"},{"id":"hr_HR","text":"Croatian"},{"id":"cs_CZ","text":"Czech"},{"id":"da_DK","text":"Danish"},{"id":"nl_NL","text":"Dutch"},{"id":"eo_EO","text":"Esperanto"},{"id":"et_EE","text":"Estonian"},{"id":"fi_FI","text":"Finnish"},{"id":"fr_FR","text":"French"},{"id":"es_GL","text":"Galician"},{"id":"de_DE","text":"German"},{"id":"el_GR","text":"Greek"},{"id":"iw_IL","text":"Hebrew"},{"id":"hi_IN","text":"Hindi"},{"id":"hu_HU","text":"Hungarian"},{"id":"is_IS","text":"Icelandic"},{"id":"in_ID","text":"Indonesian"},{"id":"ga_IE","text":"Irish"},{"id":"it_IT","text":"Italian"},{"id":"ja_JP","text":"Japanese"},{"id":"ko_KR","text":"Korean"},{"id":"lv_LV","text":"Latvian"},{"id":"lt_LT","text":"Lithuanian"},{"id":"mk_MK","text":"Macedonian"},{"id":"ms_MY","text":"Malay"},{"id":"mt_MT","text":"Maltese"},{"id":"no_NO","text":"Norwegian"},{"id":"nn_NO","text":"Nynorsk"},{"id":"fa_FA","text":"Persian"},{"id":"pl_PL","text":"Polish"},{"id":"pt_PT","text":"Portuguese"},{"id":"ro_RO","text":"Romanian"},{"id":"ru_RU","text":"Russian"},{"id":"sr_RS","text":"Serbian"},{"id":"sk_SK","text":"Slovak"},{"id":"sl_SI","text":"Slovenian"},{"id":"es_ES","text":"Spanish"},{"id":"sv_SE","text":"Swedish"},{"id":"th_TH","text":"Thai"},{"id":"tr_TR","text":"Turkish"},{"id":"uk_UA","text":"Ukrainian"},{"id":"vi_VN","text":"Vietnamese"}]