diff --git a/lib/referator/machine.rb b/lib/referator/machine.rb index de27e9e..75aaf11 100644 --- a/lib/referator/machine.rb +++ b/lib/referator/machine.rb @@ -49,6 +49,25 @@ module Referator :pong end + def do_exec(command) + File.open File.expand_path command.data, workdir do |file| + code = '' + while running? + line = file.gets&.strip + break if line.nil? + next if line.empty? || line.start_with?('#') + + if line.end_with? '\\' + code += line[...-1] + else + call Command.parse "#{code}#{line}" + code = '' + end + end + end + nil + end + ########## # Config # ########## diff --git a/test.rb b/test.rb index df8050b..1e3c61b 100755 --- a/test.rb +++ b/test.rb @@ -133,9 +133,9 @@ cmd :REGISTER_FORMAT, { name: :json, script: :render } ################ cmd :REGISTER_REF, RAW_REFS[:self][:foo] -cmd :REGISTER_REF, RAW_REFS[:self][:bar] cmd :REGISTER_REF, RAW_REFS[:link][:example_com] -cmd :REGISTER_REF, RAW_REFS[:link][:causa_arcana_com] + +cmd(:EXEC, 'conf_register_ref') { |result| raise unless result.nil? } ####### # REF # diff --git a/test/conf_register_ref b/test/conf_register_ref new file mode 100644 index 0000000..d5419a4 --- /dev/null +++ b/test/conf_register_ref @@ -0,0 +1,16 @@ +# self references +register_ref { \ + "category": "self", \ + "id": "/blog/bar", \ + "slug": "blog-bar", \ + "text": "Bar" \ +} + +# link references +register_ref { \ + "category": "link", \ + "id": "causa_arcana_com", \ + "slug": "causa-arcana-com", \ + "url": "https://causa-arcana.com", \ + "text": "Causa Arcana" \ +}