Clean and compare #3

Merged
merged 3 commits into from Mar 14, 2013

4 participants

@rick rick commented on the diff Mar 14, 2013
README.md
@@ -85,6 +85,19 @@ After creating a subclass, tell `Dat::Science` to instantiate it any time the
Dat::Science.experiment = MyApp::Experiment
```
+### Controlling comparison
+
+By default the results of the `candidate` and `control` blocks are compared
+with `==`. Use `comparator` to do something more fancy:
+
+```ruby
+science "loose-comparison" do |e|
+ e.control { "vmg" }
+ e.candidate { "VMG" }
+ e.comparator { |a, b| a.downcase == b.downcase }
@rick
rick added a note Mar 14, 2013

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rick rick commented on the diff Mar 14, 2013
README.md
@@ -173,6 +186,24 @@ end
`context` takes a Symbol-keyed Hash of additional information to publish and
merges it with the default payload.
+#### Keeping it clean
+
+Sometimes the things you're comparing can be huge, and there's no good way
+to do science against something simpler. Use a `cleaner` to publish a
+simple version of a big nasty object graph:
+
+```ruby
+science "huge-results" do |e|
+ e.control { OldAndBusted.huge_results_for query }
+ e.candidate { NewHotness.huge_results_for query }
+ e.cleaner { |result| result.count }
@rick
rick added a note Mar 14, 2013

💥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rick

👍 🚢 🎸

@jbarnette

@rick Finna 1.1.0, I think.

@rick

Do this.

@bhuga

Comments were in chat but for posterity I want a chance to say that this is all 🍬 🐈 🐕 👸 🍔

@jbarnette

🆒 I'm gonna fix up some original result stuff when cleaning and then 💥.

@jbarnette jbarnette merged commit 20b7f5c into master Mar 14, 2013
@jbarnette jbarnette deleted the clean-and-compare branch Mar 14, 2013
@mtodd

I think test, match, or equal? are more descriptive than comparator. And publish_result more than cleaner. Aliases are a simple option, but I'm pretty 👎 on the names as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment