gooddata 0.6.12 → 0.6.13

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: b9ebfa575ef6b28f90189e3429f1b4563daa44ca
4
- data.tar.gz: 1ca90d7f9414423d00baf8dd87634e8e356dd61e
3
+ metadata.gz: cb9665af325baabe9f6f170e113ca64b2a0f1d52
4
+ data.tar.gz: 851eae13fb6b6dedd5ebb4e27f18e5ef6ea78636
5
5
  SHA512:
6
- metadata.gz: e1f73a4b8df1f90db97fd13752e336f0c59e05ebf1713471ea6c48f01fddc7702f0f53f4822e74604c3ac70074383058d0a5b91a8e8cdeb24ed0c8e13eb2e197
7
- data.tar.gz: 332429c9389f81b6475c31e495a44f93ba9154f7c4886770578a71eb29c82a4140dae49263be12ab6e5cfea6745ecd17d849ac84e97a8301b66ad30f0af299fb
6
+ metadata.gz: e846c86dff64caceda53415158c122204e76159be7a14357456e9ebb5f5074d3b693a0f25d208bdd61aedfe4a2ba6a20da699d908fec6b30bedd7a34fdfb8ff2
7
+ data.tar.gz: 3559aa1d3e696ff1d1e9f686c505ef8042346d5ca867f1fc0fe8f9cb0332759c9a2a98b95174981b557299ee087613a8c32aeab040aedca1c9bef2a4024bb197
data/.travis.yml CHANGED
@@ -1,26 +1,21 @@
1
1
  language: ruby
2
2
 
3
- # cache: bundler
3
+ cache: bundler
4
4
 
5
5
  sudo: false
6
6
 
7
- os:
8
- - linux
9
- - osx
10
-
11
7
  branches:
12
8
  except:
13
- - gh-pages
14
- - next_doc_release
15
-
9
+ - gh-pages
10
+ - next_doc_release
16
11
  env:
17
- - secure: "d/fE2Iuyrf5mfvQPe2nl++a06hpy82mEM5jbmXmS1ttQgMpf955GWTmZ+16VBZa9MU2pJLBXoBXy53tp8P9ADysE4R7YCeI68yE0CZ/OuU+FVADZ9/F6i4nlUESjNNQnlC0mTIjDMO5WI9HbVQiS07HqDHzr6bcS51ZvBzItcn4="
12
+ global:
13
+ - secure: d/fE2Iuyrf5mfvQPe2nl++a06hpy82mEM5jbmXmS1ttQgMpf955GWTmZ+16VBZa9MU2pJLBXoBXy53tp8P9ADysE4R7YCeI68yE0CZ/OuU+FVADZ9/F6i4nlUESjNNQnlC0mTIjDMO5WI9HbVQiS07HqDHzr6bcS51ZvBzItcn4=
14
+ - TRAVIS_BUILD=true
18
15
 
19
16
  rvm:
20
17
  - 1.9.3
21
- # - ruby-head
22
18
  - jruby-19mode
23
- # - rbx-2.2.9
24
19
  - 2.1
25
20
  - 2.2
26
21
 
@@ -31,4 +26,8 @@ before_install:
31
26
  before_script:
32
27
  - cp spec/data/.gooddata ~/
33
28
 
34
- script: rake ci
29
+ script: bundle exec rake ci
30
+
31
+ notifications:
32
+ slack:
33
+ secure: VIiymls7MDsR+3TeICWA41+uK4WAfe+CaNZhMvC/9Z/uWrPD9EsH7sX/GT2GoPJdjj7wCzTjWMy5fQOwY243cXu17umkTRHKYYhZYPjhGi4X0Diqjdx7A/eKieIUMS2xGb12a40HTPIB5Owc2+8C+sOPRk5AXRR/YrOB5xG61y8=
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # GoodData Ruby SDK Changelog
2
2
 
3
- ## 0.6.12 (in progress)
3
+ ## 0.6.13
4
+
5
+ - Fixed TT problems
6
+ - Fixed process redeployment helpers
7
+ - Rubocop compliance with the latest version
8
+ - MD datasets are now available
9
+ - SSL set to verify none for now. We will make it more secure in next version.
10
+ - Changed limit on users pulled from domain. Will change it in the future so there is no fixed limit.
11
+
12
+ ## 0.6.12
4
13
 
5
14
  - Ability to create a Data Warehouse (ADS)
6
15
  - Retry all requests 3 times when SystemCallError, RestClient::InternalServerError or RestClient::RequestTimeout
data/gooddata.gemspec CHANGED
@@ -25,13 +25,10 @@ Gem::Specification.new do |s|
25
25
  s.homepage = %q{http://github.com/gooddata/gooddata-ruby}
26
26
  s.require_paths = ["lib"]
27
27
 
28
- # s.add_development_dependency "debase" if RUBY_VERSION >= '2.1'
29
28
  s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.1'
30
29
  s.add_development_dependency 'rake-notes', '~> 0.2', '>= 0.2.0'
31
30
  s.add_development_dependency 'redcarpet', '~> 3.1', '>= 3.1.1' if RUBY_PLATFORM != 'java'
32
31
  s.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
33
- # s.add_development_dependency "ruby-debug-base"
34
- # s.add_development_dependency "ruby-debug-ide" if RUBY_VERSION >= '2.1'
35
32
  s.add_development_dependency 'rubocop', '~> 0.27', '>= 0.27.0'
36
33
  s.add_development_dependency 'simplecov', '~> 0.9', '>= 0.9.1'
37
34
  s.add_development_dependency 'yard', '~> 0.8.7.3'
@@ -39,6 +36,9 @@ Gem::Specification.new do |s|
39
36
  s.add_development_dependency 'ZenTest', '~> 4.10', '>= 4.11.0'
40
37
  s.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7.0'
41
38
 
39
+ s.add_development_dependency 'debase' if !ENV['TRAVIS_BUILD'] && RUBY_VERSION >= '2.0.0'
40
+ s.add_development_dependency 'ruby-debug-ide' if !ENV['TRAVIS_BUILD'] && RUBY_VERSION >= '2.0.0'
41
+
42
42
  s.add_dependency 'activesupport', '~> 4.1', '>= 4.1.0'
43
43
  s.add_dependency 'bundler', '~> 1.7', '>= 1.7.3'
44
44
  s.add_dependency 'docile', '~> 1.1', '>= 1.1.5'
@@ -11,12 +11,10 @@ module GoodData
11
11
  description = options[:summary] || options[:description]
12
12
  token = options[:token] || options[:auth_token]
13
13
  client = options[:client]
14
- GoodData::DataWarehouse.create(
15
- :title => title,
16
- :description => description,
17
- :auth_token => token,
18
- :client => client
19
- )
14
+ GoodData::DataWarehouse.create(:title => title,
15
+ :description => description,
16
+ :auth_token => token,
17
+ :client => client)
20
18
  end
21
19
  end
22
20
  end
@@ -72,9 +72,7 @@ module GoodData
72
72
  u = URI(project.links['uploads'])
73
73
  url = URI.join(u.to_s.chomp(u.path.to_s), '/uploads/')
74
74
 
75
- connection.upload(file, options.merge(
76
- :staging_url => url
77
- ))
75
+ connection.upload(file, options.merge(staging_url: url))
78
76
  end
79
77
 
80
78
  # Get WebDav directory for project data
@@ -10,7 +10,7 @@ module GoodData
10
10
  class Domain < GoodData::Rest::Object
11
11
  attr_reader :name
12
12
 
13
- USERS_OPTIONS = { :offset => 0, :limit => 1000 }
13
+ USERS_OPTIONS = { :offset => 0, :limit => 10_000 }
14
14
 
15
15
  class << self
16
16
  # Looks for domain
@@ -8,7 +8,7 @@ module GoodData
8
8
  # @param stuff [Hash] Whatever comes from wire
9
9
  # @return [Hash] Manifest for a particular reference
10
10
  def self.dataset_from_wire(stuff)
11
- Hash.new.tap do |d|
11
+ {}.tap do |d|
12
12
  d[:type] = :dataset
13
13
  d[:title] = stuff['dataset']['title'] if stuff['dataset']['title'] != stuff['dataset']['identifier'].split('.').last.titleize
14
14
  d[:name] = stuff['dataset']['identifier'].split('.').last
@@ -86,7 +86,7 @@ module GoodData
86
86
  # @param stuff [Hash] Whatever comes from wire
87
87
  # @return [Hash] Manifest for a particular reference
88
88
  def self.parse_date_dimensions(stuff)
89
- Hash.new.tap do |d|
89
+ {}.tap do |d|
90
90
  d[:type] = :date_dimension
91
91
  # d[:urn] = :date_dimension
92
92
  d[:name] = stuff['dateDimension']['name']
@@ -101,7 +101,7 @@ module GoodData
101
101
  def self.parse_facts(stuff)
102
102
  facts = stuff['dataset']['facts'] || []
103
103
  facts.map do |fact|
104
- Hash.new.tap do |f|
104
+ {}.tap do |f|
105
105
  f[:type] = fact['fact']['identifier'] =~ /^dt\./ ? :date_fact : :fact
106
106
  f[:name] = fact['fact']['identifier'].split('.').last
107
107
  f[:title] = fact['fact']['title'] if fact['fact']['title'] != fact['fact']['identifier'].split('.').last.titleize
@@ -115,7 +115,7 @@ module GoodData
115
115
  # @param stuff [Hash] Whatever comes from wire
116
116
  # @return [Hash] Manifest for a particular reference
117
117
  def self.parse_label(attribute, label, type, default_label = nil)
118
- Hash.new.tap do |l|
118
+ {}.tap do |l|
119
119
  l[:type] = type
120
120
  l[:reference] = attribute['identifier'].split('.').last if type == 'label'
121
121
  l[:name] = label['label']['identifier'].split('.').last
@@ -25,10 +25,6 @@ module GoodData
25
25
  @json['invitation']['content']['firstname']
26
26
  end
27
27
 
28
- def first_name
29
- @json['invitation']['content']['firstname']
30
- end
31
-
32
28
  def phone
33
29
  @json['invitation']['content']['phone']
34
30
  end
@@ -299,13 +299,6 @@ module GoodData
299
299
  @json['user']['content']['status'] || ''
300
300
  end
301
301
 
302
- # Sets the status
303
- #
304
- # @param new_status [String] New phone number to be assigned
305
- def status=(new_status)
306
- @json['user']['content']['status'] = new_status
307
- end
308
-
309
302
  # Gets the title
310
303
  #
311
304
  # @return [String] User title
@@ -44,10 +44,38 @@ module GoodData
44
44
  def dimension
45
45
  uri = content['dimension']
46
46
  return nil if uri.nil?
47
-
48
47
  GoodData::Dimension[uri, client: client, project: project]
49
48
  end
50
49
 
50
+ # Tells you if an attribute is a date dimension. This happens by inspecting
51
+ # an identifier if it conforms to a particular scheme.
52
+ #
53
+ # @return [Boolean] Is the attribute a date attribute?
54
+ def date_attribute?
55
+ things = [
56
+ 'week',
57
+ 'euweek.in.year',
58
+ 'day.in.week',
59
+ 'day.in.month',
60
+ 'day.in.quarter',
61
+ 'day.in.euweek',
62
+ 'date',
63
+ 'quarter.in.year',
64
+ 'week.in.year',
65
+ 'day.in.year',
66
+ 'month',
67
+ 'quarter',
68
+ 'month.in.quarter',
69
+ 'week.in.quarter',
70
+ 'year',
71
+ 'euweek',
72
+ 'euweek.in.quarter',
73
+ 'month.in.year'
74
+ ]
75
+ potential_id = identifier.split('.')[1..-1].join('.')
76
+ things.include?(potential_id) ? true : false
77
+ end
78
+
51
79
  # Returns the first display form which is the primary one
52
80
  # @return [GoodData::Label] Primary label
53
81
  def primary_display_form
@@ -0,0 +1,62 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../metadata'
4
+
5
+ module GoodData
6
+ class Dataset < MdObject
7
+ root_key :dataSet
8
+
9
+ class << self
10
+ # Method intended to get all objects of that type in a specified project
11
+ #
12
+ # @param options [Hash] the options hash
13
+ # @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
14
+ # @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
15
+ def all(options = { :client => GoodData.connection, :project => GoodData.project })
16
+ query('datasets', Dataset, options)
17
+ end
18
+ end
19
+
20
+ # Gives you list of attributes on a dataset
21
+ #
22
+ # @return [Array<GoodData::Attribute>]
23
+ def attributes
24
+ attribute_uris.pmap { |a_uri| project.attributes(a_uri) }
25
+ end
26
+
27
+ # Gives you list of attribute uris on a dataset
28
+ #
29
+ # @return [Array<String>]
30
+ def attribute_uris
31
+ content['attributes']
32
+ end
33
+
34
+ # Gives you list of facts on a dataset
35
+ #
36
+ # @return [Array<GoodData::Fact>]
37
+ def facts
38
+ fact_uris.pmap { |a_uri| project.attributes(a_uri) }
39
+ end
40
+
41
+ # Gives you list of fact uris on a dataset
42
+ #
43
+ # @return [Array<String>]
44
+ def fact_uris
45
+ content['facts']
46
+ end
47
+
48
+ # Tells you if a dataset is a date dimension. This is done by looking at
49
+ # the attributes and inspecting their identifiers.
50
+ #
51
+ # @return [Boolean]
52
+ def date_dimension?
53
+ attributes.all?(&:date_attribute?) && fact_uris.empty?
54
+ end
55
+
56
+ # Delete the data in a dataset
57
+ def synchronize
58
+ project.execute_maql("SYNCHRONIZE {#{identifier}}")
59
+ end
60
+ alias_method :delete_data, :synchronize
61
+ end
62
+ end
@@ -178,10 +178,22 @@ module GoodData
178
178
  # @param [GoodData::MdObject] what Object that should be replaced
179
179
  # @param [GoodData::MdObject] for_what Object it is replaced with
180
180
  # @return [GoodData::Metric]
181
- def replace(what, for_what)
182
- uri_what = what.respond_to?(:uri) ? what.uri : what
183
- uri_for_what = for_what.respond_to?(:uri) ? for_what.uri : for_what
184
- self.expression = expression.gsub(uri_what, uri_for_what)
181
+ def replace(what, for_what = nil)
182
+ pairs = if what.is_a?(Hash)
183
+ whats = what.keys
184
+ to_whats = what.values
185
+ whats.zip(to_whats)
186
+ elsif what.is_a?(Array) && for_what.is_a?(Array)
187
+ whats.zip(to_whats)
188
+ else
189
+ [[what, for_what]]
190
+ end
191
+
192
+ pairs.each do |a, b|
193
+ uri_what = a.respond_to?(:uri) ? a.uri : a
194
+ uri_for_what = b.respond_to?(:uri) ? b.uri : b
195
+ self.expression = expression.gsub(uri_what, uri_for_what)
196
+ end
185
197
  self
186
198
  end
187
199
 
@@ -301,6 +301,8 @@ module GoodData
301
301
  whats = what.keys
302
302
  to_whats = what.values
303
303
  whats.zip(to_whats)
304
+ elsif what.is_a?(Array) && for_what.is_a?(Array)
305
+ whats.zip(to_whats)
304
306
  else
305
307
  [[what, for_what]]
306
308
  end
@@ -196,7 +196,7 @@ module GoodData
196
196
  # @option options [String] :name Readable name of the process
197
197
  # @option options [Boolean] :verbose (false) Switch on verbose mode for detailed logging
198
198
  def deploy(path, options = {})
199
- Process.deploy(path, client: client, process_id: process_id, :project => project).merge(options)
199
+ Process.deploy(path, { client: client, process_id: process_id, :project => project, :name => name, :type => type }.merge(options))
200
200
  end
201
201
 
202
202
  # Downloads the process from S3 in a zipped form.
@@ -256,6 +256,15 @@ module GoodData
256
256
  end
257
257
  end
258
258
 
259
+ # Gives you list of datasets. These are not blueprint datasets but model datasets coming from meta
260
+ # data server.
261
+ #
262
+ # @param id [Symbol | String | GoodData::MdObject] Export options
263
+ # @return [Array<GoodData::Dataset> | GoodData::Dataset] Dataset or list of datasets in the project
264
+ def datasets(id = :all)
265
+ GoodData::Dataset[id, project: self, client: client]
266
+ end
267
+
259
268
  def dimensions(id = :all)
260
269
  GoodData::Dimension[id, client: client, project: self]
261
270
  end
@@ -326,16 +335,12 @@ module GoodData
326
335
  end
327
336
  # Helper for getting dashboards of a project
328
337
  #
329
- # @param [String | Number | Object] Anything that you can pass to GoodData::Dashboard[id]
338
+ # @param id [String | Number | Object] Anything that you can pass to GoodData::Dashboard[id]
330
339
  # @return [GoodData::Dashboard | Array<GoodData::Dashboard>] dashboard instance or list
331
340
  def dashboards(id = :all)
332
341
  GoodData::Dashboard[id, project: self, client: client]
333
342
  end
334
343
 
335
- def datasets
336
- blueprint.datasets
337
- end
338
-
339
344
  def data_permissions
340
345
  GoodData::MandatoryUserFilter.all(client: client, project: self)
341
346
  end
@@ -352,9 +357,7 @@ module GoodData
352
357
  # @return [Array] Result of executing MAQLs
353
358
  def delete_all_data(options = {})
354
359
  return false unless options[:force]
355
- datasets.pmap do |dataset|
356
- execute_maql("SYNCHRONIZE {#{dataset.identifier}}")
357
- end
360
+ datasets.pmap(&:delete_data)
358
361
  end
359
362
 
360
363
  # Deletes dashboards for project
@@ -871,7 +874,7 @@ module GoodData
871
874
  # List of users in project
872
875
  #
873
876
  # @return [Array<GoodData::User>] List of users
874
- def users(opts = { offset: 0, limit: 100 })
877
+ def users(opts = { offset: 0, limit: 10_000 })
875
878
  result = []
876
879
 
877
880
  # TODO: @korczis, review this after WA-3953 get fixed
@@ -145,16 +145,6 @@ module GoodData
145
145
  datasets(project).mapcat { |d| DatasetBlueprint.fields(d) }
146
146
  end
147
147
 
148
- # Returns a dataset of a given name. If a dataset is not found it throws an exeception
149
- #
150
- # @param project [GoodData::Model::ProjectBlueprint | Hash] Project blueprint
151
- # @param project [String] Dataset title
152
- # @return [Array<Hash>]
153
- def find_dataset_by_title(project, title)
154
- ds = datasets(project).find { |d| Model.title(d) == title }
155
- fail "Dataset #{title} could not be found" if ds.nil?
156
- end
157
-
158
148
  def change(&block)
159
149
  builder = ProjectBuilder.create_from_data(self)
160
150
  block.call(builder)
@@ -425,10 +415,9 @@ module GoodData
425
415
  attrs, metric = e
426
416
 
427
417
  attrs.each do |attr|
428
- a << GoodData::Report.create(
429
- :title => 'Fantastic report',
430
- :top => [attr],
431
- :left => metric)
418
+ a << GoodData::Report.create(:title => 'Fantastic report',
419
+ :top => [attr],
420
+ :left => metric)
432
421
  end
433
422
  a
434
423
  end
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require_relative 'user_filter'
4
+
3
5
  module GoodData
4
6
  class VariableUserFilter < UserFilter
5
7
  # Creates or updates the variable user filter on the server