lib/gooddata/client.rb in gooddata-0.6.0.pre6 vs lib/gooddata/client.rb in gooddata-0.6.0.pre7
- old
+ new
@@ -1,7 +1,8 @@
require 'gooddata/version'
require 'gooddata/connection'
+require 'gooddata/helpers'
# fastercsv is built in Ruby 1.9
if RUBY_VERSION < "1.9"
require 'fastercsv'
else
@@ -92,10 +93,21 @@
threaded[:connection] = Connection.new(options, second_options, third_options)
end
end
+ def logging_on
+ if logger.is_a? NilLogger
+ GoodData::logger = Logger.new(STDOUT)
+ end
+ end
+
+ def logging_off
+ GoodData::logger = NilLogger.new
+ end
+
+
# Hepler for starting with SST easier
# === Parameters
#
# * +token+ - SST token
# * +options+ - options get routed to connect eventually so everything that you can use there should be possible to use here.
@@ -121,11 +133,11 @@
def with_project(project, &bl)
fail "You have to specify a project when using with_project" if project.nil? || (project.is_a?(String) && project.empty?)
old_project = GoodData.project
begin
GoodData.use(project)
- bl.call(project)
+ bl.call(GoodData.project)
rescue Exception => e
fail e
ensure
GoodData.project = old_project
end
@@ -245,9 +257,17 @@
def upload_to_project_webdav(file, options={})
u = URI(connection.options[:webdav_server] || GoodData.project.links["uploads"])
url = URI.join(u.to_s.chomp(u.path.to_s), "/project-uploads/", "#{GoodData.project.pid}/")
connection.upload(file, options.merge({
:directory => options[:directory],
+ :staging_url => url
+ }))
+ end
+
+ def download_form_user_webdav(file, where, options={})
+ u = URI(connection.options[:webdav_server] || GoodData.project.links["uploads"])
+ url = URI.join(u.to_s.chomp(u.path.to_s), "/uploads/")
+ connection.download(file, where, options.merge({
:staging_url => url
}))
end
def poll(result, key, options={})