jsonbrowser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00288f5de256537dbbaddf0f2030328ac876c08b
4
+ data.tar.gz: 835d4b90c1e0bd5f4d3dbbce23ff140437cfed2d
5
+ SHA512:
6
+ metadata.gz: d5e624e984a9c3e0554aca3c862556b2e925a46c90bd779d9ed625cd533e8c05b3b33d3fab6a0b2b9beb7bf95085a0374be8ac3471264bb624e51b02d8db027e
7
+ data.tar.gz: 611cff790488420b256c2e7f45a94224b756b9b76c80507dfca66545a330d88a92ebb43b86120a04d0fc7783c62dd2e27a7b9f4d78d8145fb4a16b7a1b80a7a0
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jsonbrowser.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Levente Bagi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # Jsonbrowser
2
+
3
+ A tool for making sense of large JSON structures while debugging. It sends the JSON to a website and outputs a direct URL where you can browse the JSON structure.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'jsonbrowser'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install jsonbrowser
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ JsonBrowser({ a: { b: [{ x: 13, y: 49}, { x: 45, y: -35 }], c: [3, 4]}})
25
+ # "https://json.jkl.me/documents/FFdTSmypfT"
26
+ ```
27
+
28
+ You can supply a JSON String, Hash, Array, or any object that responds to one of
29
+ `to_json`, `as_json`, `to_hash`, `to_h`, `to_array`, `to_a` or `serializable_hash`.
30
+
31
+ You can [host the web app yourself](https://github.com/bagilevi/jsonbrowser) and
32
+ add this configuration:
33
+
34
+ ```ruby
35
+ JsonBrowser.root = 'http://json.local' # no trailing slash
36
+ ```
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bagilevi/jsonbrowser.
47
+
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jsonbrowser"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jsonbrowser/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jsonbrowser"
8
+ spec.version = JsonBrowser::VERSION
9
+ spec.authors = ["Levente Bagi"]
10
+ spec.email = ["bagilevi@gmail.com"]
11
+
12
+ spec.summary = %q{Sends a JSON structure to website where you can browse it}
13
+ spec.description = %q{A tool for making sense of large JSON structures while debugging. It sends the JSON to a website and outputs a direct URL where you can browse the JSON structure.}
14
+ spec.homepage = "https://github.com/bagilevi/jsonbrowser-gem"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "rest-client", ">= 1.7.3", "< 3"
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -0,0 +1,54 @@
1
+ require "jsonbrowser/version"
2
+ require 'json'
3
+ require 'rest-client'
4
+
5
+ def JsonBrowser(subject)
6
+ JsonBrowser.browse(subject)
7
+ end
8
+
9
+ module JsonBrowser
10
+ class << self
11
+ attr_accessor :root
12
+
13
+ def root
14
+ @root || 'https://json.jkl.me'
15
+ end
16
+ end
17
+
18
+ def self.browse(subject)
19
+ puts get_url(subject)
20
+ end
21
+
22
+ def self.get_url(subject)
23
+ json = get_json_string(subject)
24
+ response = RestClient.post(
25
+ "#{root}/documents?return=json",
26
+ json,
27
+ content_type: :json,
28
+ accept: :json
29
+ )
30
+ "#{root}#{JSON.parse(response.body)['path']}"
31
+ end
32
+
33
+ def self.get_json_string(subject)
34
+ return subject if subject.is_a?(String) && subject[0].in?(['{', '['])
35
+ return subject.to_json if subject.respond_to?(:to_json)
36
+
37
+ %i(
38
+ to_h
39
+ to_hash
40
+ to_a
41
+ to_array
42
+ as_json
43
+ serializable_hash
44
+ ).each do |method_name|
45
+ if subject.respond_to?(method_name)
46
+ return JSON.generate(subject.public_send(method_name))
47
+ end
48
+ end
49
+
50
+ raise "Cannot convert #{subject.class.name} to a JSON. "\
51
+ "Please convert it yourself and pass a string or provide an object "\
52
+ "with a supported method."
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module JsonBrowser
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jsonbrowser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Levente Bagi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.7.3
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.3
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.12'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.12'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ description: A tool for making sense of large JSON structures while debugging. It
62
+ sends the JSON to a website and outputs a direct URL where you can browse the JSON
63
+ structure.
64
+ email:
65
+ - bagilevi@gmail.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - ".gitignore"
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/console
76
+ - bin/setup
77
+ - jsonbrowser.gemspec
78
+ - lib/jsonbrowser.rb
79
+ - lib/jsonbrowser/version.rb
80
+ homepage: https://github.com/bagilevi/jsonbrowser-gem
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.1
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Sends a JSON structure to website where you can browse it
104
+ test_files: []