gooddata 0.6.0.pre11 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/spec/data/.gooddata
ADDED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Global requires
|
2
|
-
require '
|
2
|
+
require 'multi_json'
|
3
3
|
|
4
4
|
# Local requires
|
5
5
|
require 'gooddata/models/models'
|
@@ -11,7 +11,7 @@ module BlueprintHelper
|
|
11
11
|
|
12
12
|
# TODO: Try to load as relative path if failed
|
13
13
|
|
14
|
-
parsed =
|
14
|
+
parsed = MultiJson.load(raw, :symbolize_keys => true)
|
15
15
|
return GoodData::Model::ProjectBlueprint.new(parsed)
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'gooddata/cli/cli'
|
2
|
+
|
3
|
+
module CliHelper
|
4
|
+
# Execute block and capture its stdou
|
5
|
+
# @param block Block to be executed with stdout redirected
|
6
|
+
# @returns Captured output as string
|
7
|
+
def capture_stdout(&block)
|
8
|
+
original_stdout = $stdout
|
9
|
+
$stdout = fake = StringIO.new
|
10
|
+
begin
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
$stdout = original_stdout
|
14
|
+
end
|
15
|
+
fake.string
|
16
|
+
end
|
17
|
+
|
18
|
+
# Run CLI with arguments and return captured stdout
|
19
|
+
# @param args Arguments
|
20
|
+
# @return Captured stdout
|
21
|
+
def run_cli(args = [])
|
22
|
+
old = $0
|
23
|
+
$0 = 'gooddata'
|
24
|
+
res = capture_stdout { GoodData::CLI.main(args) }
|
25
|
+
$0 = old
|
26
|
+
res
|
27
|
+
end
|
28
|
+
end
|
@@ -2,11 +2,11 @@ require 'gooddata/connection'
|
|
2
2
|
|
3
3
|
module ConnectionHelper
|
4
4
|
GD_PROJECT_TOKEN = ENV["GD_PROJECT_TOKEN"]
|
5
|
-
DEFAULT_USERNAME = "svarovsky+gem_tester@
|
5
|
+
DEFAULT_USERNAME = "svarovsky+gem_tester@gooddata.com"
|
6
6
|
DEFAULT_PASSWORD = "jindrisska"
|
7
7
|
|
8
8
|
def self.create_default_connection(username = DEFAULT_USERNAME, password = DEFAULT_PASSWORD)
|
9
|
-
GoodData::
|
9
|
+
GoodData::connect(username, password)
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
@@ -7,7 +7,7 @@ describe GoodData::Command::Projects, :constraint => 'slow' do
|
|
7
7
|
@blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/test_project_model_spec.json")
|
8
8
|
@module_blueprint = GoodData::Model::ProjectBlueprint.from_json("./spec/data/additional_dataset_module.json")
|
9
9
|
|
10
|
-
|
10
|
+
ConnectionHelper::create_default_connection
|
11
11
|
@project = GoodData::Command::Projects.build({:spec => @blueprint, :token => GD_PROJECT_TOKEN})
|
12
12
|
end
|
13
13
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'gooddata'
|
2
|
+
|
3
|
+
describe "Spin a project from template", :constraint => 'slow' do
|
4
|
+
before(:all) do
|
5
|
+
ConnectionHelper::create_default_connection
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should spin a project from a template that does not exist. It should throw an error" do
|
9
|
+
expect{GoodData::Project.create(:title => "Test project", :template => "/some/nonexisting/tempalte/uri", :auth_token => ENV['GD_PROJECT_TOKEN'])}.to raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -2,8 +2,8 @@ require 'gooddata'
|
|
2
2
|
|
3
3
|
describe "Spin a project", :constraint => 'slow' do
|
4
4
|
before(:all) do
|
5
|
-
spec =
|
6
|
-
|
5
|
+
spec = MultiJson.load(File.read("./spec/data/test_project_model_spec.json"), :symbolize_keys => true)
|
6
|
+
ConnectionHelper::create_default_connection
|
7
7
|
|
8
8
|
@project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => GD_PROJECT_TOKEN})
|
9
9
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'gooddata'
|
2
|
+
|
3
|
+
describe "Spin a project", :constraint => 'slow' do
|
4
|
+
before(:all) do
|
5
|
+
spec = MultiJson.load(File.read("./spec/data/test_project_model_spec.json"), :symbolize_keys => true)
|
6
|
+
ConnectionHelper::create_default_connection
|
7
|
+
|
8
|
+
@source_project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => GD_PROJECT_TOKEN})
|
9
|
+
@target_project = GoodData::Model::ProjectCreator.migrate({:spec => spec, :token => GD_PROJECT_TOKEN})
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:all) do
|
13
|
+
@source_project.delete unless @source_project.nil?
|
14
|
+
@target_project.delete unless @target_project.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should transfer a metric" do
|
18
|
+
GoodData.with_project(@source_project) do |p|
|
19
|
+
f = GoodData::Fact.find_first_by_title('Lines changed')
|
20
|
+
metric_title = "Testing metric to be exported"
|
21
|
+
metric = GoodData::Metric.xcreate(:expression => "SELECT SUM(#\"#{f.title}\")", :title => metric_title)
|
22
|
+
metric.save
|
23
|
+
|
24
|
+
GoodData.with_project(@target_project) {|p| GoodData::Metric[:all].count.should == 0}
|
25
|
+
p.partial_md_export([metric.uri], :project => @target_project)
|
26
|
+
GoodData.with_project(@target_project) do |p|
|
27
|
+
GoodData::Metric[:all].count.should == 1
|
28
|
+
metric = GoodData::Metric.find_first_by_title(metric_title)
|
29
|
+
metric.should_not be_nil
|
30
|
+
metric.title.should == metric_title
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -5,7 +5,7 @@ describe GoodData::Connection, :constraint => 'slow' do
|
|
5
5
|
|
6
6
|
it "should log in and disconnect" do
|
7
7
|
|
8
|
-
|
8
|
+
ConnectionHelper::create_default_connection
|
9
9
|
GoodData.get("/gdc/md")
|
10
10
|
|
11
11
|
conn = GoodData.connection
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,38 @@
|
|
1
|
+
require 'simplecov'
|
1
2
|
require 'rspec'
|
3
|
+
require 'coveralls'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
Coveralls.wear!
|
2
7
|
|
3
8
|
# Automagically include all helpers/*_helper.rb
|
4
9
|
|
5
|
-
|
6
|
-
|
10
|
+
base = Pathname(__FILE__).dirname.expand_path
|
11
|
+
Dir.glob(base + 'helpers/*_helper.rb').each do |file|
|
12
|
+
require file
|
13
|
+
end
|
7
14
|
|
8
15
|
RSpec.configure do |config|
|
9
16
|
include BlueprintHelper
|
17
|
+
include CliHelper
|
10
18
|
include ConnectionHelper
|
11
19
|
end
|
20
|
+
|
21
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
22
|
+
SimpleCov::Formatter::HTMLFormatter,
|
23
|
+
Coveralls::SimpleCov::Formatter
|
24
|
+
]
|
25
|
+
|
26
|
+
SimpleCov.start do
|
27
|
+
add_filter 'spec/'
|
28
|
+
add_filter 'test/'
|
29
|
+
|
30
|
+
add_group 'Bricks', 'lib/gooddata/bricks'
|
31
|
+
add_group 'CLI', 'lib/gooddata/cli'
|
32
|
+
add_group 'Commands', 'lib/gooddata/commands'
|
33
|
+
add_group 'Core', 'lib/gooddata/core'
|
34
|
+
add_group 'Exceptions', 'lib/gooddata/exceptions'
|
35
|
+
add_group 'Extensions', 'lib/gooddata/extensions'
|
36
|
+
add_group 'Goodzilla', 'lib/gooddata/goodzilla'
|
37
|
+
add_group 'Models', 'lib/gooddata/models'
|
38
|
+
end
|
data/spec/unit/cli/cli_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'gooddata/cli/cli'
|
2
2
|
|
3
3
|
describe GoodData::CLI do
|
4
|
-
it
|
4
|
+
it 'Has GoodData::CLI class' do
|
5
5
|
GoodData::CLI.should_not == nil
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
|
8
|
+
it 'Has GoodData::CLI::main() working' do
|
9
|
+
run_cli
|
10
10
|
end
|
11
11
|
end
|
@@ -2,10 +2,27 @@ require 'gooddata/cli/cli'
|
|
2
2
|
|
3
3
|
describe GoodData::CLI do
|
4
4
|
it "Has working 'api' command" do
|
5
|
-
args =
|
6
|
-
'api'
|
7
|
-
]
|
5
|
+
args = %w(api)
|
8
6
|
|
9
|
-
|
7
|
+
out = run_cli(args)
|
8
|
+
out.should include("Command 'api' requires a subcommand info,get")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "Has working 'api info' command" do
|
12
|
+
args = %w(api info)
|
13
|
+
|
14
|
+
run_cli(args)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "Has working 'api get' command" do
|
18
|
+
args = %w(api get)
|
19
|
+
|
20
|
+
run_cli(args)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "Has working 'api get /gdc' command" do
|
24
|
+
args = %w(api get /gdc)
|
25
|
+
|
26
|
+
run_cli(args)
|
10
27
|
end
|
11
28
|
end
|
@@ -2,10 +2,26 @@ require 'gooddata/cli/cli'
|
|
2
2
|
|
3
3
|
describe GoodData::CLI do
|
4
4
|
it "Has working 'process' command" do
|
5
|
-
args =
|
6
|
-
'process'
|
7
|
-
]
|
5
|
+
args = %w(process)
|
8
6
|
|
9
|
-
|
7
|
+
run_cli(args)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "Has working 'process deploy' command" do
|
11
|
+
args = %w(process deploy)
|
12
|
+
|
13
|
+
run_cli(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "Has working 'process get' command" do
|
17
|
+
args = %w(process get)
|
18
|
+
|
19
|
+
run_cli(args)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "Has working 'process list' command" do
|
23
|
+
args = %w(process list)
|
24
|
+
|
25
|
+
run_cli(args)
|
10
26
|
end
|
11
27
|
end
|
@@ -2,10 +2,15 @@ require 'gooddata/cli/cli'
|
|
2
2
|
|
3
3
|
describe GoodData::CLI do
|
4
4
|
it "Has working 'profile' command" do
|
5
|
-
args =
|
6
|
-
'profile'
|
7
|
-
]
|
5
|
+
args = %w(profile)
|
8
6
|
|
9
|
-
|
7
|
+
out = run_cli(args)
|
8
|
+
out.should include("Command 'profile' requires a subcommand show")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "Has working 'profile show' command" do
|
12
|
+
args = %w(profile show)
|
13
|
+
|
14
|
+
run_cli(args)
|
10
15
|
end
|
11
16
|
end
|
@@ -2,10 +2,59 @@ require 'gooddata/cli/cli'
|
|
2
2
|
|
3
3
|
describe GoodData::CLI do
|
4
4
|
it "Has working 'project' command" do
|
5
|
-
args =
|
6
|
-
'project'
|
7
|
-
]
|
5
|
+
args = %w(project)
|
8
6
|
|
9
|
-
|
7
|
+
run_cli(args)
|
10
8
|
end
|
9
|
+
|
10
|
+
it "Has working 'project build' command" do
|
11
|
+
args = %w(project build)
|
12
|
+
|
13
|
+
run_cli(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "Has working 'project clone' command" do
|
17
|
+
args = %w(project clone)
|
18
|
+
|
19
|
+
run_cli(args)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "Has working 'project create' command" do
|
23
|
+
args = %w(project create)
|
24
|
+
|
25
|
+
# TODO: Pass all required args to prevent interaction
|
26
|
+
# TODO: Investigate, fix and enable execution
|
27
|
+
# run_cli(args)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "Has working 'project delete' command" do
|
31
|
+
args = %w(project delete)
|
32
|
+
|
33
|
+
run_cli(args)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "Has working 'project jack_in' command" do
|
37
|
+
args = %w(project jack_in)
|
38
|
+
|
39
|
+
run_cli(args)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "Has working 'project list' command" do
|
43
|
+
args = %w(project list)
|
44
|
+
|
45
|
+
run_cli(args)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "Has working 'project show' command" do
|
49
|
+
args = %w(project show)
|
50
|
+
|
51
|
+
run_cli(args)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "Has working 'project update' command" do
|
55
|
+
args = %w(project update)
|
56
|
+
|
57
|
+
run_cli(args)
|
58
|
+
end
|
59
|
+
|
11
60
|
end
|
@@ -2,10 +2,20 @@ require 'gooddata/cli/cli'
|
|
2
2
|
|
3
3
|
describe GoodData::CLI do
|
4
4
|
it "Has working 'scaffold' command" do
|
5
|
-
args =
|
6
|
-
'scaffold'
|
7
|
-
]
|
5
|
+
args = %w(scaffold)
|
8
6
|
|
9
|
-
|
7
|
+
run_cli(args)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "Has working 'scaffold brick' command" do
|
11
|
+
args = %w(scaffold brick)
|
12
|
+
|
13
|
+
run_cli(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "Has working 'scaffold project' command" do
|
17
|
+
args = %w(scaffold project)
|
18
|
+
|
19
|
+
run_cli(args)
|
10
20
|
end
|
11
21
|
end
|
@@ -2,11 +2,30 @@ require 'gooddata/commands/api'
|
|
2
2
|
|
3
3
|
describe GoodData::Command::Api do
|
4
4
|
before(:each) do
|
5
|
-
|
5
|
+
ConnectionHelper::create_default_connection
|
6
6
|
end
|
7
7
|
|
8
|
-
it "Is Possible to create GoodData::Command::
|
8
|
+
it "Is Possible to create GoodData::Command::Api instance" do
|
9
9
|
cmd = GoodData::Command::Api.new()
|
10
10
|
cmd.should be_a(GoodData::Command::Api)
|
11
11
|
end
|
12
|
+
|
13
|
+
describe "#get" do
|
14
|
+
it "Call without arguments" do
|
15
|
+
GoodData::Command::Api.test()
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#delete" do
|
20
|
+
it "Call without arguments" do
|
21
|
+
GoodData::Command::Api.test()
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#test" do
|
26
|
+
it "Call without arguments" do
|
27
|
+
GoodData::Command::Api.test()
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
12
31
|
end
|