From fb808be8871c1ddf27f94d60b7a7f278902b8b90 Mon Sep 17 00:00:00 2001 From: Sharon Rosner Date: Wed, 8 May 2024 08:15:44 +0200 Subject: [PATCH] Compiler: move fixtures, update sirop --- Gemfile.lock | 8 ++--- lib/papercraft/compiler.rb | 30 ------------------- papercraft.gemspec | 2 +- test/fixtures/{ => compiler}/attributes.html | 0 .../{ => compiler}/attributes_compiled.rb | 0 .../{ => compiler}/attributes_source.rb | 0 test/fixtures/{ => compiler}/basic.html | 0 .../fixtures/{ => compiler}/basic_compiled.rb | 0 test/fixtures/{ => compiler}/basic_source.rb | 0 test/fixtures/{ => compiler}/expr_text.html | 0 .../{ => compiler}/expr_text_compiled.rb | 0 .../{ => compiler}/expr_text_source.rb | 0 .../fixtures/{ => compiler}/interspersed.html | 0 .../{ => compiler}/interspersed_compiled.rb | 0 .../{ => compiler}/interspersed_source.rb | 0 test/fixtures/{ => compiler}/iteration.html | 0 .../{ => compiler}/iteration_compiled.rb | 0 .../{ => compiler}/iteration_source.rb | 0 test/test_compiler.rb | 6 ++-- 19 files changed, 8 insertions(+), 38 deletions(-) rename test/fixtures/{ => compiler}/attributes.html (100%) rename test/fixtures/{ => compiler}/attributes_compiled.rb (100%) rename test/fixtures/{ => compiler}/attributes_source.rb (100%) rename test/fixtures/{ => compiler}/basic.html (100%) rename test/fixtures/{ => compiler}/basic_compiled.rb (100%) rename test/fixtures/{ => compiler}/basic_source.rb (100%) rename test/fixtures/{ => compiler}/expr_text.html (100%) rename test/fixtures/{ => compiler}/expr_text_compiled.rb (100%) rename test/fixtures/{ => compiler}/expr_text_source.rb (100%) rename test/fixtures/{ => compiler}/interspersed.html (100%) rename test/fixtures/{ => compiler}/interspersed_compiled.rb (100%) rename test/fixtures/{ => compiler}/interspersed_source.rb (100%) rename test/fixtures/{ => compiler}/iteration.html (100%) rename test/fixtures/{ => compiler}/iteration_compiled.rb (100%) rename test/fixtures/{ => compiler}/iteration_source.rb (100%) diff --git a/Gemfile.lock b/Gemfile.lock index 1b47c41..00295cf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,7 @@ PATH kramdown (~> 2.4.0) kramdown-parser-gfm (~> 1.1.0) rouge (~> 4.2.0) - sirop (~> 0.3) + sirop (~> 0.4) GEM remote: https://rubygems.org/ @@ -19,11 +19,11 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) minitest (5.22.3) - prism (0.19.0) + prism (0.27.0) rexml (3.2.6) rouge (4.2.1) - sirop (0.3) - prism (~> 0.19.0) + sirop (0.4) + prism (~> 0.27.0) tilt (2.2.0) PLATFORMS diff --git a/lib/papercraft/compiler.rb b/lib/papercraft/compiler.rb index 9dda78f..5de896a 100644 --- a/lib/papercraft/compiler.rb +++ b/lib/papercraft/compiler.rb @@ -4,36 +4,6 @@ require 'escape_utils' require 'sirop' -class Sirop::Sourcifier - # VISIT_PLANS.merge!({ - # self: :emit_verbatim - # }) - - def emit_nothing(node) - # emit nothing - end - - def visit_self_node(node) - emit_verbatim(node) - end - - def visit_numbered_parameters_node(node) - emit_nothing(node) - end - - def visit_hash_node(node) - emit_code(node.opening_loc) - visit_comma_separated_nodes(node.elements) - emit_code(node.closing_loc) - end - - def visit_array_node(node) - emit_code(node.opening_loc) - visit_comma_separated_nodes(node.elements) - emit_code(node.closing_loc) - end -end - class Papercraft::Compiler < Sirop::Sourcifier def initialize super diff --git a/papercraft.gemspec b/papercraft.gemspec index fcb91c8..7c4b210 100644 --- a/papercraft.gemspec +++ b/papercraft.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib"] s.required_ruby_version = '>= 3.2' - s.add_runtime_dependency 'sirop', '~>0.3' + s.add_runtime_dependency 'sirop', '~>0.4' s.add_runtime_dependency 'escape_utils', '~>1.3.0' s.add_runtime_dependency 'kramdown', '~>2.4.0' s.add_runtime_dependency 'rouge', '~>4.2.0' diff --git a/test/fixtures/attributes.html b/test/fixtures/compiler/attributes.html similarity index 100% rename from test/fixtures/attributes.html rename to test/fixtures/compiler/attributes.html diff --git a/test/fixtures/attributes_compiled.rb b/test/fixtures/compiler/attributes_compiled.rb similarity index 100% rename from test/fixtures/attributes_compiled.rb rename to test/fixtures/compiler/attributes_compiled.rb diff --git a/test/fixtures/attributes_source.rb b/test/fixtures/compiler/attributes_source.rb similarity index 100% rename from test/fixtures/attributes_source.rb rename to test/fixtures/compiler/attributes_source.rb diff --git a/test/fixtures/basic.html b/test/fixtures/compiler/basic.html similarity index 100% rename from test/fixtures/basic.html rename to test/fixtures/compiler/basic.html diff --git a/test/fixtures/basic_compiled.rb b/test/fixtures/compiler/basic_compiled.rb similarity index 100% rename from test/fixtures/basic_compiled.rb rename to test/fixtures/compiler/basic_compiled.rb diff --git a/test/fixtures/basic_source.rb b/test/fixtures/compiler/basic_source.rb similarity index 100% rename from test/fixtures/basic_source.rb rename to test/fixtures/compiler/basic_source.rb diff --git a/test/fixtures/expr_text.html b/test/fixtures/compiler/expr_text.html similarity index 100% rename from test/fixtures/expr_text.html rename to test/fixtures/compiler/expr_text.html diff --git a/test/fixtures/expr_text_compiled.rb b/test/fixtures/compiler/expr_text_compiled.rb similarity index 100% rename from test/fixtures/expr_text_compiled.rb rename to test/fixtures/compiler/expr_text_compiled.rb diff --git a/test/fixtures/expr_text_source.rb b/test/fixtures/compiler/expr_text_source.rb similarity index 100% rename from test/fixtures/expr_text_source.rb rename to test/fixtures/compiler/expr_text_source.rb diff --git a/test/fixtures/interspersed.html b/test/fixtures/compiler/interspersed.html similarity index 100% rename from test/fixtures/interspersed.html rename to test/fixtures/compiler/interspersed.html diff --git a/test/fixtures/interspersed_compiled.rb b/test/fixtures/compiler/interspersed_compiled.rb similarity index 100% rename from test/fixtures/interspersed_compiled.rb rename to test/fixtures/compiler/interspersed_compiled.rb diff --git a/test/fixtures/interspersed_source.rb b/test/fixtures/compiler/interspersed_source.rb similarity index 100% rename from test/fixtures/interspersed_source.rb rename to test/fixtures/compiler/interspersed_source.rb diff --git a/test/fixtures/iteration.html b/test/fixtures/compiler/iteration.html similarity index 100% rename from test/fixtures/iteration.html rename to test/fixtures/compiler/iteration.html diff --git a/test/fixtures/iteration_compiled.rb b/test/fixtures/compiler/iteration_compiled.rb similarity index 100% rename from test/fixtures/iteration_compiled.rb rename to test/fixtures/compiler/iteration_compiled.rb diff --git a/test/fixtures/iteration_source.rb b/test/fixtures/compiler/iteration_source.rb similarity index 100% rename from test/fixtures/iteration_source.rb rename to test/fixtures/compiler/iteration_source.rb diff --git a/test/test_compiler.rb b/test/test_compiler.rb index bf8e807..44d8ef4 100644 --- a/test/test_compiler.rb +++ b/test/test_compiler.rb @@ -3,11 +3,11 @@ require_relative './helper' class CompilerTest < Minitest::Test - Dir["#{FIXTURES_PATH}/*_source.rb"].each do |fn| + Dir["#{FIXTURES_PATH}/compiler/*_source.rb"].each do |fn| basename = File.basename(fn) test_name = basename.match(/^(.+)_source\.rb$/)[1] - compiled_fn = File.join(FIXTURES_PATH, "#{test_name}_compiled.rb") - html_fn = File.join(FIXTURES_PATH, "#{test_name}.html") + compiled_fn = File.join(FIXTURES_PATH, "compiler/#{test_name}_compiled.rb") + html_fn = File.join(FIXTURES_PATH, "compiler/#{test_name}.html") original_src = IO.read(fn).chomp compiled_src = IO.read(compiled_fn).chomp