gooddata 0.6.0.pre3 → 0.6.0.pre4

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.
@@ -1,14 +1,17 @@
1
1
  require 'benchmark'
2
2
 
3
- class BenchMiddleware < GoodData::Bricks::Middleware
4
-
5
- def call(params)
6
- puts "Starting timer"
7
- result = nil
8
- report = Benchmark.measure { result = @app.call(params) }
9
- puts "Stopping timer"
10
- pp report
11
- result
12
- end
3
+ module GoodData::Bricks
4
+
5
+ class BenchMiddleware < GoodData::Bricks::Middleware
13
6
 
14
- end
7
+ def call(params)
8
+ puts "Starting timer"
9
+ result = nil
10
+ report = Benchmark.measure { result = @app.call(params) }
11
+ puts "Stopping timer"
12
+ pp report
13
+ result
14
+ end
15
+
16
+ end
17
+ end
@@ -1,22 +1,27 @@
1
1
  require 'gooddata'
2
2
 
3
- class GoodDataMiddleware < GoodData::Bricks::Middleware
3
+ module GoodData::Bricks
4
+ class GoodDataMiddleware < GoodData::Bricks::Middleware
4
5
 
5
- def call(params)
6
- logger = params[:gdc_logger]
7
- token_name = :GDC_SST
8
- protocol_name = :GDC_PROTOCOL
9
- server_name = :GDC_SERVER
6
+ def call(params)
7
+ logger = params[:gdc_logger]
8
+ token_name = :GDC_SST
9
+ protocol_name = :GDC_PROTOCOL
10
+ server_name = :GDC_SERVER
11
+ project_id = params[:GDC_PROJECT_ID]
10
12
 
11
- fail "SST (SuperSecureToken) not present in params" if params[token_name].nil?
12
- logger.info "Connecting to GD with SST"
13
- server = if !params[protocol_name].empty? && !params[server_name].empty?
14
- params[protocol_name] + "://" + params[server_name]
13
+ fail "SST (SuperSecureToken) not present in params" if params[token_name].nil?
14
+ logger.info "Connecting to GD with SST"
15
+ server = if !params[protocol_name].empty? && !params[server_name].empty?
16
+ params[protocol_name] + "://" + params[server_name]
17
+ end
18
+
19
+ GoodData.connect_with_sst(params[token_name], {:server => server})
20
+ GoodData.logger = logger
21
+ GoodData.with_project(project_id) do |p|
22
+ @app.call(params)
23
+ end
15
24
  end
16
25
 
17
- GoodData.connect_with_sst(params[token_name], {:server => server})
18
- GoodData.logger = logger
19
- @app.call(params)
20
26
  end
21
-
22
- end
27
+ end
@@ -1,14 +1,16 @@
1
1
  require 'logger'
2
2
 
3
- class LoggerMiddleware < GoodData::Bricks::Middleware
3
+ module GoodData::Bricks
4
+ class LoggerMiddleware < GoodData::Bricks::Middleware
4
5
 
5
- def call(params)
6
- logger = params[:gdc_logger] = params[:GDC_LOGGER_FILE].nil? ? Logger.new(STDOUT) : Logger.new(params[:GDC_LOGGER_FILE])
7
- logger.info("Pipeline starts")
6
+ def call(params)
7
+ logger = params[:gdc_logger] = params[:GDC_LOGGER_FILE].nil? ? Logger.new(STDOUT) : Logger.new(params[:GDC_LOGGER_FILE])
8
+ logger.info("Pipeline starts")
8
9
 
9
- returning(@app.call(params)) do |result|
10
- logger.info("Pipeline ending")
10
+ returning(@app.call(params)) do |result|
11
+ logger.info("Pipeline ending")
12
+ end
11
13
  end
12
- end
13
14
 
15
+ end
14
16
  end
@@ -1,12 +1,14 @@
1
- class STDOUTLoggingMiddleware < GoodData::Bricks::Middleware
1
+ module GoodData::Bricks
2
+ class STDOUTLoggingMiddleware < GoodData::Bricks::Middleware
2
3
 
3
- def call(params)
4
- logger = Logger.new(STDOUT)
5
- params[:logger] = logger
6
- logger.info("Pipeline starting with STDOUT logger")
7
- returning(@app.call(params)) do
8
- logger.info("Pipeline ending")
4
+ def call(params)
5
+ logger = Logger.new(STDOUT)
6
+ params[:logger] = logger
7
+ logger.info("Pipeline starting with STDOUT logger")
8
+ returning(@app.call(params)) do
9
+ logger.info("Pipeline ending")
10
+ end
9
11
  end
10
- end
11
12
 
12
- end
13
+ end
14
+ end
@@ -1,19 +1,22 @@
1
1
  require 'twitter'
2
2
 
3
- class TwitterMiddleware < GoodData::Bricks::Middleware
3
+ module GoodData::Bricks
4
+
5
+ class TwitterMiddleware < GoodData::Bricks::Middleware
4
6
 
5
- def call(params)
7
+ def call(params)
6
8
 
7
- client = Twitter::REST::Client.new do |config|
8
- config.consumer_key = params[:twitter_consumer_key]
9
- config.consumer_secret = params[:twitter_consumer_secret]
10
- config.access_token = params[:twitter_access_token]
11
- config.access_token_secret = params[:twitter_access_token_secret]
12
- end
9
+ client = Twitter::REST::Client.new do |config|
10
+ config.consumer_key = params[:twitter_consumer_key]
11
+ config.consumer_secret = params[:twitter_consumer_secret]
12
+ config.access_token = params[:twitter_access_token]
13
+ config.access_token_secret = params[:twitter_access_token_secret]
14
+ end
13
15
 
14
- returning(@app.call(params)) do |result|
15
- client.update(result)
16
+ returning(@app.call(params)) do |result|
17
+ client.update(result)
18
+ end
16
19
  end
17
- end
18
20
 
19
- end
21
+ end
22
+ end
@@ -119,6 +119,7 @@ module GoodData
119
119
  end
120
120
 
121
121
  def with_project(project, &bl)
122
+ fail "You have to specify a project when using with_project" if project.nil? || project.empty?
122
123
  old_project = GoodData.project
123
124
  begin
124
125
  GoodData.use(project)
@@ -239,6 +240,10 @@ module GoodData
239
240
  connection.delete path, options
240
241
  end
241
242
 
243
+ def upload_webdav(file, options={})
244
+ connection.upload(file, options[:directory], options)
245
+ end
246
+
242
247
  def poll(result, key, options={})
243
248
  sleep_interval = options[:sleep_interval] || 10
244
249
  link = result[key]["links"]["poll"]
@@ -199,7 +199,7 @@ module GoodData
199
199
  def upload(file, dir = nil, options={})
200
200
  ensure_connection
201
201
  # We should have followed a link. If it was correct.
202
-
202
+
203
203
  stage_url = @options[:webdav_server] || @url.sub(/\./, '-di.')
204
204
  # Make a directory, if needed
205
205
  if dir then
@@ -208,29 +208,25 @@ module GoodData
208
208
  GoodData.logger.debug "#{method}: #{url}"
209
209
  begin
210
210
  # first check if it does exits
211
- RestClient::Request.execute(
211
+ RestClient::Request.execute({
212
212
  :method => method,
213
213
  :url => url,
214
- :user => @username,
215
- :password => @password,
216
214
  :timeout => @options[:timeout],
217
215
  :headers => {
218
216
  :user_agent => GoodData.gem_version_string
219
- }
217
+ }}.merge(cookies)
220
218
  )
221
219
  rescue RestClient::Exception => e
222
220
  if e.http_code == 404 then
223
221
  method = :mkcol
224
222
  GoodData.logger.debug "#{method}: #{url}"
225
- RestClient::Request.execute(
223
+ RestClient::Request.execute({
226
224
  :method => method,
227
225
  :url => url,
228
- :user => @username,
229
- :password => @password,
230
226
  :timeout => @options[:timeout],
231
227
  :headers => {
232
228
  :user_agent => GoodData.gem_version_string
233
- }
229
+ }}.merge(cookies)
234
230
  )
235
231
  end
236
232
  end
@@ -242,17 +238,18 @@ module GoodData
242
238
  filename = options[:filename] || options[:stream] ? "randome-filename.txt" : File.basename(file)
243
239
 
244
240
  # Upload the file
245
- RestClient::Request.execute(
241
+ req = RestClient::Request.new({
246
242
  :method => :put,
247
243
  :url => stage_url + STAGE_PATH + dir + '/' + filename,
248
- :user => @username,
249
- :password => @password,
250
244
  :timeout => @options[:timeout],
251
245
  :headers => {
252
246
  :user_agent => GoodData.gem_version_string,
253
247
  },
254
- :payload => payload
255
- )
248
+ :payload => payload,
249
+ :raw_response => true
250
+ }.merge(cookies))
251
+ resp = req.execute
252
+ pp e.inspect
256
253
  end
257
254
 
258
255
  def download(what, where)
@@ -1,3 +1,3 @@
1
1
  module GoodData
2
- VERSION = "0.6.0.pre3"
2
+ VERSION = "0.6.0.pre4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.pre3
4
+ version: 0.6.0.pre4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: