wikk_json 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e1a676d87f911cb97f550e1f5a67eede337f7a8b
4
+ data.tar.gz: 25984707a985be9e798fd228e8d541af787fdc7f
5
+ SHA512:
6
+ metadata.gz: 4c678427fde5959b00d5c6aa93ba2d8f678f27718af9c8b418e359aade3edb7ffcc2b9e68ff279259b14cc5eda36e0fdd3da7ee857f0837986052acbd18b9902
7
+ data.tar.gz: 50ccc1df5dcf0d2ea30c5e9e77a5b59e3ba0e2cbce0210aa2bdd06b1f6b096ebc1c3d287c6567124dc5906c2ee7fd6e632f08b680af631e3367a79fe7f76df06
data/History.txt ADDED
@@ -0,0 +1,8 @@
1
+ robertburrowes Mon May 9 19:11:41 2016 +1200
2
+ added example
3
+ robertburrowes Mon May 9 19:06:40 2016 +1200
4
+ Merge branch 'master' of github.com:wikarekare/json
5
+ robertburrowes Mon May 9 19:04:28 2016 +1200
6
+ Quick hack to add to_j methods, to pp json for config files
7
+ Rob Burrowes Sun May 8 22:46:49 2016 +1200
8
+ Initial commit
data/Manifest.txt ADDED
@@ -0,0 +1,11 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ bin/wikk_json
6
+ lib/wikk_json.rb
7
+ lib/array.rb
8
+ lib/hash.rb
9
+ lib/nil.rb
10
+ lib/numeric.rb
11
+ lib/string.rb
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # wikk_json
2
+
3
+ * http://wikarekare.github.com/json/
4
+ * Source https://github.com/wikarekare/json
5
+ * Gem https://rubygems.org/gems/wikk_json
6
+
7
+ ## DESCRIPTION:
8
+
9
+ Quick hack to add to_j methods to Array,Hash,Nil,String and Numeric to output nicely formatted json for my config files.
10
+
11
+ ## FEATURES/PROBLEMS:
12
+
13
+
14
+ ## SYNOPSIS:
15
+
16
+ require 'wikk_json'
17
+
18
+ ## REQUIREMENTS:
19
+
20
+ * require 'wikk_json'
21
+
22
+ ## INSTALL:
23
+
24
+ * sudo gem install wikk_json
25
+
26
+ ## LICENSE:
27
+
28
+ The MIT License
29
+
30
+ Copyright (c) 2016
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining
33
+ a copy of this software and associated documentation files (the
34
+ 'Software'), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ Hoe.plugin :yard
6
+
7
+ Hoe.spec 'wikk_json' do
8
+ self.readme_file = "README.md"
9
+ self.developer( "Rob Burrowes","r.burrowes@auckland.ac.nz")
10
+ remote_rdoc_dir = '' # Release to root
11
+
12
+ self.yard_title = 'wikk_json'
13
+ self.yard_options = ['--markup', 'markdown', '--protected']
14
+ end
15
+
16
+
17
+ #Validate manfest.txt
18
+ #rake check_manifest
19
+
20
+ #Local checking. Creates pkg/
21
+ #rake gem
22
+
23
+ #create doc/
24
+ #rake docs
25
+
26
+ #Copy up to rubygem.org
27
+ #rake release VERSION=1.0.1
data/bin/wikk_json ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ abort "you need to write me"
data/lib/array.rb ADDED
@@ -0,0 +1,17 @@
1
+ #Extend Array to output nicely formated json.
2
+ class Array
3
+ # @return [String] Json array
4
+ def to_j(indent=0)
5
+ s = "[\n"
6
+ self.each do |v|
7
+ if v.class == Array || v.class == Hash
8
+ s += " "*(indent+1) + "#{v.to_j(indent+1)},\n"
9
+ else
10
+ s += " "*(indent+1) + "#{v.to_j},\n"
11
+ end
12
+ end
13
+ s[-2] = " " #remove last ,
14
+ s += " "*indent + "]"
15
+ return s
16
+ end
17
+ end
data/lib/hash.rb ADDED
@@ -0,0 +1,17 @@
1
+ #Extend simple key => string Hash to output nicely formated json for SQL output
2
+ class Hash
3
+ # @return [String] Json for the Hash, and recurse for each value in the Hash
4
+ def to_j(indent=0)
5
+ s = "{\n"
6
+ self.each do |k,v|
7
+ if v.class == Array || v.class == Hash
8
+ s += " "*(indent+1) + "\"#{k}\": #{v.to_j(indent+1)},\n"
9
+ else
10
+ s += " "*(indent+1) + "\"#{k}\": #{v.to_j},\n"
11
+ end
12
+ end
13
+ s[-2] = " " #remove last ,
14
+ s += " "*indent + "}"
15
+ return s
16
+ end
17
+ end
data/lib/nil.rb ADDED
@@ -0,0 +1,6 @@
1
+ class NilClass
2
+ # @return [String] Json for the nil, which is "null"
3
+ def to_j(indent = 0)
4
+ " "*indent + "null"
5
+ end
6
+ end
data/lib/numeric.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Numeric
2
+ # @return [String] Json for the numeric value
3
+ def to_j(indent = 0)
4
+ " "*indent + self.to_s
5
+ end
6
+ end
data/lib/string.rb ADDED
@@ -0,0 +1,6 @@
1
+ class String
2
+ # @return [String] Json for the String, which is quoted self.
3
+ def to_j(indent = 0)
4
+ " "*indent + "\"#{self}\""
5
+ end
6
+ end
data/lib/wikk_json.rb ADDED
@@ -0,0 +1,13 @@
1
+ module WIKK
2
+ class Wikk_Json
3
+ VERSION = '0.1.0'
4
+ end
5
+
6
+ require 'json'
7
+ require_relative "nil.rb"
8
+ require_relative "array.rb"
9
+ require_relative "hash.rb"
10
+ require_relative "string.rb"
11
+ require_relative "numeric.rb"
12
+ require_relative "boolean.rb"
13
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wikk_json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob Burrowes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hoe-yard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.2
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: hoe
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.15'
41
+ description: Quick hack to add to_j methods to Array,Hash,Nil,String and Numeric to
42
+ output nicely formatted json for my config files.
43
+ email:
44
+ - r.burrowes@auckland.ac.nz
45
+ executables:
46
+ - wikk_json
47
+ extensions: []
48
+ extra_rdoc_files:
49
+ - History.txt
50
+ - Manifest.txt
51
+ - README.md
52
+ files:
53
+ - History.txt
54
+ - Manifest.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/wikk_json
58
+ - lib/array.rb
59
+ - lib/hash.rb
60
+ - lib/nil.rb
61
+ - lib/numeric.rb
62
+ - lib/string.rb
63
+ - lib/wikk_json.rb
64
+ homepage: http://wikarekare.github.com/json/
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options:
70
+ - "--markup"
71
+ - markdown
72
+ - "--protected"
73
+ - "--title"
74
+ - wikk_json
75
+ - "--quiet"
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.5.1
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Quick hack to add to_j methods to Array,Hash,Nil,String and Numeric to output
94
+ nicely formatted json for my config files.
95
+ test_files: []