Class: LogicaCompiler::Installer
- Inherits:
-
Object
- Object
- LogicaCompiler::Installer
- Defined in:
- lib/logica_compiler/installer.rb
Constant Summary collapse
- PINNED_LOGICA_VERSION =
"1.3.1415926535897"- DEFAULT_ENGINE =
"postgres"- DEFAULT_OUTPUT_DIR =
"logica/compiled"- SAMPLE_PROGRAM_REL =
"logica/programs/hello_world.l"- SAMPLE_QUERY_NAME =
"hello_world"- SAMPLE_PREDICATE =
"Greet"
Instance Method Summary collapse
-
#initialize(root:, force: false, stdout: $stdout, stderr: $stderr) ⇒ Installer
constructor
A new instance of Installer.
- #run! ⇒ Object
Constructor Details
#initialize(root:, force: false, stdout: $stdout, stderr: $stderr) ⇒ Installer
Returns a new instance of Installer.
19 20 21 22 23 24 25 |
# File 'lib/logica_compiler/installer.rb', line 19 def initialize(root:, force: false, stdout: $stdout, stderr: $stderr) @root = Pathname(root) @force = !!force @stdout = stdout @stderr = stderr @conflicts = [] end |
Instance Method Details
#run! ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/logica_compiler/installer.rb', line 27 def run! ensure_dir(@root.join("logica/programs")) ensure_dir(@root.join("logica/compiled")) ensure_file(@root.join("logica/programs/.keep"), "", mode: nil) ensure_file(@root.join("logica/compiled/.keep"), "", mode: nil) ensure_template(@root.join(SAMPLE_PROGRAM_REL), "hello_world.l", mode: nil) ensure_config_yml ensure_requirements ensure_gitignore_block ensure_template(@root.join("bin/logica"), "bin_logica", mode: 0o755) ensure_template(@root.join("config/initializers/logica_compiler.rb"), "initializer.rb", mode: nil) if @conflicts.any? @stderr.puts "\nConflicts detected. No files were overwritten." @stderr.puts @conflicts.map { |p| " - #{p}" }.join("\n") @stderr.puts "\nHow to resolve:" @stderr.puts " - Re-run with FORCE=1 to overwrite conflicting files" @stderr.puts " - Or manually merge the templates and re-run" @stderr.puts "Template source: #{template_root}" raise InstallError, "LogicaCompiler install aborted due to conflicts (FORCE=1 to overwrite)." end say("done", "Installed LogicaCompiler integration into #{@root}") say("next", "bin/logica install") say("next", "bin/logica compile") true end |