Class: CelluloidBenchmark::Target
- Inherits:
-
Object
- Object
- CelluloidBenchmark::Target
- Defined in:
- lib/celluloid_benchmark/target.rb
Instance Attribute Summary collapse
-
#http_auth_password ⇒ Object
readonly
Returns the value of attribute http_auth_password.
-
#http_auth_username ⇒ Object
readonly
Returns the value of attribute http_auth_username.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #http_auth? ⇒ Boolean
-
#initialize(key, uri, http_auth_username = nil, http_auth_password = nil) ⇒ Target
constructor
A new instance of Target.
Constructor Details
#initialize(key, uri, http_auth_username = nil, http_auth_password = nil) ⇒ Target
Returns a new instance of Target.
34 35 36 37 38 39 |
# File 'lib/celluloid_benchmark/target.rb', line 34 def initialize(key, uri, http_auth_username = nil, http_auth_password = nil) @http_auth_password = http_auth_password @http_auth_username = http_auth_username @key = key @uri = uri end |
Instance Attribute Details
#http_auth_password ⇒ Object (readonly)
Returns the value of attribute http_auth_password.
3 4 5 |
# File 'lib/celluloid_benchmark/target.rb', line 3 def http_auth_password @http_auth_password end |
#http_auth_username ⇒ Object (readonly)
Returns the value of attribute http_auth_username.
4 5 6 |
# File 'lib/celluloid_benchmark/target.rb', line 4 def http_auth_username @http_auth_username end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/celluloid_benchmark/target.rb', line 5 def key @key end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/celluloid_benchmark/target.rb', line 6 def uri @uri end |
Class Method Details
.default_target ⇒ Object
30 31 32 |
# File 'lib/celluloid_benchmark/target.rb', line 30 def self.default_target Target.new("local", "http://localhost") end |
.new_from_key(key, config_file_path = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/celluloid_benchmark/target.rb', line 8 def self.new_from_key(key, config_file_path = nil) key ||= "local" config_file_path ||= "config/targets.yml" if key == "local" && !File.exists?(config_file_path) return default_target end configs = YAML.load_file(config_file_path) config = configs[key] unless config raise ArgumentError, "No target for '#{key}'" end if config["http_auth"] Target.new(key, config["uri"], config["http_auth"]["username"], config["http_auth"]["password"]) else Target.new(key, config["uri"]) end end |
Instance Method Details
#http_auth? ⇒ Boolean
41 42 43 |
# File 'lib/celluloid_benchmark/target.rb', line 41 def http_auth? http_auth_username && http_auth_password end |