Class: Berkshelf::API::CacheBuilder::Worker::Github
- Defined in:
- lib/berkshelf/api/cache_builder/worker/github.rb
Instance Attribute Summary collapse
- #organization ⇒ String readonly
Attributes inherited from Base
Instance Method Summary collapse
-
#cookbooks ⇒ Array<RemoteCookbook>
The list of cookbooks this builder can find.
-
#initialize(options = {}) ⇒ Github
constructor
A new instance of Github.
-
#metadata(remote) ⇒ Ridley::Chef::Cookbook::Metadata?
Return the metadata of the given RemoteCookbook.
- #to_s ⇒ String
Methods inherited from Base
Methods included from Mixin::Services
Methods included from Logging
Constructor Details
#initialize(options = {}) ⇒ Github
Returns a new instance of Github.
19 20 21 22 23 24 25 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 19 def initialize( = {}) @connection = Octokit::Client.new(access_token: [:access_token], auto_paginate: true, api_endpoint: [:api_endpoint], web_endpoint: [:web_endpoint], connection_options: {ssl: {verify: [:ssl_verify].nil? ? true : [:ssl_verify]}}) @organization = [:organization] super() end |
Instance Attribute Details
#organization ⇒ String (readonly)
12 13 14 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 12 def organization @organization end |
Instance Method Details
#cookbooks ⇒ Array<RemoteCookbook>
Returns The list of cookbooks this builder can find.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 34 def cookbooks [].tap do |cookbook_versions| connection.organization_repositories(organization).each do |repo| connection.(repo.full_name).each do |tag| if match = /^v(?<version>.*)$/.match(tag.name) begin next unless = (repo.name, tag.name) if .version.to_s == match[:version].to_s cookbook_versions << RemoteCookbook.new(repo.name, .version, self.class.worker_type, repo.full_name, priority) else log.warn "Version found in metadata for #{repo.name} (#{tag.name}) does not " + "match the tag. Got #{.version}." end rescue Semverse::InvalidVersionFormat log.debug "Ignoring tag #{tag.name} for: #{repo.name}. Does not conform to semver." rescue Octokit::NotFound log.debug "Ignoring tag #{tag.name} for: #{repo.name}. No raw metadata found." end else log.debug "Version number cannot be parsed" end end end end end |
#metadata(remote) ⇒ Ridley::Chef::Cookbook::Metadata?
Return the metadata of the given RemoteCookbook. If the metadata could not be found or parsed nil is returned.
68 69 70 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 68 def (remote) (remote.name, "v#{remote.version}") end |
#to_s ⇒ String
28 29 30 |
# File 'lib/berkshelf/api/cache_builder/worker/github.rb', line 28 def to_s friendly_name(organization) end |