-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decouple measuring of results from reporting results using formatters. #94
Conversation
Improves semantics as a first step toward decoupling the measuring of metric "results" and the formatting of those results into "reports" (or whatever).
end | ||
end | ||
end | ||
# TODO: Can we just remove this? Doesn't seem to be used and causes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. feel free to switch out the internals of the cli option parsing however you like
In terms of directory structure as we move forward, here are my thoughts beyond what I've written elsewhere Also see my config PR and grapher PR
Part of doing this is to not make the Configuration object create methods and instance variables everywhere. Each metric can configure itself and add itself to metric_fu (allows for plugins). |
Directory structure seems reasonable to me. I think a lot of the templating/graphing stuff could move underneath formatter (i.e. |
yes On Sat, Jul 13, 2013 at 10:54 AM, Robin Curry notifications@github.comwrote:
|
Looking good. Lemme know if you want to chat about this here, on skype, or elsewhere |
Cool, yeah. Anytime here, or I'm usually on gtalk (robin.curry@gmail.com) during the day and off and on in the evenings. Now that the builds are passing, I think I've just about wrapped up what I had in mind on this pending any additional feedback you might have. |
I honestly want to 1) not have long-running branches 2) release code right |
Ok, took a stab at updating README and HISTORY. Let me know if you need me to modify anything. Thanks @BJ4! |
Try running with btw, you got my handle wrong above; I'm bf4 :) I'm looking at the commits now |
@@ -71,6 +77,14 @@ def process!(arguments = ARGV) | |||
validate(@result) if self.respond_to?("validate") | |||
@result | |||
end | |||
|
|||
def format_descriptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment what this method does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, in YaRDoc format, I believe this would be return, see example
# Build a nicely formatted list of built-in
# formatter keys and their descriptions
# @see MetricFu::Formatter::BUILTIN_FORMATS
# @example " yaml : ['MetricFu::Formatter::YAML', 'Generates the raw output as yaml']"
# @return [Array<String>] in the form of
# " <key> : <description>."
def format_descriptions
grapher_name = graph_type.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } + graph_engine.to_s.capitalize + "Grapher" | ||
self.clazz.push MetricFu.const_get(grapher_name).new | ||
self.clazz.push MetricFu.const_get(grapher_name).new.tap{|g| g.output_directory = output_directory } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you want to use constantize
here, now that you've introduced it?
BTW, I hope we can soon clean up how hard to read the code is in this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed. Was just trying to limit changes to code outside of the realms of the PR.
I've made a bunch of comments. This is awesome! You now have commit access when you feel ready to merge it in. |
Ack! Sorry about the handle mistake. The perils of late night coding! |
👍 |
|
||
# To configure different formatter(s) or output ... | ||
# MetricFu::Configuration.run do |config| | ||
# config.add_formatter(:html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably has:
require 'metric_fu/formatter/my_custom'
This is so awesome. Great work and great code! |
Got an error running tests on cruby 2.0.0-p195 on mac osx leopard via rvm
And I see RailsBestPractices now has active_support as a dependency. Ugh |
Hrm. Running the same locally and seems ok. As well as on travis. Happen to catch an rspec seed? Maybe order dependent? Something not getting cleaned up in a previous spec? |
Dunno, didn't see a seed. Passed again for me. Ran with order='random', got failures with seeds: 61176, 18737 |
Well, I've run the specs a good 20-30 times and can't seem to reproduce the spec failure. I'm going to go ahead and merge but I'll keep a close eye on it. I know there's nothing worse than an intermittent failing spec. |
Decouple measuring of results from reporting results using formatters.
Yay! |
The idea here is to use similar approach that you see in libraries like simplecov, rspec or cucumber, where you can specify different formats (either pre-built or custom) from the command-line.
So, you could do something like:
or
or perhaps even something like...
I think it opens up some interesting possibilities.
My intent is to keep everything backward-compatible (and I think so far, so good), so running metric_fu without specifying a format will use the built-in html formatter which uses the awesome templating / graphing stuff and produces your standard metric_fu report.