hiiro 0.1.76 → 0.1.78

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: a6a109a34648d12d88b1e85da0f92ef2517000eff0f3ebd40e6e82416765322b
4
- data.tar.gz: e288f5f15c20d43ca8ffc9e3eed99b4413f504be0cfcabf2245788c600993325
3
+ metadata.gz: b02d82eafaf2fdc5a89635f5e9e33d35edd22254d19c23cae2544a5c8f746803
4
+ data.tar.gz: fb0c92ba92136c89f9bcc83963b517f6ad51880da1787dc5f1d1174d1962589a
5
5
  SHA512:
6
- metadata.gz: 8c8e54fcc3023a4be5f93de4d141962a73a1daf81d47f1132fc90bdd83fd1094737964b6d184c175bbb0507d8b6dd199473557a9fdcffe6f8fceb3ed6c0d1624
7
- data.tar.gz: 716d6525ec8287732a74b332678a67f0d98b361b2bc80b68ba1ee8cfdaf123a2155c4569200dd032bbea39d845e40683466385e259b4481b06242af6f491aee2
6
+ metadata.gz: 936baa6258b7a76df4cb0730cb154f849382df80a9cf8e75a4c93e99719fe924d96df94aefd717c09902b4d1b4acf2fcfb249e50a6d0c45e53e594f3864e9fcb
7
+ data.tar.gz: 3d7b2e749a478b514d5c75bf22c448f60a58ad513afbbe6bdde7b2eb1454a2b7d50566ad72b38381f4fa5a7f281e7020a7e89339e85267b6cf3416710568e7c9
data/exe/h CHANGED
@@ -50,6 +50,6 @@ Hiiro.run(*ARGV, cwd: Dir.pwd, plugins: [Tasks]) do
50
50
  end
51
51
 
52
52
  add_subcmd(:alert) do |*args|
53
- puts Hiiro::Notification.new(self).sounds
53
+ Hiiro::Notification.show(self)
54
54
  end
55
55
  end
@@ -1,6 +1,6 @@
1
1
  class Hiiro
2
2
  class Notification
3
- def self.send(hiiro)
3
+ def self.show(hiiro)
4
4
  new(hiiro).send
5
5
  end
6
6
 
@@ -11,18 +11,43 @@ class Hiiro
11
11
  @original_args = hiiro.args.dup
12
12
  end
13
13
 
14
+ def options
15
+ @options ||= Options.parse(args) do
16
+ option(:sound, short: :s, default: 'basso', desc: 'sound name')
17
+ option(:title, short: :t, desc: 'title')
18
+ option(:message, short: :m, desc: 'message')
19
+ option(:link, short: :l, desc: 'link to open')
20
+ option(:command, short: :c, desc: 'command to run')
21
+ end
22
+ end
23
+
14
24
  def args
15
25
  @args ||= hiiro.args
16
26
  end
17
27
 
18
28
  def sounds
19
- system = Dir.glob('/System/Library/Sounds/*')
20
29
  custom = Dir.glob(File.join(Dir.home, '.config/hiiro/sounds/*'))
21
30
 
22
- all_sounds = system + custom
23
- all_sounds.each_with_object({}) do |fn, h|
31
+ @sounds ||= custom.each_with_object({}) do |fn, h|
24
32
  basename = File.basename(fn, File.extname(fn))
25
- puts basename: basename
33
+ h[basename.downcase] = fn
34
+ end
35
+ end
36
+
37
+ def show
38
+ cmd = ['terminal-notifier']
39
+ cmd << ['-message', options.message] if options.message
40
+ cmd << ['-title', options.title.tr('()[]', '')] if options.title
41
+ cmd << ['-open', options.link] if options.link
42
+ cmd << ['-execute', options.command] if options.command
43
+ system(*cmd)
44
+
45
+ play_sound
46
+ end
47
+
48
+ def play_sound
49
+ if options.sound && sounds[options.sound]
50
+ system('afplay', sounds[options.sound.downcase])
26
51
  end
27
52
  end
28
53
  end
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.76"
2
+ VERSION = "0.1.78"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.76
4
+ version: 0.1.78
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota