Implement configuration files
This commit is contained in:
parent
15b24b8ebe
commit
16de2d44e6
3 changed files with 37 additions and 2 deletions
|
@ -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 #
|
||||
##########
|
||||
|
|
4
test.rb
4
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 #
|
||||
|
|
16
test/conf_register_ref
Normal file
16
test/conf_register_ref
Normal file
|
@ -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" \
|
||||
}
|
Loading…
Reference in a new issue