Class: RSGem::Dependencies::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rsgem/dependencies/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, **args) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
# File 'lib/rsgem/dependencies/base.rb', line 9

def initialize(name:, **args)
  @config_file_source = args[:config_file_source]
  @config_file_destination = args[:config_file_destination]
  @mode = args[:mode] || 'development' # Either `development' or `runtime'
  @name = name
  @post_install_task = args[:post_install_task]
  version = args[:version]
  @version = version ? "'#{version}'" : nil
end

Instance Attribute Details

#config_file_destinationObject (readonly)

Returns the value of attribute config_file_destination.



6
7
8
# File 'lib/rsgem/dependencies/base.rb', line 6

def config_file_destination
  @config_file_destination
end

#config_file_sourceObject (readonly)

Returns the value of attribute config_file_source.



6
7
8
# File 'lib/rsgem/dependencies/base.rb', line 6

def config_file_source
  @config_file_source
end

#modeObject (readonly)

Returns the value of attribute mode.



6
7
8
# File 'lib/rsgem/dependencies/base.rb', line 6

def mode
  @mode
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/rsgem/dependencies/base.rb', line 6

def name
  @name
end

#post_install_taskObject (readonly)

Returns the value of attribute post_install_task.



6
7
8
# File 'lib/rsgem/dependencies/base.rb', line 6

def post_install_task
  @post_install_task
end

#versionObject (readonly)

Returns the value of attribute version.



6
7
8
# File 'lib/rsgem/dependencies/base.rb', line 6

def version
  @version
end

Instance Method Details

#install(context) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/rsgem/dependencies/base.rb', line 19

def install(context)
  if config_file_source
    File.open("#{context.folder_path}/#{config_file_destination}", 'w') do |file|
      file.puts config_file_source_content
    end
  end

  post_install_task&.new(context: context)&.perform
end