gooddata 0.5.16 → 0.6.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/bin/gooddata +291 -8
- data/gooddata.gemspec +14 -5
- data/lib/gooddata/client.rb +34 -5
- data/lib/gooddata/commands/api.rb +27 -30
- data/lib/gooddata/commands/process.rb +137 -0
- data/lib/gooddata/commands/profile.rb +5 -5
- data/lib/gooddata/commands/projects.rb +107 -40
- data/lib/gooddata/commands/runners.rb +37 -0
- data/lib/gooddata/commands/scaffold.rb +30 -0
- data/lib/gooddata/connection.rb +31 -19
- data/lib/gooddata/extract.rb +1 -1
- data/lib/gooddata/goodzilla/goodzilla.rb +40 -0
- data/lib/gooddata/model.rb +418 -138
- data/lib/gooddata/models/attribute.rb +24 -0
- data/lib/gooddata/models/dashboard.rb +60 -0
- data/lib/gooddata/models/data_result.rb +4 -6
- data/lib/gooddata/models/data_set.rb +20 -0
- data/lib/gooddata/models/display_form.rb +7 -0
- data/lib/gooddata/models/fact.rb +17 -0
- data/lib/gooddata/models/metadata.rb +69 -17
- data/lib/gooddata/models/metric.rb +90 -0
- data/lib/gooddata/models/process.rb +112 -0
- data/lib/gooddata/models/profile.rb +1 -1
- data/lib/gooddata/models/project.rb +85 -29
- data/lib/gooddata/models/report.rb +45 -0
- data/lib/gooddata/models/report_definition.rb +139 -0
- data/lib/gooddata/version.rb +1 -1
- data/lib/templates/bricks/brick.rb.erb +7 -0
- data/lib/templates/bricks/main.rb.erb +4 -0
- data/spec/goodzilla_spec.rb +57 -0
- data/spec/model_dsl_spec.rb +22 -0
- data/test/test_commands.rb +1 -1
- data/test/test_model.rb +6 -6
- metadata +137 -16
- data/bin/igd.rb +0 -33
- data/lib/gooddata/command.rb +0 -75
- data/lib/gooddata/commands/help.rb +0 -104
- data/lib/gooddata/commands/version.rb +0 -7
- data/test/helper.rb +0 -13
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'gooddata/model'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
describe GoodData::Model::SchemaBuilder do
|
5
|
+
|
6
|
+
it "should create a schema" do
|
7
|
+
builder = GoodData::Model::SchemaBuilder.new("a_title")
|
8
|
+
schema = builder.to_schema
|
9
|
+
schema.title.should == "a_title"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should create a schema with some columns" do
|
13
|
+
builder = GoodData::Model::SchemaBuilder.new("payments")
|
14
|
+
builder.add_attribute("id", :title => "My Id")
|
15
|
+
builder.add_fact("amount", :title => "Amount")
|
16
|
+
|
17
|
+
schema = builder.to_schema
|
18
|
+
schema.attributes.keys.count == 1
|
19
|
+
schema.attributes["attr.payments.id"].title.should == "My Id"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/test/test_commands.rb
CHANGED
data/test/test_model.rb
CHANGED
@@ -9,12 +9,12 @@ GoodData.logger = Logger.new(STDOUT)
|
|
9
9
|
|
10
10
|
class TestModel < Test::Unit::TestCase
|
11
11
|
COLUMNS = [
|
12
|
-
{ 'type' =>
|
13
|
-
{ 'type' =>
|
14
|
-
{ 'type' =>
|
15
|
-
{ 'type' =>
|
16
|
-
{ 'type' =>
|
17
|
-
{ 'type' =>
|
12
|
+
{ 'type' => :anchor, 'name' => 'cp', 'title' => 'CP', 'folder' => 'test' },
|
13
|
+
{ 'type' => :attribute, 'name' => 'a1', 'title' => 'A1', 'folder' => 'test' },
|
14
|
+
{ 'type' => :attribute, 'name' => 'a2', 'title' => 'A2', 'folder' => 'test' },
|
15
|
+
{ 'type' => :date, 'name' => 'event', 'title' => 'Event', 'folder' => 'test' },
|
16
|
+
{ 'type' => :fact, 'name' => 'f1', 'title' => 'F1', 'folder' => 'test' },
|
17
|
+
{ 'type' => :fact, 'name' => 'f2', 'title' => 'F2', 'folder' => 'test' },
|
18
18
|
]
|
19
19
|
SCHEMA = GoodData::Model::Schema.new 'title' => 'test', 'columns' => COLUMNS
|
20
20
|
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gooddata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.6.0.pre2
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Pavel Kolesnikov
|
@@ -17,17 +17,17 @@ dependencies:
|
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
|
-
- -
|
20
|
+
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
none: false
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - ! '>='
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
30
|
+
version: '0'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: thoughtbot-shoulda
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,6 +44,54 @@ dependencies:
|
|
44
44
|
- - ! '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pry
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: rspec
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
type: :development
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
47
95
|
- !ruby/object:Gem::Dependency
|
48
96
|
name: parseconfig
|
49
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,22 +161,85 @@ dependencies:
|
|
113
161
|
requirement: !ruby/object:Gem::Requirement
|
114
162
|
none: false
|
115
163
|
requirements:
|
116
|
-
- -
|
164
|
+
- - ! '>='
|
117
165
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
166
|
+
version: '0'
|
119
167
|
type: :runtime
|
120
168
|
prerelease: false
|
121
169
|
version_requirements: !ruby/object:Gem::Requirement
|
122
170
|
none: false
|
123
171
|
requirements:
|
124
|
-
- -
|
172
|
+
- - ! '>='
|
125
173
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
174
|
+
version: '0'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: highline
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
none: false
|
179
|
+
requirements:
|
180
|
+
- - ! '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
type: :runtime
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
187
|
+
requirements:
|
188
|
+
- - ! '>='
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: gli
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
none: false
|
195
|
+
requirements:
|
196
|
+
- - ! '>='
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
199
|
+
type: :runtime
|
200
|
+
prerelease: false
|
201
|
+
version_requirements: !ruby/object:Gem::Requirement
|
202
|
+
none: false
|
203
|
+
requirements:
|
204
|
+
- - ! '>='
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
- !ruby/object:Gem::Dependency
|
208
|
+
name: pry
|
209
|
+
requirement: !ruby/object:Gem::Requirement
|
210
|
+
none: false
|
211
|
+
requirements:
|
212
|
+
- - ! '>='
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
type: :runtime
|
216
|
+
prerelease: false
|
217
|
+
version_requirements: !ruby/object:Gem::Requirement
|
218
|
+
none: false
|
219
|
+
requirements:
|
220
|
+
- - ! '>='
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: erubis
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
none: false
|
227
|
+
requirements:
|
228
|
+
- - ! '>='
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
type: :runtime
|
232
|
+
prerelease: false
|
233
|
+
version_requirements: !ruby/object:Gem::Requirement
|
234
|
+
none: false
|
235
|
+
requirements:
|
236
|
+
- - ! '>='
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '0'
|
127
239
|
description: Use the Gooddata::Client class to integrate GoodData into your own application
|
128
240
|
or use the CLI to work with GoodData directly from the command line.
|
129
241
|
email: pavel@gooddata.com
|
130
242
|
executables:
|
131
|
-
- igd.rb
|
132
243
|
- gooddata
|
133
244
|
extensions: []
|
134
245
|
extra_rdoc_files:
|
@@ -144,33 +255,43 @@ files:
|
|
144
255
|
- Rakefile
|
145
256
|
- TODO.md
|
146
257
|
- bin/gooddata
|
147
|
-
- bin/igd.rb
|
148
258
|
- examples.rb
|
149
259
|
- gooddata.gemspec
|
150
260
|
- lib/gooddata.rb
|
151
261
|
- lib/gooddata/client.rb
|
152
|
-
- lib/gooddata/command.rb
|
153
262
|
- lib/gooddata/commands/api.rb
|
154
263
|
- lib/gooddata/commands/auth.rb
|
155
264
|
- lib/gooddata/commands/base.rb
|
156
265
|
- lib/gooddata/commands/datasets.rb
|
157
|
-
- lib/gooddata/commands/
|
266
|
+
- lib/gooddata/commands/process.rb
|
158
267
|
- lib/gooddata/commands/profile.rb
|
159
268
|
- lib/gooddata/commands/projects.rb
|
160
|
-
- lib/gooddata/commands/
|
269
|
+
- lib/gooddata/commands/runners.rb
|
270
|
+
- lib/gooddata/commands/scaffold.rb
|
161
271
|
- lib/gooddata/connection.rb
|
162
272
|
- lib/gooddata/extract.rb
|
273
|
+
- lib/gooddata/goodzilla/goodzilla.rb
|
163
274
|
- lib/gooddata/helpers.rb
|
164
275
|
- lib/gooddata/model.rb
|
276
|
+
- lib/gooddata/models/attribute.rb
|
165
277
|
- lib/gooddata/models/dashboard.rb
|
166
278
|
- lib/gooddata/models/data_result.rb
|
279
|
+
- lib/gooddata/models/data_set.rb
|
280
|
+
- lib/gooddata/models/display_form.rb
|
281
|
+
- lib/gooddata/models/fact.rb
|
167
282
|
- lib/gooddata/models/links.rb
|
168
283
|
- lib/gooddata/models/metadata.rb
|
284
|
+
- lib/gooddata/models/metric.rb
|
285
|
+
- lib/gooddata/models/process.rb
|
169
286
|
- lib/gooddata/models/profile.rb
|
170
287
|
- lib/gooddata/models/project.rb
|
171
288
|
- lib/gooddata/models/report.rb
|
289
|
+
- lib/gooddata/models/report_definition.rb
|
172
290
|
- lib/gooddata/version.rb
|
173
|
-
-
|
291
|
+
- lib/templates/bricks/brick.rb.erb
|
292
|
+
- lib/templates/bricks/main.rb.erb
|
293
|
+
- spec/goodzilla_spec.rb
|
294
|
+
- spec/model_dsl_spec.rb
|
174
295
|
- test/test_commands.rb
|
175
296
|
- test/test_guessing.rb
|
176
297
|
- test/test_model.rb
|
data/bin/igd.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'gooddata'
|
4
|
-
require 'gooddata/command'
|
5
|
-
|
6
|
-
require 'irb'
|
7
|
-
|
8
|
-
include GoodData
|
9
|
-
|
10
|
-
module IRB
|
11
|
-
def IRB.start2(bind, ap_path)
|
12
|
-
IRB.setup(ap_path)
|
13
|
-
irb = Irb.new(WorkSpace.new(bind))
|
14
|
-
@CONF[:MAIN_CONTEXT] = irb.context
|
15
|
-
trap("SIGINT") do
|
16
|
-
irb.signal_handle
|
17
|
-
end
|
18
|
-
catch(:IRB_EXIT) do
|
19
|
-
irb.eval_input
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
param = ARGV.shift if ARGV.length
|
25
|
-
if param == '--debug' then
|
26
|
-
require 'logger'
|
27
|
-
GoodData.logger = Logger.new STDOUT
|
28
|
-
end
|
29
|
-
Command.connect
|
30
|
-
puts "Logged into GoodData as #{GoodData.profile.user} (#{GoodData.profile['login']})"
|
31
|
-
puts
|
32
|
-
IRB::start2 binding, $STDIN
|
33
|
-
puts "Logging out"
|
data/lib/gooddata/command.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'pp'
|
2
|
-
require 'gooddata/helpers'
|
3
|
-
require 'gooddata/commands/base'
|
4
|
-
Dir[File.dirname(__FILE__) + '/commands/*.rb'].each { |file| require file unless file =~ /\/base.rb$/ }
|
5
|
-
|
6
|
-
module GoodData::Command
|
7
|
-
class InvalidCommand < RuntimeError; end
|
8
|
-
class InvalidOption < RuntimeError; end
|
9
|
-
class CommandFailed < RuntimeError; end
|
10
|
-
|
11
|
-
extend GoodData::Helpers
|
12
|
-
|
13
|
-
class << self
|
14
|
-
def run(command, args)
|
15
|
-
begin
|
16
|
-
run_internal command, args.dup
|
17
|
-
rescue InvalidCommand
|
18
|
-
error "Unknown command. Run 'gooddata help' for usage information."
|
19
|
-
rescue InvalidOption
|
20
|
-
error "Unknown option."
|
21
|
-
rescue RestClient::Unauthorized
|
22
|
-
error "Authentication failure"
|
23
|
-
rescue RestClient::ResourceNotFound => e
|
24
|
-
error extract_not_found(e.http_body)
|
25
|
-
rescue RestClient::RequestFailed => e
|
26
|
-
error extract_error(e.http_body)
|
27
|
-
rescue RestClient::RequestTimeout
|
28
|
-
error "API request timed out. Please try again, or contact support@gooddata.com if this issue persists."
|
29
|
-
rescue CommandFailed => e
|
30
|
-
error e.message
|
31
|
-
rescue Interrupt => e
|
32
|
-
error "\n[canceled]"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def run_internal(command, args)
|
37
|
-
klass, method = parse(command)
|
38
|
-
runner = klass.new(args)
|
39
|
-
raise InvalidCommand unless runner.respond_to?(method)
|
40
|
-
runner.send(method)
|
41
|
-
end
|
42
|
-
|
43
|
-
def parse(command)
|
44
|
-
parts = command.split(':')
|
45
|
-
|
46
|
-
parts << :index if parts.size == 1
|
47
|
-
raise InvalidCommand if parts.size > 2
|
48
|
-
|
49
|
-
begin
|
50
|
-
return GoodData::Command.const_get(parts[0].capitalize), parts[1]
|
51
|
-
rescue NameError
|
52
|
-
raise InvalidCommand
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def extract_not_found(body)
|
57
|
-
body =~ /^[\w\s]+ not found$/ ? body : "Resource not found"
|
58
|
-
end
|
59
|
-
|
60
|
-
def extract_error(body)
|
61
|
-
msg = parse_error_json(body) || 'Internal server error'
|
62
|
-
msg.split("\n").map { |line| ' ! ' + line }.join("\n")
|
63
|
-
end
|
64
|
-
|
65
|
-
def parse_error_json(body)
|
66
|
-
begin
|
67
|
-
error = JSON.parse(body.to_s)['error']
|
68
|
-
return error['message'] if !error['parameters']
|
69
|
-
return error['message'] % error['parameters'] rescue error
|
70
|
-
rescue
|
71
|
-
return body
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
module GoodData
|
2
|
-
module Command
|
3
|
-
class Help < Base
|
4
|
-
class HelpGroup < Array
|
5
|
-
attr_reader :title
|
6
|
-
|
7
|
-
def initialize(title)
|
8
|
-
@title = title
|
9
|
-
end
|
10
|
-
|
11
|
-
def command(name, description)
|
12
|
-
self << [name, description]
|
13
|
-
end
|
14
|
-
|
15
|
-
def space
|
16
|
-
self << ['', '']
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class << self
|
21
|
-
def groups
|
22
|
-
@groups ||= []
|
23
|
-
end
|
24
|
-
|
25
|
-
def group(title, &block)
|
26
|
-
groups << begin
|
27
|
-
group = HelpGroup.new(title)
|
28
|
-
yield group
|
29
|
-
group
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def create_default_groups!
|
34
|
-
group 'General Commands' do |group|
|
35
|
-
group.command 'help', 'show this usage'
|
36
|
-
group.command 'version', 'show the gem version'
|
37
|
-
group.space
|
38
|
-
group.command 'api', 'general info about the current GoodData API version'
|
39
|
-
group.command 'api:test', 'test you credentials and the connection to GoodData server'
|
40
|
-
group.command 'api:get', 'issue a generic GET request to the GoodData API'
|
41
|
-
group.space
|
42
|
-
group.command 'auth:store', 'save your GoodData credentials and we won\'t ask you for them ever again'
|
43
|
-
group.command 'auth:unstore', 'remove the saved GoodData credentials from your computer'
|
44
|
-
group.space
|
45
|
-
group.command 'datasets', 'list remote data sets in the project specified via --project'
|
46
|
-
group.command 'datasets:describe', 'describe a local data set and save the description in a JSON file'
|
47
|
-
group.space
|
48
|
-
group.command 'profile', 'show your GoodData profile'
|
49
|
-
group.space
|
50
|
-
group.command 'projects', 'list available projects'
|
51
|
-
group.command 'projects:create', 'create new project'
|
52
|
-
group.command 'projects:show <key>', 'show project details'
|
53
|
-
group.command 'projects:delete <key> [...]', 'delete one or more existing projects'
|
54
|
-
end
|
55
|
-
|
56
|
-
group 'General Options' do |group|
|
57
|
-
group.command '--log-level <level>', 'Set the log level (fatal, error, warn [default], info, debug)'
|
58
|
-
group.command '--project <project_id>', 'Set the working remote project identified by an URI or project ID'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def index
|
64
|
-
puts usage
|
65
|
-
end
|
66
|
-
|
67
|
-
def version
|
68
|
-
puts Client.version
|
69
|
-
end
|
70
|
-
|
71
|
-
def usage
|
72
|
-
longest_command_length = self.class.groups.map do |group|
|
73
|
-
group.map { |g| g.first.length }
|
74
|
-
end.flatten.max
|
75
|
-
|
76
|
-
s = StringIO.new
|
77
|
-
s << <<-EOT
|
78
|
-
=== Usage
|
79
|
-
|
80
|
-
gooddata COMMAND [options]
|
81
|
-
|
82
|
-
EOT
|
83
|
-
|
84
|
-
self.class.groups.inject(s) do |output, group|
|
85
|
-
output.puts "=== %s" % group.title
|
86
|
-
output.puts
|
87
|
-
|
88
|
-
group.each do |command, description|
|
89
|
-
if command.empty?
|
90
|
-
output.puts
|
91
|
-
else
|
92
|
-
output.puts "%-*s # %s" % [longest_command_length, command, description]
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
output.puts
|
97
|
-
output
|
98
|
-
end.string
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
GoodData::Command::Help.create_default_groups!
|