Class: ToolVersion::DirectoryInterfaces::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/tool_version/directory_interfaces/github.rb

Constant Summary collapse

DEFAULT_RELEVANT_BRANCH =
:main

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, repository, branch: DEFAULT_RELEVANT_BRANCH) ⇒ Github

Returns a new instance of Github.



7
8
9
10
11
# File 'lib/tool_version/directory_interfaces/github.rb', line 7

def initialize(client, repository, branch: DEFAULT_RELEVANT_BRANCH)
  @client = client
  @repository = repository
  @files = load_all_files(client, repository, branch)
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



5
6
7
# File 'lib/tool_version/directory_interfaces/github.rb', line 5

def files
  @files
end

Instance Method Details

#content(file_path) ⇒ Object



19
20
21
22
# File 'lib/tool_version/directory_interfaces/github.rb', line 19

def content(file_path)
  response = @client.contents(@repository, path: file_path)
  Base64.decode64(response[:content])
end

#find(pattern) ⇒ Object



13
14
15
16
17
# File 'lib/tool_version/directory_interfaces/github.rb', line 13

def find(pattern)
  @files.select do |file_path|
    file_path.match(pattern)
  end
end