gooddata 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -1,5 +1,9 @@
1
1
  require 'gooddata/version'
2
2
  require 'gooddata/connection'
3
+
4
+ # Metadata packages, such as report.rb, require this to be loaded first
5
+ require File.dirname(__FILE__) + '/models/metadata.rb'
6
+
3
7
  Dir[File.dirname(__FILE__) + '/models/*.rb'].each { |file| require file }
4
8
  Dir[File.dirname(__FILE__) + '/collections/*.rb'].each { |file| require file }
5
9
 
@@ -44,8 +44,10 @@ module GoodData
44
44
  begin
45
45
  if options.has_key? :answers
46
46
  answer = nil
47
+ options[:default] = options[:answers][0] if !options.has_key? :default
47
48
  while !options[:answers].include?(answer)
48
- answer = get_answer "#{question} [#{options[:answers].join(',')}]? ", options[:secret]
49
+ answer = get_answer "#{question} (#{options[:answers].join(',')}) [#{options[:default]}]? ", options[:secret]
50
+ answer = options[:default] if answer == ""
49
51
  end
50
52
  else
51
53
  question = "#{question} [#{options[:default]}]" if options[:default]
@@ -1,5 +1,4 @@
1
1
  require 'json'
2
- require 'net/ftptls'
3
2
 
4
3
  # silence the parenthesis warning in rest-client 1.6.1
5
4
  old_verbose, $VERBOSE = $VERBOSE, nil ; require 'rest-client' ; $VERBOSE = old_verbose
@@ -33,6 +32,7 @@ module GoodData
33
32
  DEFAULT_URL = 'https://secure.gooddata.com'
34
33
  LOGIN_PATH = '/gdc/account/login'
35
34
  TOKEN_PATH = '/gdc/account/token'
35
+ STAGE_PATH = '/uploads'
36
36
 
37
37
  # Set the GoodData account credentials.
38
38
  #
@@ -133,16 +133,39 @@ module GoodData
133
133
  connect
134
134
  end
135
135
 
136
- # Uploads a file to GoodData server via FTPS
136
+ # Uploads a file to GoodData server
137
+ # /uploads/ resources are special in that they use a different
138
+ # host and a basic authentication.
137
139
  def upload(file, dir = nil)
138
- Net::FTPTLS.open('secure-di.gooddata.com', @username, @password) do |ftp|
139
- ftp.passive = true
140
- if dir then
141
- begin ; ftp.mkdir dir ; rescue ; ensure ; ftp.chdir dir ; end
142
- end
143
- ftp.binary = true
144
- ftp.put file
140
+ # We should have followed a link. If it was correct.
141
+ stage_url = DEFAULT_URL.sub(/\./, '-di.')
142
+
143
+ # Make a directory, if needed
144
+ if dir then
145
+ RestClient::Request.execute(
146
+ :method => :mkcol,
147
+ :url => stage_url + STAGE_PATH + dir + '/',
148
+ :user => @username,
149
+ :password => @password,
150
+ :timeout => @options[:timeout],
151
+ :headers => {
152
+ :user_agent => GoodData.gem_version_string,
153
+ }
154
+ )
145
155
  end
156
+
157
+ # Upload the file
158
+ RestClient::Request.execute(
159
+ :method => :put,
160
+ :url => stage_url + STAGE_PATH + dir + '/' + File.basename(file),
161
+ :user => @username,
162
+ :password => @password,
163
+ :timeout => @options[:timeout],
164
+ :headers => {
165
+ :user_agent => GoodData.gem_version_string,
166
+ },
167
+ :payload => File.read(file)
168
+ )
146
169
  end
147
170
 
148
171
  private
@@ -572,6 +572,9 @@ module GoodData
572
572
  def to_csv_data(headers, row)
573
573
  val = row[name]
574
574
  val.nil?() ? nil : (Date.strptime(val, format) - BEGINNING_OF_TIMES).to_i
575
+ rescue ArgumentError
576
+ raise "Value \"#{val}\" for column \"#{name}\" did not match the format: #{format}. " +
577
+ "Perhaps you need to add or change the \"format\" key in the data set configuration."
575
578
  end
576
579
 
577
580
  def to_manifest_part(mode)
@@ -1,3 +1,3 @@
1
1
  module GoodData
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
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: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
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: 2011-09-20 00:00:00 Z
19
+ date: 2011-09-21 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement