tidy_json 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c8377fc4c17ae11f718b6cadd5a0bbf5a806c1706f8184370e036dbeb714d73
4
- data.tar.gz: dd9dcac5f8b3294f1edbd7a05762ad89277e6b593b0610d79d501e3d68e62fea
3
+ metadata.gz: 16df8d716d6fcdfeba6ed6afbf5954089e172f39b61a73fa853babb5d3c2cde6
4
+ data.tar.gz: bc64fa60a34d16af688444e0fb706c7a087dc38ced05babcc0680bf1874fed8f
5
5
  SHA512:
6
- metadata.gz: 62b421c64ac5ecbd6fcc54a9e43f57d1e04ae52b6b6ab21c5eb65d65b4a267e44a28dde2ee67cf80167c5d0857c242c246e3881d510f00493e44b835fb17b52a
7
- data.tar.gz: 0b7534efee7f35486f1bc8f60dab7031f762aa6fdc69a7eb83d603b2cfae25583aa702e4009ff8dba284a0e1b3136e0c4bafe39f43e235951d7bc93a767eca1a
6
+ metadata.gz: 54185c4b206f63502a061f2a8397a78697fee2eea068c77b1392f02c24d95136ecac03026c1b08b1782c554c0d3356373c367980ce857197f5c3ff2061393663
7
+ data.tar.gz: ba130a35229098c25b0e750dc631f725c53013eac9b69a702c26110cd321930c056f13627c066ac805a72851405cdc5203e90638def06e75396970a2c5b52b7d
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Robert Di Pardo
3
+ Copyright (c) 2019-2020 Robert Di Pardo
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,24 +1,16 @@
1
1
  # TidyJson
2
2
 
3
- [![Build Status](https://travis-ci.com/rdipardo/tidy_json.svg)](https://travis-ci.com/rdipardo/tidy_json)
3
+ [![Travis Build Status][travis_build_status_badge]][travis_build_status] [![Circle CI Build Status][cci_build_status_badge]][cci_build_status] ![Gem Version][gem_version_badge]
4
4
 
5
5
  A mixin providing (recursive) JSON serialization and pretty printing.
6
6
 
7
7
  ### Installation
8
8
 
9
- #### Minimal
10
-
11
- ```bash
12
- $ gem install tidy_json
13
- ```
14
-
15
- #### Development (tests, YARD docs)
16
-
17
9
  ```bash
18
- $ gem install -​-development tidy_json
10
+ $ gem install tidy_json
19
11
  ```
20
12
 
21
- Or, with `bundler`:
13
+ Or, in your `Gemfile`:
22
14
 
23
15
  ```ruby
24
16
  source 'https://rubygems.org'
@@ -32,21 +24,53 @@ gem 'tidy_json'
32
24
  ```ruby
33
25
  require 'tidy_json'
34
26
 
35
- JSON.parse [].stringify
36
- # => {"class"=>"Array"}
27
+ class Jsonable
28
+ attr_reader :a, :b
29
+ def initialize
30
+ @a = { a: 'uno', b: 'dos', c: ['I', 'II', 'III', ['i.', 'ii.', 'iii.', { 'ichi': "\u{4e00}", 'ni': "\u{4e8c}", 'san': "\u{4e09}", 'yon': "\u{56db}" }]] }
31
+ @b = { a: 1, b: ['two', 3, '<abbr title="four">IV</abbr>'] }
32
+ end
33
+ end
37
34
 
38
- complex_object = { :a => 1, :b => ['two', 3, '<abbr title="four">IV</abbr>'] }
39
- # => {:a=>1, :b=>["two", 3, "<abbr title=\"four\">IV</abbr>"]}
35
+ complex_object = Jsonable.new
36
+ puts JSON.parse complex_object.stringify
37
+ # => {"class"=>"Jsonable", "a"=>{"a"=>"uno", "b"=>"dos", "c"=>["I", "II", "III", ["i.", "ii.", "iii.", {"ichi"=>"一", "ni"=>"二", "san"=>"三", "yon"=>"四"}]]}, "b"=>{"a"=>1, "b"=>["two", 3, "<abbr title=\"four\">IV</abbr>"]}}
40
38
 
41
39
  puts complex_object.to_tidy_json
42
40
  # {
43
- # "a": 1,
41
+ # "class": "Jsonable",
42
+ # "a":
43
+ # {
44
+ # "a": "uno",
45
+ # "b": "dos",
46
+ # "c":
47
+ # [
48
+ # "I",
49
+ # "II",
50
+ # "III",
51
+ # [
52
+ # "i.",
53
+ # "ii.",
54
+ # "iii.",
55
+ # {
56
+ # "ichi":"一",
57
+ # "ni":"二",
58
+ # "san":"三",
59
+ # "yon":"四"
60
+ # }
61
+ # ]
62
+ # ]
63
+ # },
44
64
  # "b":
45
- # [
46
- # "two",
47
- # 3,
48
- # "<abbr title=\"four\">IV</abbr>"
49
- # ]
65
+ # {
66
+ # "a": 1,
67
+ # "b":
68
+ # [
69
+ # "two",
70
+ # 3,
71
+ # "<abbr title=\"four\">IV</abbr>"
72
+ # ]
73
+ # }
50
74
  # }
51
75
  # => nil
52
76
  ```
@@ -57,12 +81,16 @@ puts complex_object.to_tidy_json
57
81
  - [json](https://rubygems.org/gems/json) ~> 2.2
58
82
 
59
83
  #### Building
60
- - [bundler](https://rubygems.org/gems/bundler) ~> 2.1
84
+ - [bundler](https://rubygems.org/gems/bundler) ~> 1.17
61
85
  - [minitest](https://rubygems.org/gems/minitest) ~> 5.0
62
86
  - [yard](https://rubygems.org/gems/yard) ~> 0.9
63
87
 
64
88
  ### License
65
89
  [MIT](https://opensource.org/licenses/MIT)
66
90
 
67
- ### Author
68
- [Robert Di Pardo](mailto:rdipardo0520@conestogac.on.ca)
91
+
92
+ [travis_build_status]: https://travis-ci.com/rdipardo/tidy_json
93
+ [cci_build_status]: https://circleci.com/gh/rdipardo/tidy_json
94
+ [travis_build_status_badge]: https://travis-ci.com/rdipardo/tidy_json.svg
95
+ [cci_build_status_badge]: https://circleci.com/gh/rdipardo/tidy_json.svg?style=svg
96
+ [gem_version_badge]: https://img.shields.io/gem/v/tidy_json
@@ -1,10 +1,8 @@
1
1
  module TidyJson # :nodoc:
2
- DEDICATION = "#{'.' * 50}\n#{'.' * 20} tidy_json #{'.' * 19}\n" \
3
- "#{'.' * 12} (c) 2019 Robert Di Pardo #{'.' * 12}\n" \
4
- "#{'.' * 50}\n#{'.' * 19} IN MEMORIAM #{'.' * 18}\n" \
2
+ DEDICATION = "#{'.' * 50}\n#{'.' * 19} IN MEMORIAM #{'.' * 18}\n" \
5
3
  "#{'.' * 16} Michael Di Pardo #{'.' * 16}\n" \
6
4
  "#{'.' * 19} 1950 - 2019 #{'.' * 18}\n#{'.' * 50}\n" \
7
- "#{'.' * 12} Please consider supporting #{'.' * 11}\n" \
5
+ "#{'.' * 11} Please consider supporting #{'.' * 11}\n" \
8
6
  "#{'.' * 13} the MS Society of Canada #{'.' * 11}\n" \
9
7
  "#{'.' * 8} https://mssociety.ca/get-involved #{'.' * 7}\n" \
10
8
  "#{'.' * 50}\n"
@@ -1,3 +1,3 @@
1
1
  module TidyJson
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/tidy_json.rb CHANGED
@@ -73,7 +73,7 @@ module TidyJson
73
73
  # Writes a pretty-printed JSON representation of the sender object to the file specified by +out+.
74
74
  #
75
75
  # @param pretty [Boolean] Whether or not the output should be pretty-printed.
76
- # @param out [String] The destination filename. Defaults to <tt><obj_class_name>_<current_UNIX_time></tt>.json
76
+ # @param out [String] The destination filename. Defaults to <tt><obj_class_name>_<unix timestamp></tt>.json
77
77
  # @return [String, nil] The path to the written output file, if successful.
78
78
  def write_json(pretty = true, out = "#{self.class.name}_#{Time.now.to_i}")
79
79
  path = nil
@@ -374,7 +374,7 @@ end
374
374
  # ~TidyJson
375
375
 
376
376
  ##
377
- # Exposes the +TidyJson+ mixin to all Ruby objects.
377
+ # Includes +TidyJson+ in every Ruby class.
378
378
  # ====
379
379
  # class Object
380
380
  # include TidyJson
data/tidy_json.gemspec CHANGED
@@ -4,21 +4,22 @@ require_relative 'lib/tidy_json/dedication'
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'tidy_json'
6
6
  spec.version = TidyJson::VERSION
7
- spec.date = Time.now.to_s[0..9].to_s
7
+ spec.date = Time.now.to_s[0..9]
8
8
  spec.summary = 'Serialize any Ruby object as readable JSON'
9
9
  spec.description = 'A mixin providing (recursive) JSON serialization and pretty printing.'
10
10
  spec.authors = ['Robert Di Pardo']
11
11
  spec.email = 'rdipardo0520@conestogac.on.ca'
12
12
  spec.homepage = 'https://github.com/rdipardo/tidy_json'
13
+ spec.metadata = {'documentation_uri' => 'https://rubydoc.org/github/rdipardo/tidy_json'}
13
14
  spec.license = 'MIT'
14
15
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
15
16
  ['.yardopts'].concat(`git ls-files -z`.split("\x0").reject { |f| f.match(/^(\.[\w+\.]+|test|spec|features)/) })
16
17
  end
17
18
  spec.test_files = Dir['test/*']
18
19
  spec.require_paths = ['lib']
19
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
20
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3')
20
21
  spec.add_runtime_dependency 'json', '~> 2.2'
21
- spec.add_development_dependency 'bundler', '~> 2.1'
22
+ spec.add_development_dependency 'bundler', '~> 1.17'
22
23
  spec.add_development_dependency 'minitest', '~> 5.0'
23
24
  spec.add_development_dependency 'yard', '~> 0.9'
24
25
  spec.rdoc_options = ['-x test/*']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tidy_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Di Pardo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-19 00:00:00.000000000 Z
11
+ date: 2020-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.1'
33
+ version: '1.17'
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
- version: '2.1'
40
+ version: '1.17'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -85,17 +85,15 @@ files:
85
85
  homepage: https://github.com/rdipardo/tidy_json
86
86
  licenses:
87
87
  - MIT
88
- metadata: {}
88
+ metadata:
89
+ documentation_uri: https://rubydoc.org/github/rdipardo/tidy_json
89
90
  post_install_message: |
90
- ..................................................
91
- .................... tidy_json ...................
92
- ............ (c) 2019 Robert Di Pardo ............
93
91
  ..................................................
94
92
  ................... IN MEMORIAM ..................
95
93
  ................ Michael Di Pardo ................
96
94
  ................... 1950 - 2019 ..................
97
95
  ..................................................
98
- ............ Please consider supporting ...........
96
+ ........... Please consider supporting ...........
99
97
  ............. the MS Society of Canada ...........
100
98
  ........ https://mssociety.ca/get-involved .......
101
99
  ..................................................
@@ -107,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
105
  requirements:
108
106
  - - ">="
109
107
  - !ruby/object:Gem::Version
110
- version: 2.3.0
108
+ version: '2.3'
111
109
  required_rubygems_version: !ruby/object:Gem::Requirement
112
110
  requirements:
113
111
  - - ">="