Class: Superhosting::Base
- Inherits:
-
Object
- Object
- Superhosting::Base
- Includes:
- Helpers
- Defined in:
- lib/superhosting/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#lib ⇒ Object
readonly
Returns the value of attribute lib.
Instance Method Summary collapse
- #get_base_controller_options ⇒ Object
- #get_controller(controller, **kwargs) ⇒ Object
-
#initialize(config_path: '/etc/sx', lib_path: '/var/sx', logger: nil, docker_api: nil, dry_run: nil, debug: nil, **kwargs) ⇒ Base
constructor
A new instance of Base.
Methods included from Helpers
Methods included from Helper::Config
#_config, #_config_options, #_save_registry!, #apply, #configure, #configure_with_apply, #reconfig, #unapply, #unconfigure, #unconfigure_with_unapply
Methods included from Helper::Cmd
#_command, #_command_without_debug, #command, #command!
Methods included from Helper::File
#chmod!, #chown!, #chown_r!, #safe_link!, #safe_unlink!
Methods included from Helper::Logger
#__debug, #__dry_run, #__dry_run=, #__logger, #__logger=, #debug, #debug_block, #debug_operation, #indent, #indent=, #indent_reset, #indent_step, #indent_step_back, #info, #storage, #t, #with_dry_run, #with_indent, #with_logger
Constructor Details
#initialize(config_path: '/etc/sx', lib_path: '/var/sx', logger: nil, docker_api: nil, dry_run: nil, debug: nil, **kwargs) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/superhosting/base.rb', line 7 def initialize(config_path: '/etc/sx', lib_path: '/var/sx', logger: nil, docker_api: nil, dry_run: nil, debug: nil, **kwargs) @config_path = Pathname.new(config_path) @lib_path = Pathname.new(lib_path) @config = PathMapper.new(config_path) @lib = PathMapper.new(lib_path) Thread.current[:logger] ||= logger Thread.current[:debug] ||= debug Thread.current[:dry_run] ||= dry_run @docker_api = docker_api || DockerApi.new(socket: @config.f('docker_socket', default: nil)) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/superhosting/base.rb', line 5 def config @config end |
#lib ⇒ Object (readonly)
Returns the value of attribute lib.
5 6 7 |
# File 'lib/superhosting/base.rb', line 5 def lib @lib end |
Instance Method Details
#get_base_controller_options ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/superhosting/base.rb', line 19 def { config_path: @config_path.to_s, lib_path: @lib_path.to_s, docker_api: @docker_api, } end |
#get_controller(controller, **kwargs) ⇒ Object
27 28 29 |
# File 'lib/superhosting/base.rb', line 27 def get_controller(controller, **kwargs) controller.new(**self..merge!(kwargs)) end |