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.
10 11 12 13 14 15 16 |
# File 'lib/probe_dock_ruby/config.rb', line 10 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.
8 9 10 |
# File 'lib/probe_dock_ruby/config.rb', line 8 def load_warnings @load_warnings end |
#local_mode=(value) ⇒ Object (writeonly)
Sets the attribute local_mode
7 8 9 |
# File 'lib/probe_dock_ruby/config.rb', line 7 def local_mode=(value) @local_mode = value end |
#print_payload=(value) ⇒ Object (writeonly)
Sets the attribute print_payload
7 8 9 |
# File 'lib/probe_dock_ruby/config.rb', line 7 def print_payload=(value) @print_payload = value end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'lib/probe_dock_ruby/config.rb', line 8 def project @project end |
#publish=(value) ⇒ Object (writeonly)
Sets the attribute publish
7 8 9 |
# File 'lib/probe_dock_ruby/config.rb', line 7 def publish=(value) @publish = value end |
#save_payload=(value) ⇒ Object (writeonly)
Sets the attribute save_payload
7 8 9 |
# File 'lib/probe_dock_ruby/config.rb', line 7 def save_payload=(value) @save_payload = value end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
8 9 10 |
# File 'lib/probe_dock_ruby/config.rb', line 8 def server @server end |
#workspace ⇒ Object
Returns the value of attribute workspace.
8 9 10 |
# File 'lib/probe_dock_ruby/config.rb', line 8 def workspace @workspace end |
Instance Method Details
#client_options ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/probe_dock_ruby/config.rb', line 30 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
40 41 42 43 44 45 46 47 48 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 |
# File 'lib/probe_dock_ruby/config.rb', line 40 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
22 23 24 |
# File 'lib/probe_dock_ruby/config.rb', line 22 def servers @servers.dup end |