Class: Gigawatt::Commands::Stop
- Inherits:
-
Object
- Object
- Gigawatt::Commands::Stop
- Defined in:
- lib/gigawatt/commands/stop.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(settings, options) ⇒ Stop
constructor
A new instance of Stop.
- #punch_out ⇒ Object
Constructor Details
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/gigawatt/commands/stop.rb', line 4 def @options end |
Class Method Details
.run!(settings) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gigawatt/commands/stop.rb', line 6 def self.run!(settings) = Trollop:: do <<-EOS 88 Miles Command line application - http://88miles.net Punch out of the project. Usage 88miles stop [options] options: EOS opt :notes, "Save notes against the shift", :type => :string opt :tags, "Allocate tags to the shift", :type => :string end instance = self.new(settings, ) begin return instance.punch_out rescue OAuth2::Error => e say "Access to your 88 Miles may have been revoked. Please run <%= color('88miles setup', BOLD) %> again." return INVALID_OAUTH_TOKEN_EXIT_CODE end end |
Instance Method Details
#punch_out ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gigawatt/commands/stop.rb', line 39 def punch_out project = Gigawatt::ProjectFile.new.project if project response = JSON.parse(@access_key.post("/api/1/projects/#{project["uuid"]}/punch_out.json", { :params => { :notes => .notes.to_s } }).body) current = response["response"] ProjectFile.write(current) company = @cache.companies(true)[project["company_uuid"]] say("Punched out of #{company["name"]}: #{project["name"]}") return OK_EXIT_CODE else say("No project found. Did you remember to run <%= color('88miles init [directory]', BOLD) %>?") return NO_PROJECT_EXIT_CODE end end |