Module: NetRecorder
- Defined in:
- lib/http.rb,
lib/config.rb,
lib/http_header.rb,
lib/netrecorder.rb
Overview
NetRecorder - the global namespace
Defined Under Namespace
Modules: NetHTTP, NetHTTPHeader Classes: Config
Class Method Summary collapse
-
.cache! ⇒ Object
save the fakes hash to the cash file.
-
.cache_file ⇒ Object
the path to the cache file.
-
.clear_cache! ⇒ Object
delete the cache file.
-
.config {|@@config| ... } ⇒ Object
configure netrecorder.
- .fakes ⇒ Object
-
.recording? ⇒ Boolean
returns true if record_net_calls is set to true in the config.
- .register_scope(name) ⇒ Object
- .scope ⇒ Object
- .scope=(name) ⇒ Object
Class Method Details
.cache! ⇒ Object
save the fakes hash to the cash file
37 38 39 |
# File 'lib/netrecorder.rb', line 37 def self.cache! File.open(@@config.cache_file, 'w') {|f| f.write Net::HTTP.fakes.to_yaml} end |
.cache_file ⇒ Object
the path to the cache file
13 14 15 |
# File 'lib/netrecorder.rb', line 13 def self.cache_file @@config.cache_file end |
.clear_cache! ⇒ Object
delete the cache file
42 43 44 45 46 47 |
# File 'lib/netrecorder.rb', line 42 def self.clear_cache! if File.exist?(@@config.cache_file) File.delete(@@config.cache_file) end Net::HTTP.clear_netrecorder_cache! end |
.config {|@@config| ... } ⇒ Object
configure netrecorder
22 23 24 25 26 27 28 29 |
# File 'lib/netrecorder.rb', line 22 def self.config @@configured ||= nil @@config = Config.new yield @@config record_net_calls clear_cache! if @@config.clear_cache fakeweb if @@config.fakeweb end |
.fakes ⇒ Object
17 18 19 |
# File 'lib/netrecorder.rb', line 17 def self.fakes Fake.to_array(@@config.cache_file) end |
.recording? ⇒ Boolean
returns true if record_net_calls is set to true in the config
32 33 34 |
# File 'lib/netrecorder.rb', line 32 def self.recording? @@config.record_net_calls end |
.register_scope(name) ⇒ Object
49 50 51 |
# File 'lib/netrecorder.rb', line 49 def self.register_scope(name) fakeweb(name) end |
.scope ⇒ Object
57 58 59 60 |
# File 'lib/netrecorder.rb', line 57 def self.scope return @@scope if defined?(@@scope) 'global' end |
.scope=(name) ⇒ Object
53 54 55 |
# File 'lib/netrecorder.rb', line 53 def self.scope=(name) @@scope = name end |