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.
Files changed (102) hide show
  1. data/.gitignore +3 -0
  2. data/.rspec +3 -0
  3. data/.yardopts +19 -0
  4. data/Gemfile +5 -0
  5. data/README.md +191 -0
  6. data/Rakefile +18 -1
  7. data/bin/gooddata +74 -63
  8. data/doc/.gitignore +1 -0
  9. data/doc/css/.gitkeepme +1 -0
  10. data/doc/images/.gitkeepme +1 -0
  11. data/doc/images/background.png +0 -0
  12. data/doc/images/bg-callout-button.png +0 -0
  13. data/doc/images/header-logo.png +0 -0
  14. data/doc/images/logo-image.png +0 -0
  15. data/doc/js/.gitkeepme +1 -0
  16. data/doc/pages/GET_STARTED.md +309 -0
  17. data/doc/pages/HOMEPAGE.md +75 -0
  18. data/doc/pages/TUTORIALS.md +52 -0
  19. data/doc/pages/tutorial/BRICKS.md +257 -0
  20. data/doc/pages/tutorial/CREATING_A_MODEL.md +79 -0
  21. data/doc/pages/tutorial/CRUNCHING_NUMBERS.md +233 -0
  22. data/doc/pages/tutorial/TEST_DRIVEN_DEVELOPMENT.md +118 -0
  23. data/doc/pages/tutorial/YOUR_FIRST_PROJECT.md +52 -0
  24. data/doc/templates/default/class/dot/setup.rb +6 -0
  25. data/doc/templates/default/class/dot/superklass.erb +3 -0
  26. data/doc/templates/default/class/setup.rb +36 -0
  27. data/doc/templates/default/class/text/setup.rb +11 -0
  28. data/doc/templates/default/class/text/subclasses.erb +5 -0
  29. data/doc/templates/default/constant/text/header.erb +11 -0
  30. data/doc/templates/default/constant/text/setup.rb +3 -0
  31. data/doc/templates/default/docstring/setup.rb +51 -0
  32. data/doc/templates/default/docstring/text/abstract.erb +2 -0
  33. data/doc/templates/default/docstring/text/deprecated.erb +2 -0
  34. data/doc/templates/default/docstring/text/index.erb +2 -0
  35. data/doc/templates/default/docstring/text/note.erb +4 -0
  36. data/doc/templates/default/docstring/text/private.erb +2 -0
  37. data/doc/templates/default/docstring/text/returns_void.erb +1 -0
  38. data/doc/templates/default/docstring/text/text.erb +1 -0
  39. data/doc/templates/default/docstring/text/todo.erb +4 -0
  40. data/doc/templates/default/layout/dot/header.erb +6 -0
  41. data/doc/templates/default/layout/dot/setup.rb +14 -0
  42. data/doc/templates/default/method/setup.rb +3 -0
  43. data/doc/templates/default/method/text/header.erb +1 -0
  44. data/doc/templates/default/method_details/setup.rb +10 -0
  45. data/doc/templates/default/method_details/text/header.erb +10 -0
  46. data/doc/templates/default/method_details/text/method_signature.erb +12 -0
  47. data/doc/templates/default/method_details/text/setup.rb +10 -0
  48. data/doc/templates/default/module/dot/child.erb +1 -0
  49. data/doc/templates/default/module/dot/dependencies.erb +3 -0
  50. data/doc/templates/default/module/dot/header.erb +6 -0
  51. data/doc/templates/default/module/dot/info.erb +14 -0
  52. data/doc/templates/default/module/dot/setup.rb +14 -0
  53. data/doc/templates/default/module/setup.rb +164 -0
  54. data/doc/templates/default/module/text/children.erb +10 -0
  55. data/doc/templates/default/module/text/class_meths_list.erb +8 -0
  56. data/doc/templates/default/module/text/extends.erb +8 -0
  57. data/doc/templates/default/module/text/header.erb +7 -0
  58. data/doc/templates/default/module/text/includes.erb +8 -0
  59. data/doc/templates/default/module/text/instance_meths_list.erb +8 -0
  60. data/doc/templates/default/module/text/setup.rb +12 -0
  61. data/doc/templates/default/root/dot/child.erb +3 -0
  62. data/doc/templates/default/root/dot/setup.rb +5 -0
  63. data/doc/templates/default/tags/setup.rb +55 -0
  64. data/doc/templates/default/tags/text/example.erb +12 -0
  65. data/doc/templates/default/tags/text/index.erb +1 -0
  66. data/doc/templates/default/tags/text/option.erb +20 -0
  67. data/doc/templates/default/tags/text/overload.erb +19 -0
  68. data/doc/templates/default/tags/text/see.erb +11 -0
  69. data/doc/templates/default/tags/text/tag.erb +13 -0
  70. data/examples.rb +2 -2
  71. data/gooddata.gemspec +31 -26
  72. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +1 -1
  73. data/lib/gooddata/client.rb +65 -53
  74. data/lib/gooddata/commands/commands.rb +9 -0
  75. data/lib/gooddata/commands/process.rb +9 -8
  76. data/lib/gooddata/commands/projects.rb +29 -0
  77. data/lib/gooddata/commands/runners.rb +1 -1
  78. data/lib/gooddata/connection.rb +6 -4
  79. data/lib/gooddata/exceptions.rb +2 -1
  80. data/lib/gooddata/helpers.rb +1 -1
  81. data/lib/gooddata/model.rb +360 -189
  82. data/lib/gooddata/models/metadata.rb +1 -1
  83. data/lib/gooddata/models/metric.rb +2 -1
  84. data/lib/gooddata/models/project.rb +1 -1
  85. data/lib/gooddata/models/report.rb +0 -18
  86. data/lib/gooddata/version.rb +1 -1
  87. data/spec/blueprint_spec.rb +83 -43
  88. data/spec/data/additional_dataset_module.json +18 -0
  89. data/spec/data/blueprint_invalid.json +36 -0
  90. data/spec/data/blueprint_valid.json +37 -0
  91. data/spec/data/model_module.json +18 -0
  92. data/spec/{test_project_model_spec.json → data/test_project_model_spec.json} +4 -0
  93. data/spec/full_project_spec.rb +4 -3
  94. data/spec/helpers/blueprint_helper.rb +17 -0
  95. data/spec/merging_blueprints_spec.rb +23 -48
  96. data/spec/model_dsl_spec.rb +2 -2
  97. data/spec/model_spec.rb +44 -0
  98. data/spec/project_build_and_update_spec.rb +28 -0
  99. data/spec/spec_helper.rb +6 -0
  100. data/yard-server.sh +3 -0
  101. metadata +251 -74
  102. data/README.rdoc +0 -176
@@ -119,7 +119,7 @@ module GoodData
119
119
  end
120
120
 
121
121
  def tags=(list_of_tags)
122
- data["meta"]["tags"] = tags
122
+ data["meta"]["tags"] = list_of_tags
123
123
  end
124
124
 
125
125
  def meta
@@ -1,7 +1,8 @@
1
1
  require 'gooddata/goodzilla/goodzilla'
2
2
 
3
3
  module GoodData
4
- class Metric < GoodData::MdObject
4
+ # Metric representation
5
+ class Metric < GoodData::MdObject
5
6
 
6
7
  root_key :metric
7
8
 
@@ -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.delete(:auth_token) || GoodData.connection.auth_token
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
@@ -1,3 +1,3 @@
1
1
  module GoodData
2
- VERSION = "0.6.0.pre9"
2
+ VERSION = "0.6.0.pre10"
3
3
  end
@@ -4,46 +4,85 @@ require 'pry'
4
4
  describe GoodData::Model::ProjectBlueprint do
5
5
 
6
6
  before(:each) do
7
- @valid_blueprint = blueprint = GoodData::Model::ProjectBlueprint.new(
8
- {
9
- :title => "x",
10
- :datasets => [
7
+ @valid_blueprint = GoodData::Model::ProjectBlueprint.new(
11
8
  {
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
- @invalid_blueprint = blueprint = GoodData::Model::ProjectBlueprint.new(
28
- {
29
- :title => "x",
30
- :datasets => [
31
- {
32
- :name=>"payments",
33
- :columns => [
34
- {:type=>:attribute, :name=>"id"},
35
- {:type=>:fact, :name=>"amount"},
36
- {:type=>:reference, :name=>"user_id", :dataset => "users", :reference => "user_id"},
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
- :name=>"users",
41
- :columns => [
42
- {:type=>:attribute, :name=>"user_id"},
43
- {:type=>:fact, :name=>"amount"}]
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 == {:type=>:reference,
65
- :name=>"user_id",
66
- :dataset=>"users",
67
- :reference=>"user_id"}
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,18 @@
1
+ {
2
+ "title": "Region module",
3
+ "datasets": [
4
+ {
5
+ "name": "regions",
6
+ "columns": [
7
+ {
8
+ "type": "anchor",
9
+ "name": "id"
10
+ },
11
+ {
12
+ "type": "attribute",
13
+ "name": "name"
14
+ }
15
+ ]
16
+ }
17
+ ]
18
+ }
@@ -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
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "title": "Devs module",
3
+ "datasets": [
4
+ {
5
+ "name": "devs",
6
+ "columns": [
7
+ {
8
+ "type": "anchor",
9
+ "name": "id"
10
+ },
11
+ {
12
+ "type": "attribute",
13
+ "name": "region"
14
+ }
15
+ ]
16
+ }
17
+ ]
18
+ }
@@ -12,6 +12,10 @@
12
12
  "type": "label",
13
13
  "name": "name",
14
14
  "reference": "id"
15
+ },
16
+ {
17
+ "type": "attribute",
18
+ "name": "department"
15
19
  }
16
20
  ]
17
21
  },
@@ -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 => "INTNA000000GDPM"})
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 = blueprint = GoodData::Model::ProjectBlueprint.new(
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=>"users",
15
+ :name=>"commits",
45
16
  :columns => [
46
- {:type=>:fact, :name=>"amount"}
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=>"users",
27
+ :name=>"commits",
57
28
  :columns => [
58
- {:type=>:attribute, :name=>"amount"}
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("users").to_hash
66
- additional_blueprint = @additional_blueprint.get_dataset("users").to_hash
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=>:attribute, :name=>"region"}).should == true
69
- stuff[:columns].include?({:type=>:fact, :name=>"amount"}).should == true
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 all attributes are identical" do
73
- first_dataset = @base_blueprint.get_dataset("users").to_hash
74
- additional_blueprint = @blueprint_with_duplicate.get_dataset("users").to_hash
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].count.should == 2
78
- stuff[:columns].include?({:type=>:fact, :name=>"amount"}).should == true
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("users").to_hash
84
- additional_blueprint = @conflicting_blueprint.get_dataset("users").to_hash
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