json2table 1.0.2 → 1.0.3

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. checksums.yaml +4 -4
  2. data/bin/json2table +15 -0
  3. data/lib/json2table.rb +5 -1
  4. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a9ba0f295a4f058d0ea1a175af6319d65eccd84
4
- data.tar.gz: 4d48a073e78d72a7a5a2d790a5efc7b668066a55
3
+ metadata.gz: efea0b6a3abe9d4f3a19b9fda503fa2bb44b1119
4
+ data.tar.gz: cc66c0af76dce74b7160a87eaaa866b8c7e68f05
5
5
  SHA512:
6
- metadata.gz: 3eaf6a258563e600dcbfe90987dce197c0402b589dd3d2cf9fabca8db9b58a30289498a0fb59d467633a8b0e0a51a270ba6260c0576d06cdb7a9b55c07fe89f9
7
- data.tar.gz: 170b888444332facaec717bcd57f29624a50218e34fad24a4630bdd4fc4a7c6885ac4f1ab435ed17de81334811fe354d92fb35da114910abeebbd88912f29591
6
+ metadata.gz: 5b314e561b140f602c028da81498b8ed7158bacc4ead4dc16b78ca895401f3986952472f030b8d41a3c43e1dec2cb8f48536d06bbfcebad91e49b2bbbac5bada
7
+ data.tar.gz: a73c97c442a33114d18d054cf62f652aa4eeb8f258321795c65e2d6471e24ff2f458e45f9b5e169cfa1f207c793b14394be6e9bdfcccd565e567a3d5adf74302
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json2table'
4
+
5
+ table_options = {
6
+ table_style: "border: 1px solid black; max-width: 600px;",
7
+ table_class: "table table-striped table-hover table-condensed table-bordered",
8
+ table_attributes: "border=1"
9
+ }
10
+
11
+ json = STDIN.read
12
+ json2table = Json2table::get_html_table(json, table_options)
13
+ puts json2table
14
+
15
+
@@ -13,7 +13,11 @@ module Json2table
13
13
  def self.get_html_table(json_str, options = {})
14
14
  html = ""
15
15
  begin
16
- hash = JSON.parse(json_str)
16
+ if json_str.is_a?(Hash)
17
+ hash = json_str
18
+ else
19
+ hash = JSON.parse(json_str)
20
+ end
17
21
  rescue Exception => e
18
22
  puts "JSON2TABLE:: Input not a valid JSON, provide valid JSON object"
19
23
  puts e.message
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json2table
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code Express
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  This gem provides functionality to convert a JSON object into HTML
@@ -19,6 +19,7 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - bin/json2table
22
23
  - lib/json2table.rb
23
24
  homepage: https://github.com/codeexpress/json2table
24
25
  licenses:
@@ -40,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
41
  version: '0'
41
42
  requirements: []
42
43
  rubyforge_project:
43
- rubygems_version: 2.4.2
44
+ rubygems_version: 2.4.6
44
45
  signing_key:
45
46
  specification_version: 4
46
47
  summary: Converts JSON to HTML tables