amigo 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +8 -0
- data/lib/amigo/solution.rb +5 -1
- data/lib/amigo/store.rb +4 -0
- data/lib/amigo/variables.rb +4 -0
- data/lib/amigo/version.rb +1 -1
- data/spec/amigo/select/to_sql_spec.rb +8 -8
- data/spec/amigo/solution/to_ary_spec.rb +28 -0
- data/spec/amigo/store/to_ntriples_spec.rb +13 -1
- data/spec/amigo/store/to_sql_spec.rb +28 -0
- metadata +6 -4
data/History.rdoc
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 0.1.4 / 2010-05-31
|
2
|
+
|
3
|
+
* Implement Solution#to_ary so you can auto-expand the variables as block arguments.
|
4
|
+
|
5
|
+
* Improve error message when solution variable not found.
|
6
|
+
|
7
|
+
* Implement Store#to_ntriples.
|
8
|
+
|
1
9
|
=== 0.1.3 / 2010-05-23
|
2
10
|
|
3
11
|
* Fixed: weird 1.9 scoping behaviour.
|
data/lib/amigo/solution.rb
CHANGED
data/lib/amigo/store.rb
CHANGED
data/lib/amigo/variables.rb
CHANGED
data/lib/amigo/version.rb
CHANGED
@@ -9,14 +9,14 @@ module Amigo
|
|
9
9
|
describe "#to_sql" do
|
10
10
|
|
11
11
|
[
|
12
|
-
[Select.new(:*), "SELECT * FROM
|
13
|
-
[Select.new(:*).where(:x, :y, :z), "SELECT subject x, predicate y, object z FROM
|
14
|
-
[Select.new(:x, :y, :z).where(:x, :y, :z), "SELECT subject x, predicate y, object z FROM
|
15
|
-
[Select.new(:x, :z).where(:x, :y, :z), "SELECT subject x, object z FROM
|
16
|
-
[Select.new(:*).where(:x, "bee", :z), "SELECT subject x, object z, FROM
|
17
|
-
[Select.new(:x, :z).where(:x, "bee", :z), "SELECT subject x, object z FROM
|
18
|
-
[Select.new(:*).where(:x, "bee", :z).where("dee", :y, "eff"), "SELECT a.subject x, a.object z, b.predicate y FROM
|
19
|
-
[Select.new(:x, :y).where(:x, "bee", :z).where(:z, :y, "see"), "SELECT a.subject x, b.predicate y FROM
|
12
|
+
[Select.new(:*), "SELECT * FROM triple LIMIT 0"],
|
13
|
+
[Select.new(:*).where(:x, :y, :z), "SELECT subject x, predicate y, object z FROM triple"],
|
14
|
+
[Select.new(:x, :y, :z).where(:x, :y, :z), "SELECT subject x, predicate y, object z FROM triple"],
|
15
|
+
[Select.new(:x, :z).where(:x, :y, :z), "SELECT subject x, object z FROM triple"],
|
16
|
+
[Select.new(:*).where(:x, "bee", :z), "SELECT subject x, object z, FROM triple WHERE triple.predicate = 'bee'"],
|
17
|
+
[Select.new(:x, :z).where(:x, "bee", :z), "SELECT subject x, object z FROM triple WHERE triple.predicate = 'bee'"],
|
18
|
+
[Select.new(:*).where(:x, "bee", :z).where("dee", :y, "eff"), "SELECT a.subject x, a.object z, b.predicate y FROM triple a CROSS JOIN triple b WHERE a.predicate = 'bee' AND b.subject = 'dee' AND b.object = 'eff'"],
|
19
|
+
[Select.new(:x, :y).where(:x, "bee", :z).where(:z, :y, "see"), "SELECT a.subject x, b.predicate y FROM triple a JOIN triple b ON (a.object = b.subject) WHERE a.predicate = 'bee' AND b.object = 'see'"],
|
20
20
|
].each do |select, sql|
|
21
21
|
|
22
22
|
describe "given #{select.inspect}" do
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'hamster/list'
|
4
|
+
require 'hamster/hash'
|
5
|
+
require 'amigo/solution'
|
6
|
+
|
7
|
+
module Amigo
|
8
|
+
|
9
|
+
describe Solution do
|
10
|
+
|
11
|
+
describe "#to_ary" do
|
12
|
+
|
13
|
+
before do
|
14
|
+
@solution = Solution.new(
|
15
|
+
Hamster.list(:a, :b, :c),
|
16
|
+
Hamster.hash(:a => "Aye", :b => "Bee", :c => "See")
|
17
|
+
).to_ary
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should description" do
|
21
|
+
@solution.to_ary.should == ["Aye", "Bee", "See"]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
require 'amigo/uri'
|
3
4
|
require 'amigo/store'
|
4
5
|
|
5
6
|
module Amigo
|
@@ -8,7 +9,18 @@ module Amigo
|
|
8
9
|
|
9
10
|
describe "#to_ntriples" do
|
10
11
|
|
11
|
-
|
12
|
+
before do
|
13
|
+
@store = Store.new.
|
14
|
+
add("a", "b", "c").
|
15
|
+
add(URI.parse("http://www.example.com/x"), "b", URI.parse("http://www.example.com/z"))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns a textual representation of the store in the form of N-Triples" do
|
19
|
+
[
|
20
|
+
%Q{"a" "b" "c" .\n<http://www.example.com/x> "b" <http://www.example.com/z> .},
|
21
|
+
%Q{<http://www.example.com/x> "b" <http://www.example.com/z> .\n"a" "b" "c" .}
|
22
|
+
].should include(@store.to_ntriples)
|
23
|
+
end
|
12
24
|
|
13
25
|
end
|
14
26
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'amigo/uri'
|
4
|
+
require 'amigo/store'
|
5
|
+
|
6
|
+
module Amigo
|
7
|
+
|
8
|
+
describe Store do
|
9
|
+
|
10
|
+
describe "#to_sql" do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@store = Store.new.
|
14
|
+
add("a", "b", "c").
|
15
|
+
add(URI.parse("http://www.example.com/x"), "b", URI.parse("http://www.example.com/z"))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns a textual representation of the store in the form of SQL" do
|
19
|
+
# COPY triple (subject, predicate, object) FROM stdin;
|
20
|
+
# \.
|
21
|
+
# ].should include(@store.to_ntriples)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amigo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Simon Harris
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-05-
|
18
|
+
date: 2010-05-31 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -97,8 +97,10 @@ files:
|
|
97
97
|
- spec/amigo/select/immutable_spec.rb
|
98
98
|
- spec/amigo/select/to_sparql_spec.rb
|
99
99
|
- spec/amigo/select/to_sql_spec.rb
|
100
|
+
- spec/amigo/solution/to_ary_spec.rb
|
100
101
|
- spec/amigo/store/hash_spec.rb
|
101
102
|
- spec/amigo/store/to_ntriples_spec.rb
|
103
|
+
- spec/amigo/store/to_sql_spec.rb
|
102
104
|
- spec/amigo/term/to_sparql_spec.rb
|
103
105
|
- spec/amigo/triple/immutable_spec.rb
|
104
106
|
- spec/amigo/triple/inspect_spec.rb
|