jsplain 0.0.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.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +145 -0
- data/Rakefile +1 -0
- data/bin/jsplain +10 -0
- data/explain.rb +23 -0
- data/jsplain.gemspec +21 -0
- data/lib/jsplain/object.rb +26 -0
- data/lib/jsplain/version.rb +3 -0
- data/lib/jsplain.rb +6 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDFiMjVjNmYyOTc5MDk2MmFlNTAxNjdlYTU5YzE5OGJjMTFhODhkNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzZlZTc4OGM0YzQzNTRjYTlkMDBmYzNiNmExYzQ1ZmZjNmNjM2MyZA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjliYTdiMmQ0NzVmNTAwZTcxYjcyNGFkMTZkODFiOTkyZmQzMjY1NGJjMzIy
|
10
|
+
NTcxOTk3YTcxODlmMTRhMTVkNTMwNmNkNGVkMzAyNzdmZTYyZDQwZDFjNDAy
|
11
|
+
NDM5YWYwYTU4ZmU3YTc4Yjg3ZTBjZTBhNTU2N2IzZGM0OWUzZTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MWI3ODk2N2IwMDRhZTMzYjZmNjc3ODNlYzZiM2NjNTU1ZTg2OTMxNDA5MGMy
|
14
|
+
ZjVjNzc1Mzg5OWNlNjQ2N2E4ZGM1NDc4N2E2ZmJmYWI3ZmRiNmIwZjExMzY4
|
15
|
+
YmUzYzEwMmMzYzlmNjE2YjY3YzQ5ZmM0ZmZjY2IxNDJhYTMxMTY=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 David Campbell
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
JSplain
|
2
|
+
=======
|
3
|
+
|
4
|
+
Ruby-ism to explain a complex JSON structure without diving in too deeply.
|
5
|
+
Simply call it against any object and it will dive through it.
|
6
|
+
|
7
|
+
|
8
|
+
Installation
|
9
|
+
----------------
|
10
|
+
|
11
|
+
gem install jsplain
|
12
|
+
|
13
|
+
Usage
|
14
|
+
--------
|
15
|
+
### CLI
|
16
|
+
|
17
|
+
$ jsplain path/to/file
|
18
|
+
$ jsplain http://blogname.blogspot.com/feeds/posts/default?alt=json
|
19
|
+
$ jsplain -h
|
20
|
+
jsplain [path | url]
|
21
|
+
|
22
|
+
### Code
|
23
|
+
|
24
|
+
Nearly any Object can be explained.
|
25
|
+
|
26
|
+
* Arrays will be explained only as deeply as one element deep.
|
27
|
+
* Hashes will explain their key value pairs until value is no longer an Array or Hash.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'jsplain'
|
31
|
+
object.explain
|
32
|
+
```
|
33
|
+
|
34
|
+
Example
|
35
|
+
------------
|
36
|
+
|
37
|
+
```json
|
38
|
+
{
|
39
|
+
"Array":{
|
40
|
+
"Hash":{
|
41
|
+
"listener_descriptions":{
|
42
|
+
"Array":{
|
43
|
+
"Hash":{
|
44
|
+
"policy_names":{
|
45
|
+
"Array":"NilClass"
|
46
|
+
},
|
47
|
+
"listener":{
|
48
|
+
"Hash":{
|
49
|
+
"protocol":"String",
|
50
|
+
"load_balancer_port":"Fixnum",
|
51
|
+
"instance_protocol":"String",
|
52
|
+
"instance_port":"Fixnum"
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"backend_server_descriptions":{
|
59
|
+
"Array":"NilClass"
|
60
|
+
},
|
61
|
+
"availability_zones":{
|
62
|
+
"Array":"String"
|
63
|
+
},
|
64
|
+
"subnets":{
|
65
|
+
"Array":"NilClass"
|
66
|
+
},
|
67
|
+
"instances":{
|
68
|
+
"Array":{
|
69
|
+
"Hash":{
|
70
|
+
"instance_id":"String"
|
71
|
+
}
|
72
|
+
}
|
73
|
+
},
|
74
|
+
"security_groups":{
|
75
|
+
"Array":"NilClass"
|
76
|
+
},
|
77
|
+
"created_time":"Time",
|
78
|
+
"load_balancer_name":"String",
|
79
|
+
"health_check":{
|
80
|
+
"Hash":{
|
81
|
+
"interval":"Fixnum",
|
82
|
+
"target":"String",
|
83
|
+
"healthy_threshold":"Fixnum",
|
84
|
+
"timeout":"Fixnum",
|
85
|
+
"unhealthy_threshold":"Fixnum"
|
86
|
+
}
|
87
|
+
},
|
88
|
+
"policies":{
|
89
|
+
"Hash":{
|
90
|
+
"app_cookie_stickiness_policies":{
|
91
|
+
"Array":"NilClass"
|
92
|
+
},
|
93
|
+
"lb_cookie_stickiness_policies":{
|
94
|
+
"Array":"NilClass"
|
95
|
+
},
|
96
|
+
"other_policies":{
|
97
|
+
"Array":"NilClass"
|
98
|
+
}
|
99
|
+
}
|
100
|
+
},
|
101
|
+
"canonical_hosted_zone_name":"String",
|
102
|
+
"canonical_hosted_zone_name_id":"String",
|
103
|
+
"scheme":"String",
|
104
|
+
"source_security_group":{
|
105
|
+
"Hash":{
|
106
|
+
"owner_alias":"String",
|
107
|
+
"group_name":"String"
|
108
|
+
}
|
109
|
+
},
|
110
|
+
"dns_name":"String",
|
111
|
+
"instance_states":{
|
112
|
+
"Array":{
|
113
|
+
"Hash":{
|
114
|
+
"description":"String",
|
115
|
+
"instance_id":"String",
|
116
|
+
"state":"String",
|
117
|
+
"reason_code":"String"
|
118
|
+
}
|
119
|
+
}
|
120
|
+
},
|
121
|
+
"Dimensions":{
|
122
|
+
"Array":{
|
123
|
+
"Hash":{
|
124
|
+
"name":"String",
|
125
|
+
"value":"String"
|
126
|
+
}
|
127
|
+
}
|
128
|
+
},
|
129
|
+
"Stats":{
|
130
|
+
"Hash":{
|
131
|
+
"Metric":"String",
|
132
|
+
"Datapoints":{
|
133
|
+
"Array":{
|
134
|
+
"Hash":{
|
135
|
+
"timestamp":"Time",
|
136
|
+
"unit":"String",
|
137
|
+
"average":"Float"
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}}
|
145
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/jsplain
ADDED
data/explain.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class Object
|
2
|
+
|
3
|
+
def returning(value)
|
4
|
+
yield(value)
|
5
|
+
value
|
6
|
+
end
|
7
|
+
|
8
|
+
def explain
|
9
|
+
returning Hash.new do |h|
|
10
|
+
if self.is_a?(Hash)
|
11
|
+
h[self.class.name] = returning Hash.new do |hh|
|
12
|
+
self.each do |k,v|
|
13
|
+
hh[k] = self[k].explain
|
14
|
+
end
|
15
|
+
end
|
16
|
+
elsif self.is_a?(Array)
|
17
|
+
h[self.class.name] = self[0].explain
|
18
|
+
else
|
19
|
+
return self.class.name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/jsplain.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'jsplain/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "jsplain"
|
7
|
+
spec.version = Jsplain::VERSION
|
8
|
+
spec.author = "David Campbell"
|
9
|
+
spec.email = "david@mrcampbell.org"
|
10
|
+
spec.description = %q{Ruby-ism to explain a complex structure without diving in too deep.}
|
11
|
+
spec.summary = %q{Ruby-ism to explain a complex JSON structure without diving in too deeply.
|
12
|
+
Simply call it against any object and it will dive through it.}
|
13
|
+
spec.homepage = "https://github.com/dacamp/jsplain"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Object
|
2
|
+
def returning(value)
|
3
|
+
yield(value)
|
4
|
+
value
|
5
|
+
end
|
6
|
+
|
7
|
+
def jsplain fh
|
8
|
+
jj JSON.parse(open(fh).read).explain
|
9
|
+
end
|
10
|
+
|
11
|
+
def explain
|
12
|
+
returning Hash.new do |h|
|
13
|
+
if self.is_a?(Hash)
|
14
|
+
h[self.class.name] = returning Hash.new do |hh|
|
15
|
+
self.each do |k,v|
|
16
|
+
hh[k] = self[k].explain
|
17
|
+
end
|
18
|
+
end
|
19
|
+
elsif self.is_a?(Array)
|
20
|
+
h[self.class.name] = self[0].explain
|
21
|
+
else
|
22
|
+
return self.class.name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/jsplain.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jsplain
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Campbell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Ruby-ism to explain a complex structure without diving in too deep.
|
42
|
+
email: david@mrcampbell.org
|
43
|
+
executables:
|
44
|
+
- jsplain
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/jsplain
|
54
|
+
- explain.rb
|
55
|
+
- jsplain.gemspec
|
56
|
+
- lib/jsplain.rb
|
57
|
+
- lib/jsplain/object.rb
|
58
|
+
- lib/jsplain/version.rb
|
59
|
+
homepage: https://github.com/dacamp/jsplain
|
60
|
+
licenses: []
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Ruby-ism to explain a complex JSON structure without diving in too deeply.
|
82
|
+
Simply call it against any object and it will dive through it.
|
83
|
+
test_files: []
|