Skip to content

Commit 87e8fd5

Browse files
committed
Merge pull request #280 from fluke777/master
Merge before release 0.6.8
2 parents 68df400 + 61bac59 commit 87e8fd5

59 files changed

Lines changed: 582 additions & 898 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/gooddata/cli/commands/domain_cmd.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@
3737
fail ArgumentError, 'Domain name has to be provided' if domain.nil? || domain.empty?
3838

3939
users = GoodData::Command::Domain.list_users(domain, :client => client)
40-
puts users.map { |u| [u['firstName'], u['lastName'], u['login']].join(',') }
40+
puts users.map { |u| [u.first_name, u.last_name, u.login].join(',') }
4141
end
4242
end
4343
end
44-
4544
end

lib/gooddata/cli/commands/process_cmd.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
c.command :list do |list|
3636
list.action do |global_options, options, args|
3737
opts = options.merge(global_options)
38-
GoodData.connect(opts)
38+
client = GoodData.connect(opts)
3939
opts = opts.merge(:project_id => args[0]) if args.length > 0
40-
processes = GoodData::Command::Process.list(opts)
40+
processes = GoodData::Command::Process.list(opts.merge(client: client))
4141
processes.each do |process|
42-
puts "#{process.name},#{GoodData.connection.url + process.uri}"
42+
puts "#{process.name},#{client.connection.server_url + process.uri}"
4343
end
4444
end
4545
end
@@ -48,8 +48,8 @@
4848
c.command :show do |get|
4949
get.action do |global_options, options, args|
5050
opts = options.merge(global_options)
51-
GoodData.connect(opts)
52-
pp GoodData::Command::Process.get(options.merge(global_options)).raw_data
51+
client = GoodData.connect(opts)
52+
pp GoodData::Command::Process.get(opts.merge(client: client)).raw_data
5353
end
5454
end
5555

@@ -61,8 +61,9 @@
6161
name = opts[:name]
6262
fail 'You have to provide a directory or a file to deploy. Use --dir param' if dir.nil? || dir.empty?
6363
fail 'You have to provide a name of the deployed process. Use --name param' if name.nil? || name.empty?
64-
GoodData.connect(opts)
65-
pp GoodData::Command::Process.deploy(dir, options.merge(global_options))
64+
client = GoodData.connect(opts)
65+
process = GoodData::Command::Process.deploy(dir, opts.merge(client: client))
66+
puts "Process #{process.uri} was deployed"
6667
end
6768
end
6869

@@ -72,8 +73,9 @@
7273
opts = options.merge(global_options)
7374
process_id = opts[:process_id]
7475
fail 'You have to provide a process id. Use --process_id param' if process_id.nil? || process_id.empty?
75-
GoodData.connect(opts)
76-
pp GoodData::Command::Process.delete(process_id, opts)
76+
client = GoodData.connect(opts)
77+
GoodData::Command::Process.delete(process_id, opts.merge(client: client))
78+
puts "Process #{process_id} was deleted"
7779
end
7880
end
7981

lib/gooddata/cli/commands/project_cmd.rb

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
token = opts[:token] || ask('token')
3232

3333
opts = options.merge(global_options)
34-
GoodData.connect(opts)
34+
client = GoodData.connect(opts)
3535
project = GoodData::Command::Project.create(
3636
:title => title,
3737
:summary => summary,
3838
:template => template,
39-
:token => token
40-
)
41-
puts "Project '#{project.title}' with id #{project.uri} created successfully!"
39+
:token => token,
40+
client: client)
41+
puts "Project '#{project.title}' with id #{project.pid} created successfully!"
4242
end
4343
end
4444

@@ -47,8 +47,8 @@
4747
delete.action do |global_options, options, args|
4848
id = global_options[:project_id]
4949
opts = options.merge(global_options)
50-
GoodData.connect(opts)
51-
GoodData::Command::Project.delete(id)
50+
client = GoodData.connect(opts)
51+
GoodData::Command::Project.delete(id, opts.merge(client: client))
5252
end
5353
end
5454

@@ -73,8 +73,8 @@
7373
opts[:auth_token] = token
7474
fail 'You have to provide a token for creating a project. Please use parameter --token' if token.nil? || token.empty?
7575

76-
GoodData.connect(opts)
77-
new_project = GoodData::Command::Project.clone(id, opts)
76+
client = GoodData.connect(opts)
77+
new_project = GoodData::Command::Project.clone(id, opts.merge(client: client))
7878
puts "Project with title \"#{new_project.title}\" was cloned with id #{new_project.pid}"
7979
end
8080
end
@@ -92,26 +92,26 @@
9292
fail 'Role name has to be provided' if role.nil? || role.empty?
9393

9494
msg = args[2]
95-
msg = GoodData::Command::Project::DEFAULT_INVITE_MESSAGE if msg.nil? || msg.empty?
95+
msg = GoodData::Project::DEFAULT_INVITE_MESSAGE if msg.nil? || msg.empty?
9696

9797
opts = options.merge(global_options)
98-
GoodData.connect(opts)
98+
client = GoodData.connect(opts)
9999

100-
GoodData::Command::Project.invite(project_id, email, role, msg)
100+
GoodData::Command::Project.invite(project_id, email, role, msg, opts.merge(client: client))
101101
end
102102
end
103103

104104
c.desc 'List users'
105105
c.command :users do |list|
106106
list.action do |global_options, options, args|
107107
opts = options.merge(global_options)
108-
GoodData.connect(opts)
108+
client = GoodData.connect(opts)
109109

110110
pid = global_options[:project_id]
111111
fail 'Project ID has to be provided' if pid.nil? || pid.empty?
112112

113-
user_list = GoodData::Command::Project.users(pid)
114-
puts user_list.map { |u| [u[:last_name], u[:first_name], u[:login], u[:uri]].join(',') }
113+
user_list = GoodData::Command::Project.users(pid, opts.merge(client: client))
114+
puts user_list.map { |u| [u.last_name, u.first_name, u.login, u.uri].join(',') }
115115
end
116116
end
117117

@@ -120,8 +120,8 @@
120120
show.action do |global_options, options, args|
121121
id = global_options[:project_id]
122122
opts = options.merge(global_options)
123-
GoodData.connect(opts)
124-
p = GoodData::Command::Project.show(id)
123+
client = GoodData.connect(opts)
124+
p = GoodData::Command::Project.show(id, client: client)
125125
pp p.data
126126
end
127127
end
@@ -130,9 +130,9 @@
130130
c.command :build do |show|
131131
show.action do |global_options, options, args|
132132
opts = options.merge(global_options)
133-
GoodData.connect(opts)
133+
client = GoodData.connect(opts)
134134
spec, _ = GoodData::Command::Project.get_spec_and_project_id('.')
135-
new_project = GoodData::Command::Project.build(opts.merge(:spec => spec))
135+
new_project = GoodData::Command::Project.build(opts.merge(spec: spec, client: client))
136136
puts "Project was created. New project PID is #{new_project.pid}, URI is #{new_project.uri}."
137137
end
138138
end
@@ -151,27 +151,26 @@
151151
end
152152
end
153153

154-
c.desc 'Roles'
154+
c.desc 'Shows roles in the project'
155155
c.command :roles do |roles|
156156
roles.action do |global_options, options, args|
157157
project_id = global_options[:project_id]
158158
fail 'Project ID has to be provided' if project_id.nil? || project_id.empty?
159159

160160
opts = options.merge(global_options)
161-
GoodData.connect(opts)
161+
client = GoodData.connect(opts)
162162

163-
roles = GoodData::Command::Project.roles(project_id)
164-
165-
puts roles.map { |r| [r['url'], r['role']['projectRole']['meta']['title']].join(',') }
163+
roles = GoodData::Command::Project.roles(project_id, client: client)
164+
puts roles.map { |r| [r.uri, r.title].join(',') }
166165
end
167166
end
168167

169-
c.desc 'You can run project validation which will check RI integrity and other problems.'
168+
c.desc 'You can run project validation which will check RI and other problems.'
170169
c.command :validate do |show|
171170
show.action do |global_options, options, args|
172171
opts = options.merge(global_options)
173-
GoodData.connect(opts)
174-
pp GoodData::Command::Project.validate(global_options[:project_id])
172+
client = GoodData.connect(opts)
173+
pp GoodData::Command::Project.validate(global_options[:project_id], opts.merge(client: client))
175174
end
176175
end
177176
end

lib/gooddata/cli/commands/projects_cmd.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
c.command :list do |list|
1313
list.action do |global_options, options, args|
1414
opts = options.merge(global_options)
15-
GoodData.connect(opts)
16-
list = GoodData::Command::Projects.list
15+
client = GoodData.connect(opts)
16+
list = GoodData::Command::Projects.list(client: client)
1717
puts list.map { |p| [p.uri, p.title].join(',') }
1818
end
1919
end

lib/gooddata/cli/commands/role_cmd.rb

Lines changed: 0 additions & 28 deletions
This file was deleted.

lib/gooddata/cli/commands/run_ruby_cmd.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
GoodData::CLI.module_eval do
1111

12-
desc 'Run ruby bricks either locally or remotely deployed on our server'
12+
desc 'Run ruby bricks either locally or remotely deployed on our server. Currently private alpha.'
1313
# arg_name 'show'
1414
command :run_ruby do |c|
1515

lib/gooddata/cli/commands/user_cmd.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
c.command :show do |show|
1414
show.action do |global_options, options, args|
1515
opts = options.merge(global_options)
16-
GoodData.connect(opts)
17-
pp GoodData::Command::User.show
16+
client = GoodData.connect(opts)
17+
pp GoodData::Command::User.show(client: client)
1818
end
1919
end
2020
end

lib/gooddata/cli/hooks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# return false to skip default error handling
4242
# binding.pry
4343
# pp exception.backtrace
44-
pp exception
44+
# pp exception
4545
true
4646
end
4747
end

lib/gooddata/cli/shared.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
flag [:p, :project_id]
3131

3232
desc 'Server'
33-
default_value GoodData::Connection::DEFAULT_URL
33+
default_value GoodData::Rest::Connection::DEFAULT_URL
3434
arg_name 'server'
3535
flag [:s, :server]
3636

lib/gooddata/commands/process.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,29 @@ def get(options = {})
1818

1919
id = options[:process_id]
2020
fail ArgumentError, 'None or invalid process_id' if id.nil? || id.empty?
21-
22-
GoodData.with_project(pid) do
23-
GoodData::Process[id]
21+
c = options[:client]
22+
c.with_project(pid) do |project|
23+
project.processes(id)
2424
end
2525
end
2626

2727
def delete(process_id, options = { :client => GoodData.connection, :project => GoodData.project })
28-
process = GoodData::Process[process_id, options]
28+
c = options[:client]
29+
pid = options[:project_id]
30+
process = c.with_project(pid) do |project|
31+
project.processes(process_id)
32+
end
2933
process.delete
3034
end
3135

3236
# TODO: check files_to_exclude param. Does it do anything? It should check that in case of using CLI, it makes sure the files are not deployed
3337
def deploy(dir, options = { :client => GoodData.connection, :project => GoodData.project })
3438
params = options[:params].nil? ? [] : [options[:params]]
35-
GoodData::Process.deploy(dir, options.merge(:files_to_exclude => params))
39+
c = options[:client]
40+
pid = options[:project_id]
41+
c.with_project(pid) do |project|
42+
project.deploy_process(dir, options.merge(:files_to_exclude => params))
43+
end
3644
end
3745

3846
def execute_process(process_id, executable, options = { :client => GoodData.connection, :project => GoodData.project })

0 commit comments

Comments
 (0)