Class: ProbeDockRSpec::Config
- Inherits:
-
Object
- Object
- ProbeDockRSpec::Config
- Defined in:
- lib/probe_dock_rspec/config.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#cache_payload ⇒ Object
writeonly
Sets the attribute cache_payload.
-
#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
- #check! ⇒ Object
- #client_options ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load! ⇒ Object
- #servers ⇒ Object
-
#setup! ⇒ Object
Plugs Probe Dock utilities into RSpec.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
28 29 30 31 32 33 34 |
# File 'lib/probe_dock_rspec/config.rb', line 28 def initialize @servers = [] @server = Server.new @project = Project.new @publish, @local_mode, @cache_payload, @print_payload, @save_payload = false, false, false, false, false @load_warnings = [] end |
Instance Attribute Details
#cache_payload=(value) ⇒ Object (writeonly)
Sets the attribute cache_payload
25 26 27 |
# File 'lib/probe_dock_rspec/config.rb', line 25 def cache_payload=(value) @cache_payload = value end |
#load_warnings ⇒ Object (readonly)
Returns the value of attribute load_warnings.
26 27 28 |
# File 'lib/probe_dock_rspec/config.rb', line 26 def load_warnings @load_warnings end |
#local_mode=(value) ⇒ Object (writeonly)
Sets the attribute local_mode
25 26 27 |
# File 'lib/probe_dock_rspec/config.rb', line 25 def local_mode=(value) @local_mode = value end |
#print_payload=(value) ⇒ Object (writeonly)
Sets the attribute print_payload
25 26 27 |
# File 'lib/probe_dock_rspec/config.rb', line 25 def print_payload=(value) @print_payload = value end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
26 27 28 |
# File 'lib/probe_dock_rspec/config.rb', line 26 def project @project end |
#publish=(value) ⇒ Object (writeonly)
Sets the attribute publish
25 26 27 |
# File 'lib/probe_dock_rspec/config.rb', line 25 def publish=(value) @publish = value end |
#save_payload=(value) ⇒ Object (writeonly)
Sets the attribute save_payload
25 26 27 |
# File 'lib/probe_dock_rspec/config.rb', line 25 def save_payload=(value) @save_payload = value end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
26 27 28 |
# File 'lib/probe_dock_rspec/config.rb', line 26 def server @server end |
#workspace ⇒ Object
Returns the value of attribute workspace.
26 27 28 |
# File 'lib/probe_dock_rspec/config.rb', line 26 def workspace @workspace end |
Instance Method Details
#check! ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/probe_dock_rspec/config.rb', line 104 def check! configs = [ home_config_file, working_config_file ] actual_configs = configs.select{ |f| File.exists? f } if actual_configs.empty? @load_warnings << %|no config file found, looking for:\n #{configs.join "\n "}| end if @servers.empty? @load_warnings << "No server defined" elsif !@server_name && !@server.name @load_warnings << "No server name given" end end |
#client_options ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/probe_dock_rspec/config.rb', line 55 def { publish: @publish, local_mode: @local_mode, workspace: @workspace, cache_payload: @cache_payload, print_payload: @print_payload, save_payload: @save_payload }.select{ |k,v| !v.nil? } end |
#load! ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/probe_dock_rspec/config.rb', line 66 def load! @server.clear @servers.clear @load_warnings = [] return unless config = load_config_files @publish = parse_env_flag :publish, !!config[:publish] @server_name = parse_env_option(:server) || config[:server] @local_mode = parse_env_flag(:local) || !!config[:local] self.workspace = parse_env_option(:workspace) || config[:workspace] @cache_payload = parse_env_flag :cache_payload, !!config[:payload][:cache] @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 self end |
#servers ⇒ Object
40 41 42 |
# File 'lib/probe_dock_rspec/config.rb', line 40 def servers @servers.dup end |
#setup! ⇒ Object
Plugs Probe Dock utilities into RSpec.
45 46 47 48 49 |
# File 'lib/probe_dock_rspec/config.rb', line 45 def setup! ::RSpec.configure do |c| c.add_formatter Formatter end end |