caff 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/bin/caff +4 -7
  2. data/lib/caff.rb +18 -4
  3. data/lib/caff/version.rb +2 -2
  4. metadata +3 -3
data/bin/caff CHANGED
@@ -1,10 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- command = ARGV.shift
3
+ $: << File.dirname(__FILE__)+'/../lib'
4
4
 
5
- unless %w{on off}.include? command
6
- puts 'usage: caff [on|off]'
7
- exit 0
8
- end
9
-
10
- `osascript -e 'tell application \"Caffeine\" to turn #{command}'`
5
+ require 'caff'
6
+ include Caff
7
+ execute ARGV.shift
data/lib/caff.rb CHANGED
@@ -1,5 +1,19 @@
1
- require "caff/version"
2
-
3
1
  module Caff
4
- # Your code goes here...
5
- end
2
+ def execute on_off
3
+ if %w{on off}.include? on_off
4
+ tell_caffeine "turn #{on_off}"
5
+ else
6
+ puts 'usage: caff [on|off]'
7
+ end
8
+ show_status
9
+ end
10
+
11
+ def show_status
12
+ current = tell_caffeine('active') == 'true' ? 'on' : 'off'
13
+ puts "caffeine is now #{current}"
14
+ end
15
+
16
+ def tell_caffeine command
17
+ `osascript -e 'tell application \"Caffeine\" to #{command}'`.chomp
18
+ end
19
+ end
data/lib/caff/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Caff
2
- VERSION = "0.0.1"
3
- end
2
+ VERSION = "0.0.2"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -58,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
58
  version: '0'
59
59
  segments:
60
60
  - 0
61
- hash: -2185213358945124182
61
+ hash: -4562975574575536837
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  segments:
69
69
  - 0
70
- hash: -2185213358945124182
70
+ hash: -4562975574575536837
71
71
  requirements: []
72
72
  rubyforge_project:
73
73
  rubygems_version: 1.8.23