Class: Megam::ScmmRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/megam/core/scmm/scmmrepo.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.error(response) ⇒ Object



49
50
51
# File 'lib/megam/core/scmm/scmmrepo.rb', line 49

def self.error(response)
  {:status => response.code, :body => "", :some_msg => response.message }
end

.list(username, password) ⇒ Object

Load a account by email_p



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/megam/core/scmm/scmmrepo.rb', line 36

def self.list(username, password)
  #acct = self.new(username, password)
  megams = Megam::Scmmanager.new
  res = megams.get_repos(username, password)
  hash = {}
  if res.code != "200"
     hash = self.error(res)
   else
     hash = self.to_hash(res)
  end      
  hash
end

.to_hash(response) ⇒ Object

Transform the ruby obj -> to a Hash



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/megam/core/scmm/scmmrepo.rb', line 20

def self.to_hash(response)
  index_hash = []
  i = 0
  config = Nokogiri::XML(response.body)
  config.css("repositories repositories").map do |node|
    node.children.map {|n|
      if n.name == 'url'            
        index_hash << n.text.strip
      end
    }
  end
  {:status => response.code, :body => index_hash, :some_msg => response.message }
end

Instance Method Details

#to_sObject



53
54
55
# File 'lib/megam/core/scmm/scmmrepo.rb', line 53

def to_s
  Megam::Stuff.styled_hash(to_hash)
end