Class: Rhohub::Base

Inherits:
Object show all
Defined in:
lib/build/rhohub/base.rb

Direct Known Subclasses

App, Build, Subscription, Token

Class Method Summary collapse

Class Method Details

.catch_allObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/build/rhohub/base.rb', line 3

def self.catch_all
  begin
    raise Exception.new "you need to enter an api_token first ex:ENV['api_token']=sometoken" unless Rhohub.token
    yield
  rescue Exception => e
    #puts "#{e.message}\n#{e.backtrace}"
    #throw :halt, [503, {:text => "Unable to complete request: #{e.message}"}.to_json]
    raise #Exception.new "#{e.message}#{$/}#{e.backtrace.join($/)}"
  end
end

.check(options, resource) ⇒ Object



41
42
43
44
# File 'lib/build/rhohub/base.rb', line 41

def self.check(options,resource)
  resp = Rhohub.requester[Rhohub.resource_url(options,resource)].get
  resp.body
end

.create(options, data, resource) ⇒ Object



14
15
16
17
# File 'lib/build/rhohub/base.rb', line 14

def self.create(options,data,resource)
  resp = Rhohub.requester[Rhohub.resource_url(options,resource)].post data.to_json
  resp.body
end

.delete(options, resource) ⇒ Object

options = => build_id || app_id



25
26
27
28
# File 'lib/build/rhohub/base.rb', line 25

def self.delete(options,resource)
  resp = Rhohub.requester[Rhohub.resource_url(options,resource)].delete
  resp.body
end

.list(options, resource) ⇒ Object

options = => app_id || nil



31
32
33
34
# File 'lib/build/rhohub/base.rb', line 31

def self.list(options,resource)
  resp = Rhohub.requester[Rhohub.resource_url(options,resource)].get
  resp.body
end

.login(options, resource) ⇒ Object



57
58
59
60
# File 'lib/build/rhohub/base.rb', line 57

def self.(options,resource)
  resp = Rhohub.requester(false)[Rhohub.resource_url(options,resource)].post( {:login => options[:username].downcase, :password => options[:password]})
  resp.body
end

.platforms(options, resource) ⇒ Object



36
37
38
39
# File 'lib/build/rhohub/base.rb', line 36

def self.platforms(options,resource)
  resp = Rhohub.requester[Rhohub.resource_url(options,resource)].get
  resp.body
end

.show(options, resource) ⇒ Object

options = => build_id || app_id



20
21
22
23
# File 'lib/build/rhohub/base.rb', line 20

def self.show(options,resource)
  resp = Rhohub.requester[Rhohub.resource_url(options,resource)].get
  resp.body
end

.supported_gems(options, resource) ⇒ Object



52
53
54
55
# File 'lib/build/rhohub/base.rb', line 52

def self.supported_gems(options,resource)
  resp = Rhohub.requester[Rhohub.resource_url(options,resource)].get
  resp.body
end

.user_status(options, resource) ⇒ Object



47
48
49
50
# File 'lib/build/rhohub/base.rb', line 47

def self.user_status(options,resource)
  resp = Rhohub.requester[Rhohub.resource_url(options,resource)].get
  resp.body
end