gooddata 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.5
1
+ 0.5.6
@@ -1,6 +1,14 @@
1
1
  require 'gooddata/version'
2
2
  require 'gooddata/connection'
3
3
 
4
+ # fastercsv is built in Ruby 1.9
5
+ if RUBY_VERSION < "1.9"
6
+ require 'fastercsv'
7
+ else
8
+ require 'csv'
9
+ FasterCSV = CSV
10
+ end
11
+
4
12
  # Metadata packages, such as report.rb, require this to be loaded first
5
13
  require File.dirname(__FILE__) + '/models/metadata.rb'
6
14
 
@@ -86,7 +94,7 @@ module GoodData
86
94
  # @see GoodData.connect
87
95
  #
88
96
  def connection
89
- threaded[:connection]
97
+ threaded[:connection] || raise("Please authenticate with GoodData.connect first")
90
98
  end
91
99
 
92
100
  # Sets the active project
@@ -2,7 +2,7 @@ module GoodData::Command
2
2
  class Auth < Base
3
3
  def connect
4
4
  unless defined? @connected
5
- GoodData.connect user, password, url
5
+ GoodData.connect user, password, url, :auth_token => auth_token
6
6
  @connected = true
7
7
  end
8
8
  @connected
@@ -23,6 +23,11 @@ module GoodData::Command
23
23
  @credentials[:url]
24
24
  end
25
25
 
26
+ def auth_token
27
+ ensure_credentials
28
+ @credentials[:auth_token]
29
+ end
30
+
26
31
  def credentials_file
27
32
  "#{home_directory}/.gooddata"
28
33
  end
@@ -46,7 +51,8 @@ module GoodData::Command
46
51
  puts "Enter your GoodData credentials."
47
52
  user = ask("Email")
48
53
  password = ask("Password", :secret => true)
49
- { :username => user, :password => password }
54
+ auth_token = ask("Authorization Token")
55
+ { :username => user, :password => password, :auth_token => auth_token }
50
56
  end
51
57
 
52
58
  def store
@@ -71,4 +77,4 @@ module GoodData::Command
71
77
  FileUtils.rm_f(credentials_file)
72
78
  end
73
79
  end
74
- end
80
+ end
@@ -48,4 +48,4 @@ module GoodData
48
48
  end
49
49
  end
50
50
  end
51
- end
51
+ end
@@ -34,6 +34,32 @@ module GoodData
34
34
  TOKEN_PATH = '/gdc/account/token'
35
35
  STAGE_PATH = '/uploads/'
36
36
 
37
+ attr_reader(:auth_token)
38
+
39
+ # Options:
40
+ # * :tries - Number of retries to perform. Defaults to 1.
41
+ # * :on - The Exception on which a retry will be performed. Defaults to Exception, which retries on any Exception.
42
+ #
43
+ # Example
44
+ # =======
45
+ # retryable(:tries => 1, :on => OpenURI::HTTPError) do
46
+ # # your code here
47
+ # end
48
+ #
49
+ def retryable(options = {}, &block)
50
+ opts = { :tries => 1, :on => Exception }.merge(options)
51
+
52
+ retry_exception, retries = opts[:on], opts[:tries]
53
+
54
+ begin
55
+ return yield
56
+ rescue retry_exception
57
+ retry if (retries -= 1) > 0
58
+ end
59
+
60
+ yield
61
+ end
62
+
37
63
  # Set the GoodData account credentials.
38
64
  #
39
65
  # This have to be performed before any calls to the API.
@@ -43,11 +69,12 @@ module GoodData
43
69
  # * +username+ - The GoodData account username
44
70
  # * +password+ - The GoodData account password
45
71
  def initialize(username, password, url = nil, options = {})
46
- @status = :not_connected
47
- @username = username
48
- @password = password
49
- @url = url || DEFAULT_URL
50
- @options = options
72
+ @status = :not_connected
73
+ @username = username
74
+ @password = password
75
+ @url = url || DEFAULT_URL
76
+ @auth_token = options.delete(:auth_token)
77
+ @options = options
51
78
  end
52
79
 
53
80
  # Returns the user JSON object of the currently logged in GoodData user account.
@@ -287,6 +314,9 @@ module GoodData
287
314
  elsif response.headers[:content_length].to_s == '0'
288
315
  result = nil
289
316
  GoodData.logger.debug "Response: Empty response possibly 204"
317
+ elsif response.code == 204
318
+ result = nil
319
+ GoodData.logger.debug "Response: 204 no content"
290
320
  else
291
321
  raise "Unsupported response content type '%s':\n%s" % [ content_type, response.to_str[0..127] ]
292
322
  end
@@ -1,5 +1,4 @@
1
1
  require 'iconv'
2
- require 'fastercsv'
3
2
 
4
3
  ##
5
4
  # Module containing classes that counter-part GoodData server-side meta-data
@@ -1,5 +1,3 @@
1
- require 'fastercsv'
2
-
3
1
  module GoodData
4
2
 
5
3
  class Row < FasterCSV::Row
@@ -74,6 +74,17 @@ module GoodData
74
74
  def project
75
75
  @project ||= Project[uri.gsub(/\/obj\/\d+$/, '')]
76
76
  end
77
+
78
+ def get_usedby
79
+ result = GoodData.get "#{GoodData.project.md['usedby2']}/#{obj_id}"
80
+ result["entries"]
81
+ end
82
+
83
+ def get_using
84
+ result = GoodData.get "#{GoodData.project.md['using2']}/#{obj_id}"
85
+ result["entries"]
86
+ end
87
+
77
88
  end
78
89
 
79
90
  class DataSet < MdObject
@@ -48,6 +48,8 @@ module GoodData
48
48
  def create(attributes)
49
49
  GoodData.logger.info "Creating project #{attributes[:title]}"
50
50
 
51
+ auth_token = attributes.delete(:auth_token) || GoodData.connection.auth_token
52
+
51
53
  json = {
52
54
  'meta' => {
53
55
  'title' => attributes[:title],
@@ -55,7 +57,8 @@ module GoodData
55
57
  },
56
58
  'content' => {
57
59
  # 'state' => 'ENABLED',
58
- 'guidedNavigation' => 1
60
+ 'guidedNavigation' => 1,
61
+ 'authorizationToken' => auth_token
59
62
  }
60
63
  }
61
64
 
@@ -11,6 +11,27 @@ module GoodData
11
11
  end
12
12
  end
13
13
 
14
+ def results
15
+ content["results"]
16
+ end
17
+
18
+ def get_latest_report_definition_uri
19
+ report_result = get_latest_report_result
20
+ report_result.content["reportDefinition"]
21
+ end
22
+
23
+ def get_latest_report_definition
24
+ GoodData::MdObject[get_latest_report_definition_uri]
25
+ end
26
+
27
+ def get_latest_report_result_uri
28
+ results.last
29
+ end
30
+
31
+ def get_latest_report_result
32
+ GoodData::MdObject[get_latest_report_result_uri]
33
+ end
34
+
14
35
  def execute
15
36
  # puts "Executing report #{uri}"
16
37
  result = GoodData.post '/gdc/xtab2/executor3', {"report_req" => {"report" => uri}}
@@ -1,3 +1,3 @@
1
1
  module GoodData
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
@@ -7,7 +7,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
7
  require 'gooddata'
8
8
 
9
9
  # used in test that expect an existing accessible project
10
- $DEMO_PROJECT = 'ca6a1r1lbfwpt2v05k36nbc0cjpu7lh9'
10
+ $DEMO_PROJECT = 'uhq8dikmtxog8n19jmuqn4gtj3cm2q0t'
11
11
 
12
12
  class Test::Unit::TestCase
13
13
  end
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require 'logger'
2
3
 
3
4
  require 'helper'
@@ -1,6 +1,5 @@
1
1
  require 'logger'
2
2
  require 'tempfile'
3
- require 'fastercsv'
4
3
 
5
4
  require 'helper'
6
5
  require 'gooddata/model'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
- prerelease:
4
+ hash: 7
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 5
10
- version: 0.5.5
9
+ - 6
10
+ version: 0.5.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pavel Kolesnikov
@@ -16,9 +16,11 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-04-18 00:00:00 Z
19
+ date: 2012-12-12 00:00:00 -08:00
20
+ default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
23
+ prerelease: false
22
24
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
25
  none: false
24
26
  requirements:
@@ -29,10 +31,10 @@ dependencies:
29
31
  - 0
30
32
  version: "0"
31
33
  name: thoughtbot-shoulda
32
- prerelease: false
33
- type: :development
34
34
  requirement: *id001
35
+ type: :development
35
36
  - !ruby/object:Gem::Dependency
37
+ prerelease: false
36
38
  version_requirements: &id002 !ruby/object:Gem::Requirement
37
39
  none: false
38
40
  requirements:
@@ -43,10 +45,10 @@ dependencies:
43
45
  - 0
44
46
  version: "0"
45
47
  name: parseconfig
46
- prerelease: false
47
- type: :runtime
48
48
  requirement: *id002
49
+ type: :runtime
49
50
  - !ruby/object:Gem::Dependency
51
+ prerelease: false
50
52
  version_requirements: &id003 !ruby/object:Gem::Requirement
51
53
  none: false
52
54
  requirements:
@@ -57,10 +59,10 @@ dependencies:
57
59
  - 0
58
60
  version: "0"
59
61
  name: json_pure
60
- prerelease: false
61
- type: :runtime
62
62
  requirement: *id003
63
+ type: :runtime
63
64
  - !ruby/object:Gem::Dependency
65
+ prerelease: false
64
66
  version_requirements: &id004 !ruby/object:Gem::Requirement
65
67
  none: false
66
68
  requirements:
@@ -71,10 +73,10 @@ dependencies:
71
73
  - 0
72
74
  version: "0"
73
75
  name: rest-client
74
- prerelease: false
75
- type: :runtime
76
76
  requirement: *id004
77
+ type: :runtime
77
78
  - !ruby/object:Gem::Dependency
79
+ prerelease: false
78
80
  version_requirements: &id005 !ruby/object:Gem::Requirement
79
81
  none: false
80
82
  requirements:
@@ -85,10 +87,10 @@ dependencies:
85
87
  - 0
86
88
  version: "0"
87
89
  name: fastercsv
88
- prerelease: false
89
- type: :runtime
90
90
  requirement: *id005
91
+ type: :runtime
91
92
  - !ruby/object:Gem::Dependency
93
+ prerelease: false
92
94
  version_requirements: &id006 !ruby/object:Gem::Requirement
93
95
  none: false
94
96
  requirements:
@@ -99,10 +101,10 @@ dependencies:
99
101
  - 0
100
102
  version: "0"
101
103
  name: json
102
- prerelease: false
103
- type: :runtime
104
104
  requirement: *id006
105
+ type: :runtime
105
106
  - !ruby/object:Gem::Dependency
107
+ prerelease: false
106
108
  version_requirements: &id007 !ruby/object:Gem::Requirement
107
109
  none: false
108
110
  requirements:
@@ -113,9 +115,8 @@ dependencies:
113
115
  - 0
114
116
  version: "0"
115
117
  name: rubyzip
116
- prerelease: false
117
- type: :runtime
118
118
  requirement: *id007
119
+ type: :runtime
119
120
  description: Use the Gooddata::Client class to integrate GoodData into your own application or use the CLI to work with GoodData directly from the command line.
120
121
  email: pavel@gooddata.com
121
122
  executables:
@@ -160,6 +161,7 @@ files:
160
161
  - test/test_model.rb
161
162
  - test/test_rest_api_basic.rb
162
163
  - test/test_upload.rb
164
+ has_rdoc: true
163
165
  homepage: http://github.com/gooddata/gooddata-ruby
164
166
  licenses: []
165
167
 
@@ -189,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
191
  requirements: []
190
192
 
191
193
  rubyforge_project:
192
- rubygems_version: 1.8.11
194
+ rubygems_version: 1.3.7
193
195
  signing_key:
194
196
  specification_version: 3
195
197
  summary: A convenient Ruby wrapper around the GoodData RESTful API