Class: Replr::Stack::REPLMaker

Inherits:
Object
  • Object
show all
Defined in:
lib/replr/stack/repl_maker.rb

Overview

Abstract class to do many things common when creating a REPL across stacks

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stack:, libraries:) ⇒ REPLMaker

Returns a new instance of REPLMaker.



27
28
29
30
31
32
33
# File 'lib/replr/stack/repl_maker.rb', line 27

def initialize(stack:, libraries:)
  @process_runner = Replr::ProcessRunner.new

  @stack = stack
  @libraries = libraries
  @work_dir = Dir.mktmpdir
end

Instance Attribute Details

#bootstrap_file_nameObject (readonly)

Returns the value of attribute bootstrap_file_name.



11
12
13
# File 'lib/replr/stack/repl_maker.rb', line 11

def bootstrap_file_name
  @bootstrap_file_name
end

#filter_matching_lines_for_installObject (readonly)

Returns the value of attribute filter_matching_lines_for_install.



11
12
13
# File 'lib/replr/stack/repl_maker.rb', line 11

def filter_matching_lines_for_install
  @filter_matching_lines_for_install
end

#filter_not_matching_lines_for_installObject (readonly)

Returns the value of attribute filter_not_matching_lines_for_install.



11
12
13
# File 'lib/replr/stack/repl_maker.rb', line 11

def filter_not_matching_lines_for_install
  @filter_not_matching_lines_for_install
end

#librariesObject (readonly)

Returns the value of attribute libraries.



10
11
12
# File 'lib/replr/stack/repl_maker.rb', line 10

def libraries
  @libraries
end

#library_file_nameObject (readonly)

Returns the value of attribute library_file_name.



11
12
13
# File 'lib/replr/stack/repl_maker.rb', line 11

def library_file_name
  @library_file_name
end

#process_runnerObject (readonly)

Returns the value of attribute process_runner.



9
10
11
# File 'lib/replr/stack/repl_maker.rb', line 9

def process_runner
  @process_runner
end

#stackObject (readonly)

Returns the value of attribute stack.



10
11
12
# File 'lib/replr/stack/repl_maker.rb', line 10

def stack
  @stack
end

#template_dirObject (readonly)

Returns the value of attribute template_dir.



11
12
13
# File 'lib/replr/stack/repl_maker.rb', line 11

def template_dir
  @template_dir
end

#work_dirObject (readonly)

Returns the value of attribute work_dir.



10
11
12
# File 'lib/replr/stack/repl_maker.rb', line 10

def work_dir
  @work_dir
end

Class Method Details

.load(stack:, libraries:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/replr/stack/repl_maker.rb', line 15

def self.load(stack:, libraries:)
  stack_name, _stack_version = stack.split(':')
  require_relative "#{stack_name}/repl_maker"

  repl_maker_class_name = "Replr::Stack::#{stack_name.capitalize}::REPLMaker"
  repl_maker = Object.const_get(repl_maker_class_name).new(
    stack: stack,
    libraries: libraries
  )
  repl_maker.create
end

Instance Method Details

#createObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/replr/stack/repl_maker.rb', line 35

def create
  set_template_dir
  set_library_file_name
  set_bootstrap_file_name
  set_filter_lines_for_install

  copy_library_file
  copy_initialization_files
  initialize_docker_repl
end