File tree Expand file tree Collapse file tree 6 files changed +73
-6
lines changed Expand file tree Collapse file tree 6 files changed +73
-6
lines changed Original file line number Diff line number Diff line change
1
+ # This workflow runs continuous CI across different versions of ruby on all branches and pull requests to develop.
2
+
3
+ name : CI
4
+ on :
5
+ push :
6
+ branches : [ '**' ]
7
+ pull_request :
8
+ branches : [ develop ]
9
+ workflow_dispatch :
10
+
11
+ jobs :
12
+ tests :
13
+ name : Ruby ${{ matrix.ruby }}
14
+ if : " contains(github.event.commits[0].message, '[ci skip]') == false"
15
+ runs-on : ubuntu-latest
16
+ env :
17
+ CI : true
18
+ strategy :
19
+ fail-fast : false
20
+ matrix :
21
+ ruby :
22
+ - 2.4
23
+ - 2.5
24
+ - 2.6
25
+ - 2.7
26
+ - ruby-head
27
+ - jruby
28
+ steps :
29
+ - name : Clone repository
30
+ uses : actions/checkout@v2
31
+ - name : Set up Ruby
32
+ uses : ruby/setup-ruby@v1
33
+ with :
34
+ ruby-version : ${{ matrix.ruby }}
35
+ - name : Install dependencies
36
+ run : bundle install --jobs 4 --retry 3
37
+ - name : Run tests
38
+ run : bundle exec rspec spec
39
+
Original file line number Diff line number Diff line change @@ -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://travis-ci.org /dryruby/json-canonicalization.png ?branch=master )] ( http ://travis-ci.org /dryruby/json-canonicalization)
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
Original file line number Diff line number Diff line change 1
- 0.2.0
1
+ 0.2.1
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
20
20
gem . required_ruby_version = '>= 2.4'
21
21
gem . requirements = [ ]
22
- gem . add_development_dependency 'rspec' , '~> 3.9 '
22
+ gem . add_development_dependency 'rspec' , '~> 3.10 '
23
23
gem . add_development_dependency 'yard' , '~> 0.9'
24
24
25
25
gem . post_install_message = nil
Original file line number Diff line number Diff line change @@ -61,13 +61,21 @@ def to_json_c14n
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 . encode ( Encoding :: UTF_16 ) } .
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 @@ def to_json_c14n
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
+
Original file line number Diff line number Diff line change 9
9
end
10
10
end
11
11
end
12
+
13
+ describe "special cases for hash keys" do
14
+ it "handles hash defined with symbols" do
15
+ data = { a : [ { b :"b" } ] }
16
+ expect ( data . to_json_c14n ) . to eq "{\" a\" :[{\" b\" :\" b\" }]}"
17
+ end
18
+ end
You can’t perform that action at this time.
0 commit comments