Skip to content

Commit

Permalink
Finish 3.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Nov 15, 2020
2 parents 085cc59 + ef5f330 commit 53f46cc
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 23 deletions.
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -28,9 +28,11 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage devel
enough, be assured we will eventually add you in there.
* Do note that in order for us to merge any non-trivial changes (as a rule
of thumb, additions larger than about 15 lines of code), we need an
explicit [public domain dedication][PDD] on record from you.
explicit [public domain dedication][PDD] on record from you,
which you will be asked to agree to on the first commit to a repo within the organization.
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.

[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[PDD]: https://unlicense.org/#unlicensing-contributions
[pr]: https://github.com/ruby-rdf/rdf/compare/
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -26,7 +26,7 @@ group :debug do
gem "redcarpet", platforms: :ruby
gem "byebug", platforms: :mri
gem 'guard-rspec'
gem 'awesome_print', github: "akshaymohite/awesome_print", branch: "ruby-2-7-0-warnings-fix"
gem 'awesome_print', github: 'akshaymohite/awesome_print'
end

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


## License

Expand All @@ -450,7 +453,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
[N-Quads]: https://www.w3.org/TR/n-quads/
[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[PDD]: https://unlicense.org/#unlicensing-contributions
[JSONLD doc]: https://rubydoc.info/github/ruby-rdf/json-ld
[LinkedData doc]: https://rubydoc.info/github/ruby-rdf/linkeddata
[Microdata doc]: https://rubydoc.info/github/ruby-rdf/rdf-microdata
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.1.6
3.1.7
10 changes: 8 additions & 2 deletions lib/rdf/model/literal/decimal.rb
Expand Up @@ -63,9 +63,15 @@ def abs
##
# 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.
#
# @return [RDF::Literal::Integer]
# @return [RDF::Literal::Decimal]
def round
RDF::Literal::Integer.new(to_d.round)
rounded = to_d.round(half: (to_d < 0 ? :down : :up))
if rounded == -0.0
# to avoid -0.0
self.class.new(0.0)
else
self.class.new(rounded)
end
end

##
Expand Down
6 changes: 3 additions & 3 deletions lib/rdf/model/literal/double.rb
Expand Up @@ -181,11 +181,11 @@ def abs
end

##
# 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.
# 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.
#
# @return [RDF::Literal::Integer]
# @return [RDF::Literal::Double]
def round
RDF::Literal::Integer.new(to_f.round)
self.class.new(to_d.round(half: (to_d < 0 ? :down : :up)))
end

##
Expand Down
16 changes: 13 additions & 3 deletions lib/rdf/model/uri.rb
Expand Up @@ -311,12 +311,22 @@ def relative?; !absolute?; end
# @param [#to_s] base_uri
# @return [RDF::URI]
def relativize(base_uri)
if base_uri.to_s.end_with?("/", "#") &&
if self.to_s.start_with?(base_uri.to_s) && %w(# ?).include?(self.to_s[base_uri.to_s.length, 1]) ||
base_uri.to_s.end_with?("/", "#") &&
self.to_s.start_with?(base_uri.to_s)
RDF::URI(self.to_s[base_uri.to_s.length..-1])
return RDF::URI(self.to_s[base_uri.to_s.length..-1])
else
self
# Create a list of parents, for which this IRI may be relative.
u = RDF::URI(base_uri)
iri_set = u.to_s.end_with?('/') ? [u.to_s] : []
iri_set << u.to_s while (u = u.parent)
iri_set.each_with_index do |bb, index|
next unless self.to_s.start_with?(bb)
rel = "../" * index + self.to_s[bb.length..-1]
return rel.empty? ? "./" : rel
end
end
self
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/vocabulary.rb
Expand Up @@ -731,7 +731,7 @@ def initialize(uri)
# @param [#to_s] property
# @return [URI]
def [](property)
Term.intern([to_s, property.to_s].join(''), vocab: self.class, attributes: {})
Term.intern([to_s, property.to_s].join(''), vocab: self, attributes: {})
end

##
Expand Down
14 changes: 9 additions & 5 deletions spec/model_literal_spec.rb
Expand Up @@ -1044,12 +1044,16 @@ def self.literals(*selector)
0 => 0,
BigDecimal("1.1") => BigDecimal("1"),
BigDecimal("-1.1") => BigDecimal("-1"),
BigDecimal("0.5") => BigDecimal("1"),
BigDecimal("-0.5") => BigDecimal("0"),
BigDecimal("1.5") => BigDecimal("2"),
BigDecimal("-1.5") => BigDecimal("-2"),
+0.0 => 0,
-0.0 => 0,
1.5 => 2,
-1.5 => -2,
BigDecimal("-1.5") => BigDecimal("-1"),
+0.0e0 => 0.0e0,
-0.0e0 => 0e0,
0.5e0 => 1e0,
-0.5e0 => -0e0,
1.5e0 => 2e0,
-1.5e0 => -1e0,
1.2e0 => 1.0e0,
-1.2e0 => -1.0e0
}.each do |value, result|
Expand Down
27 changes: 24 additions & 3 deletions spec/model_uri_spec.rb
Expand Up @@ -778,12 +778,33 @@
{
"prefix with #" => ["http://example.com/#", "http://example.com/#foo", "foo"],
"prefix with /" => ["http://example.com/", "http://example.com/#foo", "#foo"],
"prefix without / or #" => ["http://example.com/f", "http://example.com/foo", "http://example.com/foo"],
"prefix without / or #" => ["http://example.com/f", "http://example.com/foo", "foo"],
}.each do |name, (base_uri,orig,result)|
it "<#{base_uri}> + <#{orig}>: <#{result}>" do
expect(described_class.new(orig).relativize(base_uri)).to eq result
end
end

context "json-ld compact#t0066" do
{
"https://w3c.github.io/json-ld-api/tests/compact/link" => "link",
"https://w3c.github.io/json-ld-api/tests/compact/0066-in.jsonld#fragment-works" => "#fragment-works",
"https://w3c.github.io/json-ld-api/tests/compact/0066-in.jsonld?query=works" => "?query=works",
"https://w3c.github.io/json-ld-api/tests/" => "../",
"https://w3c.github.io/json-ld-api/" => "../../",
"https://w3c.github.io/json-ld-api/parent" => "../../parent",
"https://w3c.github.io/json-ld-api/parent#fragment" => "../../parent#fragment",
"https://w3c.github.io/parent-parent-eq-root" => "../../../parent-parent-eq-root",
"https://w3c.github.io/still-root" => "../../../still-root",
"https://w3c.github.io/too-many-dots" => "../../../too-many-dots",
"https://w3c.github.io/absolute" => "../../../absolute",
"http://example.org/scheme-relative" => "http://example.org/scheme-relative"
}.each do |orig, result|
it "relativises #{orig} to #{result}" do
expect(described_class.new(orig).relativize("https://w3c.github.io/json-ld-api/tests/compact/0066-in.jsonld")).to eq result
end
end
end
end

describe "#request_uri" do
Expand Down Expand Up @@ -950,8 +971,8 @@
end

it "#=~" do
expect(RDF::URI('http://example.org/')).to match /example/
expect(RDF::URI('http://example.org/')).not_to match /foobar/
expect(RDF::URI('http://example.org/')).to match(/example/)
expect(RDF::URI('http://example.org/')).not_to match(/foobar/)
end

it "#to_str" do
Expand Down
5 changes: 5 additions & 0 deletions spec/vocabulary_spec.rb
Expand Up @@ -16,26 +16,31 @@
it "should allow method_missing" do
expect {subject.foo}.not_to raise_error
expect(subject.foo).to be_a(RDF::Vocabulary::Term)
expect(subject.foo.vocab.to_s).to eq('http://example.org/')
end

it "camelizes on method_missing" do
expect(subject.foo_bar).to be_a(RDF::Vocabulary::Term)
expect(subject.foo_bar).to eq (subject.to_uri / 'fooBar')
expect(subject.foo_bar.vocab.to_s).to eq('http://example.org/')
end

it "should allow []" do
expect {subject["foo"]}.not_to raise_error
expect(subject["foo"]).to be_a(RDF::Vocabulary::Term)
expect(subject["foo"].vocab.to_s).to eq('http://example.org/')
end

it "allows #send" do
expect {subject.send(:foo)}.not_to raise_error
expect(subject.send(:foo)).to be_a(RDF::Vocabulary::Term)
expect(subject.send(:foo).vocab.to_s).to eq('http://example.org/')
end

it "allows #public_send" do
expect {subject.public_send(:foo)}.not_to raise_error
expect(subject.public_send(:foo)).to be_a(RDF::Vocabulary::Term)
expect(subject.public_send(:foo).vocab.to_s).to eq('http://example.org/')
end

it "does not add to @@uris" do
Expand Down

0 comments on commit 53f46cc

Please sign in to comment.