json-canonicalization 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/VERSION +1 -1
- data/lib/json/canonicalization.rb +18 -1
- data/spec/c14n_spec.rb +7 -0
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74053bcdd29c8b37b6ccf7927b51d84b709811680c13d86024d2197717f434e5
|
4
|
+
data.tar.gz: b7d28a594afb192f957e67eb68a523d5f3566c3731f818d656ea4ac916171a25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 987dc4159f279aaa8c645c487f4ff0212d8366711ae06e34baafd706718d33cc4d1c36a8923f67c6a76bb8bb6611346eb2ad8c266fdb51c290b05619f4ac3868
|
7
|
+
data.tar.gz: cdccc503a88f77e9f46e62406a33feb7c07e1eeeec9bbe495e171da28815d12edd652e98cdd277b1ec8166db453cd0face221f93d4e34ce12499c988f64edeb4
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ An implementation of the JSON Canonicalization Scheme for Ruby
|
|
4
4
|
Implements version 5 of [draft-rundgren-json-canonicalization-scheme-05](https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-05#page-5).
|
5
5
|
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/json-canonicalization.png)](http://badge.fury.io/rb/json-canonicalization)
|
7
|
-
[![Build Status](https://
|
7
|
+
[![Build Status](https://github.com/dryruby/json-canonicalization/workflows/CI/badge.svg?branch=develop)](https://github.com/dryruby/json-canonicalization/actions?query=workflow%3ACI)
|
8
8
|
[![Coverage Status](https://coveralls.io/repos/dryruby/json-canonicalization/badge.svg)](https://coveralls.io/r/dryruby/json-canonicalization)
|
9
9
|
|
10
10
|
# Description
|
@@ -84,10 +84,14 @@ Full documentation available on [RubyDoc](http://rubydoc.info/gems/json-canonica
|
|
84
84
|
list in the the `README`. Alphabetical order applies.
|
85
85
|
* Do note that in order for us to merge any non-trivial changes (as a rule
|
86
86
|
of thumb, additions larger than about 15 lines of code), we need an
|
87
|
-
explicit [public domain dedication][PDD] on record from you
|
87
|
+
explicit [public domain dedication][PDD] on record from you,
|
88
|
+
which you will be asked to agree to on the first commit to a repo within the organization.
|
88
89
|
|
89
|
-
##License
|
90
|
+
## License
|
90
91
|
|
91
92
|
This is free and unencumbered public domain software. For more information,
|
92
93
|
see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
93
94
|
|
95
|
+
[YARD]: https://yardoc.org/
|
96
|
+
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
97
|
+
[PDD]: https://unlicense.org/#unlicensing-contributions
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
@@ -61,13 +61,21 @@ class Numeric
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
def encode_key(k)
|
65
|
+
case k
|
66
|
+
when String
|
67
|
+
return k.encode(Encoding::UTF_16)
|
68
|
+
end
|
69
|
+
k
|
70
|
+
end
|
71
|
+
|
64
72
|
class Hash
|
65
73
|
# Output JSON with keys sorted lexicographically
|
66
74
|
# @return [String]
|
67
75
|
def to_json_c14n
|
68
76
|
"{" + self.
|
69
77
|
keys.
|
70
|
-
sort_by {|k| k
|
78
|
+
sort_by {|k| encode_key(k)}.
|
71
79
|
map {|k| k.to_json_c14n + ':' + self[k].to_json_c14n}
|
72
80
|
.join(',') +
|
73
81
|
'}'
|
@@ -81,3 +89,12 @@ class String
|
|
81
89
|
self.to_json
|
82
90
|
end
|
83
91
|
end
|
92
|
+
|
93
|
+
class Symbol
|
94
|
+
# Output JSON with control characters escaped
|
95
|
+
# @return [String]
|
96
|
+
def to_json_c14n
|
97
|
+
self.to_json
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
data/spec/c14n_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-canonicalization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yard
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.9'
|
41
41
|
description: JSON::Canonicalization generates canonical JSON output from Ruby objects.
|
42
|
-
email:
|
42
|
+
email:
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
@@ -69,7 +69,7 @@ homepage: http://github.com/dryruby/json-canonicalization
|
|
69
69
|
licenses:
|
70
70
|
- Unlicense
|
71
71
|
metadata: {}
|
72
|
-
post_install_message:
|
72
|
+
post_install_message:
|
73
73
|
rdoc_options: []
|
74
74
|
require_paths:
|
75
75
|
- lib
|
@@ -84,23 +84,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
88
|
-
signing_key:
|
87
|
+
rubygems_version: 3.2.3
|
88
|
+
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: JSON Canonicalization for Ruby.
|
91
91
|
test_files:
|
92
|
-
- spec/spec_helper.rb
|
93
92
|
- spec/c14n_spec.rb
|
94
93
|
- spec/number_spec.rb
|
95
|
-
- spec/
|
94
|
+
- spec/spec_helper.rb
|
96
95
|
- spec/input/arrays.json
|
96
|
+
- spec/input/french.json
|
97
97
|
- spec/input/structures.json
|
98
98
|
- spec/input/unicode.json
|
99
|
-
- spec/input/wierd.json
|
100
99
|
- spec/input/values.json
|
101
|
-
- spec/
|
100
|
+
- spec/input/wierd.json
|
102
101
|
- spec/output/arrays.json
|
102
|
+
- spec/output/french.json
|
103
103
|
- spec/output/structures.json
|
104
104
|
- spec/output/unicode.json
|
105
|
-
- spec/output/wierd.json
|
106
105
|
- spec/output/values.json
|
106
|
+
- spec/output/wierd.json
|