Remove some manual URI munging from Twigg::Command::GitHub

Let the URI library do some of the work for us here.

Change-Id: Ie13872b27e44cb866bdd6f4e2030f48306128e45
Reviewed-on: https://gerrit.causes.com/25281
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add Twigg.root

This method is inspired by `Rails.root`; it returns a Pathname object
pointed at the root level of the gem. This in turn can be used to make a
number of different uses of `File.expand_path` and `File.join` turn into
much simpler and more readable `+` operations.

Change-Id: I578a9b3378e02b33dd501d735390669242a23964
Reviewed-on: https://gerrit.causes.com/25282
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Make paging of GitHub API responses a little nicer

Extract the parsing of the `Link` header out into a separate method for
readability, and use a `begin`/`end until ...` loop in order to get rid
of an explicit `break` and `next` combo.

Change-Id: I8547c70a5e12c08650a7fb4a523ea9fd9e5cb1f4
Reviewed-on: https://gerrit.causes.com/25283
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Replace references to `twiggrc.yml.example` in the README

Change-Id: I6552149c24f8ec6dab6547541708c8c94ed003bc
Reviewed-on: https://gerrit.causes.com/25284
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Warn if TWIGGRC has loose filesystem permissions

As the config file may contain things like GitHub access tokens (which
are effectively almost as useful as passwords), we should warn if we
note that it has weak permissions on it.

I made some of the utility methods on the Command class public so that I
could use them in this commit. It is somewhat inelegant having to talk
to the Command class for these things, so I will likely move them into a
module in a subsequent commit.

Change-Id: Ie9f5181342d605e8466b4cb24af8194d44d51b1f
Reviewed-on: https://gerrit.causes.com/25285
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Extract generic console-related functions into Console module

This is quite a bit nicer than having random parts of the codebase
talking to the `Command` class in order to get at this functionality.

Change-Id: Ib0aceaced6a0c878c5bff7a856425022ce481e41
Reviewed-on: https://gerrit.causes.com/25286
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add specs for Twigg::Settings::DSL, fixing a latent bug

As mentioned in the previous commit, we're already tested part of this
functionality in the Twigg::Settings specs. Those specs are partly tied
to the settings hierarchy as it is specifically manifested in the
Twigg::Settings class, by virtue of the calls it makes to the DSL.

The specs added here are more generic in nature. I create anonymous
classes (to avoid possible future naming clashes) and make up some phony
settings for the purposes of exercising three capabilities of the DSL
that are not exercised in the other specs:

  - nesting namespaces
  - re-opening pre-existing namespaces and adding more settings
  - memoization

We're not using either of these features yet, but I wanted to have them
reflected in the spec suite because the system was designed with them in
mind.

I was delighted to discover a latent bug in the course of writing these
tests; we weren't running into it in our use, but the spec revealed that
it was possible for `@namespaces` to be `nil` when the first use of the
DSL was a `settings` call instead of a `namespace` one. Fix that by
mediating access to the instance variable through a new reader method,
`#namespaces`.

These are the first specs that need mocking. I went with RR despite the
fact that we have mostly used Mocha in other projects at Causes and
people are familiar with it; RR offers a range of powerful doubles
(including spies and proxies) that Mocha doesn't support.

There is a deprecation warning with the version of RSpec that I'm using:

  DEPRECATION: RSpec::Core::Configuration#backtrace_clean_patterns is
  deprecated. Use
  RSpec::Core::Configuration#backtrace_exclusion_patterns instead.

but this is already fixed in this pull request, which should be merged
soon:

  https://github.com/rr/rr/pull/37

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