diff options
| author | Zack Hobson | 2013-11-21 15:57:17 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2013-11-21 15:57:17 -0800 | 
| commit | c32bdade26fbf53587e9f8ccc67c5f22c6d45b80 (patch) | |
| tree | 296876acf2addbb6e29dafc9e57826c74734de5d | |
| parent | 88fbc92940d628b4b7d9a7b37826beecd43b3f22 (diff) | |
| download | hcl-c32bdade26fbf53587e9f8ccc67c5f22c6d45b80.tar.bz2 | |
app: add option to force auth refresh
| -rw-r--r-- | Gemfile.lock | 2 | ||||
| -rw-r--r-- | lib/hcl/app.rb | 10 | ||||
| -rw-r--r-- | lib/hcl/timesheet_resource.rb | 2 | ||||
| -rw-r--r-- | test/test_helper.rb | 2 | 
4 files changed, 9 insertions, 7 deletions
| diff --git a/Gemfile.lock b/Gemfile.lock index 1da046e..9d443b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@  PATH    remote: .    specs: -    hcl (0.4.5) +    hcl (0.4.6)        chronic        highline        trollop diff --git a/lib/hcl/app.rb b/lib/hcl/app.rb index 4ff63d5..ac1b992 100644 --- a/lib/hcl/app.rb +++ b/lib/hcl/app.rb @@ -15,8 +15,8 @@ module HCl      OLD_SETTINGS_FILE = "#{ENV['HOME']}/.hcl_settings"      OLD_CONFIG_FILE = "#{ENV['HOME']}/.hcl_config" -    def configure -      FileUtils.mkdir_p(File.join(ENV['HOME'], ".hcl")) +    def initialize +      FileUtils.mkdir_p(HCL_DIR)        read_config        read_settings        self @@ -24,7 +24,7 @@ module HCl      # Run the given command and arguments.      def self.command *args -      new.configure.process_args(*args).run +      new.process_args(*args).run      end      # Return true if the string is a known command, false otherwise. @@ -37,6 +37,7 @@ module HCl      # Start the application.      def run +      request_config if @options[:reauth]        begin          if @command            if command? @command @@ -71,7 +72,7 @@ module HCl      end      def process_args *args -      Trollop::options(args) do +      @options = Trollop::options(args) do          stop_on Commands.instance_methods          version "HCl version #{VERSION}"          banner <<-EOM @@ -119,6 +120,7 @@ Examples:  Options:  EOM +        opt :reauth, "Force refresh of auth details"        end        @command = args.shift        @args = args diff --git a/lib/hcl/timesheet_resource.rb b/lib/hcl/timesheet_resource.rb index 7ab99ec..69eeb75 100644 --- a/lib/hcl/timesheet_resource.rb +++ b/lib/hcl/timesheet_resource.rb @@ -24,8 +24,6 @@ module HCl          self.password = opts['password']          self.subdomain = opts['subdomain']          self.ssl = opts['ssl'] -      else -        yield self        end      end diff --git a/test/test_helper.rb b/test/test_helper.rb index 3434ccc..978920a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,6 +13,8 @@ require 'fileutils'  # override the default hcl dir  FileUtils.mkdir_p __dir__+"/dot_hcl" +FileUtils.touch __dir__+"/dot_hcl/config.yml" +FileUtils.touch __dir__+"/dot_hcl/settings.yml"  ENV['HCL_DIR'] = __dir__+"/dot_hcl"  require 'hcl' | 
