gooddata 0.6.0.pre9 → 0.6.0.pre10
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.rspec +3 -0
- data/.yardopts +19 -0
- data/Gemfile +5 -0
- data/README.md +191 -0
- data/Rakefile +18 -1
- data/bin/gooddata +74 -63
- data/doc/.gitignore +1 -0
- data/doc/css/.gitkeepme +1 -0
- data/doc/images/.gitkeepme +1 -0
- data/doc/images/background.png +0 -0
- data/doc/images/bg-callout-button.png +0 -0
- data/doc/images/header-logo.png +0 -0
- data/doc/images/logo-image.png +0 -0
- data/doc/js/.gitkeepme +1 -0
- data/doc/pages/GET_STARTED.md +309 -0
- data/doc/pages/HOMEPAGE.md +75 -0
- data/doc/pages/TUTORIALS.md +52 -0
- data/doc/pages/tutorial/BRICKS.md +257 -0
- data/doc/pages/tutorial/CREATING_A_MODEL.md +79 -0
- data/doc/pages/tutorial/CRUNCHING_NUMBERS.md +233 -0
- data/doc/pages/tutorial/TEST_DRIVEN_DEVELOPMENT.md +118 -0
- data/doc/pages/tutorial/YOUR_FIRST_PROJECT.md +52 -0
- data/doc/templates/default/class/dot/setup.rb +6 -0
- data/doc/templates/default/class/dot/superklass.erb +3 -0
- data/doc/templates/default/class/setup.rb +36 -0
- data/doc/templates/default/class/text/setup.rb +11 -0
- data/doc/templates/default/class/text/subclasses.erb +5 -0
- data/doc/templates/default/constant/text/header.erb +11 -0
- data/doc/templates/default/constant/text/setup.rb +3 -0
- data/doc/templates/default/docstring/setup.rb +51 -0
- data/doc/templates/default/docstring/text/abstract.erb +2 -0
- data/doc/templates/default/docstring/text/deprecated.erb +2 -0
- data/doc/templates/default/docstring/text/index.erb +2 -0
- data/doc/templates/default/docstring/text/note.erb +4 -0
- data/doc/templates/default/docstring/text/private.erb +2 -0
- data/doc/templates/default/docstring/text/returns_void.erb +1 -0
- data/doc/templates/default/docstring/text/text.erb +1 -0
- data/doc/templates/default/docstring/text/todo.erb +4 -0
- data/doc/templates/default/layout/dot/header.erb +6 -0
- data/doc/templates/default/layout/dot/setup.rb +14 -0
- data/doc/templates/default/method/setup.rb +3 -0
- data/doc/templates/default/method/text/header.erb +1 -0
- data/doc/templates/default/method_details/setup.rb +10 -0
- data/doc/templates/default/method_details/text/header.erb +10 -0
- data/doc/templates/default/method_details/text/method_signature.erb +12 -0
- data/doc/templates/default/method_details/text/setup.rb +10 -0
- data/doc/templates/default/module/dot/child.erb +1 -0
- data/doc/templates/default/module/dot/dependencies.erb +3 -0
- data/doc/templates/default/module/dot/header.erb +6 -0
- data/doc/templates/default/module/dot/info.erb +14 -0
- data/doc/templates/default/module/dot/setup.rb +14 -0
- data/doc/templates/default/module/setup.rb +164 -0
- data/doc/templates/default/module/text/children.erb +10 -0
- data/doc/templates/default/module/text/class_meths_list.erb +8 -0
- data/doc/templates/default/module/text/extends.erb +8 -0
- data/doc/templates/default/module/text/header.erb +7 -0
- data/doc/templates/default/module/text/includes.erb +8 -0
- data/doc/templates/default/module/text/instance_meths_list.erb +8 -0
- data/doc/templates/default/module/text/setup.rb +12 -0
- data/doc/templates/default/root/dot/child.erb +3 -0
- data/doc/templates/default/root/dot/setup.rb +5 -0
- data/doc/templates/default/tags/setup.rb +55 -0
- data/doc/templates/default/tags/text/example.erb +12 -0
- data/doc/templates/default/tags/text/index.erb +1 -0
- data/doc/templates/default/tags/text/option.erb +20 -0
- data/doc/templates/default/tags/text/overload.erb +19 -0
- data/doc/templates/default/tags/text/see.erb +11 -0
- data/doc/templates/default/tags/text/tag.erb +13 -0
- data/examples.rb +2 -2
- data/gooddata.gemspec +31 -26
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +1 -1
- data/lib/gooddata/client.rb +65 -53
- data/lib/gooddata/commands/commands.rb +9 -0
- data/lib/gooddata/commands/process.rb +9 -8
- data/lib/gooddata/commands/projects.rb +29 -0
- data/lib/gooddata/commands/runners.rb +1 -1
- data/lib/gooddata/connection.rb +6 -4
- data/lib/gooddata/exceptions.rb +2 -1
- data/lib/gooddata/helpers.rb +1 -1
- data/lib/gooddata/model.rb +360 -189
- data/lib/gooddata/models/metadata.rb +1 -1
- data/lib/gooddata/models/metric.rb +2 -1
- data/lib/gooddata/models/project.rb +1 -1
- data/lib/gooddata/models/report.rb +0 -18
- data/lib/gooddata/version.rb +1 -1
- data/spec/blueprint_spec.rb +83 -43
- data/spec/data/additional_dataset_module.json +18 -0
- data/spec/data/blueprint_invalid.json +36 -0
- data/spec/data/blueprint_valid.json +37 -0
- data/spec/data/model_module.json +18 -0
- data/spec/{test_project_model_spec.json → data/test_project_model_spec.json} +4 -0
- data/spec/full_project_spec.rb +4 -3
- data/spec/helpers/blueprint_helper.rb +17 -0
- data/spec/merging_blueprints_spec.rb +23 -48
- data/spec/model_dsl_spec.rb +2 -2
- data/spec/model_spec.rb +44 -0
- data/spec/project_build_and_update_spec.rb +28 -0
- data/spec/spec_helper.rb +6 -0
- data/yard-server.sh +3 -0
- metadata +251 -74
- data/README.rdoc +0 -176
@@ -49,7 +49,7 @@ module GoodData
|
|
49
49
|
def create(attributes, &block)
|
50
50
|
GoodData.logger.info "Creating project #{attributes[:title]}"
|
51
51
|
|
52
|
-
auth_token = attributes
|
52
|
+
auth_token = attributes[:auth_token] || GoodData.connection.auth_token
|
53
53
|
|
54
54
|
json = {:project =>
|
55
55
|
{
|
@@ -35,24 +35,6 @@ module GoodData
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# ----
|
39
|
-
|
40
|
-
def title=(a_title)
|
41
|
-
@json["report"]["meta"]["title"] = a_title
|
42
|
-
end
|
43
|
-
|
44
|
-
def summary=(a_summary)
|
45
|
-
@json[:report][:meta][:summary] = a_summary
|
46
|
-
end
|
47
|
-
|
48
|
-
def add_definition(a_definition)
|
49
|
-
@json[:report][:content][:definitions] << a_definition
|
50
|
-
end
|
51
|
-
|
52
|
-
# ----
|
53
|
-
|
54
|
-
|
55
|
-
|
56
38
|
def results
|
57
39
|
content["results"]
|
58
40
|
end
|
data/lib/gooddata/version.rb
CHANGED
data/spec/blueprint_spec.rb
CHANGED
@@ -4,46 +4,85 @@ require 'pry'
|
|
4
4
|
describe GoodData::Model::ProjectBlueprint do
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
@valid_blueprint =
|
8
|
-
{
|
9
|
-
:title => "x",
|
10
|
-
:datasets => [
|
7
|
+
@valid_blueprint = GoodData::Model::ProjectBlueprint.new(
|
11
8
|
{
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
9
|
+
title: 'x',
|
10
|
+
datasets: [
|
11
|
+
{
|
12
|
+
name: 'payments',
|
13
|
+
columns: [
|
14
|
+
{
|
15
|
+
type: 'attribute',
|
16
|
+
name: 'id'
|
17
|
+
},
|
18
|
+
{
|
19
|
+
type: 'fact',
|
20
|
+
name: 'amount'
|
21
|
+
},
|
22
|
+
{
|
23
|
+
type: 'reference',
|
24
|
+
name: 'user_id',
|
25
|
+
dataset: 'users',
|
26
|
+
reference: 'user_id'
|
27
|
+
},
|
28
|
+
]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
name: 'users',
|
32
|
+
columns: [
|
33
|
+
{
|
34
|
+
type: 'anchor',
|
35
|
+
name: 'user_id'
|
36
|
+
},
|
37
|
+
{
|
38
|
+
type: 'fact',
|
39
|
+
name: 'amount'
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
43
|
+
]})
|
44
|
+
|
45
|
+
@invalid_blueprint = GoodData::Model::ProjectBlueprint.new(
|
39
46
|
{
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
title: 'x',
|
48
|
+
datasets: [
|
49
|
+
{
|
50
|
+
name: 'payments',
|
51
|
+
columns: [
|
52
|
+
{
|
53
|
+
type: 'attribute',
|
54
|
+
name: 'id'
|
55
|
+
},
|
56
|
+
{
|
57
|
+
type: 'fact',
|
58
|
+
name: 'amount'
|
59
|
+
},
|
60
|
+
{
|
61
|
+
type: 'reference',
|
62
|
+
name: 'user_id',
|
63
|
+
dataset: 'users',
|
64
|
+
reference: 'user_id'
|
65
|
+
},
|
66
|
+
]
|
67
|
+
},
|
68
|
+
{
|
69
|
+
name: 'users',
|
70
|
+
columns: [
|
71
|
+
{
|
72
|
+
type: 'attribute',
|
73
|
+
name: 'user_id'
|
74
|
+
},
|
75
|
+
{
|
76
|
+
type: 'fact',
|
77
|
+
name: 'amount'
|
78
|
+
}
|
79
|
+
]
|
80
|
+
}
|
81
|
+
]})
|
82
|
+
|
83
|
+
# @valid_blueprint = blueprint = BlueprintHelper.blueprint_from_file(File.join(File.dirname(__FILE__), 'data', 'blueprint_valid.json'))
|
84
|
+
|
85
|
+
# @invalid_blueprint = BlueprintHelper.blueprint_from_file(File.join(File.dirname(__FILE__), 'data', 'blueprint_valid.json'))
|
47
86
|
end
|
48
87
|
|
49
88
|
it "valid blueprint should be marked as valid" do
|
@@ -61,10 +100,12 @@ describe GoodData::Model::ProjectBlueprint do
|
|
61
100
|
it "invalid blueprint should give you list of violating references" do
|
62
101
|
errors = @invalid_blueprint.model_validate
|
63
102
|
errors.size.should == 1
|
64
|
-
errors.first.should == {
|
65
|
-
|
66
|
-
|
67
|
-
|
103
|
+
errors.first.should == {
|
104
|
+
type: 'reference',
|
105
|
+
name: 'user_id',
|
106
|
+
dataset: 'users',
|
107
|
+
reference: 'user_id'
|
108
|
+
}
|
68
109
|
end
|
69
110
|
|
70
111
|
it "references return empty array if there is no reference" do
|
@@ -87,6 +128,5 @@ describe GoodData::Model::ProjectBlueprint do
|
|
87
128
|
ds.has_anchor?.should == false
|
88
129
|
end
|
89
130
|
|
90
|
-
|
91
131
|
|
92
132
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"title": "x",
|
3
|
+
"datasets": [
|
4
|
+
{
|
5
|
+
"name": "payments",
|
6
|
+
"columns": [
|
7
|
+
{
|
8
|
+
"type": "attribute",
|
9
|
+
"name": "id"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"type": "fact",
|
13
|
+
"name": "amount"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"type": "reference",
|
17
|
+
"name": "user_id",
|
18
|
+
"dataset": "users",
|
19
|
+
"reference": "user_id"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "users",
|
25
|
+
"columns": [
|
26
|
+
{
|
27
|
+
"type": "attribute",
|
28
|
+
"name": "user_id"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"type": "fact",
|
32
|
+
"name": "amount"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
]}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"title": "x",
|
3
|
+
"datasets": [
|
4
|
+
{
|
5
|
+
"name": "payments",
|
6
|
+
"columns": [
|
7
|
+
{
|
8
|
+
"type": "attribute",
|
9
|
+
"name": "id"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"type": "fact",
|
13
|
+
"name": "amount"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"type": "reference",
|
17
|
+
"name": "user_id",
|
18
|
+
"dataset": "users",
|
19
|
+
"reference": "user_id"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "users",
|
25
|
+
"columns": [
|
26
|
+
{
|
27
|
+
"type": "attribute",
|
28
|
+
"name": "user_id"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"type": "fact",
|
32
|
+
"name": "amount"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
data/spec/full_project_spec.rb
CHANGED
@@ -2,12 +2,13 @@ require 'gooddata'
|
|
2
2
|
|
3
3
|
describe "Spin a project", :constraint => 'slow' do
|
4
4
|
|
5
|
+
GD_PROJECT_TOKEN = ENV["GD_PROJECT_TOKEN"]
|
6
|
+
|
5
7
|
before(:all) do
|
6
|
-
spec = JSON.parse(File.read("./spec/test_project_model_spec.json"), :symbolize_names => true)
|
8
|
+
spec = JSON.parse(File.read("./spec/data/test_project_model_spec.json"), :symbolize_names => true)
|
7
9
|
GoodData.connect("svarovsky+gem_tester@gooddata.com", "jindrisska")
|
8
|
-
GoodData.logging_on
|
9
10
|
|
10
|
-
@project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token =>
|
11
|
+
@project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => GD_PROJECT_TOKEN})
|
11
12
|
end
|
12
13
|
|
13
14
|
after(:all) do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Global requires
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
# Local requires
|
5
|
+
require 'gooddata/model'
|
6
|
+
|
7
|
+
module BlueprintHelper
|
8
|
+
def blueprint_from_file(bp)
|
9
|
+
# Try to load as full path
|
10
|
+
raw = IO.read(bp)
|
11
|
+
|
12
|
+
# TODO: Try to load as relative path if failed
|
13
|
+
|
14
|
+
parsed = JSON.parse(raw, :symbolize_names => true)
|
15
|
+
return GoodData::Model::ProjectBlueprint.new(parsed)
|
16
|
+
end
|
17
|
+
end
|
@@ -4,46 +4,17 @@ require 'pry'
|
|
4
4
|
describe GoodData::Model::ProjectBlueprint do
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
@base_blueprint =
|
8
|
-
|
9
|
-
:title => "x",
|
10
|
-
:datasets => [
|
11
|
-
{
|
12
|
-
:name=>"payments",
|
13
|
-
:columns => [
|
14
|
-
{:type=>:attribute, :name=>"id"},
|
15
|
-
{:type=>:fact, :name=>"amount"},
|
16
|
-
{:type=>:reference, :name=>"user_id", :dataset => "users", :reference => "user_id"},
|
17
|
-
]
|
18
|
-
},
|
19
|
-
{
|
20
|
-
:name=>"users",
|
21
|
-
:columns => [
|
22
|
-
{:type=>:anchor, :name=>"user_id"},
|
23
|
-
{:type=>:fact, :name=>"amount"}]
|
24
|
-
}
|
25
|
-
]})
|
26
|
-
|
27
|
-
@additional_blueprint = GoodData::Model::ProjectBlueprint.new(
|
28
|
-
{
|
29
|
-
:title => "x",
|
30
|
-
:datasets => [
|
31
|
-
{
|
32
|
-
:name=>"users",
|
33
|
-
:columns => [
|
34
|
-
{:type=>:attribute, :name=>"region"}
|
35
|
-
]
|
36
|
-
}
|
37
|
-
]})
|
7
|
+
@base_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/test_project_model_spec.json")
|
8
|
+
@additional_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/model_module.json")
|
38
9
|
|
39
10
|
@blueprint_with_duplicate = GoodData::Model::ProjectBlueprint.new(
|
40
11
|
{
|
41
12
|
:title => "x",
|
42
13
|
:datasets => [
|
43
14
|
{
|
44
|
-
:name=>"
|
15
|
+
:name=>"commits",
|
45
16
|
:columns => [
|
46
|
-
{:type
|
17
|
+
{:type=>"fact", :name=>"lines_changed"}
|
47
18
|
]
|
48
19
|
}
|
49
20
|
]})
|
@@ -53,37 +24,41 @@ describe GoodData::Model::ProjectBlueprint do
|
|
53
24
|
:title => "x",
|
54
25
|
:datasets => [
|
55
26
|
{
|
56
|
-
:name=>"
|
27
|
+
:name=>"commits",
|
57
28
|
:columns => [
|
58
|
-
{:type
|
29
|
+
{:type=>"attribute", :name=>"lines_changed"}
|
59
30
|
]
|
60
31
|
}
|
61
32
|
]})
|
62
33
|
end
|
63
34
|
|
64
35
|
it "should be possible to merge Schema blueprints" do
|
65
|
-
first_dataset = @base_blueprint.get_dataset("
|
66
|
-
additional_blueprint = @additional_blueprint.get_dataset("
|
36
|
+
first_dataset = @base_blueprint.get_dataset("devs").to_hash
|
37
|
+
additional_blueprint = @additional_blueprint.get_dataset("devs").to_hash
|
67
38
|
stuff = GoodData::Model.merge_dataset_columns(first_dataset, additional_blueprint)
|
68
|
-
stuff[:columns].include?({:type
|
69
|
-
stuff[:columns].include?({:type
|
39
|
+
stuff[:columns].include?({:type=>"attribute", :name=>"region"}).should == true
|
40
|
+
stuff[:columns].include?({:type=>"anchor", :name=>"id"}).should == true
|
70
41
|
end
|
71
42
|
|
72
|
-
it "should pass when merging 2 columns with the same name if
|
73
|
-
first_dataset = @base_blueprint.get_dataset("
|
74
|
-
additional_blueprint = @blueprint_with_duplicate.get_dataset("
|
43
|
+
it "should pass when merging 2 columns with the same name if both columns are identical" do
|
44
|
+
first_dataset = @base_blueprint.get_dataset("commits").to_hash
|
45
|
+
additional_blueprint = @blueprint_with_duplicate.get_dataset("commits").to_hash
|
75
46
|
stuff = GoodData::Model.merge_dataset_columns(first_dataset, additional_blueprint)
|
76
|
-
|
77
|
-
stuff[:columns].
|
78
|
-
stuff[:columns].
|
79
|
-
stuff[:columns].include?({:type=>:anchor, :name=>"user_id"}).should == true
|
47
|
+
stuff[:columns].count.should == 4
|
48
|
+
stuff[:columns].include?({:type=>"fact", :name=>"lines_changed"}).should == true
|
49
|
+
stuff[:columns].group_by {|col| col[:name]}["lines_changed"].count.should == 1
|
80
50
|
end
|
81
51
|
|
82
52
|
it "should pass when merging 2 columns with the same name if all attributes are identical" do
|
83
|
-
first_dataset = @base_blueprint.get_dataset("
|
84
|
-
additional_blueprint = @conflicting_blueprint.get_dataset("
|
53
|
+
first_dataset = @base_blueprint.get_dataset("commits").to_hash
|
54
|
+
additional_blueprint = @conflicting_blueprint.get_dataset("commits").to_hash
|
85
55
|
|
86
56
|
expect{GoodData::Model.merge_dataset_columns(first_dataset, additional_blueprint)}.to raise_error
|
87
57
|
end
|
88
58
|
|
59
|
+
it "should be possible to merge directly whole bleuprints. Blueprint is changed in place when merge! is used" do
|
60
|
+
@base_blueprint.merge!(@additional_blueprint)
|
61
|
+
@base_blueprint.get_dataset("repos").attributes.include?({:type => "attribute", :name => "department"})
|
62
|
+
end
|
63
|
+
|
89
64
|
end
|