lib/gooddata/commands/api.rb in gooddata-0.6.0.pre11 vs lib/gooddata/commands/api.rb in gooddata-0.6.0

- old
+ new

@@ -1,35 +1,52 @@ -module GoodData::Command - class Api - class << self - def info - json = {} - puts "GoodData API" - puts " Version: #{json['releaseName']}" - puts " Released: #{json['releaseDate']}" - puts " For more info see #{json['releaseNotesUri']}" - end +# encoding: UTF-8 - alias :index :info +require_relative '../exceptions/command_failed' - def test - if GoodData.test_login - puts "Succesfully logged in as #{GoodData.profile.user}" - else - puts "Unable to log in to GoodData server!" +module GoodData + module Command + # Low level access to GoodData API + class Api + class << self + def info + json = { + 'releaseName' => 'N/A', + 'releaseDate' => 'N/A', + 'releaseNotesUri' => 'N/A' + } + + puts 'GoodData API' + puts " Version: #{json['releaseName']}" + puts " Released: #{json['releaseDate']}" + puts " For more info see #{json['releaseNotesUri']}" end - end - def get(path) - raise(CommandFailed, "Specify the path you want to GET.") if path.nil? - result = GoodData.get path - result rescue puts result - end + alias_method :index, :info - def delete(path) - raise(CommandFailed, "Specify the path you want to DELETE.") if path.nil? - result = GoodData.delete path - result rescue puts result + # Test of login + def test + if GoodData.test_login + puts "Succesfully logged in as #{GoodData.profile.user}" + else + puts 'Unable to log in to GoodData server!' + end + end + + # Get resource + # @param path Resource path + def get(path) + raise(GoodData::CommandFailed, 'Specify the path you want to GET.') if path.nil? + result = GoodData.get path + result rescue puts result + end + + # Delete resource + # @param path Resource path + def delete(path) + raise(GoodData::CommandFailed, 'Specify the path you want to DELETE.') if path.nil? + result = GoodData.delete path + result rescue puts result + end end end end end \ No newline at end of file