-2

I am using github api for GISTs and I find a gem octokit I arrived well recovered my GISTs.

The problem I have is to get the name because it adds the key like this

files: {
  gistfile1.js: {
  filename: "gistfile1.js",
  type: "application/javascript",
  language: "JavaScript",
  size: 231,
  truncated: false,
 }

How I could browse the files without knowing the key because I have tried several solutions but none works.

Thank you.

user1774481
  • 193
  • 3
  • 12

1 Answers1

1

I think I understand what you mean, I believe it is because the Octokit gem does not return hashes but rather similar looking Sawyer::Resource objects. Try this:

gists = Octokit.gists 'username'
files = gists.map{|g| g[:files] }.map{|f| f.to_h.keys }
file_names = files.flatten.map(&:to_s)
Lewis Buckley
  • 1,583
  • 15
  • 22