Class: Cheatly::GithubAdapter
- Inherits:
-
Object
- Object
- Cheatly::GithubAdapter
- Includes:
- HTTParty
- Defined in:
- lib/cheatly/sheet.rb
Instance Method Summary collapse
Instance Method Details
#all ⇒ Object
103 104 105 106 107 |
# File 'lib/cheatly/sheet.rb', line 103 def all response = self.class.get(base_path, headers) json = JSON.parse(response.body) json.map { |entry| entry["name"].gsub('.yml', '') } end |
#base_path ⇒ Object
91 92 93 |
# File 'lib/cheatly/sheet.rb', line 91 def base_path "/repos/arthurnn/cheatly/contents/sheets" end |
#create ⇒ Object
109 110 111 |
# File 'lib/cheatly/sheet.rb', line 109 def create raise NotImplementedError end |
#find(path) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/cheatly/sheet.rb', line 95 def find(path) response = self.class.get("#{base_path}/#{path}.yml", headers) json = JSON.parse(response.body) sheet_yaml = Base64.decode64(json["content"]) yml = YAML.load(sheet_yaml).first [yml.first, yml.last] end |
#headers ⇒ Object
87 88 89 |
# File 'lib/cheatly/sheet.rb', line 87 def headers { :headers => {"User-Agent" => "Cheatly Gem"} } end |