jsonpp 1.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/jsonpp +12 -2
  2. metadata +10 -5
data/bin/jsonpp CHANGED
@@ -1,6 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'multi_json'
3
3
 
4
+ PAIRS = {
5
+ :load => [:load, :dump],
6
+ :decode => [:decode, :encode],
7
+ }
8
+
4
9
  def main(file_path)
5
10
  case file_path
6
11
  when '-h', '--help'
@@ -12,9 +17,14 @@ def main(file_path)
12
17
  input = File.read file_path
13
18
  end
14
19
 
15
- data = MultiJson.decode input
20
+ if MultiJson.respond_to?(:load)
21
+ decode, encode = PAIRS[:load]
22
+ else
23
+ decode, encode = PAIRS[:decode]
24
+ end
16
25
 
17
- output = MultiJson.encode(data, :pretty => true)
26
+ data = MultiJson.public_send(decode, input)
27
+ output = MultiJson.public_send(encode, data, :pretty => true)
18
28
 
19
29
  puts output
20
30
  rescue MultiJson::DecodeError => ex
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonpp
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.3
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: 2012-02-15 00:00:00.000000000 Z
12
+ date: 2013-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &70306291142560 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70306291142560
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: A really small gem that prints your `curl` output nicely
26
31
  email: jonas@pfenniger.name
27
32
  executables:
@@ -51,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
56
  version: '0'
52
57
  requirements: []
53
58
  rubyforge_project:
54
- rubygems_version: 1.8.11
59
+ rubygems_version: 1.8.23
55
60
  signing_key:
56
61
  specification_version: 3
57
62
  summary: Command-line JSON pretty-printer