thyme 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -3
- data/thyme.rb +4 -4
- data/thyme_test.rb +18 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -36,7 +36,12 @@ Thyme is configurable and extensible. All configurations live in the
|
|
36
36
|
set :tmux, true
|
37
37
|
set :tmux_theme "#[fg=mycolor,bg=mycolor]#[fg=%s]%s#[fg=mycolor,bg=mycolor]"
|
38
38
|
|
39
|
-
option :
|
39
|
+
option :b, :break, 'start a break' do
|
40
|
+
set :timer, 5*60
|
41
|
+
run
|
42
|
+
end
|
43
|
+
|
44
|
+
option :t, :today, 'open today sheet' do
|
40
45
|
`vim -O ~/.thyme-today.md ~/.thyme-records.md < \`tty\` > \`tty\``
|
41
46
|
end
|
42
47
|
|
@@ -55,8 +60,8 @@ The `set` method sets different configurations. There are only two:
|
|
55
60
|
* `:tmux` is whether or not you want tmux integration on (off by default)
|
56
61
|
|
57
62
|
The `option` method adds new options to the `thyme` command. In the above
|
58
|
-
example, we can now execute `thyme -
|
59
|
-
options.
|
63
|
+
example, we can now execute `thyme -b` or `thyme -t`. Use `thyme -h` to see
|
64
|
+
available options.
|
60
65
|
|
61
66
|
The `before` and `after` adds hooks to our timer. Now before the timer starts,
|
62
67
|
an mp3 will play. After the timer ends, a notification will be sent.
|
data/thyme.rb
CHANGED
@@ -2,7 +2,7 @@ require 'ruby-progressbar'
|
|
2
2
|
require 'date'
|
3
3
|
|
4
4
|
class Thyme
|
5
|
-
VERSION = '0.0.
|
5
|
+
VERSION = '0.0.9'
|
6
6
|
CONFIG_FILE = "#{ENV['HOME']}/.thymerc"
|
7
7
|
PID_FILE = "#{ENV['HOME']}/.thyme-pid"
|
8
8
|
TMUX_FILE = "#{ENV['HOME']}/.thyme-tmux"
|
@@ -41,7 +41,7 @@ class Thyme
|
|
41
41
|
tmux_file.flush
|
42
42
|
end
|
43
43
|
if before_hook
|
44
|
-
before_hook
|
44
|
+
self.instance_exec(&before_hook)
|
45
45
|
before_hook = nil
|
46
46
|
end
|
47
47
|
sleep(@interval)
|
@@ -53,7 +53,7 @@ class Thyme
|
|
53
53
|
File.delete(TMUX_FILE) if File.exists?(TMUX_FILE)
|
54
54
|
File.delete(PID_FILE) if File.exists?(PID_FILE)
|
55
55
|
seconds_left = [seconds_start - seconds_since(start_time), 0].max
|
56
|
-
|
56
|
+
self.instance_exec(seconds_left, &@after) if @after
|
57
57
|
end
|
58
58
|
|
59
59
|
def stop
|
@@ -82,7 +82,7 @@ class Thyme
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def option(optparse, short, long, desc, &block)
|
85
|
-
optparse.on("-#{short}", "--#{long}", desc) { block
|
85
|
+
optparse.on("-#{short}", "--#{long}", desc) { self.instance_exec(&block); exit }
|
86
86
|
end
|
87
87
|
|
88
88
|
def load_config(optparse)
|
data/thyme_test.rb
CHANGED
@@ -6,7 +6,10 @@ Minitest.autorun
|
|
6
6
|
|
7
7
|
class ThymeTest < Minitest::Test
|
8
8
|
def setup
|
9
|
+
# TODO: stub out progress bar
|
9
10
|
@thyme = Thyme.new
|
11
|
+
@thyme.set(:interval, 0)
|
12
|
+
@thyme.set(:timer, 0)
|
10
13
|
end
|
11
14
|
|
12
15
|
def test_format
|
@@ -22,9 +25,23 @@ class ThymeTest < Minitest::Test
|
|
22
25
|
end
|
23
26
|
|
24
27
|
def test_set
|
25
|
-
assert_equal(
|
28
|
+
assert_equal(0, @thyme.instance_variable_get('@timer'))
|
26
29
|
@thyme.set(:timer, 20*60)
|
27
30
|
assert_equal(20*60, @thyme.instance_variable_get('@timer'))
|
28
31
|
assert_raises(ThymeError) { @thyme.set(:invalid, nil) }
|
29
32
|
end
|
33
|
+
|
34
|
+
def test_run
|
35
|
+
@thyme.run
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_hooks
|
39
|
+
@thyme.before { @before_flag = true }
|
40
|
+
@thyme.after { @after_flag = true }
|
41
|
+
refute(@thyme.instance_variable_get('@before_flag'))
|
42
|
+
refute(@thyme.instance_variable_get('@after_flag'))
|
43
|
+
@thyme.run
|
44
|
+
assert(@thyme.instance_variable_get('@before_flag'))
|
45
|
+
assert(@thyme.instance_variable_get('@after_flag'))
|
46
|
+
end
|
30
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thyme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: .
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-progressbar
|