ldp 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5891836d3638c426292b938c2e815bc78963a486
4
- data.tar.gz: e846d7a47515ee66db76b539979b01024b39f56d
3
+ metadata.gz: a0192dec60a69549a92992ee9a8a17dc7a2e7bea
4
+ data.tar.gz: 9f1d63533db1609c91b7ca86d807e645a1148343
5
5
  SHA512:
6
- metadata.gz: f82a7c37efd44e165cfba252c64073255d805074ba78e92a3a5ea2d988407b13987b9947614102b120b006578a15ddb43f68e30904cdcc006765ab79c48dec36
7
- data.tar.gz: 44771b0779cbd68c5c0f8b2917176ca9de4a36290b3d433318bf859b77688e1e6164e28150af0ee3a66612ea304944ce235c886ffd5f93f8ac7cb626645e1bb7
6
+ metadata.gz: a2576375233b5f9c8fb7879e26c187c75a0cb30e740db682d084ebd57f88db616d81efaeb6c04d4289fcb10095fe34dca5199f7936ebc1c65028e08f56bae31d
7
+ data.tar.gz: 0bcd587f427cefcc0d4d702d57da18389a2b9c602b898a06708d829c28cbfd3a8cb8abff4ed195c7f51d25cd67584a77140d03fbb3f493f6609849bcef1427e6
@@ -1,4 +1,9 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ env:
5
+ global:
6
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
2
7
  rvm:
3
8
  - 1.9.3
4
9
  - 2.0.0
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in ldp-client.gemspec
4
4
  gemspec
5
5
 
6
- gem 'byebug', :platforms => [:mri_20]
6
+ gem 'slop', '~> 3.6' if RUBY_PLATFORM == "java"
7
+ gem 'byebug', platforms: :mri_20
7
8
  gem 'activesupport'
@@ -4,20 +4,27 @@ module Ldp
4
4
 
5
5
  def initialize client, subject, content_or_response = nil, base_path = ''
6
6
  super
7
-
7
+
8
8
  case content_or_response
9
9
  when Faraday::Response
10
10
  else
11
11
  @content = content_or_response
12
12
  end
13
13
  end
14
-
14
+
15
15
  def content
16
16
  @content ||= get.body
17
17
  end
18
-
18
+
19
19
  def described_by
20
20
  client.find_or_initialize Array(Ldp::Response.links(self)["describedby"]).first
21
21
  end
22
+
23
+ # Override inspect so that `content` is never shown. It is typically too big to be helpful
24
+ def inspect
25
+ string = "#<#{self.class.name}:#{self.object_id} "
26
+ fields = [:subject].map{|field| "#{field}=\"#{self.send(field)}\""}
27
+ string << fields.join(", ") << ">"
28
+ end
22
29
  end
23
30
  end
@@ -60,6 +60,17 @@ module Ldp
60
60
  container?(response) || Array(links(response)["type"]).include?(Ldp.rdf_source)
61
61
  end
62
62
 
63
+ def dup
64
+ super.tap do |new_resp|
65
+ new_resp.send(:extend, Ldp::Response)
66
+ if ::RUBY_VERSION < '2.0'
67
+ new_resp.send(:remove_instance_variable, :@graph)
68
+ else
69
+ new_resp.remove_instance_variable(:@graph)
70
+ end
71
+ end
72
+ end
73
+
63
74
  ##
64
75
  # Link: headers from the HTTP response
65
76
  def links
@@ -109,7 +120,7 @@ module Ldp
109
120
  # Get the graph for the resource (or a blank graph if there is no metadata for the resource)
110
121
  def graph
111
122
  @graph ||= begin
112
- raise UnexpectedContentType, "The resource #{page_subject} is not an RDFSource" unless rdf_source?
123
+ raise UnexpectedContentType, "The resource at #{page_subject} is not an RDFSource" unless rdf_source?
113
124
  graph = RDF::Graph.new
114
125
 
115
126
  if resource?
@@ -1,3 +1,3 @@
1
1
  module Ldp
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ldp::Resource::BinarySource do
4
+ let(:client) { double }
5
+ let(:uri) { 'http://example.com/foo/bar' }
6
+ let(:content) { 'somecontent' }
7
+ subject { described_class.new(client, uri, content) }
8
+
9
+ it "should not display content to inspect" do
10
+ expect(subject.inspect).to match /subject=\"http:\/\/example\.com\/foo\/bar\"/
11
+ expect(subject.inspect).not_to match /somecontent/
12
+ end
13
+
14
+ end
@@ -4,7 +4,7 @@ describe Ldp::Response do
4
4
  LDP_RDF_RESOURCE_HEADERS = { "Link" => "<#{Ldp.resource.to_s}>;rel=\"type\", <#{Ldp.direct_container.to_s}>;rel=\"type\""}
5
5
  LDP_NON_RDF_SOURCE_HEADERS = { "Link" => "<#{Ldp.resource.to_s}>;rel=\"type\", <#{Ldp.non_rdf_source.to_s}>;rel=\"type\""}
6
6
 
7
- let(:mock_response) { double(headers: {}, env: { url: "info:a" }) }
7
+ let(:mock_response) { double("mock response", headers: {}, env: { url: "info:a" }) }
8
8
  let(:mock_client) { double(Ldp::Client) }
9
9
 
10
10
  subject do
@@ -18,6 +18,34 @@ describe Ldp::Response do
18
18
  end
19
19
  end
20
20
 
21
+ describe "#dup" do
22
+ let(:simple_container_graph) { "<> a <http://www.w3.org/ns/ldp#Container> ." }
23
+ let(:link) { ["<http://www.w3.org/ns/ldp#Resource>;rel=\"type\"","<http://www.w3.org/ns/ldp#BasicContainer>;rel=\"type\""] }
24
+
25
+ let(:conn_stubs) do
26
+ Faraday::Adapter::Test::Stubs.new do |stub|
27
+ stub.get('/a_container') { [200, {"Link" => link}, simple_container_graph] }
28
+ end
29
+ end
30
+
31
+ let(:mock_conn) { Faraday.new { |builder| builder.adapter :test, conn_stubs } }
32
+ let(:client) { Ldp::Client.new mock_conn }
33
+ let(:raw_response) { client.get "a_container" }
34
+
35
+ let(:response) { Ldp::Response.wrap mock_client, raw_response }
36
+ subject { response.dup }
37
+ it { is_expected.to respond_to :links }
38
+
39
+ it "should not have duplicated the graph" do
40
+ expect(response.graph.object_id).not_to eq subject.graph.object_id
41
+ end
42
+
43
+ it "should have duplicated the body" do
44
+ expect(response.body.object_id).to eq subject.body.object_id
45
+ end
46
+ end
47
+
48
+
21
49
  describe ".links" do
22
50
  it "should extract link headers with relations as a hash" do
23
51
  allow(mock_response).to receive(:headers).and_return(
@@ -26,7 +54,7 @@ describe Ldp::Response do
26
54
  "<abc>;rel=\"some-multi-rel\"",
27
55
  "<123>;rel=\"some-multi-rel\"",
28
56
  "<vanilla-link>"
29
- ]
57
+ ]
30
58
  )
31
59
  h = Ldp::Response.links mock_response
32
60
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -142,6 +142,7 @@ files:
142
142
  - spec/lib/integration/integration_spec.rb
143
143
  - spec/lib/ldp/client_spec.rb
144
144
  - spec/lib/ldp/orm/orm_spec.rb
145
+ - spec/lib/ldp/resource/binary_source_spec.rb
145
146
  - spec/lib/ldp/resource/rdf_source_spec.rb
146
147
  - spec/lib/ldp/resource_spec.rb
147
148
  - spec/lib/ldp/response_spec.rb
@@ -174,6 +175,7 @@ test_files:
174
175
  - spec/lib/integration/integration_spec.rb
175
176
  - spec/lib/ldp/client_spec.rb
176
177
  - spec/lib/ldp/orm/orm_spec.rb
178
+ - spec/lib/ldp/resource/binary_source_spec.rb
177
179
  - spec/lib/ldp/resource/rdf_source_spec.rb
178
180
  - spec/lib/ldp/resource_spec.rb
179
181
  - spec/lib/ldp/response_spec.rb