Class: Luban::Deployment::Worker::Base
- Inherits:
-
Object
- Object
- Luban::Deployment::Worker::Base
- Includes:
- Helpers::Configuration, Helpers::Utils, Parameters::Application, Parameters::General, Parameters::Project
- Defined in:
- lib/luban/deployment/worker/base.rb
Direct Known Subclasses
Application::Authenticator, Application::Repository, Application::Worker, Package::Worker
Constant Summary
Constants included from Parameters::Application
Parameters::Application::DefaultLogrotateInterval, Parameters::Application::DefaultLogrotateMaxAge
Constants included from Parameters::General
Parameters::General::DefaultLubanRootPath
Constants included from Helpers::Utils
Instance Attribute Summary collapse
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Attributes included from Helpers::Utils
Attributes included from Helpers::Configuration
Instance Method Summary collapse
- #dry_run? ⇒ Boolean
- #force? ⇒ Boolean
-
#initialize(config:, backend:, **task, &blk) ⇒ Base
constructor
A new instance of Base.
- #linux? ⇒ Boolean
- #method_missing(sym, *args, &blk) ⇒ Object
- #osx? ⇒ Boolean
- #packages ⇒ Object
- #run ⇒ Object
- #target_full_name ⇒ Object
- #target_major_version ⇒ Object
- #target_name ⇒ Object
- #target_patch_level ⇒ Object
- #target_version ⇒ Object
Methods included from Parameters::Application
#dockerize, #dockerized?, #env_name, #logrotate_count, #monitor_itself?, #monitorable?
Methods included from Parameters::Base
Methods included from Parameters::Docker
#validate_for_docker_cert_path
Methods included from Parameters::Project
#monitor_defined?, #process_monitor_via
Methods included from Parameters::General
#current_uid, #current_user, included
Methods included from Helpers::Utils
#assure, #assure_dirs, #assure_symlink, #capture, #check_pass?, #chmod, #cp, #directory?, #exists?, #file?, #hardware_name, #host, #hostname, #ln, #match?, #md5_for, #md5_for_dir, #md5_for_file, #md5_matched?, #mkdir, #mv, #now, #os_name, #os_release, #readlink, #render_template, #revision_match?, #rm, #rmdir, #sudo, #symlink?, #touch, #truncate, #upload_by_template, #url_exists?, #user_home, #with_clean_env
Methods included from Helpers::Configuration
#ask, #fetch, #find_template_file, #load_configuration_file, #primary, #release_roles, #role, #roles, #server, #set, #set_default, #syntax_error?
Constructor Details
#initialize(config:, backend:, **task, &blk) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 |
# File 'lib/luban/deployment/worker/base.rb', line 13 def initialize(config:, backend:, **task, &blk) @config = config @backend = backend @run_blk = blk @task = create_task(task) init validate end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &blk) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/luban/deployment/worker/base.rb', line 41 def method_missing(sym, *args, &blk) if args.empty? and blk.nil? and config.has_key?(sym) singleton_class.send(:define_method, sym) { config.fetch(__method__) } send(sym) else super end end |
Instance Attribute Details
#task ⇒ Object (readonly)
Returns the value of attribute task.
11 12 13 |
# File 'lib/luban/deployment/worker/base.rb', line 11 def task @task end |
Instance Method Details
#dry_run? ⇒ Boolean
23 |
# File 'lib/luban/deployment/worker/base.rb', line 23 def dry_run?; task.opts.dry_run; end |
#force? ⇒ Boolean
22 |
# File 'lib/luban/deployment/worker/base.rb', line 22 def force?; task.opts.force; end |
#linux? ⇒ Boolean
26 |
# File 'lib/luban/deployment/worker/base.rb', line 26 def linux?; os_name == 'Linux'; end |
#osx? ⇒ Boolean
25 |
# File 'lib/luban/deployment/worker/base.rb', line 25 def osx?; os_name == 'Darwin'; end |
#packages ⇒ Object
35 |
# File 'lib/luban/deployment/worker/base.rb', line 35 def packages; task.opts.packages; end |
#run ⇒ Object
37 38 39 |
# File 'lib/luban/deployment/worker/base.rb', line 37 def run update_result(__return__: @run_blk ? run_with_block : run_with_command).to_h end |
#target_full_name ⇒ Object
29 |
# File 'lib/luban/deployment/worker/base.rb', line 29 def target_full_name; "#{target_name}-#{target_version}"; end |
#target_major_version ⇒ Object
32 |
# File 'lib/luban/deployment/worker/base.rb', line 32 def target_major_version; task.opts.major_version || target_version; end |
#target_name ⇒ Object
28 |
# File 'lib/luban/deployment/worker/base.rb', line 28 def target_name; task.opts.name; end |
#target_patch_level ⇒ Object
33 |
# File 'lib/luban/deployment/worker/base.rb', line 33 def target_patch_level; task.opts.patch_level || ''; end |
#target_version ⇒ Object
31 |
# File 'lib/luban/deployment/worker/base.rb', line 31 def target_version; task.opts.version; end |