lazy-pp-json 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e219c038868b87ed3a27c5845d38ac2bade011a
4
- data.tar.gz: a15660808bc9659df9374c470e0e2d1d53904e66
3
+ metadata.gz: 7140db98d85d568b58d03a9bd826d302ea631194
4
+ data.tar.gz: 92a3bf4d3baeba9d11c164aa8d9bd32379e5e9fd
5
5
  SHA512:
6
- metadata.gz: d7a9a43625d67b0b1b2d070fec123af82fe3a448ca7d5608a3ff44ecf2275ca7467f81a163ffb13eeb57c880c9297ba07c7062dfd8c653f3199414d2858753b5
7
- data.tar.gz: d66214d414e862f0871003484d949348f26887e8eb0983174ab2ddba7b60c03b10cafbd3ffa9ce9ad9188ce857dd82bc99c929d390e3ad40c1199efc63ae4148
6
+ metadata.gz: 75120bb703e9c8e86f00a0341fff6e683653b06b7219d1443998d11e58edb43ee43f22bede6b469a4f09b8aefc73b22c5e7914355c6d77a1ac8752a99948d986
7
+ data.tar.gz: 1a43b0706df04339bdb92c0a23d30dc9b052758c82625b5b9912d42721c6c623a66fc8580e0574934997dda9470eecbacefcc85881d6908cf7c0f14a52321be2
data/README.md CHANGED
@@ -6,29 +6,6 @@
6
6
 
7
7
  Lazy pp json responses.
8
8
 
9
- ### Normal pp
10
-
11
- ```ruby
12
- pp JSON.parse('{"key1":{"key1-1":"value1-1","key1-2":"value1-2"}, "key2":"value2"}')
13
- #=> {"key1"=>{"key1-1"=>"value1-1", "key1-2"=>"value1-2"}, "key2"=>"value2"}
14
- ```
15
-
16
- ### lazy-pp-json
17
-
18
- ```ruby
19
- pp Lazy::PP::JSON.new('{"key1":{"key1-1":"value1-1","key1-2":"value1-2"}, "key2":"value2"}')
20
- #=>
21
- # {
22
- # "key1":
23
- # {
24
- # "key1-1":"value1-1",
25
- # "key1-2":"value1-2"
26
- # },
27
- # "key2":"value2"
28
- # }
29
- #
30
- ```
31
-
32
9
  ## Installation
33
10
 
34
11
  $ gem install lazy-pp-json
@@ -8,9 +8,9 @@ if ARGV.size > 1
8
8
  error: lazy-pp-json should have 1 argument only.
9
9
 
10
10
  Usage:
11
- lazy-pp-json JSON_STRING
11
+ lazy-pp-json JSON_FILE
12
12
  DESCRIPTION
13
13
  exit(false)
14
14
  end
15
15
 
16
- pp Lazy::PP::JSON.new(ARGV.first)
16
+ pp Lazy::PP::JSON.new(File.read(ARGV.first))
@@ -20,7 +20,16 @@ module Lazy
20
20
 
21
21
  def pretty_print(pretty_print)
22
22
  @pretty_print = pretty_print
23
- object = ::JSON.parse(self)
23
+ begin
24
+ object = ::JSON.parse(self)
25
+ rescue
26
+ if self.kind_of?(Numeric) or self.kind_of?(String)
27
+ @pretty_print.text self
28
+ return
29
+ else
30
+ raise
31
+ end
32
+ end
24
33
 
25
34
  if object.empty?
26
35
  @pretty_print.pp object
@@ -3,7 +3,7 @@
3
3
  module Lazy
4
4
  module PP
5
5
  class JSON < String
6
- VERSION = "0.0.2"
6
+ VERSION = "0.0.3"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,110 +1,86 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy-pp-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshihara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-09 00:00:00.000000000 Z
11
+ date: 2014-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: test-unit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: test-unit-notify
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: |-
84
- Lazy pp json responses.
85
-
86
- ### Normal pp
87
-
88
- ```ruby
89
- pp JSON.parse('{"key1":{"key1-1":"value1-1","key1-2":"value1-2"}, "key2":"value2"}')
90
- #=> {"key1"=>{"key1-1"=>"value1-1", "key1-2"=>"value1-2"}, "key2"=>"value2"}
91
- ```
92
-
93
- ### lazy-pp-json
94
-
95
- ```ruby
96
- pp Lazy::PP::JSON.new('{"key1":{"key1-1":"value1-1","key1-2":"value1-2"}, "key2":"value2"}')
97
- #=>
98
- # {
99
- # "key1":
100
- # {
101
- # "key1-1":"value1-1",
102
- # "key1-2":"value1-2"
103
- # },
104
- # "key2":"value2"
105
- # }
106
- #
107
- ```
83
+ description: Lazy pp json responses.
108
84
  email:
109
85
  - h.yoshihara@everyleaf.com
110
86
  executables:
@@ -112,19 +88,19 @@ executables:
112
88
  extensions: []
113
89
  extra_rdoc_files: []
114
90
  files:
115
- - README.md
91
+ - Gemfile
116
92
  - LICENSE.txt
93
+ - README.md
117
94
  - Rakefile
118
- - Gemfile
95
+ - bin/lazy-pp-json
119
96
  - lazy-pp-json.gemspec
120
- - lib/lazy/pp/json/version.rb
121
- - lib/lazy/pp/json.rb
122
97
  - lib/lazy-pp-json.rb
98
+ - lib/lazy/pp/json.rb
99
+ - lib/lazy/pp/json/version.rb
123
100
  - test/run-test.rb
124
101
  - test/test_array.rb
125
102
  - test/test_hash.rb
126
103
  - test/testutils.rb
127
- - bin/lazy-pp-json
128
104
  homepage: ''
129
105
  licenses:
130
106
  - MIT
@@ -135,20 +111,20 @@ require_paths:
135
111
  - lib
136
112
  required_ruby_version: !ruby/object:Gem::Requirement
137
113
  requirements:
138
- - - '>='
114
+ - - ">="
139
115
  - !ruby/object:Gem::Version
140
116
  version: '0'
141
117
  required_rubygems_version: !ruby/object:Gem::Requirement
142
118
  requirements:
143
- - - '>='
119
+ - - ">="
144
120
  - !ruby/object:Gem::Version
145
121
  version: '0'
146
122
  requirements: []
147
123
  rubyforge_project:
148
- rubygems_version: 2.1.11
124
+ rubygems_version: 2.2.0
149
125
  signing_key:
150
126
  specification_version: 4
151
- summary: Lazy pp json responses
127
+ summary: Lazy pp json responses.
152
128
  test_files:
153
129
  - test/run-test.rb
154
130
  - test/test_array.rb