Module: Curldown

Included in:
BitBucket, GitHub
Defined in:
lib/curldown.rb

Defined Under Namespace

Classes: BitBucket, GitHub, Render

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.render(user: false, repo: false, url: false, github: false, bitbucket: false) ⇒ Object



7
8
9
10
11
12
# File 'lib/curldown.rb', line 7

def self.render(user: false, repo: false, url: false, github: false, bitbucket: false)
  instance = Render.new(user: user, repo: repo, url: url, github: github, bitbucket: bitbucket)
  instance.render
  instance.highlight!
  instance
end

Instance Method Details

#get(url, json: true) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/curldown.rb', line 13

def get(url, json: true)
  http = Curl::Easy.new(url)
  http.perform
  if http.status[0] == "2"
    if json
      response = JSON.parse(http.body_str)
    else
      response = http.body_str
    end
  else
    raise StandardError.new("get method returned #{http.status} code when calling #{http.url}")
  end
  response
end