thyme 0.0.15 → 0.0.16

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2bd7f6b22e1eb3fb5b2cc353f25948207113f722
4
- data.tar.gz: 9de5a45b3b793806536927db3e4464d157e5ab95
2
+ SHA256:
3
+ metadata.gz: 5abf29ab5c23ad3c627e59ba2359fe9edadd4e29d3a9867a8bd5544bc3f4b9a1
4
+ data.tar.gz: 843d993b305a5e72067ba9e426f0b840fdc3f5f352c092fb3dff46087558c809
5
5
  SHA512:
6
- metadata.gz: 3d1a24078f5c3d2ce251ef8c2b04010e32140a1206548dfec3d4771179ae2a7bf6c8eb890b1106a0db7c855929afb5e4c1057e4ea4e7fc7c6c9b67bb8fc89bb9
7
- data.tar.gz: 7167e5a067fc49605767fd18a9d13b05a6d430b56a1b809f6c270894897d300ad216441939bfb66a42300354ad8cfed78e4e5bb5cd6bee5a2a99dadf3c7889ae
6
+ metadata.gz: 8258374971ba89526629690016690128b84cd3ba7a77adfaead03cdac0f463db4df4dbf02462938194f64483a9bd2f16fdd0a96c73a3f4a659745ffa401c4c52
7
+ data.tar.gz: 9bf433d64f8268e896a385e49777bb25d279f2b98af52bfc24c5598710dc1635a2161a54de9012aad992f762c9148b56dd45b816d699dc34e3322c7dad7d0796
data/README.md CHANGED
@@ -47,7 +47,7 @@ Configurations live in the `~/.thymerc` file:
47
47
  # adds `-s --seconds num` option, which allows on the fly timer
48
48
  option :s, 'seconds num', 'run with custom seconds' do |num|
49
49
  set :timer, num.to_i
50
- run
50
+ @run = true
51
51
  end
52
52
 
53
53
  # execute hook before thyme program starts
@@ -99,6 +99,11 @@ You can create your own plugins. They implement these methods:
99
99
  class MyThymePlugin
100
100
  def initialize(thyme, options={})
101
101
  # `thyme` is an instance of Thyme::Config (see lib/thyme/config.rb)
102
+
103
+ # adds `-t --today` option, which opens a text file in vim
104
+ thyme.option :t, :today, 'open today sheet' do
105
+ `vim -O ~/.thyme-today.md ~/.thyme-records.md < \`tty\` > \`tty\``
106
+ end
102
107
  end
103
108
 
104
109
  def before_all
@@ -1,15 +1,18 @@
1
1
  module Thyme
2
+ # Configure state for the application. This can be done via the thymerc file or CLI flags.
3
+ # Public methods in this file are exposed to the thymerc file.
2
4
  class Config
3
5
  CONFIG_FILE = "#{ENV['HOME']}/.thymerc"
4
6
  PID_FILE = "#{ENV['HOME']}/.thyme-pid"
5
7
  TMUX_FILE = "#{ENV['HOME']}/.thyme-tmux"
6
- OPTIONS = [:break_color, :interval, :timer, :timer_break, :tmux, :tmux_theme, :warning, :warning_color]
8
+ OPTIONS = [:default_color, :break_color, :interval, :timer, :timer_break, :tmux, :tmux_theme, :warning, :warning_color]
7
9
  OPTIONS.each { |opt| attr_reader(opt) }
8
- attr_accessor :break, :daemon, :repeat, :repeat_index
10
+ attr_accessor :break, :daemon, :repeat, :repeat_index, :optparse
9
11
 
10
12
  def initialize
11
13
  # options set via config file
12
14
  @break_color = 'default'
15
+ @default_color = 'default'
13
16
  @interval = 1
14
17
  @timer = 25 * 60
15
18
  @timer_break = 5 * 60
@@ -54,8 +57,9 @@ module Thyme
54
57
  @hooks_plugin.add(:tick, &block)
55
58
  end
56
59
 
57
- def option(optparse, short, long, desc, &block)
58
- optparse.on("-#{short}", "--#{long}", desc) do |*args|
60
+ def option(short, long, desc, &block)
61
+ return if !@optparse
62
+ @optparse.on("-#{short}", "--#{long}", desc) do |*args|
59
63
  self.instance_exec(*args, &block)
60
64
  exit if !@run
61
65
  end
@@ -1,4 +1,5 @@
1
1
  module Thyme
2
+ # Exposes application to the CLI in bin/thyme
2
3
  class Console
3
4
  attr_accessor :config
4
5
 
@@ -27,16 +28,18 @@ module Thyme
27
28
  timer.run
28
29
  end
29
30
 
31
+ # Loads the thymerc configuration file. Requires optparse b/c users can extend CLI via thymerc
30
32
  def load(optparse, &block)
31
33
  return if block.nil? && !File.exists?(Config::CONFIG_FILE)
32
34
  config = @config
35
+ config.optparse = optparse
33
36
  environment = Class.new do
34
37
  define_method(:set) { |opt,val| config.set(opt,val) }
35
38
  define_method(:use) { |plugin,*args,&b| config.use(plugin,*args,&b) }
36
39
  define_method(:before) { |*args,&block| config.before(*args,&block) }
37
40
  define_method(:after) { |*args,&block| config.after(*args,&block) }
38
41
  define_method(:tick) { |&block| config.tick(&block) }
39
- define_method(:option) { |sh,lo,desc,&b| config.option(optparse,sh,lo,desc,&b) }
42
+ define_method(:option) { |sh,lo,desc,&b| config.option(sh,lo,desc,&b) }
40
43
  end.new
41
44
 
42
45
  if block # for test environment
@@ -1,4 +1,4 @@
1
1
  module Thyme
2
- class Error < StandardError; end
3
- class StopTimer < StandardError; end
2
+ class Error < StandardError; end # catch all error for Thyme
3
+ class StopTimer < StandardError; end # used to stop repeat timers
4
4
  end
@@ -1,4 +1,5 @@
1
1
  module Thyme
2
+ # Methods used to nicely format output to the user
2
3
  class Format
3
4
  def initialize(config)
4
5
  @config = config
@@ -8,6 +9,7 @@ module Thyme
8
9
  ((DateTime.now - time) * 24 * 60 * 60).to_i
9
10
  end
10
11
 
12
+ # Displays time depending on configured interval eg. 15m OR 15:20
11
13
  def time_left(seconds, min_length)
12
14
  min = (seconds / 60).floor
13
15
  lead = ' ' * [0, min_length - min.to_s.length].max
@@ -34,7 +36,7 @@ module Thyme
34
36
  elsif seconds < @config.warning
35
37
  @config.warning_color
36
38
  else
37
- 'default'
39
+ @config.default_color
38
40
  end
39
41
  end
40
42
  end
@@ -1,4 +1,5 @@
1
1
  module Thyme
2
+ # Generic plugin for users to run Ruby code in Thyme event callbacks in thymerc
2
3
  class HooksPlugin
3
4
  def initialize(config)
4
5
  @config = config
@@ -1,4 +1,5 @@
1
1
  module Thyme
2
+ # The actual timer logic where you can pause, unpause, or stop one or more timers
2
3
  class Timer
3
4
  def initialize(config)
4
5
  @config = config
@@ -40,6 +41,7 @@ module Thyme
40
41
 
41
42
  private
42
43
 
44
+ # TODO: refactor this method, too large!
43
45
  def run_single
44
46
  seconds_total = @config.break ? @config.timer_break : @config.timer
45
47
  seconds_left = seconds_total + 1
@@ -107,6 +109,8 @@ module Thyme
107
109
  @config.repeat == @config.repeat_index
108
110
  end
109
111
 
112
+ # Since timers can be daemonized, we'll use Unix signals to trigger events such as
113
+ # pause/unpause in a separate process.
110
114
  def send_signal(signal)
111
115
  pid = File.read(Config::PID_FILE).to_i
112
116
  Process.kill(signal, pid) if pid > 1
@@ -1,4 +1,6 @@
1
1
  module Thyme
2
+ # Provides tmux integration. Thyme outputs the timer to TMUX_FILE. Tmux reads this file and
3
+ # outputs to its bar.
2
4
  class Tmux
3
5
  def initialize(config)
4
6
  @config = config
@@ -1,3 +1,3 @@
1
1
  module Thyme
2
- VERSION = '0.0.15'
2
+ VERSION = '0.0.16'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thyme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hugh Bien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-01 00:00:00.000000000 Z
11
+ date: 2020-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-progressbar
@@ -63,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: 1.3.6
65
65
  requirements: []
66
- rubyforge_project:
67
- rubygems_version: 2.4.5
66
+ rubygems_version: 3.1.2
68
67
  signing_key:
69
68
  specification_version: 4
70
69
  summary: Timer for Pomodoro Technique