Class: ProbeDockProbe::Config
- Inherits:
-
Object
- Object
- ProbeDockProbe::Config
- Defined in:
- lib/probe_dock_ruby/config.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#load_warnings ⇒ Object
readonly
Returns the value of attribute load_warnings.
-
#local_mode ⇒ Object
writeonly
Sets the attribute local_mode.
-
#print_payload ⇒ Object
writeonly
Sets the attribute print_payload.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#publish ⇒ Object
writeonly
Sets the attribute publish.
-
#save_payload ⇒ Object
writeonly
Sets the attribute save_payload.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Instance Method Summary collapse
- #client_options ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load! {|_self| ... } ⇒ Object
- #servers ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
19 20 21 22 23 24 25 |
# File 'lib/probe_dock_ruby/config.rb', line 19 def initialize @servers = [] @server = Server.new @project = Project.new @publish, @local_mode, @print_payload, @save_payload = false, false, false, false @load_warnings = [] end |
Instance Attribute Details
#load_warnings ⇒ Object (readonly)
Returns the value of attribute load_warnings.
17 18 19 |
# File 'lib/probe_dock_ruby/config.rb', line 17 def load_warnings @load_warnings end |
#local_mode=(value) ⇒ Object (writeonly)
Sets the attribute local_mode
16 17 18 |
# File 'lib/probe_dock_ruby/config.rb', line 16 def local_mode=(value) @local_mode = value end |
#print_payload=(value) ⇒ Object (writeonly)
Sets the attribute print_payload
16 17 18 |
# File 'lib/probe_dock_ruby/config.rb', line 16 def print_payload=(value) @print_payload = value end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
17 18 19 |
# File 'lib/probe_dock_ruby/config.rb', line 17 def project @project end |
#publish=(value) ⇒ Object (writeonly)
Sets the attribute publish
16 17 18 |
# File 'lib/probe_dock_ruby/config.rb', line 16 def publish=(value) @publish = value end |
#save_payload=(value) ⇒ Object (writeonly)
Sets the attribute save_payload
16 17 18 |
# File 'lib/probe_dock_ruby/config.rb', line 16 def save_payload=(value) @save_payload = value end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
17 18 19 |
# File 'lib/probe_dock_ruby/config.rb', line 17 def server @server end |
#workspace ⇒ Object
Returns the value of attribute workspace.
17 18 19 |
# File 'lib/probe_dock_ruby/config.rb', line 17 def workspace @workspace end |
Instance Method Details
#client_options ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/probe_dock_ruby/config.rb', line 39 def { publish: @publish, local_mode: @local_mode, workspace: @workspace, print_payload: @print_payload, save_payload: @save_payload }.select{ |k,v| !v.nil? } end |
#load! {|_self| ... } ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/probe_dock_ruby/config.rb', line 49 def load! @server.clear @servers.clear @load_warnings = [] config = load_config_files @publish = parse_env_flag :publish, config.fetch(:publish, true) @server_name = parse_env_option(:server) || config[:server] @local_mode = parse_env_flag(:local) || !!config[:local] self.workspace = parse_env_option(:workspace) || config[:workspace] @print_payload = parse_env_flag :print_payload, !!config[:payload][:print] @save_payload = parse_env_flag :save_payload, !!config[:payload][:save] @servers, server = build_servers config if server @server = server else @server.name = @server_name end { api_url: parse_env_option(:server_api_url), api_token: parse_env_option(:server_api_token), project_api_id: parse_env_option(:server_project_api_id) }.each{ |k,v| @server.send "#{k}=", v if v } = config[:project] .merge! api_id: @server.project_api_id if @server and @server.project_api_id @project.update yield self if block_given? check! @load_warnings.each{ |w| warn Paint["Probe Dock - #{w}", :yellow] } self end |
#servers ⇒ Object
31 32 33 |
# File 'lib/probe_dock_ruby/config.rb', line 31 def servers @servers.dup end |