gooddata 0.6.0.pre10 → 0.6.0.pre11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +2 -0
- data/.gitignore +3 -0
- data/.travis.yml +7 -0
- data/.yardopts +3 -2
- data/README.md +8 -145
- data/Rakefile +23 -6
- data/bin/gooddata +3 -400
- data/doc/pages/GET_STARTED.md +5 -4
- data/doc/pages/HOMEPAGE.md +2 -0
- data/doc/pages/TUTORIALS.md +3 -3
- data/doc/pages/tutorial/BRICKS.md +4 -1
- data/doc/pages/tutorial/CREATING_A_MODEL.md +2 -0
- data/doc/pages/tutorial/CRUNCHING_NUMBERS.md +1 -3
- data/doc/pages/tutorial/TEST_DRIVEN_DEVELOPMENT.md +2 -0
- data/doc/pages/tutorial/YOUR_FIRST_PROJECT.md +4 -3
- data/doc/templates/default/class/setup.rb +1 -0
- data/doc/templates/default/method_details/setup.rb +2 -1
- data/doc/templates/default/module/setup.rb +1 -1
- data/gooddata +7 -0
- data/gooddata.gemspec +1 -0
- data/lib/gooddata.rb +15 -4
- data/lib/gooddata/bricks/base_downloader.rb +1 -0
- data/lib/gooddata/bricks/brick.rb +17 -12
- data/lib/gooddata/bricks/bricks.rb +7 -0
- data/lib/gooddata/bricks/middleware/base_middleware.rb +13 -0
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +1 -0
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +2 -1
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +30 -0
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +10 -8
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +3 -2
- data/lib/gooddata/bricks/middleware/middleware.rb +4 -11
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +2 -0
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +2 -0
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +2 -0
- data/lib/gooddata/cli/cli.rb +28 -0
- data/lib/gooddata/cli/commands/api_cmd.rb +30 -0
- data/lib/gooddata/cli/commands/auth_cmd.rb +17 -0
- data/lib/gooddata/cli/commands/console_cmd.rb +17 -0
- data/lib/gooddata/cli/commands/process_cmd.rb +55 -0
- data/lib/gooddata/cli/commands/profile_cmd.rb +22 -0
- data/lib/gooddata/cli/commands/project_cmd.rb +143 -0
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +55 -0
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +32 -0
- data/lib/gooddata/cli/hooks.rb +43 -0
- data/lib/gooddata/cli/shared.rb +51 -0
- data/lib/gooddata/client.rb +37 -24
- data/lib/gooddata/commands/api.rb +1 -0
- data/lib/gooddata/commands/auth.rb +8 -4
- data/lib/gooddata/commands/base.rb +2 -80
- data/lib/gooddata/commands/commands.rb +4 -9
- data/lib/gooddata/commands/datasets.rb +1 -1
- data/lib/gooddata/commands/runners.rb +6 -7
- data/lib/gooddata/connection.rb +40 -35
- data/lib/gooddata/core/core.rb +8 -0
- data/lib/gooddata/exceptions.rb +1 -1
- data/lib/gooddata/goodzilla/goodzilla.rb +12 -0
- data/lib/gooddata/models/attribute.rb +2 -0
- data/lib/gooddata/models/dashboard.rb +9 -2
- data/lib/gooddata/models/data_result.rb +3 -256
- data/lib/gooddata/models/data_set.rb +2 -0
- data/lib/gooddata/models/display_form.rb +2 -0
- data/lib/gooddata/models/empty_result.rb +37 -0
- data/lib/gooddata/models/fact.rb +2 -0
- data/lib/gooddata/models/metadata.rb +6 -1
- data/lib/gooddata/models/metric.rb +2 -1
- data/lib/gooddata/{model.rb → models/model.rb} +1 -1
- data/lib/gooddata/models/models.rb +4 -0
- data/lib/gooddata/models/project.rb +10 -6
- data/lib/gooddata/models/report.rb +6 -0
- data/lib/gooddata/models/report_data_result.rb +167 -0
- data/lib/gooddata/models/report_definition.rb +2 -0
- data/lib/gooddata/version.rb +15 -1
- data/spec/bricks/bricks_spec.rb +39 -0
- data/spec/helpers/blueprint_helper.rb +1 -1
- data/spec/helpers/connection_helper.rb +12 -0
- data/spec/{project_build_and_update_spec.rb → integration/command_projects_spec.rb} +0 -3
- data/spec/{full_project_spec.rb → integration/full_project_spec.rb} +0 -3
- data/spec/logging_in_logging_out_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/unit/bricks/bricks_spec.rb +23 -0
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +9 -0
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +9 -0
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +9 -0
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +9 -0
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +9 -0
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +9 -0
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +9 -0
- data/spec/unit/cli/cli_spec.rb +11 -0
- data/spec/unit/cli/commands/cmd_api_spec.rb +11 -0
- data/spec/unit/cli/commands/cmd_auth_spec.rb +11 -0
- data/spec/unit/cli/commands/cmd_process_spec.rb +11 -0
- data/spec/unit/cli/commands/cmd_profile_spec.rb +11 -0
- data/spec/unit/cli/commands/cmd_project_spec.rb +11 -0
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +11 -0
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +11 -0
- data/spec/unit/commands/command_api_spec.rb +12 -0
- data/spec/unit/commands/command_auth_spec.rb +12 -0
- data/spec/unit/commands/command_dataset_spec.rb +12 -0
- data/spec/unit/commands/command_process_spec.rb +12 -0
- data/spec/unit/commands/command_profile_spec.rb +12 -0
- data/spec/unit/commands/command_projects_spec.rb +12 -0
- data/spec/unit/commands/command_scaffold_spec.rb +12 -0
- data/spec/unit/core/connection_spec.rb +25 -0
- data/spec/unit/core/core_spec.rb +7 -0
- data/spec/{goodzilla_spec.rb → unit/godzilla/goodzilla_spec.rb} +0 -0
- data/spec/{blueprint_spec.rb → unit/model/blueprint_spec.rb} +3 -3
- data/spec/{merging_blueprints_spec.rb → unit/model/model_spec.rb} +28 -26
- data/spec/{model_spec.rb → unit/model/project_blueprint_spec.rb} +0 -0
- data/spec/{model_dsl_spec.rb → unit/model/schema_builder_spec.rb} +1 -1
- metadata +77 -61
data/lib/gooddata/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
1
|
+
require File.join(File.dirname(__FILE__), 'version')
|
2
|
+
require File.join(File.dirname(__FILE__), 'connection')
|
3
|
+
require File.join(File.dirname(__FILE__), 'helpers')
|
4
4
|
|
5
5
|
# fastercsv is built in Ruby 1.9
|
6
6
|
if RUBY_VERSION < "1.9"
|
@@ -13,7 +13,7 @@ end
|
|
13
13
|
# Initializes required dynamically loaded classes
|
14
14
|
def init_gd_module()
|
15
15
|
# Metadata packages, such as report.rb, require this to be loaded first
|
16
|
-
require File.dirname(__FILE__)
|
16
|
+
require File.join(File.dirname(__FILE__), '/models/metadata.rb')
|
17
17
|
|
18
18
|
# Load models from models folder
|
19
19
|
Dir[File.dirname(__FILE__) + '/models/*.rb'].each { |file| require file }
|
@@ -80,24 +80,12 @@ module GoodData
|
|
80
80
|
|
81
81
|
RELEASE_INFO_PATH = '/gdc/releaseInfo'
|
82
82
|
|
83
|
-
# Version
|
84
|
-
def version
|
85
|
-
VERSION
|
86
|
-
end
|
87
|
-
|
88
|
-
# Identifier of gem version
|
89
|
-
# @return Formatted gem version
|
90
|
-
def gem_version_string()
|
91
|
-
"gooddata-gem/#{version}"
|
92
|
-
end
|
93
|
-
|
94
83
|
# Connect to the GoodData API
|
95
84
|
#
|
96
85
|
# @param options
|
97
86
|
# @param second_options
|
98
87
|
# @param third_options
|
99
88
|
#
|
100
|
-
# Goodd
|
101
89
|
def connect(options=nil, second_options=nil, third_options={})
|
102
90
|
if options.is_a? Hash
|
103
91
|
fail "You have to provide login and password" if ((options[:login].nil? || options[:login].empty?) && (options[:password].nil? || options[:password].empty?))
|
@@ -107,6 +95,16 @@ module GoodData
|
|
107
95
|
fail "You have to provide login and password" if ((options.nil? || options.empty?) && (second_options.nil? || second_options.empty?))
|
108
96
|
threaded[:connection] = Connection.new(options, second_options, third_options)
|
109
97
|
end
|
98
|
+
|
99
|
+
return threaded[:connection]
|
100
|
+
end
|
101
|
+
|
102
|
+
# Disconnect (logout) if logged in
|
103
|
+
def disconnect
|
104
|
+
if threaded[:connection]
|
105
|
+
threaded[:connection].disconnect
|
106
|
+
threaded[:connection] = nil
|
107
|
+
end
|
110
108
|
end
|
111
109
|
|
112
110
|
# Turn logging on
|
@@ -175,10 +173,17 @@ module GoodData
|
|
175
173
|
#
|
176
174
|
# The following calls are equivalent
|
177
175
|
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
176
|
+
# # Assign project ID
|
177
|
+
# GoodData.project = 'afawtv356b6usdfsdf34vt'
|
178
|
+
#
|
179
|
+
# # Use project ID
|
180
|
+
# GoodData.use 'afawtv356b6usdfsdf34vt'
|
181
|
+
#
|
182
|
+
# # Use project URL
|
183
|
+
# GoodData.use '/gdc/projects/afawtv356b6usdfsdf34vt'
|
184
|
+
#
|
185
|
+
# # Select project using indexer on GoodData::Project class
|
186
|
+
# GoodData.project = Project['afawtv356b6usdfsdf34vt']
|
182
187
|
#
|
183
188
|
def project=(project)
|
184
189
|
if project.is_a? Project
|
@@ -221,7 +226,7 @@ module GoodData
|
|
221
226
|
#
|
222
227
|
# ### Examples
|
223
228
|
#
|
224
|
-
#
|
229
|
+
# GoodData.post '/gdc/projects', { ... }
|
225
230
|
#
|
226
231
|
def post(path, data, options = {})
|
227
232
|
connection.post path, data, options
|
@@ -238,7 +243,7 @@ module GoodData
|
|
238
243
|
#
|
239
244
|
# ### Examples
|
240
245
|
#
|
241
|
-
#
|
246
|
+
# GoodData.put '/gdc/projects', { ... }
|
242
247
|
#
|
243
248
|
def put(path, data, options = {})
|
244
249
|
connection.put path, data, options
|
@@ -267,18 +272,26 @@ module GoodData
|
|
267
272
|
}))
|
268
273
|
end
|
269
274
|
|
270
|
-
def
|
275
|
+
def get_project_webdav_path(file, options={})
|
271
276
|
u = URI(connection.options[:webdav_server] || GoodData.project.links["uploads"])
|
272
277
|
url = URI.join(u.to_s.chomp(u.path.to_s), "/project-uploads/", "#{GoodData.project.pid}/")
|
278
|
+
end
|
279
|
+
|
280
|
+
def upload_to_project_webdav(file, options={})
|
281
|
+
url = get_project_webdav_path(file, options)
|
273
282
|
connection.upload(file, options.merge({
|
274
283
|
:directory => options[:directory],
|
275
284
|
:staging_url => url
|
276
285
|
}))
|
277
286
|
end
|
278
287
|
|
279
|
-
def
|
288
|
+
def get_user_webdav_path(file, options={})
|
280
289
|
u = URI(connection.options[:webdav_server] || GoodData.project.links["uploads"])
|
281
290
|
url = URI.join(u.to_s.chomp(u.path.to_s), "/uploads/")
|
291
|
+
end
|
292
|
+
|
293
|
+
def download_from_user_webdav(file, where, options={})
|
294
|
+
url = get_user_webdav_path(file, options)
|
282
295
|
connection.download(file, where, options.merge({
|
283
296
|
:staging_url => url
|
284
297
|
}))
|
@@ -1,3 +1,8 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require File.join(File.dirname(__FILE__), '../helpers')
|
5
|
+
|
1
6
|
module GoodData::Command
|
2
7
|
class Auth
|
3
8
|
|
@@ -58,9 +63,9 @@ module GoodData::Command
|
|
58
63
|
|
59
64
|
def ask_for_credentials
|
60
65
|
puts "Enter your GoodData credentials."
|
61
|
-
user = HighLine
|
62
|
-
password = HighLine
|
63
|
-
auth_token = HighLine
|
66
|
+
user = HighLine.new.ask("Email")
|
67
|
+
password = HighLine.new.ask("Password") { |q| q.echo = "x" }
|
68
|
+
auth_token = HighLine.new.ask("Authorization Token")
|
64
69
|
{ :username => user, :password => password, :auth_token => auth_token }
|
65
70
|
end
|
66
71
|
|
@@ -69,7 +74,6 @@ module GoodData::Command
|
|
69
74
|
|
70
75
|
ovewrite = if File.exist?(credentials_file)
|
71
76
|
HighLine::ask("Overwrite existing stored credentials (y/n)")
|
72
|
-
# { |q| q.validate = /[y,n]/ }
|
73
77
|
else
|
74
78
|
'y'
|
75
79
|
end
|
@@ -1,82 +1,4 @@
|
|
1
|
-
module GoodData
|
2
|
-
|
3
|
-
|
4
|
-
# Initializes GoodData connection with credentials loaded from
|
5
|
-
# ~/.gooddata. If the file doesn't exist or doesn't contain
|
6
|
-
# necessary information, a command line prompt will be issued
|
7
|
-
# using the GoodData::Command::Base#ask method
|
8
|
-
#
|
9
|
-
def self.connect
|
10
|
-
run_internal('auth:connect', [])
|
11
|
-
end
|
12
|
-
|
13
|
-
class Base
|
14
|
-
include GoodData::Helpers
|
15
|
-
|
16
|
-
attr_accessor :args
|
17
|
-
|
18
|
-
def initialize(args)
|
19
|
-
@args = args
|
20
|
-
end
|
21
|
-
|
22
|
-
def connect
|
23
|
-
@connected ||= Command.connect
|
24
|
-
GoodData.connection
|
25
|
-
end
|
26
|
-
|
27
|
-
def extract_option(options, default=true)
|
28
|
-
values = options.is_a?(Array) ? options : [options]
|
29
|
-
return unless opt_index = args.select { |a| values.include? a }.first
|
30
|
-
opt_position = args.index(opt_index) + 1
|
31
|
-
if args.size > opt_position && opt_value = args[opt_position]
|
32
|
-
if opt_value.include?('--')
|
33
|
-
opt_value = nil
|
34
|
-
else
|
35
|
-
args.delete_at(opt_position)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
opt_value ||= default
|
39
|
-
args.delete(opt_index)
|
40
|
-
block_given? ? yield(opt_value) : opt_value
|
41
|
-
end
|
42
|
-
|
43
|
-
def ask(question, options = {})
|
44
|
-
begin
|
45
|
-
if options.has_key? :answers
|
46
|
-
answer = nil
|
47
|
-
options[:default] = options[:answers][0] if !options.has_key? :default
|
48
|
-
while !options[:answers].include?(answer)
|
49
|
-
answer = get_answer "#{question} (#{options[:answers].join(',')}) [#{options[:default]}]? ", options[:secret]
|
50
|
-
answer = options[:default] if answer == ""
|
51
|
-
end
|
52
|
-
else
|
53
|
-
question = "#{question} [#{options[:default]}]" if options[:default]
|
54
|
-
answer = get_answer "#{question}: ", options[:secret], options[:default]
|
55
|
-
end
|
56
|
-
puts if options[:secret] # extra line-break
|
57
|
-
rescue NoMethodError, Interrupt => e
|
58
|
-
system "stty echo"
|
59
|
-
puts e
|
60
|
-
exit
|
61
|
-
end
|
62
|
-
|
63
|
-
if block_given?
|
64
|
-
yield answer
|
65
|
-
else
|
66
|
-
return answer
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def get_answer(question, secret, default = nil)
|
73
|
-
print question
|
74
|
-
system "stty -echo" if secret
|
75
|
-
answer = $stdin.gets.chomp
|
76
|
-
system "stty echo" if secret
|
77
|
-
answer = default if answer.empty? && default
|
78
|
-
answer
|
79
|
-
end
|
80
|
-
end
|
1
|
+
module GoodData::Command
|
2
|
+
class Base
|
81
3
|
end
|
82
4
|
end
|
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
|
5
|
-
require './process'
|
6
|
-
require './profile'
|
7
|
-
require './projects'
|
8
|
-
require './runners'
|
9
|
-
require './scaffold'
|
1
|
+
base = Pathname(__FILE__).dirname.expand_path
|
2
|
+
Dir.glob(base + '*.rb').each do |file|
|
3
|
+
require file
|
4
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
|
3
1
|
module GoodData::Command
|
4
2
|
class Runners
|
5
3
|
|
@@ -26,11 +24,12 @@ script_body = <<-script_body
|
|
26
24
|
require 'bundler/setup'
|
27
25
|
|
28
26
|
$SCRIPT_PARAMS = {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
"GDC_SST" => \"#{sst}\",
|
28
|
+
"GDC_PROJECT_ID" => \"#{pid}\",
|
29
|
+
"GDC_PROTOCOL" => \"#{scheme}\",
|
30
|
+
"GDC_HOSTNAME" => \"#{hostname}\",
|
31
|
+
"GDC_LOGGER_FILE" => STDOUT,
|
32
|
+
"GDC_ENV_LOCAL" => true
|
34
33
|
}.merge(#{params})
|
35
34
|
eval(File.read(\"./main.rb\"))
|
36
35
|
end
|
data/lib/gooddata/connection.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'rest-client'
|
3
3
|
|
4
|
+
require File.join(File.dirname(__FILE__), 'version')
|
5
|
+
|
4
6
|
module GoodData
|
5
7
|
|
6
|
-
#
|
8
|
+
# # GoodData HTTP wrapper
|
7
9
|
#
|
8
10
|
# Provides a convenient HTTP wrapper for talking with the GoodData API.
|
9
11
|
#
|
@@ -16,12 +18,11 @@ module GoodData
|
|
16
18
|
# makes sure that the session is stored between requests and that the JSON is
|
17
19
|
# parsed both when sending and receiving.
|
18
20
|
#
|
19
|
-
#
|
21
|
+
# ## Usage
|
20
22
|
#
|
21
|
-
# Before a connection can be made to the GoodData API, you have to supply the user
|
22
|
-
# credentials using the set_credentials method:
|
23
|
+
# Before a connection can be made to the GoodData API, you have to supply the user credentials like this:
|
23
24
|
#
|
24
|
-
# Connection.new(username, password)
|
25
|
+
# Connection.new(username, password)
|
25
26
|
#
|
26
27
|
# To send a HTTP request use either the get, post or delete methods documented below.
|
27
28
|
#
|
@@ -34,16 +35,15 @@ module GoodData
|
|
34
35
|
attr_reader(:auth_token, :url)
|
35
36
|
attr_accessor :status, :options
|
36
37
|
|
37
|
-
|
38
38
|
# Options:
|
39
39
|
# * :tries - Number of retries to perform. Defaults to 1.
|
40
40
|
# * :on - The Exception on which a retry will be performed. Defaults to Exception, which retries on any Exception.
|
41
41
|
#
|
42
|
-
# Example
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
42
|
+
# ### Example
|
43
|
+
#
|
44
|
+
# retryable(:tries => 1, :on => OpenURI::HTTPError) do
|
45
|
+
# # your code here
|
46
|
+
# end
|
47
47
|
#
|
48
48
|
def retryable(options = {}, &block)
|
49
49
|
opts = { :tries => 1, :on => Exception }.merge(options)
|
@@ -63,10 +63,9 @@ module GoodData
|
|
63
63
|
#
|
64
64
|
# This have to be performed before any calls to the API.
|
65
65
|
#
|
66
|
-
#
|
66
|
+
# @param username The GoodData account username
|
67
|
+
# @param password The GoodData account password
|
67
68
|
#
|
68
|
-
# * +username+ - The GoodData account username
|
69
|
-
# * +password+ - The GoodData account password
|
70
69
|
def initialize(username, password, options = {})
|
71
70
|
@status = :not_connected
|
72
71
|
@username = username
|
@@ -89,13 +88,12 @@ module GoodData
|
|
89
88
|
#
|
90
89
|
# Retuns the JSON response formatted as a Hash object.
|
91
90
|
#
|
92
|
-
#
|
91
|
+
# @param path The HTTP path on the GoodData server (must be prefixed with a forward slash)
|
93
92
|
#
|
94
|
-
#
|
93
|
+
# ### Examples
|
95
94
|
#
|
96
|
-
#
|
95
|
+
# Connection.new(username, password).get '/gdc/projects'
|
97
96
|
#
|
98
|
-
# Connection.new(username, password).get '/gdc/projects'
|
99
97
|
def get(path, options = {})
|
100
98
|
GoodData.logger.debug "GET #{@server}#{path}"
|
101
99
|
ensure_connection
|
@@ -107,16 +105,14 @@ module GoodData
|
|
107
105
|
#
|
108
106
|
# Retuns the JSON response formatted as a Hash object.
|
109
107
|
#
|
110
|
-
#
|
108
|
+
# @param path The HTTP path on the GoodData server (must be prefixed with a forward slash)
|
109
|
+
# @param data The payload data in the format of a Hash object
|
111
110
|
#
|
112
|
-
#
|
113
|
-
# * +data+ - The payload data in the format of a Hash object
|
111
|
+
# ### Examples
|
114
112
|
#
|
115
|
-
#
|
113
|
+
# Connection.new(username, password).post '/gdc/projects', { ... }
|
116
114
|
#
|
117
|
-
# Connection.new(username, password).post '/gdc/projects', { ... }
|
118
115
|
def post(path, data, options = {})
|
119
|
-
|
120
116
|
GoodData.logger.debug("POST #{@server}#{path}, payload: #{scrub_params(data, [:password, :login, :authorizationToken])}")
|
121
117
|
ensure_connection
|
122
118
|
payload = data.is_a?(Hash) ? data.to_json : data
|
@@ -128,14 +124,13 @@ module GoodData
|
|
128
124
|
#
|
129
125
|
# Retuns the JSON response formatted as a Hash object.
|
130
126
|
#
|
131
|
-
#
|
127
|
+
# @param path The HTTP path on the GoodData server (must be prefixed with a forward slash)
|
128
|
+
# @param data The payload data in the format of a Hash object
|
132
129
|
#
|
133
|
-
#
|
134
|
-
# * +data+ - The payload data in the format of a Hash object
|
130
|
+
# ### Examples
|
135
131
|
#
|
136
|
-
#
|
132
|
+
# Connection.new(username, password).put '/gdc/projects', { ... }
|
137
133
|
#
|
138
|
-
# Connection.new(username, password).put '/gdc/projects', { ... }
|
139
134
|
def put(path, data, options = {})
|
140
135
|
payload = data.is_a?(Hash) ? data.to_json : data
|
141
136
|
GoodData.logger.debug "PUT #{@server}#{path}, payload: #{payload}"
|
@@ -148,13 +143,12 @@ module GoodData
|
|
148
143
|
#
|
149
144
|
# Retuns the JSON response formatted as a Hash object.
|
150
145
|
#
|
151
|
-
#
|
146
|
+
# @param path The HTTP path on the GoodData server (must be prefixed with a forward slash)
|
152
147
|
#
|
153
|
-
#
|
148
|
+
# ### Examples
|
154
149
|
#
|
155
|
-
#
|
150
|
+
# Connection.new(username, password).delete '/gdc/project/1'
|
156
151
|
#
|
157
|
-
# Connection.new(username, password).delete '/gdc/project/1'
|
158
152
|
def delete(path, options = {})
|
159
153
|
GoodData.logger.debug "DELETE #{@server}#{path}"
|
160
154
|
ensure_connection
|
@@ -278,6 +272,17 @@ module GoodData
|
|
278
272
|
end
|
279
273
|
end
|
280
274
|
|
275
|
+
def connected?
|
276
|
+
@status == :logged_in
|
277
|
+
end
|
278
|
+
|
279
|
+
def disconnect
|
280
|
+
if connected? && GoodData.connection.user["state"]
|
281
|
+
GoodData.delete(GoodData.connection.user["state"])
|
282
|
+
@status = :not_connected
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
281
286
|
private
|
282
287
|
|
283
288
|
def create_server_connection(url, options)
|
@@ -286,7 +291,7 @@ module GoodData
|
|
286
291
|
:headers => {
|
287
292
|
:content_type => :json,
|
288
293
|
:accept => [ :json, :zip ],
|
289
|
-
:user_agent => GoodData
|
294
|
+
:user_agent => GoodData::gem_version_string,
|
290
295
|
}
|
291
296
|
end
|
292
297
|
|
@@ -372,7 +377,7 @@ module GoodData
|
|
372
377
|
binding.pry
|
373
378
|
end
|
374
379
|
end
|
375
|
-
end
|
380
|
+
end
|
376
381
|
new_params
|
377
382
|
end
|
378
383
|
|