gooddata 0.6.0.pre11 → 0.6.0
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/.travis.yml +12 -1
- data/.yardopts +2 -0
- data/README.md +6 -3
- data/Rakefile +24 -7
- data/gooddata +2 -2
- data/gooddata.gemspec +4 -3
- data/lib/gooddata.rb +17 -12
- data/lib/gooddata/bricks/base_downloader.rb +7 -7
- data/lib/gooddata/bricks/brick.rb +7 -8
- data/lib/gooddata/bricks/bricks.rb +4 -1
- data/lib/gooddata/bricks/middleware/base_middleware.rb +2 -2
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +5 -6
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +21 -22
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +3 -4
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +14 -14
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +6 -6
- data/lib/gooddata/bricks/middleware/middleware.rb +4 -1
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +29 -32
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +5 -5
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +6 -8
- data/lib/gooddata/bricks/utils.rb +3 -3
- data/lib/gooddata/cli/cli.rb +4 -2
- data/lib/gooddata/cli/commands/api_cmd.rb +6 -4
- data/lib/gooddata/cli/commands/auth_cmd.rb +5 -3
- data/lib/gooddata/cli/commands/console_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/process_cmd.rb +6 -4
- data/lib/gooddata/cli/commands/profile_cmd.rb +5 -3
- data/lib/gooddata/cli/commands/project_cmd.rb +24 -22
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +12 -10
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +8 -6
- data/lib/gooddata/cli/hooks.rb +4 -2
- data/lib/gooddata/cli/shared.rb +3 -1
- data/lib/gooddata/cli/terminal.rb +16 -0
- data/lib/gooddata/client.rb +28 -22
- data/lib/gooddata/commands/api.rb +43 -26
- data/lib/gooddata/commands/auth.rb +22 -53
- data/lib/gooddata/commands/base.rb +2 -0
- data/lib/gooddata/commands/commands.rb +3 -0
- data/lib/gooddata/commands/datasets.rb +39 -136
- data/lib/gooddata/commands/process.rb +134 -130
- data/lib/gooddata/commands/profile.rb +2 -0
- data/lib/gooddata/commands/projects.rb +91 -129
- data/lib/gooddata/commands/runners.rb +11 -11
- data/lib/gooddata/commands/scaffold.rb +28 -26
- data/lib/gooddata/connection.rb +61 -68
- data/lib/gooddata/core/core.rb +1 -2
- data/lib/gooddata/data/data.rb +7 -0
- data/lib/gooddata/data/guesser.rb +114 -0
- data/lib/gooddata/exceptions/command_failed.rb +7 -0
- data/lib/gooddata/exceptions/exceptions.rb +7 -0
- data/lib/gooddata/{exceptions.rb → exceptions/project_not_found.rb} +2 -2
- data/lib/gooddata/extensions/big_decimal.rb +5 -0
- data/lib/gooddata/extract.rb +2 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +11 -12
- data/lib/gooddata/helpers.rb +49 -35
- data/lib/gooddata/models/attribute.rb +7 -5
- data/lib/gooddata/models/dashboard.rb +44 -45
- data/lib/gooddata/models/data_result.rb +10 -13
- data/lib/gooddata/models/data_set.rb +6 -6
- data/lib/gooddata/models/display_form.rb +4 -4
- data/lib/gooddata/models/empty_result.rb +4 -3
- data/lib/gooddata/models/fact.rb +5 -5
- data/lib/gooddata/models/links.rb +3 -1
- data/lib/gooddata/models/metadata.rb +34 -32
- data/lib/gooddata/models/metric.rb +33 -34
- data/lib/gooddata/models/model.rb +165 -173
- data/lib/gooddata/models/models.rb +3 -0
- data/lib/gooddata/models/process.rb +18 -17
- data/lib/gooddata/models/profile.rb +3 -1
- data/lib/gooddata/models/project.rb +107 -35
- data/lib/gooddata/models/project_metadata.rb +12 -12
- data/lib/gooddata/models/report.rb +31 -30
- data/lib/gooddata/models/report_data_result.rb +22 -19
- data/lib/gooddata/models/report_definition.rb +101 -80
- data/lib/gooddata/version.rb +5 -3
- data/lib/templates/bricks/brick.rb.erb +3 -3
- data/lib/templates/bricks/main.rb.erb +3 -2
- data/lib/templates/project/Goodfile.erb +2 -2
- data/lib/templates/project/model/model.rb.erb +19 -19
- data/spec/data/.gooddata +4 -0
- data/spec/helpers/blueprint_helper.rb +2 -2
- data/spec/helpers/cli_helper.rb +28 -0
- data/spec/helpers/connection_helper.rb +2 -2
- data/spec/integration/command_projects_spec.rb +1 -1
- data/spec/integration/create_from_template_spec.rb +12 -0
- data/spec/integration/full_project_spec.rb +2 -2
- data/spec/integration/partial_md_export_import_spec.rb +36 -0
- data/spec/logging_in_logging_out_spec.rb +1 -1
- data/spec/spec_helper.rb +29 -2
- data/spec/unit/cli/cli_spec.rb +3 -3
- data/spec/unit/cli/commands/cmd_api_spec.rb +21 -4
- data/spec/unit/cli/commands/cmd_auth_spec.rb +2 -4
- data/spec/unit/cli/commands/cmd_process_spec.rb +20 -4
- data/spec/unit/cli/commands/cmd_profile_spec.rb +9 -4
- data/spec/unit/cli/commands/cmd_project_spec.rb +53 -4
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +2 -4
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +14 -4
- data/spec/unit/commands/command_api_spec.rb +21 -2
- data/spec/unit/commands/command_auth_spec.rb +62 -1
- data/spec/unit/commands/command_dataset_spec.rb +31 -3
- data/spec/unit/commands/command_process_spec.rb +75 -1
- data/spec/unit/commands/command_profile_spec.rb +7 -1
- data/spec/unit/commands/command_projects_spec.rb +1 -1
- data/spec/unit/commands/command_scaffold_spec.rb +46 -1
- data/spec/unit/core/connection_spec.rb +1 -0
- data/spec/unit/data/guesser_spec.rb +54 -0
- data/spec/unit/helpers_spec.rb +47 -0
- data/spec/unit/model/schema_builder_spec.rb +2 -0
- data/spec/unit/model/tools_spec.rb +89 -0
- data/test/test_upload.rb +39 -15
- metadata +98 -75
- data/test/test_commands.rb +0 -85
- data/test/test_guessing.rb +0 -46
- data/test/test_model.rb +0 -81
- data/test/test_rest_api_basic.rb +0 -41
data/test/test_commands.rb
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
require 'logger'
|
|
2
|
-
require 'tempfile'
|
|
3
|
-
|
|
4
|
-
require 'helper'
|
|
5
|
-
require 'gooddata/command'
|
|
6
|
-
|
|
7
|
-
GoodData.logger = Logger.new(STDOUT)
|
|
8
|
-
|
|
9
|
-
class TestRestApiBasic < Test::Unit::TestCase
|
|
10
|
-
context "datasets command" do
|
|
11
|
-
SAMPLE_DATASET_CONFIG = {
|
|
12
|
-
"columns" => [
|
|
13
|
-
{
|
|
14
|
-
"type" => "CONNECTION_POINT",
|
|
15
|
-
"name" => "A1",
|
|
16
|
-
"title" =>"A1"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"type" => "ATTRIBUTE",
|
|
20
|
-
"name" => "A2",
|
|
21
|
-
"title" => "A2",
|
|
22
|
-
"folder"=> "Test"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"type" => "FACT",
|
|
26
|
-
"name" => "F2",
|
|
27
|
-
"title" => "F2 \"asdasd\"",
|
|
28
|
-
"folder"=> "Test"
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"title" => "Test"
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
should "list datasets" do
|
|
35
|
-
GoodData::Command.run "datasets", [ "--project", $DEMO_PROJECT ]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
should "apply a dataset model" do
|
|
39
|
-
GoodData::Command.connect
|
|
40
|
-
project = GoodData::Project.create \
|
|
41
|
-
:title => "gooddata-ruby TestRestApi #{Time.new.to_i}", :template => '/projectTemplates/empty/1'
|
|
42
|
-
|
|
43
|
-
Tempfile.open 'gdrb-test-' do |file|
|
|
44
|
-
file.puts SAMPLE_DATASET_CONFIG.to_json
|
|
45
|
-
file.close
|
|
46
|
-
GoodData::Command.run "datasets:apply", [ "--project", project.uri, file.path ]
|
|
47
|
-
end
|
|
48
|
-
project.delete
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
context "projects command" do
|
|
53
|
-
should "list projects" do
|
|
54
|
-
GoodData::Command.run "projects", []
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
context "api command" do
|
|
59
|
-
should "perform a test login" do
|
|
60
|
-
GoodData::Command.run "api:test", []
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
should "get demo project's metadata" do
|
|
64
|
-
GoodData::Command.run "api:get", [ "/gdc/md/#{$DEMO_PROJECT}" ]
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context "profile command" do
|
|
69
|
-
should "show my GoodData profile" do
|
|
70
|
-
GoodData::Command.run "profile", []
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
context "help command" do
|
|
75
|
-
should "print help screen" do
|
|
76
|
-
GoodData::Command.run "help", []
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context "version command" do
|
|
81
|
-
should "print version" do
|
|
82
|
-
GoodData::Command.run "version", []
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
data/test/test_guessing.rb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
require 'helper'
|
|
2
|
-
require 'gooddata/command'
|
|
3
|
-
|
|
4
|
-
class TestGuesser < Test::Unit::TestCase
|
|
5
|
-
should "order LDM types as follows: cp, fact, date, attribute" do
|
|
6
|
-
assert_equal [ :connection_point, :fact, :date, :attribute ], \
|
|
7
|
-
GoodData::Command::Guesser::sort_types([ :fact, :attribute, :connection_point, :date ])
|
|
8
|
-
assert_equal [ :fact ], GoodData::Command::Guesser::sort_types([ :fact ])
|
|
9
|
-
assert_equal [], GoodData::Command::Guesser::sort_types([])
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
should "guess facts, dates and connection points from a simple CSV" do
|
|
13
|
-
csv = [
|
|
14
|
-
[ 'cp', 'a1', 'a2', 'd1', 'd2', 'f'],
|
|
15
|
-
[ '1', 'one', 'huh', '2001-01-02', nil, '-1' ],
|
|
16
|
-
[ '2', 'two', 'blah', nil, '1970-10-23', '2.3' ],
|
|
17
|
-
[ '3', 'three', 'bleh', '0000-00-00', nil, '-3.14159'],
|
|
18
|
-
[ '4', 'one', 'huh', '2010-02-28 08:12:34', '1970-10-23', nil ]
|
|
19
|
-
]
|
|
20
|
-
fields = GoodData::Command::Guesser.new(csv).guess(csv.size + 10)
|
|
21
|
-
|
|
22
|
-
assert_kind_of Hash, fields, "guesser should return a Hash"
|
|
23
|
-
fields.each do |field, info|
|
|
24
|
-
assert_kind_of Array, info, "guess for '%s' is not an Array" % field
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
type_msg_fmt = 'checking guessed types of "%s"'
|
|
28
|
-
|
|
29
|
-
assert_equal GoodData::Command::Guesser::sort_types([
|
|
30
|
-
:connection_point, :fact, :attribute
|
|
31
|
-
]), fields['cp'], type_msg_fmt % 'cp'
|
|
32
|
-
|
|
33
|
-
assert_equal [ :attribute ], fields['a1'], type_msg_fmt % 'a1'
|
|
34
|
-
assert_equal [ :attribute ], fields['a2'], type_msg_fmt % 'a2'
|
|
35
|
-
|
|
36
|
-
assert_equal GoodData::Command::Guesser::sort_types([
|
|
37
|
-
:attribute, :connection_point, :date
|
|
38
|
-
]), fields['d1'], type_msg_fmt % 'd1'
|
|
39
|
-
assert_equal GoodData::Command::Guesser::sort_types([
|
|
40
|
-
:attribute, :date
|
|
41
|
-
]), fields['d2'], type_msg_fmt % 'd2'
|
|
42
|
-
assert_equal GoodData::Command::Guesser::sort_types([
|
|
43
|
-
:attribute, :connection_point, :fact
|
|
44
|
-
]), fields['f'], type_msg_fmt % 'f'
|
|
45
|
-
end
|
|
46
|
-
end
|
data/test/test_model.rb
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
require 'logger'
|
|
3
|
-
|
|
4
|
-
require 'helper'
|
|
5
|
-
require 'gooddata/model'
|
|
6
|
-
require 'gooddata/command'
|
|
7
|
-
|
|
8
|
-
GoodData.logger = Logger.new(STDOUT)
|
|
9
|
-
|
|
10
|
-
class TestModel < Test::Unit::TestCase
|
|
11
|
-
COLUMNS = [
|
|
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
|
-
]
|
|
19
|
-
SCHEMA = GoodData::Model::Schema.new 'title' => 'test', 'columns' => COLUMNS
|
|
20
|
-
|
|
21
|
-
context "GoodData model tools" do
|
|
22
|
-
# Initialize a GoodData connection using the credential
|
|
23
|
-
# stored in ~/.gooddata
|
|
24
|
-
setup do
|
|
25
|
-
GoodData::Command::connect
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
should "generate identifiers star ting with letters and without ugly characters" do
|
|
29
|
-
assert_equal 'fact.test.blah', GoodData::Model::Fact.new({ 'name' => 'blah' }, SCHEMA).identifier
|
|
30
|
-
assert_equal 'attr.test.blah', GoodData::Model::Attribute.new({ 'name' => '1_2_3 blah' }, SCHEMA).identifier
|
|
31
|
-
assert_equal 'dim.blaz', GoodData::Model::AttributeFolder.new(' b*ĺ*á#ž$').identifier
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
should "create a simple model in a sandbox project using Model.add_dataset" do
|
|
35
|
-
project = GoodData::Project.create :title => "gooddata-ruby test #{Time.new.to_i}"
|
|
36
|
-
GoodData.use project
|
|
37
|
-
objects = GoodData::Model.add_dataset 'Mrkev', COLUMNS
|
|
38
|
-
|
|
39
|
-
uris = objects['uris']
|
|
40
|
-
assert_equal "#{project.md['obj']}/1", uris[0]
|
|
41
|
-
# fetch last object (temporary objects can be placed at the begining of the list)
|
|
42
|
-
GoodData.get uris[uris.length - 1]
|
|
43
|
-
|
|
44
|
-
# created model should define SLI interface on the 'Mrkev' data set
|
|
45
|
-
# TODO move this into a standalone test covering gooddata/metadata.rb
|
|
46
|
-
ds = GoodData::DataSet['dataset.mrkev']
|
|
47
|
-
assert_not_nil ds
|
|
48
|
-
|
|
49
|
-
project.delete
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
should "create a simple model with no CP in a sandbox project using Model.add_dataset" do
|
|
53
|
-
project = GoodData::Project.create :title => "gooddata-ruby test #{Time.new.to_i}"
|
|
54
|
-
GoodData.use project
|
|
55
|
-
|
|
56
|
-
# create a similar data set but without the connection point column
|
|
57
|
-
cols_no_cp = COLUMNS.select { |c| c['type'] != 'CONNECTION_POINT' }
|
|
58
|
-
objects = GoodData::Model.add_dataset 'No CP', cols_no_cp
|
|
59
|
-
uris = objects['uris']
|
|
60
|
-
|
|
61
|
-
# Repeat check of metadata objects expected to be created on the server side
|
|
62
|
-
GoodData.get uris[uris.length - 1]
|
|
63
|
-
ds = GoodData::DataSet['dataset.nocp']
|
|
64
|
-
assert_not_nil ds
|
|
65
|
-
|
|
66
|
-
# clean-up
|
|
67
|
-
project.delete
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
should "create a simple model in a sandbox project using project.model.add_dataset" do
|
|
71
|
-
project = GoodData::Project.create :title => "gooddata-ruby test #{Time.new.to_i}"
|
|
72
|
-
objects = project.add_dataset 'Mrkev', COLUMNS
|
|
73
|
-
|
|
74
|
-
uris = objects['uris']
|
|
75
|
-
assert_equal "#{project.md['obj']}/1", uris[0]
|
|
76
|
-
# fetch last object (temporary objects can be placed at the begining of the list)
|
|
77
|
-
GoodData.get uris[uris.length - 1]
|
|
78
|
-
project.delete
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
data/test/test_rest_api_basic.rb
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require 'logger'
|
|
2
|
-
|
|
3
|
-
require 'helper'
|
|
4
|
-
require 'gooddata/command'
|
|
5
|
-
|
|
6
|
-
GoodData.logger = Logger.new(STDOUT)
|
|
7
|
-
|
|
8
|
-
class TestRestApiBasic < Test::Unit::TestCase
|
|
9
|
-
context "GoodData REST Client" do
|
|
10
|
-
# Initialize a GoodData connection using the credential
|
|
11
|
-
# stored in ~/.gooddata
|
|
12
|
-
setup do
|
|
13
|
-
GoodData::Command::connect
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
should "get the demo project" do
|
|
17
|
-
p_by_hash = GoodData::Project[$DEMO_PROJECT]
|
|
18
|
-
p_by_uri = GoodData::Project["/gdc/projects/#{$DEMO_PROJECT}"]
|
|
19
|
-
p_by_md_uri = GoodData::Project["/gdc/md/#{$DEMO_PROJECT}"]
|
|
20
|
-
assert_not_nil p_by_hash
|
|
21
|
-
assert_equal p_by_hash.uri, p_by_uri.uri
|
|
22
|
-
assert_equal p_by_hash.title, p_by_uri.title
|
|
23
|
-
assert_equal p_by_hash.title, p_by_md_uri.title
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
should "connect to the demo project" do
|
|
27
|
-
GoodData.use $DEMO_PROJECT
|
|
28
|
-
GoodData.project.datasets # should not fail on unknown project or access denied
|
|
29
|
-
# TODO: should be equal to Dataset.all once implemented
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Not supported yet
|
|
33
|
-
# should "fetch dataset by numerical or string identifier" do
|
|
34
|
-
# GoodData.use $DEMO_PROJECT
|
|
35
|
-
# ds_by_hash = Dataset['amJoIYHjgESv']
|
|
36
|
-
# ds_by_id = Dataset[34]
|
|
37
|
-
# assert_not_nil ds_by_hash
|
|
38
|
-
# assert_equal ds_by_hash.uri, ds_by_id.uri
|
|
39
|
-
# end
|
|
40
|
-
end
|
|
41
|
-
end
|