module Nailed
Constants
- LOGGER
- VERSION
Public Instance Methods
fill_db_after_migration(github_client)
click to toggle source
# File lib/nailed.rb, line 31 def fill_db_after_migration(github_client) get_config["products"].each do |product,values| organization = values["organization"] values["versions"].each do |version| db_handler = Product.first_or_create(:name => version) save_state(db_handler) end unless values["versions"].nil? unless organization.nil? db_handler = Organization.first_or_create(:oname => organization) save_state(db_handler) org_repos_github = get_org_repos(github_client, organization) org_repos_yml = values["repos"] org_repos_yml.each do |org_repo| if org_repos_github.include?(org_repo) db_handler = Repository.first_or_create(:rname => org_repo, :organization_oname => organization) save_state(db_handler) end end end end end
get_config()
click to toggle source
# File lib/nailed.rb, line 21 def get_config conf = File.join(File.expand_path("..", File.dirname(__FILE__)),"config","config.yml") YAML.load_file(conf) end
get_org_repos(github_client, org)
click to toggle source
# File lib/nailed.rb, line 26 def get_org_repos(github_client, org) all_repos = github_client.org_repos(org) all_repos.map(&:name) end
list_org_repos(github_client, org)
click to toggle source
# File lib/nailed.rb, line 53 def list_org_repos(github_client, org) repos = get_org_repos(github_client, org) repos.each {|r| puts "- #{r}"} end
log(level,msg)
click to toggle source
# File lib/nailed.rb, line 14 def log(level,msg) if get_config["debug"] LOGGER.error(msg) if level == "error" LOGGER.info(msg) if level == "info" end end
save_state(db_handler)
click to toggle source
# File lib/nailed.rb, line 58 def save_state(db_handler) unless db_handler.save puts("ERROR: #{__method__}: see logfile") log("error", "#{__method__}: #{db_handler.errors.inspect}") end end