bespoke 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bespoke.gemspec +3 -2
- data/lib/bespoke.rb +14 -0
- data/lib/bespoke/dsl.rb +2 -3
- data/lib/bespoke/export.rb +7 -0
- data/lib/bespoke/export/filter.rb +154 -0
- data/lib/bespoke/export/filter/function_call.rb +61 -0
- data/lib/bespoke/export/filter/identifier.rb +66 -0
- data/lib/bespoke/export/filter/select_template.rb +109 -0
- data/lib/bespoke/export/filter/string_literal.rb +16 -0
- data/lib/bespoke/join.rb +15 -8
- data/lib/bespoke/mustache.rb +17 -0
- data/lib/bespoke/projection.rb +31 -17
- data/lib/bespoke/template.rb +2 -2
- data/lib/bespoke/typed_field.rb +30 -0
- data/lib/bespoke/version.rb +1 -1
- data/spec/fixtures/sif.student_personal.xslt +1 -1
- data/spec/fixtures/sif.xslt.mustache +1 -1
- data/spec/lib/bespoke/export/filter/function_call_spec.rb +72 -0
- data/spec/lib/bespoke/export/filter/identifier_spec.rb +62 -0
- data/spec/lib/bespoke/export/filter/select_template_spec.rb +102 -0
- data/spec/lib/bespoke/export/filter_spec.rb +102 -0
- data/spec/lib/bespoke/export_spec.rb +6 -0
- data/spec/lib/bespoke/join_spec.rb +59 -0
- data/spec/lib/bespoke/projection_spec.rb +94 -0
- data/spec/{template_spec.rb → lib/bespoke/template_spec.rb} +3 -3
- data/spec/lib/bespoke/typed_field_spec.rb +101 -0
- data/spec/{xsltproc_spec.rb → lib/bespoke/xsltproc_spec.rb} +1 -1
- data/spec/spec_helper.rb +16 -3
- data/spec/support/fixture_helpers.rb +24 -0
- metadata +52 -12
- data/spec/join_spec.rb +0 -44
data/spec/join_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
describe Bespoke::Join do
|
4
|
-
let(:projections) {
|
5
|
-
[
|
6
|
-
projection(:one) {
|
7
|
-
field :id, :integer
|
8
|
-
field :name, :string
|
9
|
-
},
|
10
|
-
projection(:two) {
|
11
|
-
field :id, :integer
|
12
|
-
field :one_id, :integer
|
13
|
-
field :description, :string
|
14
|
-
}
|
15
|
-
]
|
16
|
-
}
|
17
|
-
let(:join) { Bespoke::Join.new(projections) }
|
18
|
-
|
19
|
-
context "table 'one'" do
|
20
|
-
before { join.load_csv('one', fixture('one.csv')) }
|
21
|
-
|
22
|
-
it "loads csv" do
|
23
|
-
join.database[:one].count.should == 2
|
24
|
-
end
|
25
|
-
|
26
|
-
context "and table 'two'" do
|
27
|
-
before { join.load_csv('two', fixture('two.csv')) }
|
28
|
-
|
29
|
-
it "loads csv" do
|
30
|
-
join.database[:two].count.should == 3
|
31
|
-
end
|
32
|
-
|
33
|
-
it "joins" do
|
34
|
-
sql = "SELECT name, description FROM one LEFT JOIN two ON one.id = two.one_id"
|
35
|
-
join.query(sql).map { |row| row }.
|
36
|
-
should == [
|
37
|
-
{:name=>"bitcoin", :description=>"Cryptocurrency"},
|
38
|
-
{:name=>"bitcoin", :description=>"Investment"},
|
39
|
-
{:name=>"nxt", :description=>"Alternate Cryptocurrency"}
|
40
|
-
]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|