README.md in busted-0.1.0 vs README.md in busted-0.2.0
- old
+ new
@@ -24,10 +24,16 @@
Busted.run do
class Pizza
end
end
#=> {:invalidations=>{:method=>0, :constant=>1}}
+
+Busted.start
+class Pie
+end
+Busted.finish
+#=> {:invalidations=>{:method=>0, :constant=>1}}
```
*Method Cache*
```ruby
@@ -39,11 +45,23 @@
Busted.method_cache_invalidations do
def pizza
end
end
-#=> 3
+#=> 1
+
+Busted.run do
+ def pie
+ end
+end
+#=> {:invalidations=>{:method=>1, :constant=>0}}
+
+Busted.start
+def smoothie
+end
+Busted.finish
+#=> {:invalidations=>{:method=>1, :constant=>0}}
```
*Constant Cache*
```ruby
@@ -54,10 +72,20 @@
Busted.constant_cache_invalidations do
CHEESE = "cheese"
end
#=> 1
+
+Busted.run do
+ PIE = "pumpkin"
+end
+#=> {:invalidations=>{:method=>0, :constant=>1}}
+
+Busted.start
+SMOOTHIE = "blueberry"
+Busted.finish
+#=> {:invalidations=>{:method=>0, :constant=>1}}
```
*No Cache Busted*
```ruby
@@ -68,10 +96,15 @@
Busted.run do
pizza = "pizza"
end
#=> {:invalidations=>{:method=>0, :constant=>0}}
+
+Busted.start
+pie = "pie"
+Busted.finish
+#=> {:invalidations=>{:method=>0, :constant=>0}}
```
## Advanced Usage
Busted can report method cache invalidation locations via [`dtrace`](http://en.wikipedia.org/wiki/DTrace). The running process must have root privileges, and `dtrace` must be installed.
@@ -79,11 +112,12 @@
```ruby
require "busted"
require "pp"
report = Busted.run(trace: true) do
- def cookie; end
+ def cookie
+ end
end
pp report
```
```bash
@@ -104,9 +138,28 @@
# Busted runs dtrace in a child process with root privileges
$ ruby trace.rb
{:invalidations=>{:method=>1, :constant=>0},
:traces=>
{:method=>[{:class=>"global", :sourcefile=>"trace.rb", :lineno=>"5"}]}}
+```
+
+*start_finish_trace.rb*
+```ruby
+require "busted"
+require "pp"
+
+Busted.start trace: true
+def ice_cream
+end
+pp Busted.finish
+```
+
+```bash
+$ ruby start_finish_trace.rb
+{:invalidations=>{:method=>1, :constant=>0},
+ :traces=>
+ {:method=>
+ [{:class=>"global", :sourcefile=>"start_finish_trace.rb", :lineno=>"5"}]}}
```
Busted includes an [example `dtrace` probe](/dtrace/probes/examples/method-cache-clear.d) for use on the command line or an application. See the [probe](/dtrace/probes/examples/method-cache-clear.d) for usage.
## Installation