Skip to content

Commit 53f46cc

Browse files
committed
Finish 3.1.7
2 parents 085cc59 + ef5f330 commit 53f46cc

11 files changed

Lines changed: 74 additions & 23 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage devel
2828
enough, be assured we will eventually add you in there.
2929
* Do note that in order for us to merge any non-trivial changes (as a rule
3030
of thumb, additions larger than about 15 lines of code), we need an
31-
explicit [public domain dedication][PDD] on record from you.
31+
explicit [public domain dedication][PDD] on record from you,
32+
which you will be asked to agree to on the first commit to a repo within the organization.
33+
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
3234

3335
[YARD]: https://yardoc.org/
3436
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
35-
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
37+
[PDD]: https://unlicense.org/#unlicensing-contributions
3638
[pr]: https://github.com/ruby-rdf/rdf/compare/

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ group :debug do
2626
gem "redcarpet", platforms: :ruby
2727
gem "byebug", platforms: :mri
2828
gem 'guard-rspec'
29-
gem 'awesome_print', github: "akshaymohite/awesome_print", branch: "ruby-2-7-0-warnings-fix"
29+
gem 'awesome_print', github: 'akshaymohite/awesome_print'
3030
end
3131

3232
group :test do

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,10 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
438438
enough, be assured we will eventually add you in there.
439439
* Do note that in order for us to merge any non-trivial changes (as a rule
440440
of thumb, additions larger than about 15 lines of code), we need an
441-
explicit [public domain dedication][PDD] on record from you.
441+
explicit [public domain dedication][PDD] on record from you,
442+
which you will be asked to agree to on the first commit to a repo within the organization.
443+
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
444+
442445

443446
## License
444447

@@ -450,7 +453,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
450453
[N-Quads]: https://www.w3.org/TR/n-quads/
451454
[YARD]: https://yardoc.org/
452455
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
453-
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
456+
[PDD]: https://unlicense.org/#unlicensing-contributions
454457
[JSONLD doc]: https://rubydoc.info/github/ruby-rdf/json-ld
455458
[LinkedData doc]: https://rubydoc.info/github/ruby-rdf/linkeddata
456459
[Microdata doc]: https://rubydoc.info/github/ruby-rdf/rdf-microdata

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.6
1+
3.1.7

lib/rdf/model/literal/decimal.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,15 @@ def abs
6363
##
6464
# Returns the number with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. An error is raised if arg is not a numeric value.
6565
#
66-
# @return [RDF::Literal::Integer]
66+
# @return [RDF::Literal::Decimal]
6767
def round
68-
RDF::Literal::Integer.new(to_d.round)
68+
rounded = to_d.round(half: (to_d < 0 ? :down : :up))
69+
if rounded == -0.0
70+
# to avoid -0.0
71+
self.class.new(0.0)
72+
else
73+
self.class.new(rounded)
74+
end
6975
end
7076

7177
##

lib/rdf/model/literal/double.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ def abs
181181
end
182182

183183
##
184-
# Returns the integer with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. An error is raised if arg is not a numeric value.
184+
# Returns the number with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. An error is raised if arg is not a numeric value.
185185
#
186-
# @return [RDF::Literal::Integer]
186+
# @return [RDF::Literal::Double]
187187
def round
188-
RDF::Literal::Integer.new(to_f.round)
188+
self.class.new(to_d.round(half: (to_d < 0 ? :down : :up)))
189189
end
190190

191191
##

lib/rdf/model/uri.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,22 @@ def relative?; !absolute?; end
311311
# @param [#to_s] base_uri
312312
# @return [RDF::URI]
313313
def relativize(base_uri)
314-
if base_uri.to_s.end_with?("/", "#") &&
314+
if self.to_s.start_with?(base_uri.to_s) && %w(# ?).include?(self.to_s[base_uri.to_s.length, 1]) ||
315+
base_uri.to_s.end_with?("/", "#") &&
315316
self.to_s.start_with?(base_uri.to_s)
316-
RDF::URI(self.to_s[base_uri.to_s.length..-1])
317+
return RDF::URI(self.to_s[base_uri.to_s.length..-1])
317318
else
318-
self
319+
# Create a list of parents, for which this IRI may be relative.
320+
u = RDF::URI(base_uri)
321+
iri_set = u.to_s.end_with?('/') ? [u.to_s] : []
322+
iri_set << u.to_s while (u = u.parent)
323+
iri_set.each_with_index do |bb, index|
324+
next unless self.to_s.start_with?(bb)
325+
rel = "../" * index + self.to_s[bb.length..-1]
326+
return rel.empty? ? "./" : rel
327+
end
319328
end
329+
self
320330
end
321331

322332
##

lib/rdf/vocabulary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def initialize(uri)
731731
# @param [#to_s] property
732732
# @return [URI]
733733
def [](property)
734-
Term.intern([to_s, property.to_s].join(''), vocab: self.class, attributes: {})
734+
Term.intern([to_s, property.to_s].join(''), vocab: self, attributes: {})
735735
end
736736

737737
##

spec/model_literal_spec.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,12 +1044,16 @@ def self.literals(*selector)
10441044
0 => 0,
10451045
BigDecimal("1.1") => BigDecimal("1"),
10461046
BigDecimal("-1.1") => BigDecimal("-1"),
1047+
BigDecimal("0.5") => BigDecimal("1"),
1048+
BigDecimal("-0.5") => BigDecimal("0"),
10471049
BigDecimal("1.5") => BigDecimal("2"),
1048-
BigDecimal("-1.5") => BigDecimal("-2"),
1049-
+0.0 => 0,
1050-
-0.0 => 0,
1051-
1.5 => 2,
1052-
-1.5 => -2,
1050+
BigDecimal("-1.5") => BigDecimal("-1"),
1051+
+0.0e0 => 0.0e0,
1052+
-0.0e0 => 0e0,
1053+
0.5e0 => 1e0,
1054+
-0.5e0 => -0e0,
1055+
1.5e0 => 2e0,
1056+
-1.5e0 => -1e0,
10531057
1.2e0 => 1.0e0,
10541058
-1.2e0 => -1.0e0
10551059
}.each do |value, result|

spec/model_uri_spec.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,12 +778,33 @@
778778
{
779779
"prefix with #" => ["http://example.com/#", "http://example.com/#foo", "foo"],
780780
"prefix with /" => ["http://example.com/", "http://example.com/#foo", "#foo"],
781-
"prefix without / or #" => ["http://example.com/f", "http://example.com/foo", "http://example.com/foo"],
781+
"prefix without / or #" => ["http://example.com/f", "http://example.com/foo", "foo"],
782782
}.each do |name, (base_uri,orig,result)|
783783
it "<#{base_uri}> + <#{orig}>: <#{result}>" do
784784
expect(described_class.new(orig).relativize(base_uri)).to eq result
785785
end
786786
end
787+
788+
context "json-ld compact#t0066" do
789+
{
790+
"https://w3c.github.io/json-ld-api/tests/compact/link" => "link",
791+
"https://w3c.github.io/json-ld-api/tests/compact/0066-in.jsonld#fragment-works" => "#fragment-works",
792+
"https://w3c.github.io/json-ld-api/tests/compact/0066-in.jsonld?query=works" => "?query=works",
793+
"https://w3c.github.io/json-ld-api/tests/" => "../",
794+
"https://w3c.github.io/json-ld-api/" => "../../",
795+
"https://w3c.github.io/json-ld-api/parent" => "../../parent",
796+
"https://w3c.github.io/json-ld-api/parent#fragment" => "../../parent#fragment",
797+
"https://w3c.github.io/parent-parent-eq-root" => "../../../parent-parent-eq-root",
798+
"https://w3c.github.io/still-root" => "../../../still-root",
799+
"https://w3c.github.io/too-many-dots" => "../../../too-many-dots",
800+
"https://w3c.github.io/absolute" => "../../../absolute",
801+
"http://example.org/scheme-relative" => "http://example.org/scheme-relative"
802+
}.each do |orig, result|
803+
it "relativises #{orig} to #{result}" do
804+
expect(described_class.new(orig).relativize("https://w3c.github.io/json-ld-api/tests/compact/0066-in.jsonld")).to eq result
805+
end
806+
end
807+
end
787808
end
788809

789810
describe "#request_uri" do
@@ -950,8 +971,8 @@
950971
end
951972

952973
it "#=~" do
953-
expect(RDF::URI('http://example.org/')).to match /example/
954-
expect(RDF::URI('http://example.org/')).not_to match /foobar/
974+
expect(RDF::URI('http://example.org/')).to match(/example/)
975+
expect(RDF::URI('http://example.org/')).not_to match(/foobar/)
955976
end
956977

957978
it "#to_str" do

0 commit comments

Comments
 (0)