Class: RoxClient::Config
- Inherits:
-
Object
- Object
- RoxClient::Config
- Defined in:
- lib/rox-client-ruby/config.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#cache_payload ⇒ Object
writeonly
Sets the attribute cache_payload.
-
#client_name ⇒ Object
writeonly
Sets the attribute client_name.
-
#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 ⇒ Object
- #servers ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
29 30 31 32 33 34 |
# File 'lib/rox-client-ruby/config.rb', line 29 def initialize @servers = [] @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
26 27 28 |
# File 'lib/rox-client-ruby/config.rb', line 26 def cache_payload=(value) @cache_payload = value end |
#client_name=(value) ⇒ Object (writeonly)
Sets the attribute client_name
26 27 28 |
# File 'lib/rox-client-ruby/config.rb', line 26 def client_name=(value) @client_name = value end |
#load_warnings ⇒ Object (readonly)
Returns the value of attribute load_warnings.
27 28 29 |
# File 'lib/rox-client-ruby/config.rb', line 27 def load_warnings @load_warnings end |
#local_mode=(value) ⇒ Object (writeonly)
Sets the attribute local_mode
26 27 28 |
# File 'lib/rox-client-ruby/config.rb', line 26 def local_mode=(value) @local_mode = value end |
#print_payload=(value) ⇒ Object (writeonly)
Sets the attribute print_payload
26 27 28 |
# File 'lib/rox-client-ruby/config.rb', line 26 def print_payload=(value) @print_payload = value end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
27 28 29 |
# File 'lib/rox-client-ruby/config.rb', line 27 def project @project end |
#publish=(value) ⇒ Object (writeonly)
Sets the attribute publish
26 27 28 |
# File 'lib/rox-client-ruby/config.rb', line 26 def publish=(value) @publish = value end |
#save_payload=(value) ⇒ Object (writeonly)
Sets the attribute save_payload
26 27 28 |
# File 'lib/rox-client-ruby/config.rb', line 26 def save_payload=(value) @save_payload = value end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
27 28 29 |
# File 'lib/rox-client-ruby/config.rb', line 27 def server @server end |
#workspace ⇒ Object
Returns the value of attribute workspace.
27 28 29 |
# File 'lib/rox-client-ruby/config.rb', line 27 def workspace @workspace end |
Instance Method Details
#client_options ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rox-client-ruby/config.rb', line 48 def { publish: @publish, local_mode: @local_mode, workspace: @workspace, cache_payload: @cache_payload, print_payload: @print_payload, save_payload: @save_payload, client_name: @client_name }.select{ |k,v| !v.nil? } end |
#load ⇒ Object
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/rox-client-ruby/config.rb', line 60 def load @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 @servers.empty? @load_warnings << "No server defined" elsif !@server_name @load_warnings << "No server name given" elsif !@server @load_warnings << "Unknown server '#{@server_name}'" end = 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/rox-client-ruby/config.rb', line 40 def servers @servers.dup end |