gooddata 0.6.0.pre10 → 0.6.0.pre11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +2 -0
  3. data/.gitignore +3 -0
  4. data/.travis.yml +7 -0
  5. data/.yardopts +3 -2
  6. data/README.md +8 -145
  7. data/Rakefile +23 -6
  8. data/bin/gooddata +3 -400
  9. data/doc/pages/GET_STARTED.md +5 -4
  10. data/doc/pages/HOMEPAGE.md +2 -0
  11. data/doc/pages/TUTORIALS.md +3 -3
  12. data/doc/pages/tutorial/BRICKS.md +4 -1
  13. data/doc/pages/tutorial/CREATING_A_MODEL.md +2 -0
  14. data/doc/pages/tutorial/CRUNCHING_NUMBERS.md +1 -3
  15. data/doc/pages/tutorial/TEST_DRIVEN_DEVELOPMENT.md +2 -0
  16. data/doc/pages/tutorial/YOUR_FIRST_PROJECT.md +4 -3
  17. data/doc/templates/default/class/setup.rb +1 -0
  18. data/doc/templates/default/method_details/setup.rb +2 -1
  19. data/doc/templates/default/module/setup.rb +1 -1
  20. data/gooddata +7 -0
  21. data/gooddata.gemspec +1 -0
  22. data/lib/gooddata.rb +15 -4
  23. data/lib/gooddata/bricks/base_downloader.rb +1 -0
  24. data/lib/gooddata/bricks/brick.rb +17 -12
  25. data/lib/gooddata/bricks/bricks.rb +7 -0
  26. data/lib/gooddata/bricks/middleware/base_middleware.rb +13 -0
  27. data/lib/gooddata/bricks/middleware/bench_middleware.rb +1 -0
  28. data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +2 -1
  29. data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +30 -0
  30. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +10 -8
  31. data/lib/gooddata/bricks/middleware/logger_middleware.rb +3 -2
  32. data/lib/gooddata/bricks/middleware/middleware.rb +4 -11
  33. data/lib/gooddata/bricks/middleware/restforce_middleware.rb +2 -0
  34. data/lib/gooddata/bricks/middleware/stdout_middleware.rb +2 -0
  35. data/lib/gooddata/bricks/middleware/twitter_middleware.rb +2 -0
  36. data/lib/gooddata/cli/cli.rb +28 -0
  37. data/lib/gooddata/cli/commands/api_cmd.rb +30 -0
  38. data/lib/gooddata/cli/commands/auth_cmd.rb +17 -0
  39. data/lib/gooddata/cli/commands/console_cmd.rb +17 -0
  40. data/lib/gooddata/cli/commands/process_cmd.rb +55 -0
  41. data/lib/gooddata/cli/commands/profile_cmd.rb +22 -0
  42. data/lib/gooddata/cli/commands/project_cmd.rb +143 -0
  43. data/lib/gooddata/cli/commands/run_ruby_cmd.rb +55 -0
  44. data/lib/gooddata/cli/commands/scaffold_cmd.rb +32 -0
  45. data/lib/gooddata/cli/hooks.rb +43 -0
  46. data/lib/gooddata/cli/shared.rb +51 -0
  47. data/lib/gooddata/client.rb +37 -24
  48. data/lib/gooddata/commands/api.rb +1 -0
  49. data/lib/gooddata/commands/auth.rb +8 -4
  50. data/lib/gooddata/commands/base.rb +2 -80
  51. data/lib/gooddata/commands/commands.rb +4 -9
  52. data/lib/gooddata/commands/datasets.rb +1 -1
  53. data/lib/gooddata/commands/runners.rb +6 -7
  54. data/lib/gooddata/connection.rb +40 -35
  55. data/lib/gooddata/core/core.rb +8 -0
  56. data/lib/gooddata/exceptions.rb +1 -1
  57. data/lib/gooddata/goodzilla/goodzilla.rb +12 -0
  58. data/lib/gooddata/models/attribute.rb +2 -0
  59. data/lib/gooddata/models/dashboard.rb +9 -2
  60. data/lib/gooddata/models/data_result.rb +3 -256
  61. data/lib/gooddata/models/data_set.rb +2 -0
  62. data/lib/gooddata/models/display_form.rb +2 -0
  63. data/lib/gooddata/models/empty_result.rb +37 -0
  64. data/lib/gooddata/models/fact.rb +2 -0
  65. data/lib/gooddata/models/metadata.rb +6 -1
  66. data/lib/gooddata/models/metric.rb +2 -1
  67. data/lib/gooddata/{model.rb → models/model.rb} +1 -1
  68. data/lib/gooddata/models/models.rb +4 -0
  69. data/lib/gooddata/models/project.rb +10 -6
  70. data/lib/gooddata/models/report.rb +6 -0
  71. data/lib/gooddata/models/report_data_result.rb +167 -0
  72. data/lib/gooddata/models/report_definition.rb +2 -0
  73. data/lib/gooddata/version.rb +15 -1
  74. data/spec/bricks/bricks_spec.rb +39 -0
  75. data/spec/helpers/blueprint_helper.rb +1 -1
  76. data/spec/helpers/connection_helper.rb +12 -0
  77. data/spec/{project_build_and_update_spec.rb → integration/command_projects_spec.rb} +0 -3
  78. data/spec/{full_project_spec.rb → integration/full_project_spec.rb} +0 -3
  79. data/spec/logging_in_logging_out_spec.rb +17 -0
  80. data/spec/spec_helper.rb +6 -1
  81. data/spec/unit/bricks/bricks_spec.rb +23 -0
  82. data/spec/unit/bricks/middleware/bench_middleware_spec.rb +9 -0
  83. data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +9 -0
  84. data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +9 -0
  85. data/spec/unit/bricks/middleware/logger_middleware_spec.rb +9 -0
  86. data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +9 -0
  87. data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +9 -0
  88. data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +9 -0
  89. data/spec/unit/cli/cli_spec.rb +11 -0
  90. data/spec/unit/cli/commands/cmd_api_spec.rb +11 -0
  91. data/spec/unit/cli/commands/cmd_auth_spec.rb +11 -0
  92. data/spec/unit/cli/commands/cmd_process_spec.rb +11 -0
  93. data/spec/unit/cli/commands/cmd_profile_spec.rb +11 -0
  94. data/spec/unit/cli/commands/cmd_project_spec.rb +11 -0
  95. data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +11 -0
  96. data/spec/unit/cli/commands/cmd_scaffold_spec.rb +11 -0
  97. data/spec/unit/commands/command_api_spec.rb +12 -0
  98. data/spec/unit/commands/command_auth_spec.rb +12 -0
  99. data/spec/unit/commands/command_dataset_spec.rb +12 -0
  100. data/spec/unit/commands/command_process_spec.rb +12 -0
  101. data/spec/unit/commands/command_profile_spec.rb +12 -0
  102. data/spec/unit/commands/command_projects_spec.rb +12 -0
  103. data/spec/unit/commands/command_scaffold_spec.rb +12 -0
  104. data/spec/unit/core/connection_spec.rb +25 -0
  105. data/spec/unit/core/core_spec.rb +7 -0
  106. data/spec/{goodzilla_spec.rb → unit/godzilla/goodzilla_spec.rb} +0 -0
  107. data/spec/{blueprint_spec.rb → unit/model/blueprint_spec.rb} +3 -3
  108. data/spec/{merging_blueprints_spec.rb → unit/model/model_spec.rb} +28 -26
  109. data/spec/{model_spec.rb → unit/model/project_blueprint_spec.rb} +0 -0
  110. data/spec/{model_dsl_spec.rb → unit/model/schema_builder_spec.rb} +1 -1
  111. metadata +77 -61
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), "../shared")
2
+ require File.join(File.dirname(__FILE__), "../../commands/auth")
3
+
4
+ GoodData::CLI.module_eval do
5
+
6
+ desc 'Work with your locally stored credentials'
7
+ command :auth do |c|
8
+
9
+ c.desc "Store your credentials to ~/.gooddata so client does not have to ask you every single time"
10
+ c.command :store do |store|
11
+ store.action do |global_options, options, args|
12
+ GoodData::Command::Auth.store
13
+ end
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'pp'
2
+
3
+ require File.join(File.dirname(__FILE__), "../shared")
4
+
5
+ GoodData::CLI.module_eval do
6
+ desc 'Interactive session with gooddata sdk loaded'
7
+ command :console do |c|
8
+
9
+ c.action do |global_options, options, args|
10
+ puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
11
+ binding.pry(:quiet => true,
12
+ :prompt => [proc { |target_self, nest_level, pry|
13
+ "sdk_live_sesion: "
14
+ }])
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,55 @@
1
+ require 'pp'
2
+
3
+ require File.join(File.dirname(__FILE__), "../shared")
4
+ require File.join(File.dirname(__FILE__), "../../commands/process")
5
+
6
+ GoodData::CLI.module_eval do
7
+
8
+ desc 'Work with deployed processes'
9
+ arg_name 'Describe arguments to list here'
10
+ command :process do |c|
11
+
12
+ c.desc 'Use when you need to redeploy a specific process'
13
+ c.default_value nil
14
+ c.flag :process_id
15
+
16
+ c.desc 'Specify directory for deployment'
17
+ c.default_value nil
18
+ c.flag :dir
19
+
20
+ c.desc 'Specify type of deployment'
21
+ c.default_value nil
22
+ c.flag :type
23
+
24
+ c.desc 'Specify name of deployed process'
25
+ c.default_value nil
26
+ c.flag :name
27
+
28
+ c.desc "Lists all user's processes deployed on the plaform"
29
+ c.command :list do |list|
30
+ list.action do |global_options, options, args|
31
+ opts = options.merge(global_options)
32
+ GoodData.connect(opts)
33
+ pp GoodData::Command::Process.list(options.merge(global_options))
34
+ end
35
+ end
36
+
37
+ c.desc "Gives you some basic info about the process"
38
+ c.command :get do |get|
39
+ get.action do |global_options, options, args|
40
+ opts = options.merge(global_options)
41
+ GoodData.connect(opts)
42
+ pp GoodData::Command::Process.get(options.merge(global_options))
43
+ end
44
+ end
45
+
46
+ c.desc "Deploys provided directory to the server"
47
+ c.command :deploy do |deploy|
48
+ deploy.action do |global_options, options, args|
49
+ opts = options.merge(global_options)
50
+ GoodData.connect(opts)
51
+ pp GoodData::Command::Process.deploy(options[:dir], options.merge(global_options))
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,22 @@
1
+ require 'pp'
2
+
3
+ require File.join(File.dirname(__FILE__), "../shared")
4
+ require File.join(File.dirname(__FILE__), "../../commands/profile")
5
+
6
+ GoodData::CLI.module_eval do
7
+
8
+ desc 'Describe add here'
9
+ arg_name 'show'
10
+ command :profile do |c|
11
+
12
+ c.desc "Show your profile"
13
+ c.command :show do |show|
14
+ show.action do |global_options, options, args|
15
+ opts = options.merge(global_options)
16
+ GoodData.connect(opts)
17
+ pp GoodData::Command::Profile.show()
18
+ end
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,143 @@
1
+ require 'pp'
2
+
3
+ require File.join(File.dirname(__FILE__), "../shared")
4
+ require File.join(File.dirname(__FILE__), "../../commands/projects")
5
+
6
+ GoodData::CLI.module_eval do
7
+
8
+ desc 'Manage your projects'
9
+ arg_name 'project_command'
10
+ command :project do |c|
11
+
12
+ c.desc "Lists user's projects"
13
+ c.command :list do |list|
14
+ list.action do |global_options, options, args|
15
+ opts = options.merge(global_options)
16
+ GoodData.connect(opts)
17
+ list = GoodData::Command::Projects.list()
18
+ puts list.map { |p| [p.uri, p.title].join(",") }
19
+ end
20
+ end
21
+
22
+ c.desc "If you are in a gooddata project blueprint or if you provide a project id it will start an interactive session inside that project"
23
+ c.command :jack_in do |jack|
24
+ jack.action do |global_options, options, args|
25
+ goodfile_path = GoodData::Helpers.find_goodfile(Pathname('.'))
26
+
27
+ spin_session = Proc.new do |goodfile, blueprint|
28
+ project_id = global_options[:project_id] || goodfile[:project_id]
29
+ fail "You have to provide 'project_id'. You can either provide it through -p flag or even better way is to fill it in in your Goodfile under key \"project_id\". If you just started a project you have to create it first. One way might be through \"gooddata project build\"" if project_id.nil? || project_id.empty?
30
+
31
+ opts = options.merge(global_options)
32
+ GoodData.connect(opts)
33
+
34
+ begin
35
+ GoodData.with_project(project_id) do |project|
36
+ puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
37
+ binding.pry(:quiet => true,
38
+ :prompt => [proc { |target_self, nest_level, pry|
39
+ "project_live_sesion: "
40
+ }])
41
+ end
42
+ rescue GoodData::ProjectNotFound => e
43
+ puts "Project with id \"#{project_id}\" could not be found. Make sure that the id you provided is correct."
44
+ end
45
+ end
46
+
47
+ if goodfile_path
48
+ goodfile = JSON.parse(File.read(goodfile_path), :symbolize_names => true)
49
+ model_key = goodfile[:model]
50
+ blueprint = GoodData::Model::ProjectBlueprint.new(eval(File.read(model_key)).to_hash) if File.exist?(model_key) && !File.directory?(model_key)
51
+ FileUtils::cd(goodfile_path.dirname) do
52
+ spin_session.call(goodfile, blueprint)
53
+ end
54
+ else
55
+ spin_session.call({}, nil)
56
+ end
57
+ end
58
+ end
59
+
60
+ c.desc "Create a gooddata project"
61
+ c.command :create do |create|
62
+ create.action do |global_options, options, args|
63
+ title = ask "Project name"
64
+ summary = ask("Project summary") { |q| q.default = "" }
65
+ template = ask("Project template")
66
+ token = ask("token")
67
+
68
+ opts = options.merge(global_options)
69
+ GoodData.connect(opts)
70
+ project = GoodData::Command::Projects.create({
71
+ :title => title,
72
+ :summary => summary,
73
+ :template => template,
74
+ :token => token
75
+ })
76
+ puts "Project '#{project.title}' with id #{project.uri} created successfully!"
77
+ end
78
+ end
79
+
80
+ c.desc "Delete a project. Be careful this is impossible to revert"
81
+ c.command :delete do |delete|
82
+ delete.action do |global_options, options, args|
83
+ id = global_options[:project_id]
84
+ opts = options.merge(global_options)
85
+ GoodData.connect(opts)
86
+ GoodData::Command::Projects.delete(id)
87
+ end
88
+ end
89
+
90
+ c.desc "Clones a project. Useful for testing"
91
+ c.command :clone do |clone|
92
+ clone.desc 'Name of the new project'
93
+ clone.default_value nil
94
+ clone.arg_name 'cloned_project_name'
95
+ clone.flag [:n, :name]
96
+
97
+ clone.action do |global_options, options, args|
98
+ id = global_options[:project_id]
99
+ name = options[:name]
100
+ token = options[:token]
101
+ opts = options.merge(global_options)
102
+ GoodData.connect(opts)
103
+ GoodData::Command::Projects.clone(id, :name => name, :token => token)
104
+ end
105
+ end
106
+
107
+ c.desc "Shows basic info about a project"
108
+ c.command :show do |show|
109
+ show.action do |global_options, options, args|
110
+ id = global_options[:project_id]
111
+ opts = options.merge(global_options)
112
+ GoodData.connect(opts)
113
+ p = GoodData::Command::Projects.show(id)
114
+ pp p.data
115
+ end
116
+ end
117
+
118
+ c.desc "If you are in a gooddata project blueprint it will apply the changes. If you do not provide a project id it will build it from scratch and create a project for you."
119
+ c.command :build do |show|
120
+ show.action do |global_options, options, args|
121
+ opts = options.merge(global_options)
122
+ GoodData.connect(opts)
123
+ spec, project_id = GoodData::Command::Projects.get_spec_and_project_id(".")
124
+ new_project = GoodData::Command::Projects.build(opts.merge(:spec => spec))
125
+ puts "Project was created. New project PID is #{new_project.pid}, URI is #{new_project.uri}."
126
+ end
127
+ end
128
+
129
+ c.desc "If you are in a gooddata project blueprint it will apply the changes. If you do not provide a project id it will build it from scratch and create a project for you."
130
+ c.command :update do |show|
131
+ show.action do |global_options, options, args|
132
+
133
+ opts = options.merge(global_options)
134
+ GoodData.connect(opts)
135
+ spec, project_id = GoodData::Command::Projects.get_spec_and_project_id(".")
136
+ project = GoodData::Command::Projects.update(opts.merge(:spec => spec, :project_id => global_options[:project_id] || project_id))
137
+ puts "Migration was done. Project PID is #{project.pid}, URI is #{project.uri}."
138
+
139
+ end
140
+ end
141
+ end
142
+
143
+ end
@@ -0,0 +1,55 @@
1
+ require 'pp'
2
+
3
+ require File.join(File.dirname(__FILE__), "../shared")
4
+ require File.join(File.dirname(__FILE__), "../../commands/process")
5
+ require File.join(File.dirname(__FILE__), "../../commands/runners")
6
+ require File.join(File.dirname(__FILE__), "../../client")
7
+
8
+ GoodData::CLI.module_eval do
9
+
10
+ desc 'Run ruby bricks either locally or remotely deployed on our server'
11
+ # arg_name 'show'
12
+ command :run_ruby do |c|
13
+
14
+ c.desc 'Directory of the ruby brick'
15
+ c.default_value nil
16
+ c.flag [:d, :dir]
17
+
18
+ c.desc 'Log file. If empty STDOUT will be used instead'
19
+ c.default_value nil
20
+ c.flag [:l, :logger]
21
+
22
+ c.desc 'Params file path. Inside should be hash of key values'
23
+ c.default_value nil
24
+ c.flag [:params]
25
+
26
+ c.desc 'Run on remote machine'
27
+ c.switch [:r, :remote]
28
+
29
+ c.desc 'Name of the deployed process'
30
+ c.default_value nil
31
+ c.flag [:n, :name]
32
+
33
+ c.action do |global_options, options, args|
34
+ verbose = global_options[:verbose]
35
+ options[:expanded_params] = if (options[:params])
36
+ JSON.parse(File.read(options[:params]))
37
+ else
38
+ {}
39
+ end
40
+
41
+ opts = options.merge(global_options).merge({:type => "RUBY"})
42
+ GoodData.connect(opts)
43
+ if options[:remote]
44
+ fail "You have to specify name of the deploy when deploying remotely" if options[:name].nil? || options[:name].empty?
45
+ require 'gooddata/commands/process'
46
+ GoodData::Command::Process.run(options[:dir], opts)
47
+ else
48
+ require 'gooddata/commands/runners'
49
+ GoodData::Command::Runners.run_ruby_locally(options[:dir], opts)
50
+ end
51
+ puts HighLine::color("Running ruby brick - DONE", HighLine::GREEN) if verbose
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,32 @@
1
+ require 'pp'
2
+
3
+ require File.join(File.dirname(__FILE__), "../shared")
4
+ require File.join(File.dirname(__FILE__), "../../commands/scaffold")
5
+
6
+ GoodData::CLI.module_eval do
7
+
8
+ desc 'Scaffold things'
9
+ arg_name 'show'
10
+ command :scaffold do |c|
11
+
12
+ c.desc "Scaffold a gooddata project blueprint"
13
+ c.command :project do |project|
14
+ project.action do |global_options, options, args|
15
+ name = args.first
16
+ fail "Name of the project has to be provided" if name.nil? || name.empty?
17
+ GoodData::Command::Scaffold.project(name)
18
+ end
19
+ end
20
+
21
+ c.desc "Scaffold a gooddata ruby brick. This is a piece of code that you can run on our platform"
22
+ c.command :brick do |brick|
23
+ # brick.arg_name 'name'
24
+ brick.action do |global_options, options, args|
25
+ name = args.first
26
+ fail "Name of the brick has to be provided" if name.nil? || name.empty?
27
+ GoodData::Command::Scaffold.brick(name)
28
+ end
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,43 @@
1
+ require 'gli'
2
+ require 'pp'
3
+
4
+ GoodData::CLI.module_eval do
5
+ pre do |global, command, options, args|
6
+ require 'logger'
7
+ GoodData.logger = Logger.new(STDOUT) if global[:l]
8
+ username = global[:username]
9
+ password = global[:password]
10
+ token = global[:token]
11
+
12
+ creds = GoodData::Command::Auth.read_credentials
13
+
14
+ username = creds[:username] if username.nil?
15
+ password = creds[:password] if password.nil?
16
+ token = creds[:auth_token] if token.nil?
17
+
18
+ global[:token] = token if global[:token].nil?
19
+ global[:login] = username if global[:login].nil?
20
+ global[:password] = password if global[:password].nil?
21
+ # Pre logic here
22
+ # Return true to proceed; false to abort and not call the
23
+ # chosen command
24
+ # Use skips_pre before a command to skip this block
25
+ # on that command only
26
+ true
27
+ end
28
+
29
+ post do |global, command, options, args|
30
+ # Post logic here
31
+ # Use skips_post before a command to skip this
32
+ # block on that command only
33
+ end
34
+
35
+ on_error do |exception|
36
+ # Error logic here
37
+ # return false to skip default error handling
38
+ # binding.pry
39
+ pp exception.backtrace
40
+ pp exception
41
+ true
42
+ end
43
+ end
@@ -0,0 +1,51 @@
1
+ require 'gli'
2
+
3
+ require File.join(File.dirname(__FILE__), "../version")
4
+
5
+ include GLI::App
6
+
7
+ GoodData::CLI.module_eval do
8
+
9
+ program_desc 'GoodData Ruby gem - a wrapper over GoodData API and several useful abstractions to make your everyday usage of GoodData easier.'
10
+
11
+ version GoodData::VERSION
12
+
13
+ desc 'GoodData user name'
14
+ default_value nil
15
+ arg_name 'gooddata-login'
16
+ flag [:U, :username, :login]
17
+
18
+ desc 'GoodData password'
19
+ default_value nil
20
+ arg_name 'gooddata-password'
21
+ flag [:P, :password]
22
+
23
+ desc 'Project pid'
24
+ default_value nil
25
+ arg_name 'project-id'
26
+ flag [:p, :project_id]
27
+
28
+ desc 'Server'
29
+ default_value nil
30
+ arg_name 'server'
31
+ flag [:s, :server]
32
+
33
+ desc 'WEBDAV Server. Used for uploads of files'
34
+ default_value nil
35
+ arg_name 'web dav server'
36
+ flag [:w, :webdav_server]
37
+
38
+ desc 'Token for project creation'
39
+ default_value nil
40
+ arg_name 'token'
41
+ flag [:t, :token]
42
+
43
+ desc 'Verbose mode'
44
+ arg_name 'verbose'
45
+ switch [:v, :verbose]
46
+
47
+ desc 'Http logger on stdout'
48
+ arg_name 'logger'
49
+ switch [:l, :logger]
50
+
51
+ end