Class: Qippet::Extract

Inherits:
Object
  • Object
show all
Defined in:
lib/qippet/extract.rb

Overview

Extract Class

Constant Summary collapse

GITHUB_BASE_API_URL =
"https://api.github.com/repos/"

Class Method Summary collapse

Class Method Details

.from_file(path) ⇒ Object



15
16
17
# File 'lib/qippet/extract.rb', line 15

def from_file(path)
  read_file absolute_path(path)
end

.from_github(path = "rails/rails/contents/version.rb") ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/qippet/extract.rb', line 19

def from_github(path = "rails/rails/contents/version.rb")
  url = URI("#{GITHUB_BASE_API_URL}#{path}")
  response = Net::HTTP.get_response(url)
  response = JSON.parse(response.body)
  Base64.decode64(response["content"])
rescue StandardError
  nil
end