gooddata 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/gooddata/connection.rb +45 -12
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -68,7 +68,6 @@ module GoodData
68
68
  #
69
69
  # Connection.new(username, password).get '/gdc/projects'
70
70
  def get(path, options = {})
71
- pp options
72
71
  GoodData.logger.debug "GET #{path}"
73
72
  ensure_connection
74
73
  b = Proc.new { @server[path].get cookies }
@@ -147,19 +146,37 @@ module GoodData
147
146
 
148
147
  # Make a directory, if needed
149
148
  if dir then
150
- method = :mkcol
151
149
  url = stage_url + STAGE_PATH + dir + '/'
150
+ method = :get
152
151
  GoodData.logger.debug "#{method}: #{url}"
153
- RestClient::Request.execute(
154
- :method => method,
155
- :url => url,
156
- :user => @username,
157
- :password => @password,
158
- :timeout => @options[:timeout],
159
- :headers => {
160
- :user_agent => GoodData.gem_version_string
161
- }
162
- )
152
+ begin
153
+ # first check if it does exits
154
+ RestClient::Request.execute(
155
+ :method => method,
156
+ :url => url,
157
+ :user => @username,
158
+ :password => @password,
159
+ :timeout => @options[:timeout],
160
+ :headers => {
161
+ :user_agent => GoodData.gem_version_string
162
+ }
163
+ )
164
+ rescue RestClient::Exception => e
165
+ if e.http_code == 404 then
166
+ method = :mkcol
167
+ GoodData.logger.debug "#{method}: #{url}"
168
+ RestClient::Request.execute(
169
+ :method => method,
170
+ :url => url,
171
+ :user => @username,
172
+ :password => @password,
173
+ :timeout => @options[:timeout],
174
+ :headers => {
175
+ :user_agent => GoodData.gem_version_string
176
+ }
177
+ )
178
+ end
179
+ end
163
180
  end
164
181
 
165
182
  # Upload the file
@@ -176,6 +193,22 @@ module GoodData
176
193
  )
177
194
  end
178
195
 
196
+ def download(what, where)
197
+ stage_url = DEFAULT_URL.sub(/\./, '-di.')
198
+ url = stage_url + STAGE_PATH + what
199
+ File.open(where, 'w') do |f|
200
+ resp = RestClient::Request.execute({
201
+ :method => 'GET',
202
+ :url => url,
203
+ :user => @username,
204
+ :password => @password,
205
+ :timeout => 0
206
+ }) do |chunk, x, y|
207
+ f.write chunk
208
+ end
209
+ end
210
+ end
211
+
179
212
  private
180
213
 
181
214
  def ensure_connection
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pavel Kolesnikov
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-02-14 00:00:00 Z
19
+ date: 2012-02-26 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  version_requirements: &id001 !ruby/object:Gem::Requirement