# Pastebin Sdu5rlXp lockfile = YAML.parse(File.read("shard.lock")) result = lockfile.as_h result_shards = result["shards"] case result_shards when Hash lockfile["shards"].each do |name, value| github = value["github"] version = "refs/tags/v#{value["version"]}" uri = "https://github.com/#{github}" args = ["--url", uri, "--rev", version, "--hash", "sha256", "--leave-dotGit"] process = Process.new("nix-prefetch-git", args: args, shell: true, input: true, output: nil, error: true) output = process.output.gets_to_end status = process.wait j = JSON.parse(output) found = result_shards.find{|k,v| case k when String k == name.as_s end } case found when {String, Hash} if found found_key = found[0] found_value = found[1] if found_key && found_value case found_value when Hash found_value["sha256"] = j["sha256"].as_s end end end end end end puts result.to_yaml