gooddata 0.6.7 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/README.md +10 -2
- data/TODO.md +32 -0
- data/gooddata.gemspec +5 -0
- data/lib/gooddata.rb +4 -0
- data/lib/gooddata/app/app.rb +12 -0
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +4 -3
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +2 -1
- data/lib/gooddata/cli/commands/console_cmd.rb +23 -5
- data/lib/gooddata/cli/commands/domain_cmd.rb +9 -10
- data/lib/gooddata/cli/commands/process_cmd.rb +11 -9
- data/lib/gooddata/cli/commands/project_cmd.rb +25 -27
- data/lib/gooddata/cli/commands/projects_cmd.rb +2 -2
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/user_cmd.rb +2 -2
- data/lib/gooddata/cli/hooks.rb +4 -2
- data/lib/gooddata/cli/shared.rb +1 -1
- data/lib/gooddata/cli/terminal.rb +1 -1
- data/lib/gooddata/commands/api.rb +1 -1
- data/lib/gooddata/commands/auth.rb +4 -28
- data/lib/gooddata/commands/domain.rb +9 -4
- data/lib/gooddata/commands/process.rb +26 -23
- data/lib/gooddata/commands/project.rb +74 -50
- data/lib/gooddata/commands/projects.rb +3 -2
- data/lib/gooddata/commands/role.rb +9 -3
- data/lib/gooddata/commands/user.rb +6 -4
- data/lib/gooddata/connection.rb +11 -45
- data/lib/gooddata/core/logging.rb +0 -1
- data/lib/gooddata/core/project.rb +22 -22
- data/lib/gooddata/core/rest.rb +9 -8
- data/lib/gooddata/core/user.rb +0 -11
- data/lib/gooddata/exceptions/project_not_found.rb +1 -0
- data/lib/gooddata/extensions/enumerable.rb +10 -0
- data/lib/gooddata/extensions/hash.rb +25 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +4 -4
- data/lib/gooddata/helper/class_helper.rb +1 -0
- data/lib/gooddata/helper/helpers.rb +8 -0
- data/lib/gooddata/helpers/auth_helpers.rb +41 -0
- data/lib/gooddata/mixins/author.rb +1 -1
- data/lib/gooddata/mixins/contributor.rb +1 -1
- data/lib/gooddata/mixins/data_property_reader.rb +2 -0
- data/lib/gooddata/mixins/data_property_writer.rb +2 -0
- data/lib/gooddata/mixins/inspector.rb +49 -0
- data/lib/gooddata/mixins/md_finders.rb +16 -8
- data/lib/gooddata/mixins/md_id_to_uri.rb +12 -4
- data/lib/gooddata/mixins/md_object_indexer.rb +15 -4
- data/lib/gooddata/mixins/md_object_query.rb +42 -20
- data/lib/gooddata/mixins/md_relations.rb +21 -12
- data/lib/gooddata/mixins/meta_getter.rb +2 -0
- data/lib/gooddata/mixins/meta_property_reader.rb +2 -0
- data/lib/gooddata/mixins/meta_property_writer.rb +2 -0
- data/lib/gooddata/mixins/rest_resource.rb +32 -10
- data/lib/gooddata/mixins/root_key_getter.rb +1 -1
- data/lib/gooddata/models/data_result.rb +3 -1
- data/lib/gooddata/models/domain.rb +31 -22
- data/lib/gooddata/models/empty_result.rb +22 -0
- data/lib/gooddata/models/invitation.rb +11 -9
- data/lib/gooddata/models/links.rb +5 -3
- data/lib/gooddata/models/membership.rb +23 -28
- data/lib/gooddata/models/metadata.rb +35 -35
- data/lib/gooddata/models/metadata/attribute.rb +10 -8
- data/lib/gooddata/models/metadata/dashboard.rb +1 -1
- data/lib/gooddata/models/metadata/fact.rb +3 -3
- data/lib/gooddata/models/metadata/label.rb +4 -4
- data/lib/gooddata/models/metadata/metric.rb +76 -38
- data/lib/gooddata/models/metadata/report.rb +52 -17
- data/lib/gooddata/models/metadata/report_definition.rb +178 -28
- data/lib/gooddata/models/model.rb +13 -6
- data/lib/gooddata/models/process.rb +93 -30
- data/lib/gooddata/models/profile.rb +18 -20
- data/lib/gooddata/models/project.rb +344 -127
- data/lib/gooddata/models/project_creator.rb +32 -22
- data/lib/gooddata/models/project_metadata.rb +26 -14
- data/lib/gooddata/models/project_role.rb +15 -17
- data/lib/gooddata/models/report_data_result.rb +4 -0
- data/lib/gooddata/models/schedule.rb +51 -20
- data/lib/gooddata/models/schema_blueprint.rb +9 -3
- data/lib/gooddata/rest/README.md +37 -0
- data/lib/gooddata/rest/client.rb +318 -0
- data/lib/gooddata/rest/connection.rb +235 -0
- data/lib/gooddata/rest/connections/connections.rb +8 -0
- data/lib/gooddata/rest/connections/dummy_connection.rb +52 -0
- data/lib/gooddata/rest/connections/rest_client_connection.rb +177 -0
- data/lib/gooddata/rest/object.rb +32 -0
- data/lib/gooddata/rest/object_factory.rb +67 -0
- data/lib/gooddata/rest/resource.rb +17 -0
- data/lib/gooddata/rest/rest.rb +20 -0
- data/lib/gooddata/version.rb +1 -1
- data/spec/data/cc/data/source/commits.csv +4 -0
- data/spec/data/cc/data/source/devs.csv +4 -0
- data/spec/data/cc/data/source/repos.csv +3 -0
- data/spec/data/cc/devel.prm +0 -0
- data/spec/data/cc/graph/graph.grf +11 -0
- data/spec/data/cc/workspace.prm +19 -0
- data/spec/data/hello_world_process/hello_world.rb +1 -0
- data/spec/data/hello_world_process/hello_world.zip +0 -0
- data/spec/data/users.csv +12 -12
- data/spec/helpers/connection_helper.rb +6 -0
- data/spec/helpers/process_helper.rb +12 -0
- data/spec/helpers/project_helper.rb +2 -2
- data/spec/integration/command_projects_spec.rb +11 -9
- data/spec/integration/create_from_template_spec.rb +6 -2
- data/spec/integration/full_process_schedule_spec.rb +49 -36
- data/spec/integration/full_project_spec.rb +221 -256
- data/spec/integration/partial_md_export_import_spec.rb +18 -17
- data/spec/logging_in_logging_out_spec.rb +17 -8
- data/spec/spec_helper.rb +4 -2
- data/spec/unit/cli/commands/cmd_api_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_auth_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_domain_spec.rb +29 -3
- data/spec/unit/cli/commands/cmd_process_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_project_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_role_spec.rb +13 -2
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_user_spec.rb +1 -1
- data/spec/unit/commands/command_api_spec.rb +0 -19
- data/spec/unit/commands/command_auth_spec.rb +20 -13
- data/spec/unit/commands/command_dataset_spec.rb +2 -2
- data/spec/unit/commands/command_process_spec.rb +24 -21
- data/spec/unit/commands/command_projects_spec.rb +2 -2
- data/spec/unit/commands/command_scaffold_spec.rb +2 -2
- data/spec/unit/commands/command_user_spec.rb +3 -3
- data/spec/unit/core/connection_spec.rb +9 -10
- data/spec/unit/core/project_spec.rb +8 -4
- data/spec/unit/core/rest_spec.rb +6 -6
- data/spec/unit/models/domain_spec.rb +14 -7
- data/spec/unit/models/invitation_spec.rb +2 -2
- data/spec/unit/models/membership_spec.rb +5 -5
- data/spec/unit/models/metric_spec.rb +92 -0
- data/spec/unit/models/profile_spec.rb +25 -21
- data/spec/unit/models/project_blueprint_spec.rb +6 -6
- data/spec/unit/models/project_role_spec.rb +3 -5
- data/spec/unit/models/project_spec.rb +43 -37
- data/spec/unit/models/schedule_spec.rb +58 -107
- data/spec/unit/rest/resource_spec.rb +6 -0
- metadata +87 -10
- data/lib/gooddata/cli/commands/role_cmd.rb +0 -28
- data/lib/gooddata/core/connection.rb +0 -392
- data/lib/gooddata/core/threaded.rb +0 -14
- data/lib/gooddata/models/md_object.rb +0 -25
- data/lib/gooddata/models/metadata/folder.rb +0 -24
- data/spec/unit/models/md_object_spec.rb +0 -55
- data/spec/unit/models/metric.rb +0 -92
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
require_relative '../core/core'
|
|
4
|
-
|
|
5
3
|
require 'highline/import'
|
|
6
4
|
require 'multi_json'
|
|
7
5
|
|
|
6
|
+
require_relative '../core/core'
|
|
7
|
+
|
|
8
8
|
module GoodData
|
|
9
9
|
module Command
|
|
10
10
|
class User
|
|
@@ -24,8 +24,10 @@ module GoodData
|
|
|
24
24
|
roles
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def show
|
|
28
|
-
|
|
27
|
+
def show(opts = { client: GoodData.connection })
|
|
28
|
+
client = opts[:client]
|
|
29
|
+
fail ArgumentError, 'No :client specified' if client.nil?
|
|
30
|
+
pp client.user.json
|
|
29
31
|
end
|
|
30
32
|
end
|
|
31
33
|
end
|
data/lib/gooddata/connection.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
require_relative 'core/connection'
|
|
4
3
|
require_relative 'core/logging'
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
require_relative 'rest/rest'
|
|
6
6
|
|
|
7
7
|
module GoodData
|
|
8
8
|
class << self
|
|
@@ -10,9 +10,12 @@ module GoodData
|
|
|
10
10
|
#
|
|
11
11
|
# @see GoodData.connect
|
|
12
12
|
def connection
|
|
13
|
-
|
|
13
|
+
# TODO: Remove this after successful rest-factory transition
|
|
14
|
+
Rest::Client.connection # || fail('Please authenticate with GoodData.connect first')
|
|
14
15
|
end
|
|
15
16
|
|
|
17
|
+
alias_method :client, :connection
|
|
18
|
+
|
|
16
19
|
# Connect to the GoodData API
|
|
17
20
|
#
|
|
18
21
|
# @param options
|
|
@@ -20,57 +23,20 @@ module GoodData
|
|
|
20
23
|
# @param third_options
|
|
21
24
|
#
|
|
22
25
|
def connect(options = nil, second_options = nil, third_options = {})
|
|
23
|
-
|
|
24
|
-
threaded[:connection] = if options.is_a? Hash
|
|
25
|
-
fail 'You have to provide login and password' if (options[:login].nil? || options[:login].empty?) && (options[:password].nil? || options[:password].empty?)
|
|
26
|
-
Connection.new(options[:login], options[:password], options)
|
|
27
|
-
conn = Connection.new(options[:login], options[:password], options)
|
|
28
|
-
GoodData.project = options[:project] if options[:project]
|
|
29
|
-
conn
|
|
30
|
-
elsif options.is_a?(String) && second_options.is_a?(String)
|
|
31
|
-
fail 'You have to provide login and password' if (options.nil? || options.empty?) && (second_options.nil? || second_options.empty?)
|
|
32
|
-
Connection.new(options, second_options, third_options)
|
|
33
|
-
elsif options.nil? && second_options.nil?
|
|
34
|
-
p = GoodData::Command::Auth.read_credentials
|
|
35
|
-
Connection.new(p[:login] || p[:username], p[:password], p)
|
|
36
|
-
end
|
|
37
|
-
threaded[:connection]
|
|
26
|
+
Rest::Client.connect(options, second_options, third_options)
|
|
38
27
|
end
|
|
39
28
|
|
|
40
29
|
# Disconnect (logout) if logged in
|
|
41
30
|
def disconnect
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if threaded[:connection]
|
|
45
|
-
threaded[:connection].disconnect
|
|
46
|
-
threaded[:connection] = nil
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Hepler for starting with SST easier
|
|
51
|
-
#
|
|
52
|
-
# @param token SST token
|
|
53
|
-
# @param options Options get routed to connect eventually so everything that you can use there should be possible to use here.
|
|
54
|
-
#
|
|
55
|
-
def connect_with_sst(token, options = {})
|
|
56
|
-
create_authenticated_connection(options.merge(:cookies => { 'GDCAuthSST' => token }))
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# This method is aimed at creating an authenticated connection in case you do not hae pass/login but you have SST
|
|
60
|
-
#
|
|
61
|
-
# @param options :server => optional GD server uri, If nil it secure will be used. :cookies => you can specify a hash of cookies
|
|
62
|
-
#
|
|
63
|
-
def create_authenticated_connection(options = {})
|
|
64
|
-
connect(options)
|
|
65
|
-
server_cookies = options[:cookies]
|
|
66
|
-
connection.merge_cookies!(server_cookies)
|
|
67
|
-
connection.status = :logged_in
|
|
68
|
-
connection
|
|
31
|
+
Rest::Client.disconnect
|
|
69
32
|
end
|
|
70
33
|
|
|
71
34
|
def with_connection(options = nil, second_options = nil, third_options = {}, &bl)
|
|
72
35
|
connection = connect(options, second_options, third_options)
|
|
73
36
|
bl.call(connection)
|
|
37
|
+
rescue Exception => e # rubocop:disable RescueException
|
|
38
|
+
puts e.message
|
|
39
|
+
raise e
|
|
74
40
|
ensure
|
|
75
41
|
disconnect
|
|
76
42
|
end
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
require_relative 'threaded'
|
|
4
|
-
|
|
5
3
|
module GoodData
|
|
6
|
-
|
|
7
|
-
def project=(project)
|
|
8
|
-
GoodData.project = project
|
|
9
|
-
GoodData.project
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
alias_method :use, :project=
|
|
4
|
+
@project = nil
|
|
13
5
|
|
|
14
6
|
class << self
|
|
15
7
|
# Sets the active project
|
|
@@ -31,40 +23,48 @@ module GoodData
|
|
|
31
23
|
#
|
|
32
24
|
# # Select project using indexer on GoodData::Project class
|
|
33
25
|
# GoodData.project = Project['afawtv356b6usdfsdf34vt']
|
|
34
|
-
#
|
|
35
|
-
def project=(project)
|
|
26
|
+
# Assigns global/default GoodData project
|
|
27
|
+
def project=(project, opts = { :client => GoodData.connection })
|
|
36
28
|
if project.is_a? Project
|
|
37
|
-
|
|
29
|
+
@project = project
|
|
38
30
|
elsif project.nil?
|
|
39
|
-
|
|
31
|
+
@project = nil
|
|
40
32
|
else
|
|
41
|
-
|
|
33
|
+
@project = Project[project, opts]
|
|
42
34
|
end
|
|
35
|
+
@project
|
|
43
36
|
end
|
|
44
37
|
|
|
45
38
|
alias_method :use, :project=
|
|
46
39
|
|
|
40
|
+
attr_reader :project
|
|
41
|
+
|
|
47
42
|
# Returns the active project
|
|
48
43
|
#
|
|
49
|
-
def project
|
|
50
|
-
|
|
51
|
-
end
|
|
44
|
+
# def project
|
|
45
|
+
# threaded[:project]
|
|
46
|
+
# end
|
|
52
47
|
|
|
53
48
|
# Perform block in context of another project than currently set
|
|
54
49
|
#
|
|
55
50
|
# @param project Project to use
|
|
56
51
|
# @param bl Block to be performed
|
|
57
|
-
def with_project(project, &bl)
|
|
52
|
+
def with_project(project, opts = { :client => GoodData.connection }, &bl)
|
|
58
53
|
fail 'You have to specify a project when using with_project' if project.nil? || (project.is_a?(String) && project.empty?)
|
|
54
|
+
fail 'You have to specify block' unless bl
|
|
59
55
|
old_project = GoodData.project
|
|
56
|
+
|
|
60
57
|
begin
|
|
61
|
-
GoodData.use(project)
|
|
62
|
-
bl.call(GoodData.project)
|
|
58
|
+
GoodData.use(project, opts)
|
|
59
|
+
res = bl.call(GoodData.project)
|
|
63
60
|
rescue RestClient::ResourceNotFound
|
|
64
|
-
raise(GoodData::ProjectNotFound, 'Project was not found')
|
|
65
|
-
ensure
|
|
66
61
|
GoodData.project = old_project
|
|
62
|
+
raise(GoodData::ProjectNotFound, 'Project was not found')
|
|
67
63
|
end
|
|
64
|
+
|
|
65
|
+
GoodData.project = old_project
|
|
66
|
+
|
|
67
|
+
res
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|
data/lib/gooddata/core/rest.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
require_relative 'connection'
|
|
4
|
-
|
|
5
3
|
module GoodData
|
|
6
4
|
DEFAULT_SLEEP_INTERVAL = 10
|
|
7
5
|
|
|
@@ -67,7 +65,7 @@ module GoodData
|
|
|
67
65
|
end
|
|
68
66
|
|
|
69
67
|
def upload_to_user_webdav(file, options = {})
|
|
70
|
-
u = URI(
|
|
68
|
+
u = URI(GoodData.project.links['uploads'])
|
|
71
69
|
url = URI.join(u.to_s.chomp(u.path.to_s), '/uploads/')
|
|
72
70
|
connection.upload(file, options.merge(
|
|
73
71
|
:directory => options[:directory],
|
|
@@ -76,7 +74,7 @@ module GoodData
|
|
|
76
74
|
end
|
|
77
75
|
|
|
78
76
|
def get_project_webdav_path(file, options = {})
|
|
79
|
-
u = URI(
|
|
77
|
+
u = URI(GoodData.project.links['uploads'])
|
|
80
78
|
URI.join(u.to_s.chomp(u.path.to_s), '/project-uploads/', "#{GoodData.project.pid}/")
|
|
81
79
|
end
|
|
82
80
|
|
|
@@ -88,7 +86,7 @@ module GoodData
|
|
|
88
86
|
end
|
|
89
87
|
|
|
90
88
|
def get_user_webdav_path(file, options = {})
|
|
91
|
-
u = URI(
|
|
89
|
+
u = URI(GoodData.project.links['uploads'])
|
|
92
90
|
URI.join(u.to_s.chomp(u.path.to_s), '/uploads/')
|
|
93
91
|
end
|
|
94
92
|
|
|
@@ -134,13 +132,16 @@ module GoodData
|
|
|
134
132
|
# @param options [Hash] Options
|
|
135
133
|
# @return [Hash] Result of polling
|
|
136
134
|
def poll_on_response(link, options = {}, &bl)
|
|
135
|
+
client = options[:client]
|
|
136
|
+
fail ArgumentError, 'No :client specified' if client.nil?
|
|
137
|
+
|
|
137
138
|
sleep_interval = options[:sleep_interval] || DEFAULT_SLEEP_INTERVAL
|
|
138
|
-
response =
|
|
139
|
+
response = get(link)
|
|
139
140
|
while bl.call(response)
|
|
140
141
|
sleep sleep_interval
|
|
141
|
-
|
|
142
|
+
client.retryable(:tries => 3, :on => RestClient::InternalServerError) do
|
|
142
143
|
sleep sleep_interval
|
|
143
|
-
response =
|
|
144
|
+
response = get(link)
|
|
144
145
|
end
|
|
145
146
|
end
|
|
146
147
|
response
|
data/lib/gooddata/core/user.rb
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
require_relative 'connection'
|
|
4
|
-
require_relative 'threaded'
|
|
5
|
-
|
|
6
3
|
require_relative '../models/profile'
|
|
7
4
|
|
|
8
5
|
module GoodData
|
|
9
6
|
class << self
|
|
10
|
-
# Attempts to log in
|
|
11
|
-
#
|
|
12
|
-
# @return [Boolean] True if logged in else false
|
|
13
|
-
def test_login
|
|
14
|
-
connection.connect!
|
|
15
|
-
connection.logged_in?
|
|
16
|
-
end
|
|
17
|
-
|
|
18
7
|
# Gets currently logged user
|
|
19
8
|
#
|
|
20
9
|
# @return [GoodData::Profile] User Profile
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
class Hash
|
|
4
|
+
# Return a hash that includes everything but the given keys. This is useful for
|
|
5
|
+
# limiting a set of parameters to everything but a few known toggles:
|
|
6
|
+
#
|
|
7
|
+
# @person.update_attributes(params[:person].except(:admin))
|
|
8
|
+
#
|
|
9
|
+
# If the receiver responds to +convert_key+, the method is called on each of the
|
|
10
|
+
# arguments. This allows +except+ to play nice with hashes with indifferent access
|
|
11
|
+
# for instance:
|
|
12
|
+
#
|
|
13
|
+
# {:a => 1}.with_indifferent_access.except(:a) # => {}
|
|
14
|
+
# {:a => 1}.with_indifferent_access.except("a") # => {}
|
|
15
|
+
#
|
|
16
|
+
def except(*keys)
|
|
17
|
+
dup.except!(*keys)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Replaces the hash without the given keys.
|
|
21
|
+
def except!(*keys)
|
|
22
|
+
keys.each { |key| delete(key) }
|
|
23
|
+
self
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -38,12 +38,12 @@ module GoodData
|
|
|
38
38
|
}
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
def self.interpolate_ids(*ids)
|
|
41
|
+
def self.interpolate_ids(options, *ids)
|
|
42
42
|
ids = ids.flatten
|
|
43
43
|
if ids.empty?
|
|
44
44
|
[]
|
|
45
45
|
else
|
|
46
|
-
res = GoodData::MdObject.identifier_to_uri(*ids)
|
|
46
|
+
res = GoodData::MdObject.identifier_to_uri(options, *ids)
|
|
47
47
|
fail 'Not all of the identifiers were resolved' if Array(res).size != ids.size
|
|
48
48
|
res
|
|
49
49
|
end
|
|
@@ -54,7 +54,7 @@ module GoodData
|
|
|
54
54
|
keys.zip(x)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
def self.interpolate_metric(metric, dictionary)
|
|
57
|
+
def self.interpolate_metric(metric, dictionary, options = { :client => GoodData.connection, :project => GoodData.project })
|
|
58
58
|
interpolated = interpolate({
|
|
59
59
|
:facts => GoodData::SmallGoodZilla.get_facts(metric),
|
|
60
60
|
:attributes => GoodData::SmallGoodZilla.get_attributes(metric),
|
|
@@ -62,7 +62,7 @@ module GoodData
|
|
|
62
62
|
}, dictionary)
|
|
63
63
|
|
|
64
64
|
ids = GoodData::SmallGoodZilla.get_ids(metric)
|
|
65
|
-
interpolated_ids = ids.zip(Array(interpolate_ids(ids)))
|
|
65
|
+
interpolated_ids = ids.zip(Array(interpolate_ids(options, ids)))
|
|
66
66
|
|
|
67
67
|
metric = interpolated[:facts].reduce(metric) { |a, e| a.sub("#\"#{e[0]}\"", "[#{e[1]}]") }
|
|
68
68
|
metric = interpolated[:attributes].reduce(metric) { |a, e| a.sub("@\"#{e[0]}\"", "[#{e[1]}]") }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'multi_json'
|
|
5
|
+
|
|
6
|
+
require_relative 'global_helpers'
|
|
7
|
+
|
|
8
|
+
module GoodData
|
|
9
|
+
module Helpers
|
|
10
|
+
module AuthHelper
|
|
11
|
+
class << self
|
|
12
|
+
# Get path of .gooddata config
|
|
13
|
+
def credentials_file
|
|
14
|
+
"#{Helpers.home_directory}/.gooddata"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Read credentials
|
|
18
|
+
def read_credentials(credentials_file_path = credentials_file)
|
|
19
|
+
if File.exist?(credentials_file_path)
|
|
20
|
+
config = File.read(credentials_file_path)
|
|
21
|
+
MultiJson.load(config, :symbolize_keys => true)
|
|
22
|
+
else
|
|
23
|
+
{}
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Writes credentials
|
|
28
|
+
def write_credentials(credentials, credentials_file_path = credentials_file)
|
|
29
|
+
File.open(credentials_file_path, 'w', 0600) do |f|
|
|
30
|
+
f.puts MultiJson.encode(credentials, :pretty => true)
|
|
31
|
+
end
|
|
32
|
+
credentials
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def remove_credentials_file(credentials_file_path = credentials_file)
|
|
36
|
+
FileUtils.rm_f(credentials_file_path)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|