Class: Cheatly::Adapter::GitHub

Inherits:
Object
  • Object
show all
Defined in:
lib/cheatly/adapter/github.rb

Constant Summary collapse

FOLDER =
'sheets'
REPO =
'arthurnn/cheatly'

Instance Method Summary collapse

Instance Method Details

#allObject



19
20
21
22
# File 'lib/cheatly/adapter/github.rb', line 19

def all
  response = Octokit.contents(REPO, path: "#{FOLDER}")
  response.map { |f| f.name.gsub(/\.[a-z]+\z/, '') }
end

#createObject

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/cheatly/adapter/github.rb', line 24

def create
  raise NotImplementedError
end

#find(path) ⇒ Object



12
13
14
15
16
17
# File 'lib/cheatly/adapter/github.rb', line 12

def find(path)
  response = Octokit.contents(REPO, path: "#{FOLDER}/#{path}.yml")
  sheet_yaml = Base64.decode64(response.content)
  yml = YAML.load(sheet_yaml).first
  [yml.first, yml.last]
end