kelredd-resourceful 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ module Resourceful
13
13
  def initialize(args={})
14
14
  ATTRS.each { |a| instance_variable_set("@#{a.to_s}", args.delete(a)) }
15
15
  @cache = Resourceful::Resource::Cache.new
16
- @logger = Log4r::Logger.new('Resourceful Base')
16
+ @logger = Log4r::Logger.new('[Resourceful]')
17
17
  @logger.add(Log4r::StdoutOutputter.new('console'))
18
18
  end
19
19
 
@@ -28,10 +28,10 @@ module Resourceful
28
28
  cache_key = Resourceful::Resource::Cache.key(@host, verb.to_s, full_resource_path)
29
29
 
30
30
  if opts[:force] || (resp = cache.read(cache_key)).nil?
31
- log "Resource call: #{resource_summary}"
31
+ log "#{resource_summary}"
32
32
  resp = cache.write(cache_key, block.call(full_resource_path))
33
33
  else
34
- log "Resource call: [CACHE] #{resource_summary}"
34
+ log "[CACHE] #{resource_summary}"
35
35
  end
36
36
  format.build(resp)
37
37
  end
@@ -61,13 +61,7 @@ module Resourceful
61
61
  end
62
62
 
63
63
  def log(msg, level = :info) # :nodoc:
64
- if(msg)
65
- if @logger && @logger.respond_to?(level)
66
- @logger.send(level.to_s, msg)
67
- else
68
- puts "** [#{level.to_s.upcase}]: #{msg}"
69
- end
70
- end
64
+ @logger.send(level.to_s, msg) if msg
71
65
  end
72
66
 
73
67
  def log=(file)
@@ -3,9 +3,9 @@ module Resourceful
3
3
 
4
4
  class Base
5
5
 
6
- @@agent = nil
6
+ @@agent ||= {}
7
7
  def self.agent(&block)
8
- @@agent = block;
8
+ @@agent[self.name.to_s] = block;
9
9
  end
10
10
 
11
11
  def self.get(path, opts={})
@@ -185,10 +185,19 @@ module Resourceful
185
185
  end
186
186
 
187
187
  def self.set_agent
188
- unless @@agent.kind_of?(Resourceful::Agent::Base)
189
- @@agent = @@agent.call
188
+ klass_name = ""
189
+ self.ancestors.each do |anc|
190
+ p anc
191
+ if @@agent[anc.to_s]
192
+ klass_name = anc.to_s
193
+ break
194
+ end
195
+ end
196
+
197
+ unless @@agent[klass_name].kind_of?(Resourceful::Agent::Base)
198
+ @@agent[klass_name] = @@agent[klass_name].call
190
199
  end
191
- @@agent
200
+ @@agent[klass_name]
192
201
  end
193
202
 
194
203
  end
@@ -3,7 +3,7 @@ module Resourceful
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- TINY = 3
6
+ TINY = 4
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-resourceful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-12 00:00:00 -07:00
12
+ date: 2009-08-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency