time_block 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d05ce26ba370a2e7207c084808061e4a4c209928
4
- data.tar.gz: 88d1aa3e5bb952f2f50410e737cf1dc66c3a4999
3
+ metadata.gz: 1f28e03f24679b200a951719f22b947ff78118fd
4
+ data.tar.gz: d8957de296fa34a5409a4f93ca956279726cc2c1
5
5
  SHA512:
6
- metadata.gz: 883435be2a41958287e5cf95a4eace2a57097ed2f04f6f2b655b26c0fa8c736141d4b64d239d9ae8b984c9df1ca0e1d65df0e3d7adf74a17e13e5bb99b6c7bb6
7
- data.tar.gz: 040f7bee59daa0b6a80602f50d43da1ae5bcb67f9ec2f405eabd0d1b046b5bd1bcda6f766aa15bf0880d94b7ba3038897215e38b22bc58d718ad8720a563ba82
6
+ metadata.gz: b5268e38b822c9aad007ae5a8dc2ab5959bba9554da5d1466ab29dcfe669d7ba20112aeded0d2bf07c4c5409b16ff0f7f246333b36f38b22a06811a7c85722e3
7
+ data.tar.gz: 6658811d2186855e182683c4291c23f2785b75fcdaffa08beeb9d04ed6cc3e8bf2dd539e4ace4e4d0383132bb8680c0a2817096625aacf1ddf914e4e87fa0ca4
@@ -0,0 +1,27 @@
1
+ class TimeBlock::Agent
2
+ def initialize(time)
3
+ fail 'No terminal-notifier, please install it, brew install terminal-notifier' unless terminal_notifier_exist?
4
+ @time = time
5
+ end
6
+
7
+ def run
8
+ pre_callback
9
+ sleep @time
10
+ post_callback
11
+ end
12
+
13
+ private
14
+
15
+ def terminal_notifier_exist?
16
+ `which terminal-notifier`
17
+ $? == 0
18
+ end
19
+
20
+ def pre_callback
21
+ `terminal-notifier -message #{"Time is starting !!!".dump} -title "TimeBlock - #{@time}s" -sound "default"`
22
+ end
23
+
24
+ def post_callback
25
+ `terminal-notifier -message #{"Time is out dude !!!".dump} -title "TimeBlock - #{@time}s" -sound "default"`
26
+ end
27
+ end
@@ -1,18 +1,15 @@
1
+ require 'dante'
1
2
  require 'time_block'
3
+ require 'time_block/agent'
2
4
 
3
5
  class TimeBlock::CLI
4
6
  def self.start(*args)
5
- fail 'No terminal-notifier, please install it, brew install terminal-notifier' unless terminal_notifier_exist?
6
7
  time = args.shift.strip.to_i
7
- sleep time
8
- `terminal-notifier -message #{"Time is out dude !!!".dump} -title "TimeBlock - #{time}s" -sound "default"`
8
+ Dante::Runner.new('timeblock').execute(daemonize: true, pid_path: '/tmp/timeblock.pid', log_path: '/tmp/timblock.log') do |opts|
9
+ TimeBlock::Agent.new(time).run
10
+ end
9
11
  rescue => e
10
12
  puts e.message
11
13
  exit(1)
12
14
  end
13
-
14
- def self.terminal_notifier_exist?
15
- `which terminal-notifier`
16
- $? == 0
17
- end
18
15
  end
@@ -1,3 +1,3 @@
1
1
  module TimeBlock
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/time_block.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.6"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_runtime_dependency "terminal-notifier"
25
+ spec.add_dependency "dante"
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Faizal Zakaria
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dante
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Notifier to notify you when your time block is ended
56
70
  email:
57
71
  - phaibusiness@gmail.com
@@ -67,6 +81,7 @@ files:
67
81
  - Rakefile
68
82
  - bin/timeblock
69
83
  - lib/time_block.rb
84
+ - lib/time_block/agent.rb
70
85
  - lib/time_block/cli.rb
71
86
  - lib/time_block/version.rb
72
87
  - time_block.gemspec