This takes 3 anonymous Class.new w/ no superclasses, no documentation,
and no obvious clue as to what anything is and drops it down to 2
Class.new w/ superclasses, documents what it can, and makes it much
more clear what is going on. (yet, still not clear)
It also actually uses LibraryEvalContext. Having names is important.
Probably more important than any of the rest of this diff.
One extra thing this adds is Module.find_class_instance_variable and
hooks it up to Resource.__resource_registry. This allows it to find a
class-level registry regardless of whether it was hidden in an
anonymous superclass or not.
Signed-off-by: Ryan Davis <zenspider@chef.io>
There are only 2 options. Shortcutting one of them with a `require` just
makes it messy. Use `if`. It's really basic. Basic is good. Maybe we
should try to push towards basic and good. It would be work but make
us happier in the long run.
Signed-off-by: Ryan Davis <zenspider@chef.io>
+ State normal path first.
+ Use Enumerable to state your logic up front, don't build it into
loops with breaks/returns.
+ Remove nonsensical duplication of key formats. (should push up or remove)
+ Had to add an extra test case that wasn't covered here but was in
metadata_test.rb (why?!?)
Signed-off-by: Ryan Davis <zenspider@chef.io>
Specifically the parsing was pretty unreadable. This refactoring
emphasizes using a default hash and merging in the differences for
what was parsed. Everything is funneled through one `merge_crontab`
method that does the actual parsing and the system vs user differences
are merged in after in their respective parse methods.
Signed-off-by: Ryan Davis <zenspider@chef.io>
The biggie to know is that all the extra read_content calls were
needlessly redundant with it also being called in initialize.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Now discovers the first available conf file from a list of known
paths. Might have to expand based on various distros.
Had to tweak the tests because the mock loader mocks EVERYTHING every
time. :/
Signed-off-by: Ryan Davis <zenspider@chef.io>
* Removed Resource#inspect (calling to_s) to make debugging a happy experience.
* Added ResourceBehavior.toggle_inspect to add/remove a basic inspect.
* Added `--inspect` flag to `shell` command. Call toggle_inspect unless --inspect used.
* Cleaned up matchers.rb and removed most explicit calls to inspect.
* Added ResourceInspector to rspec's INSPECTOR_CLASSES.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Cleaned up some code.
Reordered virtualization detection by order of probability.
Added TODOs for obvious problems.
Signed-off-by: Ryan Davis <zenspider@chef.io>
+ File format oriented resources should always be `os`.
+ virtualization should (in theory) be any unix (tho, it currently seems wrong).
+ etc_hosts should be any (reasonable) unix.
Signed-off-by: Ryan Davis <zenspider@chef.io>