command_timer 0.0.3 → 0.0.4

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.
@@ -1,3 +1,3 @@
1
1
  module CommandTimer
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/command_timer.rb CHANGED
@@ -6,8 +6,14 @@ require "command_timer/parser"
6
6
  module CommandTimer
7
7
  class << self
8
8
  def ntp_time(server)
9
- server ||= 'ntp.nict.jp'
10
- parse_time(%x[ntpdate -q #{server}].scan(/[0-9]{2}:[0-9]{2}:[0-9]{2}/).first)
9
+ ENV['PATH'].split(':').each do |path|
10
+ if File.exists?(path + '/ntpdate')
11
+ server ||= 'ntp.nict.jp'
12
+ return parse_time(%x[ntpdate -q #{server}].scan(/[0-9]{2}:[0-9]{2}:[0-9]{2}/).first)
13
+ end
14
+ end
15
+ puts "Warning: ntpdate not installed and use the local clock."
16
+ Time.now
11
17
  end
12
18
 
13
19
  def parse_time(str)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_timer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: