-
-
Save RX14/2c84aa70d2f5cb7dfcd01a8853e8b70e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "secure_random" | |
require "file_utils" | |
require "json" | |
struct Foo | |
getter value : String | |
def initialize(@value) | |
end | |
end | |
def get_foo | |
cache = "/home/rx14/.cache/crane" | |
Foo.new(cache) | |
end | |
def ensure_crystal_sources | |
crystal_source_dir = File.join(get_foo.value, "git", "crystal") | |
FileUtils.mkdir_p(crystal_source_dir) | |
crystal_source_dir | |
end | |
def temp_crystal_checkout(revision) | |
base_clone_path = ensure_crystal_sources | |
temp_clone_path = File.join("/tmp", "crystal-checkout-#{SecureRandom.hex}") | |
begin | |
FileUtils.cp_r(base_clone_path, temp_clone_path) | |
yield temp_clone_path | |
ensure | |
FileUtils.rm_r(temp_clone_path) | |
end | |
end | |
temp_crystal_checkout("0.21.1") do |repository| | |
JSON.parse("") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment