Skip to content

Commit 61bac59

Browse files
author
Tomas Svarovsky
committed
Added connection to the several places to allow function with global dialect. Removing test that expects to fail.
1 parent bcfbfb8 commit 61bac59

11 files changed

Lines changed: 31 additions & 37 deletions

File tree

lib/gooddata/mixins/md_object_query.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module MdObjectQuery
88
# @param options [Hash] the options hash
99
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
1010
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
11-
def all(options = {})
11+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
1212
fail NotImplementedError, 'Method should be implemented in subclass. Currently there is no way how to get all metadata objects on API.'
1313
end
1414

lib/gooddata/models/metadata/attribute.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class << self
2020
# @param options [Hash] the options hash
2121
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
2222
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
23-
def all(options = {})
23+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
2424
query('attributes', Attribute, options)
2525
end
2626

lib/gooddata/models/metadata/dashboard.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
# @param options [Hash] the options hash
1818
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
1919
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
20-
def all(options = {})
20+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
2121
query('projectdashboards', Dashboard, options)
2222
end
2323

lib/gooddata/models/metadata/fact.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class << self
2121
# @param options [Hash] the options hash
2222
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
2323
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
24-
def all(options = {})
24+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
2525
query('facts', Fact, options)
2626
end
2727
end

lib/gooddata/models/metadata/label.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ def values(options = {})
6868
# Gives an attribute of current label
6969
# @return [GoodData::Attibute]
7070
def attribute
71-
opts = {
72-
:client => client,
73-
:project => project
74-
}
7571
project.attributes(content['formOf'])
7672
end
7773

lib/gooddata/models/metadata/metric.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class << self
2323
# @param options [Hash] the options hash
2424
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
2525
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
26-
def all(options = {})
26+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
2727
query('metrics', Metric, options)
2828
end
2929

@@ -215,14 +215,16 @@ def pretty_expression
215215
}
216216

217217
temp = expression.dup
218-
expression.scan(PARSE_MAQL_OBJECT_REGEXP).pmap do |uri|
218+
pairs = expression.scan(PARSE_MAQL_OBJECT_REGEXP).pmap do |uri|
219219
uri = uri.first
220220
if uri =~ /elements/
221221
[uri, Attribute.find_element_value(uri, opts)]
222222
else
223223
[uri, GoodData::MdObject[uri, opts].title]
224224
end
225-
end.each do |el|
225+
end
226+
227+
pairs.each do |el|
226228
uri = el[0]
227229
obj = el[1]
228230
temp.sub!(uri, obj)

lib/gooddata/models/metadata/report.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class << self
1313
# @param options [Hash] the options hash
1414
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
1515
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
16-
def all(options = {})
16+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
1717
query('reports', Report, options)
1818
end
1919

@@ -26,9 +26,9 @@ def create(options = { :client => GoodData.connection, :project => GoodData.proj
2626

2727
project = GoodData::Project[p, options]
2828
fail ArgumentError, 'Wrong :project specified' if project.nil?
29-
29+
3030
title = options[:title]
31-
fail "Report needs a title specified" unless title
31+
fail 'Report needs a title specified' unless title
3232
summary = options[:summary] || ''
3333
rd = options[:rd] || ReportDefinition.create(options)
3434
rd.save
@@ -55,7 +55,7 @@ def create(options = { :client => GoodData.connection, :project => GoodData.proj
5555

5656
# Add a report definition to a report. This will show on a UI as a new version.
5757
#
58-
# @param report_definition [GoodData::ReportDefinition | String] Report definition to add. Either it can be a URI of a report definition or an actual report definition object.
58+
# @param report_definition [GoodData::ReportDefinition | String] Report definition to add. Either it can be a URI of a report definition or an actual report definition object.
5959
# @return [GoodData::Report] Return self
6060
def add_definition(report_definition)
6161
rep_def = project.report_definitions(report_definition)
@@ -68,7 +68,7 @@ def results
6868
end
6969

7070
def definitions
71-
content['definitions'].pmap {|uri| project.report_definitions(uri)}
71+
content['definitions'].pmap { |uri| project.report_definitions(uri) }
7272
end
7373

7474
def definition_uris
@@ -138,7 +138,7 @@ def replace(what, for_what)
138138
new_defs = definitions.map do |rep_def|
139139
rep_def.replace(what, for_what)
140140
end
141-
new_defs.pmap &:save
141+
new_defs.pmap(&:save)
142142
end
143143
end
144144
end

lib/gooddata/models/metadata/report_definition.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class << self
1616
# @param options [Hash] the options hash
1717
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
1818
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
19-
def all(options = {})
19+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
2020
query('reportdefinition', ReportDefinition, options)
2121
end
2222

@@ -231,11 +231,11 @@ def attribute_parts
231231
end
232232

233233
def attributes
234-
labels.map {|label| label.attribute}
234+
labels.map { |label| label.attribute }
235235
end
236236

237237
def labels
238-
attribute_parts.map {|part| project.labels(part['attribute']['uri'])}
238+
attribute_parts.map { |part| project.labels(part['attribute']['uri']) }
239239
end
240240

241241
def metric_parts
@@ -264,7 +264,7 @@ def execute(opts = { :client => GoodData.connection, :project => GoodData.projec
264264
end
265265

266266
def filters
267-
content['filters'].map {|f| f['expression']}
267+
content['filters'].map { |f| f['expression'] }
268268
end
269269

270270
# Replace certain object in report definition. Returns new definition which is not saved.
@@ -274,12 +274,12 @@ def filters
274274
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
275275
def replace(what, for_what = nil)
276276
pairs = if what.is_a?(Hash)
277-
whats = what.keys
278-
to_whats = what.values
279-
whats.zip(to_whats)
280-
else
281-
[[what, for_what]]
282-
end
277+
whats = what.keys
278+
to_whats = what.values
279+
whats.zip(to_whats)
280+
else
281+
[[what, for_what]]
282+
end
283283

284284
pairs.each do |pair|
285285
what = pair[0]
@@ -333,9 +333,9 @@ def replace(what, for_what = nil)
333333
content['grid']['sort']['columns'] = sort.map do |item|
334334
if item.is_a?(Hash)
335335
item.deep_dup.tap do |i|
336-
next if not i.key?('metricSort')
337-
next if not i['metricSort'].key?('locators')
338-
next if not i['metricSort']['locators'][0].key?('attributeLocator2')
336+
next unless i.key?('metricSort')
337+
next unless i['metricSort'].key?('locators')
338+
next unless i['metricSort']['locators'][0].key?('attributeLocator2')
339339
i['metricSort']['locators'][0]['attributeLocator2']['uri'].gsub!(uri_what, uri_for_what)
340340
i['metricSort']['locators'][0]['attributeLocator2']['element'].gsub!(uri_what, uri_for_what)
341341
end
@@ -358,7 +358,7 @@ def replace(what, for_what = nil)
358358
end
359359
end
360360

361-
content['filters'] = filters.map { |filter_expression| { 'expression' => filter_expression.gsub(uri_what, uri_for_what) }}
361+
content['filters'] = filters.map { |filter_expression| { 'expression' => filter_expression.gsub(uri_what, uri_for_what) } }
362362
end
363363
self
364364
end

lib/gooddata/rest/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def connect(username, password, opts = {})
8585
end
8686

8787
# HACK: This line assigns class instance # if not done yet
88-
# @@instance = client # rubocop:disable ClassVars
88+
@@instance = client # rubocop:disable ClassVars
8989
client
9090
end
9191

lib/gooddata/rest/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def initialize(opts)
5454
def connect(username, password, options = {})
5555
# Reset old cookies first
5656
if options[:sst_token]
57-
merge_cookies!({ 'GDCAuthSST' => options[:sst_token] })
57+
merge_cookies!('GDCAuthSST' => options[:sst_token])
5858
@user = get(get('/gdc/app/account/bootstrap')['bootstrapResource']['accountSetting']['links']['self'])
5959
@auth = {}
6060
refresh_token :dont_reauth => true

0 commit comments

Comments
 (0)