colorful_json 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pretty_json.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Simon Gate, Joel Hansson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a
4
+ copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included
12
+ in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # Color your JSON!
2
+
3
+ Pipe your curl output to cjson and make it both sexier and easier to
4
+ read.
5
+
6
+ ```
7
+ curl -s https://api.flattr.com/rest/v2/users/smgt/things | cjson
8
+ ```
9
+
10
+ Or open a file from disk
11
+
12
+ ```
13
+ cjson things.json
14
+ ```
15
+
16
+ ## Copyright
17
+
18
+ Copyright (c) 2011 Simon Gate. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/cjson ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "colorful_json"
4
+
5
+ if ARGV.empty?
6
+ lines = STDIN.readlines.join
7
+ else
8
+ lines = File.open(ARGV[0]).readlines.join
9
+ end
10
+
11
+ puts ColorfulJson.parse(lines)
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "colorful_json/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "colorful_json"
7
+ s.version = ColorfulJson::VERSION
8
+ s.authors = ["Simon Gate"]
9
+ s.email = ["simon@smgt.me"]
10
+ s.summary = %q{Colorize and pretty parse JSON and get colored acsii output}
11
+
12
+ s.rubyforge_project = "colorful_json"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency "json"
20
+ s.add_runtime_dependency "pygments.rb"
21
+ end
@@ -0,0 +1,3 @@
1
+ class ColorfulJson
2
+ VERSION = "0.9.0"
3
+ end
@@ -0,0 +1,15 @@
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 ADDED
@@ -0,0 +1 @@
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"}]
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colorful_json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Simon Gate
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-11 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: &70205821657600 !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: *70205821657600
25
+ - !ruby/object:Gem::Dependency
26
+ name: pygments.rb
27
+ requirement: &70205821657180 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70205821657180
36
+ description:
37
+ email:
38
+ - simon@smgt.me
39
+ executables:
40
+ - cjson
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - LICENSE.md
47
+ - README.md
48
+ - Rakefile
49
+ - bin/cjson
50
+ - colorful_json.gemspec
51
+ - lib/colorful_json.rb
52
+ - lib/colorful_json/version.rb
53
+ - test
54
+ homepage:
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project: colorful_json
74
+ rubygems_version: 1.8.10
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Colorize and pretty parse JSON and get colored acsii output
78
+ test_files: []