gooddata 0.6.0.pre9 → 0.6.0.pre10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/.gitignore +3 -0
  2. data/.rspec +3 -0
  3. data/.yardopts +19 -0
  4. data/Gemfile +5 -0
  5. data/README.md +191 -0
  6. data/Rakefile +18 -1
  7. data/bin/gooddata +74 -63
  8. data/doc/.gitignore +1 -0
  9. data/doc/css/.gitkeepme +1 -0
  10. data/doc/images/.gitkeepme +1 -0
  11. data/doc/images/background.png +0 -0
  12. data/doc/images/bg-callout-button.png +0 -0
  13. data/doc/images/header-logo.png +0 -0
  14. data/doc/images/logo-image.png +0 -0
  15. data/doc/js/.gitkeepme +1 -0
  16. data/doc/pages/GET_STARTED.md +309 -0
  17. data/doc/pages/HOMEPAGE.md +75 -0
  18. data/doc/pages/TUTORIALS.md +52 -0
  19. data/doc/pages/tutorial/BRICKS.md +257 -0
  20. data/doc/pages/tutorial/CREATING_A_MODEL.md +79 -0
  21. data/doc/pages/tutorial/CRUNCHING_NUMBERS.md +233 -0
  22. data/doc/pages/tutorial/TEST_DRIVEN_DEVELOPMENT.md +118 -0
  23. data/doc/pages/tutorial/YOUR_FIRST_PROJECT.md +52 -0
  24. data/doc/templates/default/class/dot/setup.rb +6 -0
  25. data/doc/templates/default/class/dot/superklass.erb +3 -0
  26. data/doc/templates/default/class/setup.rb +36 -0
  27. data/doc/templates/default/class/text/setup.rb +11 -0
  28. data/doc/templates/default/class/text/subclasses.erb +5 -0
  29. data/doc/templates/default/constant/text/header.erb +11 -0
  30. data/doc/templates/default/constant/text/setup.rb +3 -0
  31. data/doc/templates/default/docstring/setup.rb +51 -0
  32. data/doc/templates/default/docstring/text/abstract.erb +2 -0
  33. data/doc/templates/default/docstring/text/deprecated.erb +2 -0
  34. data/doc/templates/default/docstring/text/index.erb +2 -0
  35. data/doc/templates/default/docstring/text/note.erb +4 -0
  36. data/doc/templates/default/docstring/text/private.erb +2 -0
  37. data/doc/templates/default/docstring/text/returns_void.erb +1 -0
  38. data/doc/templates/default/docstring/text/text.erb +1 -0
  39. data/doc/templates/default/docstring/text/todo.erb +4 -0
  40. data/doc/templates/default/layout/dot/header.erb +6 -0
  41. data/doc/templates/default/layout/dot/setup.rb +14 -0
  42. data/doc/templates/default/method/setup.rb +3 -0
  43. data/doc/templates/default/method/text/header.erb +1 -0
  44. data/doc/templates/default/method_details/setup.rb +10 -0
  45. data/doc/templates/default/method_details/text/header.erb +10 -0
  46. data/doc/templates/default/method_details/text/method_signature.erb +12 -0
  47. data/doc/templates/default/method_details/text/setup.rb +10 -0
  48. data/doc/templates/default/module/dot/child.erb +1 -0
  49. data/doc/templates/default/module/dot/dependencies.erb +3 -0
  50. data/doc/templates/default/module/dot/header.erb +6 -0
  51. data/doc/templates/default/module/dot/info.erb +14 -0
  52. data/doc/templates/default/module/dot/setup.rb +14 -0
  53. data/doc/templates/default/module/setup.rb +164 -0
  54. data/doc/templates/default/module/text/children.erb +10 -0
  55. data/doc/templates/default/module/text/class_meths_list.erb +8 -0
  56. data/doc/templates/default/module/text/extends.erb +8 -0
  57. data/doc/templates/default/module/text/header.erb +7 -0
  58. data/doc/templates/default/module/text/includes.erb +8 -0
  59. data/doc/templates/default/module/text/instance_meths_list.erb +8 -0
  60. data/doc/templates/default/module/text/setup.rb +12 -0
  61. data/doc/templates/default/root/dot/child.erb +3 -0
  62. data/doc/templates/default/root/dot/setup.rb +5 -0
  63. data/doc/templates/default/tags/setup.rb +55 -0
  64. data/doc/templates/default/tags/text/example.erb +12 -0
  65. data/doc/templates/default/tags/text/index.erb +1 -0
  66. data/doc/templates/default/tags/text/option.erb +20 -0
  67. data/doc/templates/default/tags/text/overload.erb +19 -0
  68. data/doc/templates/default/tags/text/see.erb +11 -0
  69. data/doc/templates/default/tags/text/tag.erb +13 -0
  70. data/examples.rb +2 -2
  71. data/gooddata.gemspec +31 -26
  72. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +1 -1
  73. data/lib/gooddata/client.rb +65 -53
  74. data/lib/gooddata/commands/commands.rb +9 -0
  75. data/lib/gooddata/commands/process.rb +9 -8
  76. data/lib/gooddata/commands/projects.rb +29 -0
  77. data/lib/gooddata/commands/runners.rb +1 -1
  78. data/lib/gooddata/connection.rb +6 -4
  79. data/lib/gooddata/exceptions.rb +2 -1
  80. data/lib/gooddata/helpers.rb +1 -1
  81. data/lib/gooddata/model.rb +360 -189
  82. data/lib/gooddata/models/metadata.rb +1 -1
  83. data/lib/gooddata/models/metric.rb +2 -1
  84. data/lib/gooddata/models/project.rb +1 -1
  85. data/lib/gooddata/models/report.rb +0 -18
  86. data/lib/gooddata/version.rb +1 -1
  87. data/spec/blueprint_spec.rb +83 -43
  88. data/spec/data/additional_dataset_module.json +18 -0
  89. data/spec/data/blueprint_invalid.json +36 -0
  90. data/spec/data/blueprint_valid.json +37 -0
  91. data/spec/data/model_module.json +18 -0
  92. data/spec/{test_project_model_spec.json → data/test_project_model_spec.json} +4 -0
  93. data/spec/full_project_spec.rb +4 -3
  94. data/spec/helpers/blueprint_helper.rb +17 -0
  95. data/spec/merging_blueprints_spec.rb +23 -48
  96. data/spec/model_dsl_spec.rb +2 -2
  97. data/spec/model_spec.rb +44 -0
  98. data/spec/project_build_and_update_spec.rb +28 -0
  99. data/spec/spec_helper.rb +6 -0
  100. data/yard-server.sh +3 -0
  101. metadata +251 -74
  102. data/README.rdoc +0 -176
data/.gitignore CHANGED
@@ -13,6 +13,9 @@ tmtags
13
13
  ## VIM
14
14
  *.swp
15
15
 
16
+ ## IDEA
17
+ .idea/
18
+
16
19
  ## PROJECT::GENERAL
17
20
  .bundle
18
21
  coverage
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
@@ -0,0 +1,19 @@
1
+ --protected
2
+ --no-private
3
+ --verbose
4
+ --markup markdown
5
+ --markup-provider redcarpet
6
+ --asset doc/css:css
7
+ --asset doc/images:images
8
+ --asset doc/js:js
9
+ --readme doc/pages/HOMEPAGE.md
10
+ --hide-void-return
11
+ --exclude LICENSE
12
+ --output-dir doc/html
13
+ --template-path doc/templates
14
+ lib/**/*.rb
15
+ ext/**/*{.m,.c}
16
+ spec/**/*.rb
17
+ -
18
+ README.md
19
+ doc/pages/**/*.md
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gooddata.gemspec
4
+ gemspec
5
+
@@ -0,0 +1,191 @@
1
+ # GoodData Ruby wrapper and CLI
2
+
3
+ A convenient Ruby wrapper around the GoodData RESTful API. The gem comes in two flavors.
4
+ It has a CLI client and it is a library which you can integrate into your application.
5
+
6
+ The best documentation for the GoodData API can be found using these resources:
7
+
8
+ * http://docs.gooddata.apiary.io/
9
+ * http://developer.gooddata.com/api
10
+ * https://secure.gooddata.com/gdc
11
+
12
+ ## Status
13
+
14
+ [![Gem Version](https://badge.fury.io/rb/gooddata.png)](http://badge.fury.io/rb/gooddata)
15
+ [![Dependency Status](https://gemnasium.com/gooddata/gooddata-ruby.png)](https://gemnasium.com/gooddata/gooddata-ruby)
16
+ [![Code Climate](https://codeclimate.com/github/gooddata/gooddata-ruby.png)](https://codeclimate.com/github/gooddata/gooddata-ruby)
17
+
18
+ ## Install
19
+
20
+ If you are using bundler. Add
21
+
22
+ gem "gooddata"
23
+
24
+ into Gemfile
25
+
26
+ and run
27
+
28
+ bundle install
29
+
30
+ If you are using gems just
31
+
32
+ gem install gooddata
33
+
34
+
35
+ ### Library usage
36
+
37
+
38
+ In its most simple form GoodData gem just cares about the logging in and juggling the tokens that are needed for you to retrive information. It provides you the usual HTTP methods that you are used to. Couple of examples.
39
+
40
+ #### Authentiacation
41
+
42
+ GoodData.connect("login", "pass")
43
+
44
+ # Different server than the usual secure.gooddata.com
45
+ GoodData.connect("login", "pass", "https://different.server.gooddata.com")
46
+
47
+ # the last argument is passed to underlying RestClient so you can specify other useful stuff there
48
+ GoodData.connect("login", "pass", "https://different.server.gooddata.com", :timeout => 0)
49
+
50
+
51
+ #### Basic requests
52
+
53
+ GoodData.get("/gdc/md")
54
+
55
+ # This post will not actually work it is just for the illustration
56
+ GoodData.post("/gdc/md/#{project_id}", {:my_object => "some_date"})
57
+
58
+ # The same goes for put delete.
59
+ # By default the response is decoded for you as json but sometimes you do not want that png or other stuff.
60
+ # You will get the response object and you can query it further.
61
+ response = GoodData.get("/gdc/md", :process => false)
62
+ response.code == 400
63
+ pp response.body
64
+
65
+ #### Loading of data
66
+
67
+ This library is able to load data but it is not used that much if at all. Since there is some data processing needed on the client side we rely on faster implementations in Java usually. Let us know if you would be interested. As the APIs improve we could bring it back.
68
+
69
+ #### Other stuff
70
+
71
+ The API is currently a little fragmented and we never had the guts to actually deal with all the ugliness and present nice object oriented API. Usually it is just better to deal with the ugly json as hashes. But there are couple of exceptions where we needed something better and we thought providing an abstraction is worth the hassle.
72
+
73
+ #### Working with obj
74
+
75
+ obj is a resource that is probably the oldest in all GoodData. Obj are all the objects that have something to do with the analytical engine (metrics, attributes, reports etc). You can find the docs here (Add link to apiary). There are coule of convenience methods to work with these
76
+
77
+ GoodData.connect("svarovsky@gooddata.com", "just_testing")
78
+ GoodData.project="fill_in_your_project_pid"
79
+
80
+ # Access raw obj
81
+ obj = GoodData::MdObject[obj_number]
82
+
83
+ # bunch of useful methods are defined on these
84
+ obj.title
85
+ obj.get_used_by
86
+ obj.get_using
87
+ obj.delete
88
+
89
+
90
+ #### Working with reports
91
+
92
+ Sometimes it is useful to compute reports outside of UI so there are couple of convenience methods for that.
93
+
94
+ require 'pp'
95
+
96
+ GoodData.connect("svarovsky@gooddata.com", "just_testing")
97
+ GoodData.project="fill_in_your_project_pid"
98
+
99
+ report = GoodData::Report[1231]
100
+ result = report.execute
101
+ pp result
102
+
103
+ File.open('png.png', 'w') do |f|
104
+ f.write(report.export(:png))
105
+ end
106
+
107
+ You can export even whole dashboards. Currently afaik reports can be exported either as xls and png and dashboards as pdf. Hopefully it will support more in the future.
108
+
109
+ dash = GoodData::Dashboard[33807]
110
+ File.open('dash.pdf', 'w') do |f|
111
+ f.write(dash.export(:pdf))
112
+ end
113
+
114
+ You can specify which tab to export. By default it is the first
115
+
116
+ dash = GoodData::Dashboard[33807]
117
+ File.open('dash.pdf', 'w') do |f|
118
+ f.write(dash.export(:pdf, :tab => dash.tabs_ids.last))
119
+ end
120
+
121
+ ### CLI Usage
122
+
123
+ After installing the gooddata gem, GoodData is available from your command line using
124
+ the `gooddata` command. To get a complete overview of possible options type:
125
+
126
+ gooddata help
127
+
128
+ The examples and descriptions below does not cover all the options available via the CLI.
129
+ So remember to refer back to the `help` command.
130
+
131
+ Before you do anything else, a good idea is to see if your account is set up correctly and
132
+ that you can log in. To do this, use the `api:test` command:
133
+
134
+ gooddata api:test
135
+
136
+ #### Authentication
137
+
138
+ As you saw if you ran the above test command <tt>gooddata</tt> will prompt you
139
+ for your GoodData username and password. If you don't wish to write your
140
+ credentials each time you connect to GoodData using <tt>gooddata</tt>, you can
141
+ create a simple gooddata credentials file called <tt>.gooddata</tt> in the root
142
+ of your home directory. To make it easy you can just run the credentials file
143
+ generator command which will create the file for you:
144
+
145
+ gooddata auth:store
146
+
147
+ #### List available projects
148
+
149
+ To get a list of projects available to your GoodData user account, run:
150
+
151
+ gooddata projects
152
+
153
+ The output from the above command will look similar to this:
154
+
155
+ ```
156
+ 521 Some project
157
+ 3521 Some other project
158
+ 3642 Some third project
159
+ ```
160
+
161
+ The first column contains the project-key. You need this if you wan't to either
162
+ see more details about the project using the `projects:show` comamnd or
163
+ if you wish to delete the project using the `projects:delete` command.
164
+
165
+ #### Create a new project
166
+
167
+ To create a new project under on the GoodData servers, run:
168
+
169
+ gooddata projects:create
170
+
171
+ You will then be asked about the desired project name and summary before it's created.
172
+
173
+ ## Note on Patches/Pull Requests
174
+
175
+ * Fork the project.
176
+ * Make your feature addition or bug fix.
177
+ * Add tests for it. This is important so I don't break it in a
178
+ future version unintentionally.
179
+ * Commit, do not mess with rakefile, version, or history.
180
+ (if you want to have your own version, that is fine but bump version in a commit by itself we can ignore when we pull)
181
+ * Send us a pull request. Bonus points for topic branches.
182
+
183
+ ## Credits
184
+
185
+ This project is developed and maintained by Pavel Kolesnikov [ <mailto:pavel@gooddata.com> / [@koles](http://twitter.com/koles) ] and Tomas Svarovsky <mailto:svarovsky.tomas@gmail.com>
186
+
187
+ Special thanks to Thomas Watson Steen [ <mailto:w@tson.dk> / [@wa7son](http://twitter.com/wa7son) ]
188
+
189
+ ## Copyright
190
+
191
+ Copyright (c) 2010 - 2014 GoodData Corporation and Thomas Watson Steen. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,8 +1,25 @@
1
- require "bundler/gem_tasks"
1
+ require 'rubygems'
2
+
3
+ require 'bundler/setup'
4
+ require 'bundler/gem_tasks'
5
+
2
6
  require 'rake/testtask'
7
+ require 'rspec/core/rake_task'
8
+
9
+ require 'yard'
10
+
11
+ RSpec::Core::RakeTask.new(:spec)
12
+
13
+ task :usage do
14
+ puts "No rake task specified, use rake -T to list them"
15
+ end
3
16
 
4
17
  Rake::TestTask.new(:test) do |test|
5
18
  test.libs << 'lib' << 'test'
6
19
  test.pattern = 'test/**/test_*.rb'
7
20
  test.verbose = true
8
21
  end
22
+
23
+ YARD::Rake::YardocTask.new
24
+
25
+ task :default => [:usage]
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  require 'gli'
3
4
  require 'gooddata'
4
5
  require 'highline/import'
@@ -19,27 +20,27 @@ version GoodData::VERSION
19
20
  desc 'GoodData user name'
20
21
  default_value nil
21
22
  arg_name 'gooddata-login'
22
- flag [:U,:username, :login]
23
+ flag [:U, :username, :login]
23
24
 
24
25
  desc 'GoodData password'
25
26
  default_value nil
26
27
  arg_name 'gooddata-password'
27
- flag [:P,:password]
28
+ flag [:P, :password]
28
29
 
29
30
  desc 'Project pid'
30
31
  default_value nil
31
32
  arg_name 'project-id'
32
- flag [:p,:project_id]
33
+ flag [:p, :project_id]
33
34
 
34
35
  desc 'Server'
35
36
  default_value nil
36
37
  arg_name 'server'
37
- flag [:s,:server]
38
+ flag [:s, :server]
38
39
 
39
40
  desc 'WEBDAV Server. Used for uploads of files'
40
41
  default_value nil
41
42
  arg_name 'web dav server'
42
- flag [:w,:webdav_server]
43
+ flag [:w, :webdav_server]
43
44
 
44
45
  desc 'Token for project creation'
45
46
  default_value nil
@@ -48,11 +49,11 @@ flag [:t, :token]
48
49
 
49
50
  desc 'Verbose mode'
50
51
  arg_name 'verbose'
51
- switch [:v,:verbose]
52
+ switch [:v, :verbose]
52
53
 
53
54
  desc 'Http logger on stdout'
54
55
  arg_name 'logger'
55
- switch [:l,:logger]
56
+ switch [:l, :logger]
56
57
 
57
58
 
58
59
  desc 'Work with deployed processes'
@@ -77,7 +78,7 @@ command :process do |c|
77
78
 
78
79
  c.desc "Lists all user's processes deployed on the plaform"
79
80
  c.command :list do |list|
80
- list.action do |global_options,options,args|
81
+ list.action do |global_options, options, args|
81
82
  opts = options.merge(global_options)
82
83
  GoodData.connect(opts)
83
84
  pp GoodData::Command::Process.list(options.merge(global_options))
@@ -86,7 +87,7 @@ command :process do |c|
86
87
 
87
88
  c.desc "Gives you some basic info about the process"
88
89
  c.command :get do |get|
89
- get.action do |global_options,options,args|
90
+ get.action do |global_options, options, args|
90
91
  opts = options.merge(global_options)
91
92
  GoodData.connect(opts)
92
93
  pp GoodData::Command::Process.get(options.merge(global_options))
@@ -95,7 +96,7 @@ command :process do |c|
95
96
 
96
97
  c.desc "Deploys provided directory to the server"
97
98
  c.command :deploy do |deploy|
98
- deploy.action do |global_options,options,args|
99
+ deploy.action do |global_options, options, args|
99
100
  opts = options.merge(global_options)
100
101
  GoodData.connect(opts)
101
102
  pp GoodData::Command::Process.deploy(options[:dir], options.merge(global_options))
@@ -110,7 +111,7 @@ command :api do |c|
110
111
 
111
112
  c.desc "Info about the API version etc"
112
113
  c.command :info do |info|
113
- info.action do |global_options,options,args|
114
+ info.action do |global_options, options, args|
114
115
  opts = options.merge(global_options)
115
116
  GoodData.connect(opts)
116
117
  pp GoodData::Command::Api.info
@@ -119,7 +120,7 @@ command :api do |c|
119
120
 
120
121
  c.desc "GET request on our API"
121
122
  c.command :get do |get|
122
- get.action do |global_options,options,args|
123
+ get.action do |global_options, options, args|
123
124
  opts = options.merge(global_options)
124
125
  GoodData.connect(opts)
125
126
  pp GoodData::Command::Api.get(args[0])
@@ -132,16 +133,16 @@ end
132
133
  desc 'Describe add here'
133
134
  arg_name 'show'
134
135
  command :profile do |c|
135
-
136
+
136
137
  c.desc "Show your profile"
137
138
  c.command :show do |show|
138
- show.action do |global_options,options,args|
139
+ show.action do |global_options, options, args|
139
140
  opts = options.merge(global_options)
140
141
  GoodData.connect(opts)
141
142
  pp GoodData::Command::Profile.show()
142
143
  end
143
144
  end
144
-
145
+
145
146
  end
146
147
 
147
148
  desc 'Scaffold things'
@@ -174,23 +175,20 @@ command :project do |c|
174
175
 
175
176
  c.desc "Lists user's projects"
176
177
  c.command :list do |list|
177
- list.action do |global_options,options,args|
178
+ list.action do |global_options, options, args|
178
179
  opts = options.merge(global_options)
179
180
  GoodData.connect(opts)
180
181
  list = GoodData::Command::Projects.list()
181
- puts list.map {|p| [p.uri, p.title].join(",")}
182
+ puts list.map { |p| [p.uri, p.title].join(",") }
182
183
  end
183
184
  end
184
185
 
185
186
  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"
186
187
  c.command :jack_in do |jack|
187
- jack.action do |global_options,options,args|
188
+ jack.action do |global_options, options, args|
188
189
  goodfile_path = GoodData::Helpers.find_goodfile(Pathname('.'))
189
- goodfile = JSON.parse(File.read(goodfile_path), :symbolize_names => true)
190
- model_key = goodfile[:model]
191
- blueprint = GoodData::Model::ProjectBlueprint.new(eval(File.read(model_key)).to_hash) if File.exist?(model_key) && !File.directory?(model_key)
192
- FileUtils::cd(goodfile_path.dirname) do
193
190
 
191
+ spin_session = Proc.new do |goodfile, blueprint|
194
192
  project_id = global_options[:project_id] || goodfile[:project_id]
195
193
  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?
196
194
 
@@ -201,40 +199,51 @@ command :project do |c|
201
199
  GoodData.with_project(project_id) do |project|
202
200
  puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
203
201
  binding.pry(:quiet => true,
204
- :prompt => [proc { |target_self, nest_level, pry|
205
- "project_live_sesion: "
206
- }])
202
+ :prompt => [proc { |target_self, nest_level, pry|
203
+ "project_live_sesion: "
204
+ }])
207
205
  end
208
206
  rescue GoodData::ProjectNotFound => e
209
207
  puts "Project with id \"#{project_id}\" could not be found. Make sure that the id you provided is correct."
210
208
  end
211
209
  end
210
+
211
+ if goodfile_path
212
+ goodfile = JSON.parse(File.read(goodfile_path), :symbolize_names => true)
213
+ model_key = goodfile[:model]
214
+ blueprint = GoodData::Model::ProjectBlueprint.new(eval(File.read(model_key)).to_hash) if File.exist?(model_key) && !File.directory?(model_key)
215
+ FileUtils::cd(goodfile_path.dirname) do
216
+ spin_session.call(goodfile, blueprint)
217
+ end
218
+ else
219
+ spin_session.call({}, nil)
220
+ end
212
221
  end
213
222
  end
214
223
 
215
224
  c.desc "Create a gooddata project"
216
225
  c.command :create do |create|
217
- create.action do |global_options,options,args|
226
+ create.action do |global_options, options, args|
218
227
  title = ask "Project name"
219
228
  summary = ask("Project summary") { |q| q.default = "" }
220
229
  template = ask("Project template")
221
230
  token = ask("token")
222
-
231
+
223
232
  opts = options.merge(global_options)
224
233
  GoodData.connect(opts)
225
234
  project = GoodData::Command::Projects.create({
226
- :title => title,
227
- :summary => summary,
228
- :template => template,
229
- :token => token
230
- })
235
+ :title => title,
236
+ :summary => summary,
237
+ :template => template,
238
+ :token => token
239
+ })
231
240
  puts "Project '#{project.title}' with id #{project.uri} created successfully!"
232
241
  end
233
242
  end
234
243
 
235
244
  c.desc "Delete a project. Be careful this is impossible to revert"
236
245
  c.command :delete do |delete|
237
- delete.action do |global_options,options,args|
246
+ delete.action do |global_options, options, args|
238
247
  id = global_options[:project_id]
239
248
  opts = options.merge(global_options)
240
249
  GoodData.connect(opts)
@@ -249,7 +258,7 @@ command :project do |c|
249
258
  clone.arg_name 'cloned_project_name'
250
259
  clone.flag [:n, :name]
251
260
 
252
- clone.action do |global_options,options,args|
261
+ clone.action do |global_options, options, args|
253
262
  id = global_options[:project_id]
254
263
  name = options[:name]
255
264
  token = options[:token]
@@ -261,7 +270,7 @@ command :project do |c|
261
270
 
262
271
  c.desc "Shows basic info about a project"
263
272
  c.command :show do |show|
264
- show.action do |global_options,options,args|
273
+ show.action do |global_options, options, args|
265
274
  id = global_options[:project_id]
266
275
  opts = options.merge(global_options)
267
276
  GoodData.connect(opts)
@@ -272,23 +281,25 @@ command :project do |c|
272
281
 
273
282
  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."
274
283
  c.command :build do |show|
275
- show.action do |global_options,options,args|
276
- goodfile = JSON.parse(File.read(GoodData::Helpers.find_goodfile(Pathname('.'))), :symbolize_names => true)
277
- spec_path = goodfile[:model] || fail("You need to specify the path of the build spec")
278
- fail "Model path provided in Goodfile \"#{spec_path}\" does not exist" unless File.exist?(spec_path) && !File.directory?(spec_path)
279
-
284
+ show.action do |global_options, options, args|
280
285
  opts = options.merge(global_options)
281
- spec_path = Pathname(spec_path)
286
+ GoodData.connect(opts)
287
+ spec, project_id = GoodData::Command::Projects.get_spec_and_project_id(".")
288
+ new_project = GoodData::Command::Projects.build(opts.merge(:spec => spec))
289
+ puts "Project was created. New project PID is #{new_project.pid}, URI is #{new_project.uri}."
290
+ end
291
+ end
282
292
 
283
- content = File.read(spec_path)
284
- spec = if (spec_path.extname == ".rb")
285
- eval(content)
286
- elsif (spec_path.extname == ".json")
287
- JSON.parse(spec_path, :symbolize_names => true)
288
- end
293
+ 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."
294
+ c.command :update do |show|
295
+ show.action do |global_options, options, args|
296
+
297
+ opts = options.merge(global_options)
289
298
  GoodData.connect(opts)
290
- new_project = GoodData::Model::ProjectCreator.migrate(opts.merge(:spec => spec))
291
- puts "Migration was done. New project PID is #{new_project.uri}."
299
+ spec, project_id = GoodData::Command::Projects.get_spec_and_project_id(".")
300
+ project = GoodData::Command::Projects.update(opts.merge(:spec => spec, :project_id => global_options[:project_id] || project_id))
301
+ puts "Migration was done. Project PID is #{project.pid}, URI is #{project.uri}."
302
+
292
303
  end
293
304
  end
294
305
 
@@ -299,7 +310,7 @@ command :auth do |c|
299
310
 
300
311
  c.desc "Store your credentials to ~/.gooddata so client does not have to ask you every single time"
301
312
  c.command :store do |store|
302
- store.action do |global_options,options,args|
313
+ store.action do |global_options, options, args|
303
314
  GoodData::Command::Auth.store
304
315
  end
305
316
  end
@@ -328,30 +339,30 @@ command :run_ruby do |c|
328
339
  c.desc 'Name of the deployed process'
329
340
  c.default_value nil
330
341
  c.flag [:n, :name]
331
-
342
+
332
343
  c.action do |global_options, options, args|
344
+ verbose = global_options[:verbose]
333
345
  options[:expanded_params] = if (options[:params])
334
- JSON.parse(File.read(options[:params]), :symbolize_names => true)
335
- else
336
- {}
337
- end
338
-
346
+ JSON.parse(File.read(options[:params]), :symbolize_names => true)
347
+ else
348
+ {}
349
+ end
350
+
339
351
  opts = options.merge(global_options).merge({:type => "RUBY"})
340
352
  GoodData.connect(opts)
341
353
  if options[:remote]
342
354
  fail "You have to specify name of the deploy when deploying remotely" if options[:name].nil? || options[:name].empty?
343
355
  require 'gooddata/commands/process'
344
- GoodData::Command::Process.run(options[:dir], opts) do
345
- puts "would run"
346
- end
356
+ GoodData::Command::Process.run(options[:dir], opts)
347
357
  else
348
358
  require 'gooddata/commands/runners'
349
359
  GoodData::Command::Runners.run_ruby_locally(options[:dir], opts)
350
360
  end
361
+ puts HighLine::color("Running ruby brick - DONE", HighLine::GREEN) if verbose
351
362
  end
352
363
  end
353
364
 
354
- pre do |global,command,options,args|
365
+ pre do |global, command, options, args|
355
366
  require 'logger'
356
367
  GoodData.logger = Logger.new(STDOUT) if global[:l]
357
368
  username = global[:username]
@@ -362,8 +373,8 @@ pre do |global,command,options,args|
362
373
 
363
374
  username = creds[:username] if username.nil?
364
375
  password = creds[:password] if password.nil?
365
- token = creds[:auth_token] if token.nil?
366
-
376
+ token = creds[:auth_token] if token.nil?
377
+
367
378
  global[:token] = token if global[:token].nil?
368
379
  global[:login] = username if global[:login].nil?
369
380
  global[:password] = password if global[:password].nil?
@@ -375,7 +386,7 @@ pre do |global,command,options,args|
375
386
  true
376
387
  end
377
388
 
378
- post do |global,command,options,args|
389
+ post do |global, command, options, args|
379
390
  # Post logic here
380
391
  # Use skips_post before a command to skip this
381
392
  # block on that command only