Skip to content

Commit

Permalink
Format files
Browse files Browse the repository at this point in the history
  • Loading branch information
meatball133 committed Nov 9, 2024
1 parent 5c27b41 commit b1f131f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
9 changes: 5 additions & 4 deletions generatorv2/lib/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(exercise = nil)
end

def generate(result_path = "./exercises/practice/#{@exercise}/#{@exercise}_test.rb")
json = get_remote_files
json = remote_files
uuid = toml("./exercises/practice/#{@exercise}/.meta/tests.toml")
additional_json(json)
json["cases"] = remove_tests(uuid, json)
Expand Down Expand Up @@ -56,11 +56,12 @@ def toml(path = "./exercises/practice/#{@exercise}/.meta/tests.toml")

uuid = TomlRB.load_file(path)
uuid.filter do |_k, v|
v.none? { |k, v| k == "include" && !v }
end.map { |k, _v| k }
v.none? { |k, inner_value| k == "include" && !inner_value }
end
uuid.map { |k, _v| k }
end

def get_remote_files
def remote_files
url = URI.parse("https://raw.githubusercontent.com/exercism/problem-specifications/main/exercises/#{@exercise}/canonical-data.json")
response = Net::HTTP.get_response(url)
case response
Expand Down
15 changes: 13 additions & 2 deletions generatorv2/test/toml_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@

class GeneratorTest < Minitest::Test
def test_importning_toml
assert_equal %w[1e22cceb-c5e4-4562-9afe-aef07ad1eaf4 79ae3889-a5c0-4b01-baf0-232d31180c08 ec7000a7-3931-4a17-890e-33ca2073a548 32dd261c-0c92-469a-9c5c-b192e94a63b0 ae2ac9fa-a606-4d05-8244-3bcc4659c1d4 0e4b1e7c-1a6d-48fb-81a7-bf65eb9e69f9 6a078f49-c68d-4b7b-89af-33a1a98c28cc],
assert_equal %w[1e22cceb-c5e4-4562-9afe-aef07ad1eaf4
79ae3889-a5c0-4b01-baf0-232d31180c08
ec7000a7-3931-4a17-890e-33ca2073a548
32dd261c-0c92-469a-9c5c-b192e94a63b0
ae2ac9fa-a606-4d05-8244-3bcc4659c1d4
0e4b1e7c-1a6d-48fb-81a7-bf65eb9e69f9
6a078f49-c68d-4b7b-89af-33a1a98c28cc],
Generator.new("two_fer").toml("generatorv2/test/misc/tests.toml")
end

def test_importing_toml_with_no_include
assert_equal %w[1e22cceb-c5e4-4562-9afe-aef07ad1eaf4 79ae3889-a5c0-4b01-baf0-232d31180c08 ec7000a7-3931-4a17-890e-33ca2073a548 32dd261c-0c92-469a-9c5c-b192e94a63b0 ae2ac9fa-a606-4d05-8244-3bcc4659c1d4 6a078f49-c68d-4b7b-89af-33a1a98c28cc],
assert_equal %w[1e22cceb-c5e4-4562-9afe-aef07ad1eaf4
79ae3889-a5c0-4b01-baf0-232d31180c08
ec7000a7-3931-4a17-890e-33ca2073a548
32dd261c-0c92-469a-9c5c-b192e94a63b0
ae2ac9fa-a606-4d05-8244-3bcc4659c1d4
6a078f49-c68d-4b7b-89af-33a1a98c28cc],
Generator.new("two_fer").toml("generatorv2/test/misc/tests_no_include.toml")
end

Expand Down

0 comments on commit b1f131f

Please sign in to comment.