thyme_verbose 0.0.4 → 0.1.0

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
2
  SHA256:
3
- metadata.gz: 7aa775b5ba33c0686b19045bc25d2d1a18cb147ed19267085181cf1f11e03f5f
4
- data.tar.gz: c4ace9c6e21f5cab418ee12923d82fa9c7b5ceb76f3b797713e73c3cb004582d
3
+ metadata.gz: 9e1469148db201ee20aea9667188e8074e2606d31728c55ba23bc934c6555015
4
+ data.tar.gz: afa03b86646cb8363979bec3a42eccea770b2615c180b222811f403c1e7d255a
5
5
  SHA512:
6
- metadata.gz: f26cc59c68ed21ae584fb2bfbb8b4241e80a593349f1fa4f9eaf2d0a5b522e50c86af840fc96e89a4c47cf3b64272d42895b8de9027a0f6ce105122cae2d9c3b
7
- data.tar.gz: 8603aaab8c713dd0599d3e99f3b4905ed2811bd6815ca3c6a5555a11ba687cc63ce0eddbca83be354128eb18c97bdfa2e893bdc3329e6bf0c7d02189ee536e7f
6
+ metadata.gz: e589b2fad0ae81bcb49dbb4ce03a169653fac99c5cb78bbb57ed43351ab7e43eaf902401f6cf0666add2affa61eb49e7e8593177a495fdbebe98aa53f9e297c4
7
+ data.tar.gz: 895862667db0c4ec170b6aefc11a4433170749527223cc4e3bcf8a3ec109382938fccd5e9f3aae67a555bf088cdae0dcca880550a1e45474258146f30ef827d9
data/README.md CHANGED
@@ -21,3 +21,4 @@ Require thyme_verbose in `~/.thymerc` and initialize plugins.
21
21
  * ThymePluginTime - print current time before and after each iteration
22
22
  * ThymePluginLabel - add a -l / --label option, which defines a custom text to print after each iteration
23
23
  * ThymePluginBell - make an terminal alarm (beep code) after each iteration
24
+ * ThymePluginMusic - play music during a pomodoro
@@ -0,0 +1,70 @@
1
+
2
+ class ThymePluginMusic
3
+ def initialize(thyme, options={})
4
+ @player = options[:player] || 'spotify'
5
+ @command_play = options[:command_play] || command_play
6
+ @command_pause = options[:command_pause] || command_pause
7
+ mute_music = @mute_music = false
8
+ thyme.option :m, nil, 'disalbe music plugin for this Pomodoro' do
9
+ mute_music.replace true
10
+ @run = true
11
+ end
12
+ end
13
+
14
+ # Hooks
15
+
16
+ def before
17
+ `#{@command_play}` unless @break || @mute_music
18
+ end
19
+
20
+ def after(seconds_left)
21
+ `#{@command_pause}` unless @break || @mute_music
22
+ end
23
+
24
+ private
25
+
26
+ def command_play
27
+ command_tpl % {:player => @player, :action => 'Play'}
28
+ end
29
+
30
+ def command_pause
31
+ command_tpl % {:player => @player, :action => 'Pause'}
32
+ end
33
+
34
+ def command_tpl
35
+ if which('osascript')
36
+ "osascript"\
37
+ " -e 'tell application \"%{player}\"'"\
38
+ " -e '%{action}'"\
39
+ " -e 'end tell'"
40
+ elsif which('dbus-send')
41
+ "dbus-send"\
42
+ " --print-reply"\
43
+ " --dest=org.mpris.MediaPlayer2.%{player}"\
44
+ " /org/mpris/MediaPlayer2"\
45
+ " org.mpris.MediaPlayer2.Player.%{action}"
46
+ else
47
+ # exception
48
+ end
49
+ end
50
+
51
+ # Cross-platform way of finding an executable in the $PATH.
52
+ def which(cmd)
53
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
54
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
55
+ exts.each { |ext|
56
+ exe = File.join(path, "#{cmd}#{ext}")
57
+ return exe if File.executable?(exe) && !File.directory?(exe)
58
+ }
59
+ end
60
+ return nil
61
+ end
62
+
63
+ def show_label
64
+ if !@label.empty?
65
+ caption = 'LABEL: ' + @label
66
+ puts caption + ' ' * (50 - caption.length)
67
+ end
68
+ end
69
+ end
70
+
data/lib/thyme_verbose.rb CHANGED
@@ -2,3 +2,4 @@
2
2
  require_relative "thyme_verbose/plugin_time"
3
3
  require_relative "thyme_verbose/plugin_label"
4
4
  require_relative "thyme_verbose/plugin_bell"
5
+ require_relative "thyme_verbose/plugin_music"
metadata CHANGED
@@ -1,20 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thyme_verbose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Shmygol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-30 00:00:00.000000000 Z
11
+ date: 2019-02-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " A set of lightweight plugins for the pomodoro timer 'thyme' aimed
14
14
  to improve verbosity.\n ThymePluginTime for printing current time before and
15
15
  after each iteration; \n ThymePluginLabel for adding a -l / --label option, which
16
16
  defines a custom text to print after each iteration;\n ThymePluginBell for making
17
- an terminal alarm (beep code) after each iteration\n"
17
+ an terminal alarm (beep code) after each iteration\n ThymePluginMusic for playing
18
+ music during a pomodoro\n"
18
19
  email:
19
20
  - ishmygol@gmail.com
20
21
  executables: []
@@ -25,6 +26,7 @@ files:
25
26
  - lib/thyme_verbose.rb
26
27
  - lib/thyme_verbose/plugin_bell.rb
27
28
  - lib/thyme_verbose/plugin_label.rb
29
+ - lib/thyme_verbose/plugin_music.rb
28
30
  - lib/thyme_verbose/plugin_time.rb
29
31
  homepage: https://github.com/trilliput/thyme_verbose
30
32
  licenses: