gooddata 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29f28bd583f3a4da577456a03cc225ac23bf2c06
4
- data.tar.gz: bfd619c784559c60daca2b02c63e1d019e04635c
3
+ metadata.gz: d7d013ba0b03cf22fd29f0ef4c266a06ecad756e
4
+ data.tar.gz: dac86a92b7e82af815df7f4900a329012d468437
5
5
  SHA512:
6
- metadata.gz: ce8b6231b9104d8b2b05ef0e8ba141be3da6af516d26e804fa97bb779a28e80a1a6f646502dcd526171ea0ea5608812c341ffa696b4e3d39feedfba538576808
7
- data.tar.gz: 612ac6eb1daf13fc91e66b07a666a0d3359e7d183ba11bebe8f13c29352ec3ac8e0517d4f7530cfba9a65603d838a914a94f13cb71faaa5b09a6c7f29dc57509
6
+ metadata.gz: 936dba585e13b83dc3a0592bf0cf068b3d4d8e23306c3ebdf0554810b7062486407d8a3ad95beaa6d86d09ca1bd8aec160080407c96d12f79dfe690ff9f40e03
7
+ data.tar.gz: b9664e85e0558d130ac3ac5452f20220d833d321d9aa9c59a53b22c126ae27f0156bce5944974645c1bf741cf604e4cd7c14dac42bf684e8f5e5a48dde0d39c0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # GoodData Ruby SDK Changelog
2
2
 
3
+ ## 0.6.9
4
+ - Fixing issues with creating models.
5
+ - Adding couple more helpers for report/metric computation
6
+ - Rewriting several full_* specs to use the new syntax
7
+
3
8
  ## 0.6.8
4
9
 
5
10
  - REST Factory - See [PR #224](https://github.com/gooddata/gooddata-ruby/pull/224)
@@ -54,7 +54,7 @@ module GoodData
54
54
  alias_method :refresh, :reload!
55
55
 
56
56
  def browser_uri
57
- GoodData.connection.url + meta['uri']
57
+ client.connection.server_url + meta['uri']
58
58
  end
59
59
 
60
60
  def deprecated=(flag)
@@ -131,7 +131,7 @@ module GoodData
131
131
  end
132
132
 
133
133
  def create_from_blueprint(blueprint, options = {})
134
- GoodData::Model::ProjectCreator.migrate(:spec => blueprint, :token => options[:auth_token])
134
+ GoodData::Model::ProjectCreator.migrate(options.merge(spec: blueprint, token: options[:auth_token], client: GoodData.connection))
135
135
  end
136
136
 
137
137
  # Takes one CSV line and creates hash from data extracted
@@ -255,6 +255,14 @@ module GoodData
255
255
  new_project
256
256
  end
257
257
 
258
+ def compute_report(spec = {})
259
+ GoodData::ReportDefinition.execute(spec.merge(:client => client, :project => self))
260
+ end
261
+
262
+ def compute_metric(expression)
263
+ GoodData::Metric.xexecute(expression, :client => client, :project => self)
264
+ end
265
+
258
266
  def create_schedule(process, date, executable, options = {})
259
267
  GoodData::Schedule.create(process, date, executable, options.merge(:client => client, :project => self))
260
268
  end
@@ -339,11 +339,10 @@ module GoodData
339
339
  # @return [Array<Hash>]
340
340
  def can_break(dataset)
341
341
  dataset = find_dataset(dataset) if dataset.is_a?(String)
342
- referenced_by(dataset).reduce([]) do |a, e|
343
- e.attributes_and_anchors.each do |attr|
344
- a.push([e, attr])
342
+ (referenced_by(dataset) + [dataset]).mapcat do |ds|
343
+ ds.attributes_and_anchors.map do |attr|
344
+ [ds, attr]
345
345
  end
346
- a
347
346
  end
348
347
  end
349
348
 
@@ -126,6 +126,14 @@ module GoodData
126
126
  @factory = ObjectFactory.new(self)
127
127
  end
128
128
 
129
+ def create_project(options = {})
130
+ GoodData::Project.create(title: 'Project for schedule testing', auth_token: ConnectionHelper::GD_PROJECT_TOKEN, client: self)
131
+ end
132
+
133
+ def create_project_from_blueprint(blueprint, options = {})
134
+ GoodData::Model::ProjectCreator.migrate(spec: blueprint, token: options[:auth_token], client: self)
135
+ end
136
+
129
137
  def domain(domain_name)
130
138
  GoodData::Domain[domain_name, :client => self]
131
139
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # GoodData Module
4
4
  module GoodData
5
- VERSION = '0.6.8'
5
+ VERSION = '0.6.9'
6
6
 
7
7
  class << self
8
8
  # Version
@@ -3,7 +3,7 @@ require 'gooddata'
3
3
  describe "Full process and schedule exercise", :constraint => 'slow' do
4
4
  before(:all) do
5
5
  @client = ConnectionHelper::create_default_connection
6
- @project = GoodData::Project.create(title: 'Project for schedule testing', auth_token: ConnectionHelper::GD_PROJECT_TOKEN, :client => @client)
6
+ @project = @client.create_project(title: 'Project for schedule testing', auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
7
7
  @process = @project.deploy_process('./spec/data/ruby_process',
8
8
  type: 'RUBY',
9
9
  name: 'Test ETL Process')
@@ -5,7 +5,7 @@ describe "Full project implementation", :constraint => 'slow' do
5
5
  @spec = JSON.parse(File.read("./spec/data/test_project_model_spec.json"), :symbolize_names => true)
6
6
  @invalid_spec = JSON.parse(File.read("./spec/data/blueprint_invalid.json"), :symbolize_names => true)
7
7
  @client = ConnectionHelper::create_default_connection
8
- @project = GoodData::Model::ProjectCreator.migrate({:spec => @spec, :token => ConnectionHelper::GD_PROJECT_TOKEN, :client => @client})
8
+ @project = @client.create_project_from_blueprint(@spec, auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
9
9
  end
10
10
 
11
11
  after(:all) do
@@ -16,7 +16,7 @@ describe "Full project implementation", :constraint => 'slow' do
16
16
 
17
17
  it "should not build an invalid model" do
18
18
  expect {
19
- GoodData::Model::ProjectCreator.migrate({:spec => @invalid_spec, :token => ConnectionHelper::GD_PROJECT_TOKEN, :client => @client})
19
+ @client.create_project_from_blueprint(@invalid_spec, auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
20
20
  }.to raise_error(GoodData::ValidationError)
21
21
  end
22
22
 
@@ -51,7 +51,7 @@ describe "Full project implementation", :constraint => 'slow' do
51
51
  @project.delete_all_data(force: true)
52
52
  f = @project.fact_by_title('Lines Changed')
53
53
  metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")")
54
- res = GoodData::ReportDefinition.execute(:left => [metric], :client => @client, :project => @project);
54
+ res = @project.compute_report(:left => [metric])
55
55
  expect(res).to be_empty
56
56
  end
57
57
 
@@ -99,11 +99,11 @@ describe "Full project implementation", :constraint => 'slow' do
99
99
  # TODO: Here we create metric which is not deleted and is used by another test - "should exercise the object relations and getting them in various ways"
100
100
  metric = @project.create_metric("SELECT SUM(#\"#{f.title}\")", :title => "My metric")
101
101
  metric.save
102
- result = GoodData::ReportDefinition.execute(:title => "My report", :top => [metric], :left => ['label.devs.dev_id.email'], :client => @client, :project => @project)
102
+ result = @project.compute_report(:top => [metric], :left => ['label.devs.dev_id.email'])
103
103
  expect(result[1][1]).to eq 3
104
104
  expect(result.include_row?(["jirka@gooddata.com", 5])).to be true
105
105
 
106
- result2 = GoodData::ReportDefinition.create(:title => "My report", :top => [metric], :left => ['label.devs.dev_id.email'], :client => @client, :project => @project).execute
106
+ result2 = @project.compute_report(:top => [metric], :left => ['label.devs.dev_id.email'])
107
107
  expect(result2[1][1]).to eq 3
108
108
  expect(result2.include_row?(["jirka@gooddata.com", 5])).to eq true
109
109
  expect(result2).to eq result
@@ -176,10 +176,10 @@ describe "Full project implementation", :constraint => 'slow' do
176
176
  expect(fact1).not_to eq fact3
177
177
 
178
178
  metric.using(nil)
179
- expect(metric.using('fact', :client => @client, :project => @project).count).to eq 1
179
+ expect(metric.using('fact').count).to eq 1
180
180
 
181
181
  fact1.used_by(nil)
182
- expect(fact1.used_by('metric', :client => @client, :project => @project).count).to eq 1
182
+ expect(fact1.used_by('metric').count).to eq 1
183
183
 
184
184
  res = metric.using?(fact1)
185
185
  expect(res).to be(true)
@@ -211,16 +211,16 @@ describe "Full project implementation", :constraint => 'slow' do
211
211
  end
212
212
 
213
213
  it "should be able to interpolate metric based on" do
214
- res = GoodData::Metric.xexecute "SELECT SUM(![fact.commits.lines_changed])", :client => @client, :project => @project
214
+ res = @project.compute_metric "SELECT SUM(![fact.commits.lines_changed])"
215
215
  expect(res).to eq 9
216
216
 
217
- res = GoodData::Metric.xexecute( "SELECT SUM(![fact.commits.lines_changed])", :client => @client, :project => @project)
217
+ res = @project.compute_metric "SELECT SUM(![fact.commits.lines_changed])"
218
218
  expect(res).to eq 9
219
219
 
220
- res = GoodData::Metric.execute("SELECT SUM(![fact.commits.lines_changed])", :extended_notation => true, :client => @client, :project => @project)
220
+ res = @project.compute_metric "SELECT SUM(![fact.commits.lines_changed])"
221
221
  expect(res).to eq 9
222
222
 
223
- res = GoodData::Metric.execute("SELECT SUM(![fact.commits.lines_changed])", :extended_notation => true, :client => @client, :project => @project)
223
+ res = @project.compute_metric "SELECT SUM(![fact.commits.lines_changed])"
224
224
  expect(res).to eq 9
225
225
 
226
226
  fact = @project.fact_by_title('Lines Changed')
@@ -1,13 +1,13 @@
1
1
  require 'gooddata'
2
2
 
3
- describe "Spin a project", :constraint => 'slow' do
3
+ describe "Object export between projects", :constraint => 'slow' do
4
4
  before(:all) do
5
5
  @client = ConnectionHelper.create_default_connection
6
6
 
7
7
  spec = MultiJson.load(File.read("./spec/data/test_project_model_spec.json"), :symbolize_keys => true)
8
8
 
9
- @source_project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => ConnectionHelper::GD_PROJECT_TOKEN, :client => @client})
10
- @target_project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => ConnectionHelper::GD_PROJECT_TOKEN, :client => @client})
9
+ @source_project = @client.create_project_from_blueprint(spec, auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
10
+ @target_project = @client.create_project_from_blueprint(spec, auth_token: ConnectionHelper::GD_PROJECT_TOKEN)
11
11
  end
12
12
 
13
13
  after(:all) do
@@ -20,18 +20,17 @@ describe "Spin a project", :constraint => 'slow' do
20
20
  it "should transfer a metric" do
21
21
  f = GoodData::Fact.find_first_by_title('Lines Changed', :client => @client, :project => @source_project)
22
22
  metric_title = "Testing metric to be exported"
23
- metric = GoodData::Metric.xcreate("SELECT SUM(#\"#{f.title}\")", :title => metric_title, :client => @client, :project => @source_project)
23
+ metric = @source_project.create_metric("SELECT SUM(#\"#{f.title}\")", :title => metric_title)
24
24
  metric.save
25
25
 
26
- GoodData.with_project(@target_project) { |p| GoodData::Metric[:all, :client => @client, :project => @target_project].count.should == 0 }
26
+ @target_project.metrics.count.should == 0
27
27
 
28
- @source_project.partial_md_export(metric, :client => @client, :project => @target_project)
29
- GoodData.with_project(@target_project) do |_p|
30
- GoodData::Metric[:all, :client => @client, :project => @target_project].count.should == 1
31
- metric = GoodData::Metric.find_first_by_title(metric_title, :client => @client, :project => @target_project)
32
- metric.should_not be_nil
33
- metric.title.should == metric_title
34
- end
28
+ @source_project.partial_md_export(metric, :project => @target_project)
29
+
30
+ expect(@target_project.metrics.count).to eq 1
31
+ metric = GoodData::Metric.find_first_by_title(metric_title, :client => @client, :project => @target_project)
32
+ expect(metric).not_to be_nil
33
+ expect(metric.title).to eq metric_title
35
34
  end
36
35
 
37
36
  end
@@ -19,29 +19,24 @@ describe 'GoodData - project' do
19
19
  end
20
20
 
21
21
  it 'Assigns project using project ID' do
22
- pending 'GoodData::project= is disabled for now'
23
- GoodData.project = ProjectHelper::PROJECT_ID
22
+ GoodData.use(ProjectHelper::PROJECT_ID, client: @client)
24
23
  end
25
24
 
26
25
  it 'Assigns project using project URL' do
27
- pending 'GoodData::project= is disabled for now'
28
- GoodData.project = ProjectHelper::PROJECT_URL
26
+ GoodData.use ProjectHelper::PROJECT_URL, client: @client
29
27
  end
30
28
 
31
29
  it 'Assigns project directly' do
32
- pending 'GoodData::project= is disabled for now'
33
- GoodData.project = GoodData::Project[ProjectHelper::PROJECT_ID]
30
+ GoodData.project = GoodData::Project[ProjectHelper::PROJECT_ID, client: @client]
34
31
  end
35
32
  end
36
33
 
37
34
  describe '#project' do
38
35
  it 'Returns project assigned' do
39
- pending 'GoodData.project= is disabled for now'
40
-
41
36
  GoodData.project = nil
42
37
  GoodData.project.should == nil
43
38
 
44
- GoodData.project = ProjectHelper::PROJECT_ID
39
+ GoodData.use ProjectHelper::PROJECT_ID, client: @client
45
40
  GoodData.project.should_not == nil
46
41
  end
47
42
  end
@@ -213,7 +213,6 @@ describe GoodData::Model::ProjectBlueprint do
213
213
  attrs = @blueprint.can_break('commits')
214
214
  attrs.count.should == 3
215
215
 
216
- pending("At least those from the same dataset should be able to break")
217
216
  attrs = @blueprint.can_break('devs')
218
217
  attrs.count.should == 1
219
218
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kolesnikov
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-09-16 00:00:00.000000000 Z
14
+ date: 2014-09-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: debase