Move lib specs into specs/lib/

This will avoid clutter as we adding more and more specs to the specs/
directory.

Change-Id: I4fc07283a31bafc07a968b46f1528512c5e81f61
Reviewed-on: https://gerrit.causes.com/25288
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add specs for Settings class

These specs are partly a verification of the Settings::DSL
functionality, and partly a verification that I've made the right calls
to the DSL in the Settings class itself. For this reason, I've tried to
walk a middle ground of testing general features (stuff around deep
OpenStructification) and testing specific configuration (for example,
making use of the `default_days` and `repositories_directory` settings).

I may follow up later with some more generic tests that are isolated
from the set-up created by the DSL in the Settings class; for example,
it would be nice to have some tests that show that namespaces can be
nested arbitrarily deeply.

Change-Id: I5bb3e8e1eeb3bdb5472c3cfdc8784bc2e934cbc0
Reviewed-on: https://gerrit.causes.com/25287
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add starter RSpec files

Generated by `bundle exec rspec --init`.

Change-Id: I18503f20d1bae4a3608ecfee3161225fe66c4523
Reviewed-on: https://gerrit.causes.com/25250
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Use simpler `require` targets in gemspec and config.ru

Thanks to our judicious use of autoloading, we never need to worry about
requiring specific files from Twigg's `lib` directory; in order to
reduce clutter, let's just always use the top-level master file.

Change-Id: I5dd7bf83ccda3ef8f35d2e53a1956138794f36ad
Reviewed-on: https://gerrit.causes.com/25268
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add missing commands to `twigg help commands` subcommand

Add `init` and `gerrit`, and kill some excess whitespace for consistency
with other help sections which all employ minimal whitespace.

Change-Id: I9d3637257e48fe76fdb391fed56176d2f5fedc72
Reviewed-on: https://gerrit.causes.com/25266
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Bump Ruby version requirement to 2.0 or above

I'd like to use keyword arguments, so let's bump the version requirement
to 2.0 or above. It's relatively easy to install Ruby nowadays with
tools such as rbenv (ruby-install), rvm, and homebrew, so we may as well
go with the latest stable release.

Change-Id: Ia9563335e8ce8477f35d504fd0f60e480b3f2ef3
Reviewed-on: https://gerrit.causes.com/25241
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Always preface `die` error messages with "error: "

Let's make error messages really obvious.

Change-Id: I4bb53284a39afc84c74e7833844acb8060a600a5
Reviewed-on: https://gerrit.causes.com/25243
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Document how to get a Twigg-aware REPL

Change-Id: I37d6c15010150e7795a43d304179896e4d751756
Reviewed-on: https://gerrit.causes.com/25247
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Use Config.default_days instead of STANDARD_DAY_INTERVAL

For consistency.

Change-Id: Ib0695b2cbb35899a498b6bffc5a4fa3830edc951
Reviewed-on: https://gerrit.causes.com/25248
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Provide default value for "bind" configuration setting

0.0.0.0 (ie. listening on all interfaces) is probably a reasonable
default for this setting, and is one less thing for the user to worry
about.

Change-Id: If6cc9508cc700a384cd526d8b3cee4f25638c4b2
Reviewed-on: https://gerrit.causes.com/25233
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Make `setting` DSL for easily setting up default values

I will shortly be adding a slew (well, four) new settings for the
`gerrit` subcommand, and several of them will have default settings.

This commit adds a DSL to make it easy to set up the readers for those
settings.

Change-Id: Iecab16afb9f0bb1d9bf2f4bac69839628fbf01d6
Reviewed-on: https://gerrit.causes.com/25234
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add memoization to methods generated by `setting` DSL

As this method is dynamically generated, it is a little uglier than just
writing:

  @foo ||= self.[](__method__) || options[:default]

but this brings us to parity with the other method in the class,
`#repositories_directory`, which already has memoization. A subsequent
commit will extend the DSL to accept a block, which means that we'll be
able to get replace the `#repositories_directory` method with a call to
the DSL.

Change-Id: I3109e2caf185e43c54e3872655efcd25ae904084
Reviewed-on: https://gerrit.causes.com/25235
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add block support to settings DSL

This allows us to remove the `#repositories_directory` method, and
replace it with a call to the DSL. This is arguably more readable,
because `name` is somewhat more pleasant on the eye than `__method__`.

Change-Id: I5499c5a733439cc3b22bdabbf35a6f71a5bd591a
Reviewed-on: https://gerrit.causes.com/25236
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Supply default values for `twigg stats` command

In the absence of explicit "repos dir" and "days" params, try to pull
them in via config.

Change-Id: I2b9699171baf54952902939629f7ed8456963fc5
Reviewed-on: https://gerrit.causes.com/25237
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Move some common option handling up into Command class

We can support -v/--verbose and -h/--help for all subcommands by putting
the code for it into the Command class, which is the superclass of the
various subcommand classes.

Note that "support" for -v/--verbose means that we set a `@verbose`
instance variable; the onus is on the subcommands to actually modify
their behavior acccordingly.

Change-Id: I511cbec701b4663f93615198930feb6554ac51e3
Reviewed-on: https://gerrit.causes.com/25238
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add -d/--debug flag

With the flag, we let exceptions explode in their full glory; without
it, we catch them, show a slightly nicer message, then exit.

Change-Id: I9924f4c88a43ad5836eae4bcc92b35bdcba0f490
Reviewed-on: https://gerrit.causes.com/25239
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Use terser format in Command#initialize method

We could go whole-hog here and make a method to encapsulate this, but it
seems unlikely that it would read any better than the simple one-line
statements here.

Change-Id: Ie1f4e31e2410c68455a03ae88a738c764d5cfdae
Reviewed-on: https://gerrit.causes.com/25240
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>