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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -1
  3. data/.yardopts +2 -0
  4. data/README.md +6 -3
  5. data/Rakefile +24 -7
  6. data/gooddata +2 -2
  7. data/gooddata.gemspec +4 -3
  8. data/lib/gooddata.rb +17 -12
  9. data/lib/gooddata/bricks/base_downloader.rb +7 -7
  10. data/lib/gooddata/bricks/brick.rb +7 -8
  11. data/lib/gooddata/bricks/bricks.rb +4 -1
  12. data/lib/gooddata/bricks/middleware/base_middleware.rb +2 -2
  13. data/lib/gooddata/bricks/middleware/bench_middleware.rb +5 -6
  14. data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +21 -22
  15. data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +3 -4
  16. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +14 -14
  17. data/lib/gooddata/bricks/middleware/logger_middleware.rb +6 -6
  18. data/lib/gooddata/bricks/middleware/middleware.rb +4 -1
  19. data/lib/gooddata/bricks/middleware/restforce_middleware.rb +29 -32
  20. data/lib/gooddata/bricks/middleware/stdout_middleware.rb +5 -5
  21. data/lib/gooddata/bricks/middleware/twitter_middleware.rb +6 -8
  22. data/lib/gooddata/bricks/utils.rb +3 -3
  23. data/lib/gooddata/cli/cli.rb +4 -2
  24. data/lib/gooddata/cli/commands/api_cmd.rb +6 -4
  25. data/lib/gooddata/cli/commands/auth_cmd.rb +5 -3
  26. data/lib/gooddata/cli/commands/console_cmd.rb +1 -1
  27. data/lib/gooddata/cli/commands/process_cmd.rb +6 -4
  28. data/lib/gooddata/cli/commands/profile_cmd.rb +5 -3
  29. data/lib/gooddata/cli/commands/project_cmd.rb +24 -22
  30. data/lib/gooddata/cli/commands/run_ruby_cmd.rb +12 -10
  31. data/lib/gooddata/cli/commands/scaffold_cmd.rb +8 -6
  32. data/lib/gooddata/cli/hooks.rb +4 -2
  33. data/lib/gooddata/cli/shared.rb +3 -1
  34. data/lib/gooddata/cli/terminal.rb +16 -0
  35. data/lib/gooddata/client.rb +28 -22
  36. data/lib/gooddata/commands/api.rb +43 -26
  37. data/lib/gooddata/commands/auth.rb +22 -53
  38. data/lib/gooddata/commands/base.rb +2 -0
  39. data/lib/gooddata/commands/commands.rb +3 -0
  40. data/lib/gooddata/commands/datasets.rb +39 -136
  41. data/lib/gooddata/commands/process.rb +134 -130
  42. data/lib/gooddata/commands/profile.rb +2 -0
  43. data/lib/gooddata/commands/projects.rb +91 -129
  44. data/lib/gooddata/commands/runners.rb +11 -11
  45. data/lib/gooddata/commands/scaffold.rb +28 -26
  46. data/lib/gooddata/connection.rb +61 -68
  47. data/lib/gooddata/core/core.rb +1 -2
  48. data/lib/gooddata/data/data.rb +7 -0
  49. data/lib/gooddata/data/guesser.rb +114 -0
  50. data/lib/gooddata/exceptions/command_failed.rb +7 -0
  51. data/lib/gooddata/exceptions/exceptions.rb +7 -0
  52. data/lib/gooddata/{exceptions.rb → exceptions/project_not_found.rb} +2 -2
  53. data/lib/gooddata/extensions/big_decimal.rb +5 -0
  54. data/lib/gooddata/extract.rb +2 -0
  55. data/lib/gooddata/goodzilla/goodzilla.rb +11 -12
  56. data/lib/gooddata/helpers.rb +49 -35
  57. data/lib/gooddata/models/attribute.rb +7 -5
  58. data/lib/gooddata/models/dashboard.rb +44 -45
  59. data/lib/gooddata/models/data_result.rb +10 -13
  60. data/lib/gooddata/models/data_set.rb +6 -6
  61. data/lib/gooddata/models/display_form.rb +4 -4
  62. data/lib/gooddata/models/empty_result.rb +4 -3
  63. data/lib/gooddata/models/fact.rb +5 -5
  64. data/lib/gooddata/models/links.rb +3 -1
  65. data/lib/gooddata/models/metadata.rb +34 -32
  66. data/lib/gooddata/models/metric.rb +33 -34
  67. data/lib/gooddata/models/model.rb +165 -173
  68. data/lib/gooddata/models/models.rb +3 -0
  69. data/lib/gooddata/models/process.rb +18 -17
  70. data/lib/gooddata/models/profile.rb +3 -1
  71. data/lib/gooddata/models/project.rb +107 -35
  72. data/lib/gooddata/models/project_metadata.rb +12 -12
  73. data/lib/gooddata/models/report.rb +31 -30
  74. data/lib/gooddata/models/report_data_result.rb +22 -19
  75. data/lib/gooddata/models/report_definition.rb +101 -80
  76. data/lib/gooddata/version.rb +5 -3
  77. data/lib/templates/bricks/brick.rb.erb +3 -3
  78. data/lib/templates/bricks/main.rb.erb +3 -2
  79. data/lib/templates/project/Goodfile.erb +2 -2
  80. data/lib/templates/project/model/model.rb.erb +19 -19
  81. data/spec/data/.gooddata +4 -0
  82. data/spec/helpers/blueprint_helper.rb +2 -2
  83. data/spec/helpers/cli_helper.rb +28 -0
  84. data/spec/helpers/connection_helper.rb +2 -2
  85. data/spec/integration/command_projects_spec.rb +1 -1
  86. data/spec/integration/create_from_template_spec.rb +12 -0
  87. data/spec/integration/full_project_spec.rb +2 -2
  88. data/spec/integration/partial_md_export_import_spec.rb +36 -0
  89. data/spec/logging_in_logging_out_spec.rb +1 -1
  90. data/spec/spec_helper.rb +29 -2
  91. data/spec/unit/cli/cli_spec.rb +3 -3
  92. data/spec/unit/cli/commands/cmd_api_spec.rb +21 -4
  93. data/spec/unit/cli/commands/cmd_auth_spec.rb +2 -4
  94. data/spec/unit/cli/commands/cmd_process_spec.rb +20 -4
  95. data/spec/unit/cli/commands/cmd_profile_spec.rb +9 -4
  96. data/spec/unit/cli/commands/cmd_project_spec.rb +53 -4
  97. data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +2 -4
  98. data/spec/unit/cli/commands/cmd_scaffold_spec.rb +14 -4
  99. data/spec/unit/commands/command_api_spec.rb +21 -2
  100. data/spec/unit/commands/command_auth_spec.rb +62 -1
  101. data/spec/unit/commands/command_dataset_spec.rb +31 -3
  102. data/spec/unit/commands/command_process_spec.rb +75 -1
  103. data/spec/unit/commands/command_profile_spec.rb +7 -1
  104. data/spec/unit/commands/command_projects_spec.rb +1 -1
  105. data/spec/unit/commands/command_scaffold_spec.rb +46 -1
  106. data/spec/unit/core/connection_spec.rb +1 -0
  107. data/spec/unit/data/guesser_spec.rb +54 -0
  108. data/spec/unit/helpers_spec.rb +47 -0
  109. data/spec/unit/model/schema_builder_spec.rb +2 -0
  110. data/spec/unit/model/tools_spec.rb +89 -0
  111. data/test/test_upload.rb +39 -15
  112. metadata +98 -75
  113. data/test/test_commands.rb +0 -85
  114. data/test/test_guessing.rb +0 -46
  115. data/test/test_model.rb +0 -81
  116. data/test/test_rest_api_basic.rb +0 -41
@@ -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
@@ -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
@@ -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