iq_triplestorage 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /coverage
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ gem "rake"
7
7
  group :test do
8
8
  gem "minitest"
9
9
  gem "webmock"
10
+ gem "simplecov", :require => false
10
11
  end
data/Rakefile CHANGED
@@ -6,3 +6,13 @@ end
6
6
 
7
7
  desc "Run tests"
8
8
  task :default => :test
9
+
10
+ desc "Build gem"
11
+ task :build do |t|
12
+ `rm *.gem; gem build *.gemspec`
13
+ end
14
+
15
+ desc "Release gem"
16
+ task :release => :build do |t|
17
+ `gem push *.gem`
18
+ end
@@ -1,3 +1,3 @@
1
1
  module IqTriplestorage
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,11 +1,14 @@
1
- require 'net/http'
2
- require 'base64'
3
- require 'typhoeus'
1
+ require "net/http"
2
+ require "base64"
3
+ require "typhoeus"
4
4
 
5
5
  module IqTriplestorage
6
6
  class VirtuosoAdaptor
7
7
 
8
8
  def initialize(host, port, username, password)
9
+ # validate to avoid nasty errors
10
+ raise(ArgumentError, "username must not be nil") if username.nil?
11
+
9
12
  @host = host
10
13
  @port = port
11
14
  @username = username
@@ -59,7 +62,7 @@ module IqTriplestorage
59
62
  "Authorization" => "Basic #{auth}", # XXX: seems like this should be built into Typhoeus!?
60
63
  "Content-Type" => content_type
61
64
  }
62
- res = Typhoeus::Request.put("#{@host}:#{@port}#{path}",
65
+ res = Typhoeus::Request.put("#{@host}:#{@port}#{path}", # XXX: is PUT correct here?
63
66
  :headers => headers, :body => rdf_data)
64
67
 
65
68
  return res.code == 201
@@ -84,7 +87,7 @@ module IqTriplestorage
84
87
  "Authorization" => "Basic #{auth}", # XXX: seems like this should be built into Typhoeus!?
85
88
  "Content-Type" => "application/sparql-query"
86
89
  }
87
- res = Typhoeus::Request.put("#{@host}:#{@port}#{path}",
90
+ res = Typhoeus::Request.post("#{@host}:#{@port}#{path}",
88
91
  :headers => headers, :body => query)
89
92
 
90
93
  return res.code == 201
@@ -0,0 +1,8 @@
1
+ require "simplecov"
2
+
3
+ # limit coverage to /lib
4
+ cwd = File.expand_path(File.join(File.dirname(__FILE__), "../"))
5
+ SimpleCov.add_filter do |src_file|
6
+ !src_file.filename.start_with?(File.join(cwd, "lib").to_s)
7
+ end
8
+ SimpleCov.start
@@ -1,6 +1,8 @@
1
- require 'base64'
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
2
+
3
+ require "base64"
2
4
  require "minitest/autorun"
3
- require 'webmock/test_unit'
5
+ require "webmock/test_unit"
4
6
 
5
7
  require "iq_triplestorage/virtuoso_adaptor"
6
8
 
@@ -13,7 +15,7 @@ class VirtuosoTest < MiniTest::Unit::TestCase
13
15
  # not using WebMock's custom assertions as those didn't seem to provide
14
16
  # sufficient flexibility
15
17
  fn = @observers.shift
16
- raise(TypeError, "missing request observer") unless fn
18
+ raise(TypeError, "missing request observer: #{req.inspect}") unless fn
17
19
  fn.call(req)
18
20
  true
19
21
  end.to_return do |req|
@@ -90,7 +92,9 @@ class VirtuosoTest < MiniTest::Unit::TestCase
90
92
  end
91
93
  @observers << lambda do |req|
92
94
  assert_equal :put, req.method
93
- assert req.uri.path.start_with?("/DAV/home/#{@username}/rdf_sink/")
95
+ path = req.uri.path
96
+ assert path.start_with?("/DAV/home/#{@username}/rdf_sink/")
97
+ assert_equal 5, path.count("/")
94
98
  assert_equal "application/rdf+xml", req.headers["Content-Type"]
95
99
  assert_equal rdf_data, req.body
96
100
  end
@@ -104,11 +108,21 @@ class VirtuosoTest < MiniTest::Unit::TestCase
104
108
  }
105
109
 
106
110
  @observers << lambda do |req|
111
+ assert_equal :post, req.method
112
+ path = req.uri.path
113
+ assert path.start_with?("/DAV/home/#{@username}/")
114
+ assert_equal 4, path.count("/")
115
+ assert_equal "application/sparql-query", req.headers["Content-Type"]
107
116
  data.keys.each do |graph_uri|
108
117
  assert req.body.include?("CLEAR GRAPH <#{graph_uri}>")
109
118
  end
110
119
  end
111
120
  @observers << lambda do |req|
121
+ assert_equal :post, req.method
122
+ path = req.uri.path
123
+ assert path.start_with?("/DAV/home/#{@username}/")
124
+ assert_equal 4, path.count("/")
125
+ assert_equal "application/sparql-query", req.headers["Content-Type"]
112
126
  data.each do |graph_uri, ntriples|
113
127
  assert req.body.
114
128
  include?(<<-EOS)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iq_triplestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-23 00:00:00.000000000 Z
12
+ date: 2012-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus
@@ -33,6 +33,7 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
+ - .gitignore
36
37
  - .travis.yml
37
38
  - Gemfile
38
39
  - README.md
@@ -40,6 +41,7 @@ files:
40
41
  - iq_triplestorage.gemspec
41
42
  - lib/iq_triplestorage.rb
42
43
  - lib/iq_triplestorage/virtuoso_adaptor.rb
44
+ - test/test_helper.rb
43
45
  - test/virtuoso_test.rb
44
46
  homepage: http://github.com/innoq/iq_triplestorage
45
47
  licenses: []
@@ -53,12 +55,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
55
  - - ! '>='
54
56
  - !ruby/object:Gem::Version
55
57
  version: '0'
58
+ segments:
59
+ - 0
60
+ hash: 1344314608360584677
56
61
  required_rubygems_version: !ruby/object:Gem::Requirement
57
62
  none: false
58
63
  requirements:
59
64
  - - ! '>='
60
65
  - !ruby/object:Gem::Version
61
66
  version: '0'
67
+ segments:
68
+ - 0
69
+ hash: 1344314608360584677
62
70
  requirements: []
63
71
  rubyforge_project: iq_triplestorage
64
72
  rubygems_version: 1.8.23
@@ -66,4 +74,5 @@ signing_key:
66
74
  specification_version: 3
67
75
  summary: IqTriplestorage - library for interacting with RDF triplestores / quadstores
68
76
  test_files:
77
+ - test/test_helper.rb
69
78
  - test/virtuoso_test.rb