Class: RSGem::Dependencies::Base
- Inherits:
-
Object
- Object
- RSGem::Dependencies::Base
- Defined in:
- lib/rsgem/dependencies/base.rb
Instance Attribute Summary collapse
-
#config_file_destination ⇒ Object
readonly
Returns the value of attribute config_file_destination.
-
#config_file_source ⇒ Object
readonly
Returns the value of attribute config_file_source.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#post_install_task ⇒ Object
readonly
Returns the value of attribute post_install_task.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(name:, **args) ⇒ Base
constructor
A new instance of Base.
- #install(context) ⇒ Object
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_destination ⇒ Object (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_source ⇒ Object (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 |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
6 7 8 |
# File 'lib/rsgem/dependencies/base.rb', line 6 def mode @mode end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rsgem/dependencies/base.rb', line 6 def name @name end |
#post_install_task ⇒ Object (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 |
#version ⇒ Object (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 |