jsonpretty 1.0.0 → 1.1.0

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/History.txt +4 -0
  2. data/README.txt +1 -1
  3. data/lib/jsonpretty.rb +16 -4
  4. metadata +8 -15
@@ -1,3 +1,7 @@
1
+ === 1.1.0 / 2010-01-20
2
+
3
+ * Parses and displays jsonp–flavored json
4
+
1
5
  === 1.0.0 / 2009-02-20
2
6
 
3
7
  * 1 major enhancement
data/README.txt CHANGED
@@ -8,7 +8,7 @@ Command-line JSON pretty-printer, using the json gem.
8
8
 
9
9
  == FEATURES/PROBLEMS:
10
10
 
11
- - Parse and pretty-print JSON either from stdin or from command-line
11
+ - Parse and pretty-print JSON/JSONP either from stdin or from command-line
12
12
  arguments.
13
13
  - All arguments are concatenated together in a single string for
14
14
  pretty-printing.
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
3
  class Jsonpretty
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
 
6
6
  def file_value(filename)
7
7
  file = if filename == '-'
@@ -24,7 +24,17 @@ class Jsonpretty
24
24
  def stdin_value
25
25
  file_value('-')
26
26
  end
27
-
27
+
28
+ def clean_jsonp(input_string)
29
+ match = input_string.match(/^(.+)\((.+)\)$/)
30
+ if match
31
+ puts "jsonp method name: #{match[1]}\n\n"
32
+ match[2]
33
+ else
34
+ input_string
35
+ end
36
+ end
37
+
28
38
  def main
29
39
  if ARGV.length == 0
30
40
  ARGV.unshift stdin_value
@@ -47,8 +57,10 @@ class Jsonpretty
47
57
  end
48
58
  end
49
59
  end
50
-
51
- puts JSON.pretty_generate(JSON.parse(ARGV.join(' ')))
60
+
61
+ input = clean_jsonp(ARGV.join(' '))
62
+ json = JSON.parse(input)
63
+ puts JSON.pretty_generate(json)
52
64
  rescue => e
53
65
  $stderr.puts "jsonpretty failed: #{e.message}"
54
66
  exit 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonpretty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger
@@ -9,19 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-20 00:00:00 -06:00
12
+ date: 2010-01-20 00:00:00 -06:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: json
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
14
+ dependencies: []
15
+
25
16
  description: Command-line JSON pretty-printer, using the json gem.
26
17
  email:
27
18
  - nick@nicksieger.com
@@ -42,6 +33,8 @@ files:
42
33
  - lib/jsonpretty.rb
43
34
  has_rdoc: true
44
35
  homepage: http://github.com/nicksieger/jsonpretty
36
+ licenses: []
37
+
45
38
  post_install_message:
46
39
  rdoc_options:
47
40
  - --main
@@ -63,9 +56,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
56
  requirements: []
64
57
 
65
58
  rubyforge_project: caldersphere
66
- rubygems_version: 1.3.1
59
+ rubygems_version: 1.3.5
67
60
  signing_key:
68
- specification_version: 2
61
+ specification_version: 3
69
62
  summary: Command-line JSON pretty-printer, using the json gem.
70
63
  test_files: []
71
64