Class: LocalClient
- Inherits:
-
Object
- Object
- LocalClient
- Defined in:
- lib/local_client.rb
Instance Method Summary collapse
- #fetch_dependabot_config(_repo) ⇒ Object
- #fetch_workflows(_repo = nil) ⇒ Object
- #file_exists?(_repo, path) ⇒ Boolean
-
#initialize(path) ⇒ LocalClient
constructor
A new instance of LocalClient.
Constructor Details
#initialize(path) ⇒ LocalClient
Returns a new instance of LocalClient.
2 3 4 5 |
# File 'lib/local_client.rb', line 2 def initialize(path) @path = File.(path) @workflows_dir = File.join(@path, ".github", "workflows") end |
Instance Method Details
#fetch_dependabot_config(_repo) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/local_client.rb', line 23 def fetch_dependabot_config(_repo) path = File.join(@path, ".github", "dependabot.yml") path = File.join(@path, ".github", "dependabot.yaml") unless File.exist?(path) return nil unless File.exist?(path) begin YAML.safe_load(File.read(path)) rescue StandardError => e nil end end |
#fetch_workflows(_repo = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/local_client.rb', line 7 def fetch_workflows(_repo = nil) workflows = [] return workflows unless File.directory?(@workflows_dir) Dir[File.join(@workflows_dir, "*.{yml,yaml}")].sort.each do |f| content = File.read(f) workflows << { filename: File.basename(f), content: content } end workflows end |
#file_exists?(_repo, path) ⇒ Boolean
19 20 21 |
# File 'lib/local_client.rb', line 19 def file_exists?(_repo, path) File.exist?(File.join(@path, path)) end |