Something went wrong. Try again.
A curated list of libraries & SDKs for the Bluesky API and AT Protocol forked from mackuba.eu/sdk.blue
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950require 'yaml'require_relative 'import_helpers'
class Project extend ImportHelpers
def self.load_all(languages: nil, project: nil) return yaml_paths(languages) .map { |y| lang = File.basename(y).chomp('.yml') YAML.load(File.read(y))['repos'].map { |r| Project.new(r, lang) } } .flatten .then { |projects| project ? filter_by_url(projects, project) : projects } end
def self.yaml_paths(languages) if languages languages.map { |lang| File.join(__dir__, '..', '_data', 'projects', "#{lang}.yml") } else Dir[File.join(__dir__, '..', '_data', 'projects', '*.yml')] end end
def self.filter_by_url(projects, url) normalized_url = normalize_repo_url(url.strip)
projects.select do |project| project.urls.any? { |u| normalize_repo_url(u) == normalized_url } end end
attr_reader :language
def initialize(yaml, language) @language = language.to_sym @yaml = yaml end
def urls @yaml['url'] ? [@yaml['url']] : @yaml['urls'] end
def name @yaml['name'] || urls.first.chomp('/').split('/').last endend