Module: Deviant
- Defined in:
- lib/deviant.rb,
lib/deviant/log.rb,
lib/deviant/client.rb,
lib/deviant/version.rb,
lib/deviant/configuration.rb
Defined Under Namespace
Classes: Client
Constant Summary collapse
- VERSION =
"0.0.2"
- DEFAULTS =
{ name: nil, redis_url: "redis://localhost:9292", elasticsearch_url: nil, sidekiq: { enabled: false, configure_server: false, configure_client: false } }
Class Method Summary collapse
- .application(name) ⇒ Object
- .client ⇒ Object
- .configure(&block) ⇒ Object
- .elasticsearch(url) ⇒ Object
- .exception(e, data = {}) ⇒ Object
- .method_missing(method, *args, &block) ⇒ Object
- .options ⇒ Object
- .options=(opts) ⇒ Object
- .redis(config) ⇒ Object
- .sidekiq(enabled, opts = {}) ⇒ Object
Class Method Details
.application(name) ⇒ Object
26 27 28 |
# File 'lib/deviant/configuration.rb', line 26 def self.application(name) [:name] = name end |
.client ⇒ Object
12 13 14 |
# File 'lib/deviant.rb', line 12 def self.client @client ||= Client.new() end |
.configure(&block) ⇒ Object
21 22 23 24 |
# File 'lib/deviant/configuration.rb', line 21 def self.configure(&block) class_eval &block setup! end |
.elasticsearch(url) ⇒ Object
39 40 41 |
# File 'lib/deviant/configuration.rb', line 39 def self.elasticsearch(url) [:elasticsearch_url] = url end |
.exception(e, data = {}) ⇒ Object
2 3 4 |
# File 'lib/deviant/log.rb', line 2 def self.exception(e, data = {}) client.store e.class.name, e., data end |
.method_missing(method, *args, &block) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/deviant/log.rb', line 6 def self.method_missing(method, *args, &block) if args.length > 0 && method.to_s[-1] == '!' && respond_to?(method.to_s[0...-1]) send method.to_s[0...-1], *args, &block raise args.first end super end |
.options ⇒ Object
13 14 15 |
# File 'lib/deviant/configuration.rb', line 13 def self. @options ||= DEFAULTS.dup end |
.options=(opts) ⇒ Object
17 18 19 |
# File 'lib/deviant/configuration.rb', line 17 def self.(opts) @options = opts end |
.redis(config) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/deviant/configuration.rb', line 30 def self.redis(config) if config.is_a?(Redis) client = config.client [:redis_url] = "#{client.scheme}://#{client.host}:#{client.port}" else [:redis_url] = config end end |
.sidekiq(enabled, opts = {}) ⇒ Object
43 44 45 46 47 |
# File 'lib/deviant/configuration.rb', line 43 def self.sidekiq(enabled, opts={}) [:sidekiq][:enabled] = enabled [:sidekiq][:configure_server] = opts[:configure_server] || false [:sidekiq][:configure_client] = opts[:configure_client] || false end |