windows-shutdown-timer 0.0.1 → 1.0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/windows-shutdown-timer.rb +11 -7
  3. metadata +7 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9831e87cb92f49bbfa7a3bc55dfbda6cbd143778
4
- data.tar.gz: 9b4f5802c79324667f617c31fe52b4265f0a9f8c
3
+ metadata.gz: 5e68c85e6781a04dfb388cf37a9d081f857eebfa
4
+ data.tar.gz: 6eb976e87c4c74627e96a972027dadd66fd3eaec
5
5
  SHA512:
6
- metadata.gz: db7b25f8b820d2167d272c91208681ee3afdad2a7008e92072532e87bb9a7b0f9e50cc13ca6dd1cc1450b6fa4c61c26980f0b8694c8cc6bb22d8b8434699ec46
7
- data.tar.gz: d2e998bfc9a1ccd1ecf3870ee0f50e37d8ed88bd072096e9c71ee81c3ec2b1b66d35bf2802bfa3fd0eb483f8c61c175e1157250444732a6f53a535a090cb261f
6
+ metadata.gz: 5a2c5f72c106bc26dc7aa9998a6152e0f02ed8d41e1d71635aff7deb4dd71fde9098a5b782bb4ac696a8af44f581901a7c0e8d4679ed5d218f8da0d54b64c9ca
7
+ data.tar.gz: 990100d6894e33043688e9ea00c5c90557dfe48a8d2c26c23a795559db62f1457564ced2a146d78e864203ba9a1405bafe274960f3af3f3538f3a2dce14341d0
@@ -7,23 +7,27 @@ module WindowsShutdownTimer
7
7
  # Shutdown!
8
8
  class ShutdownStarter
9
9
 
10
- EXE = 'Insomnia.exe'
10
+ EXE = 'start Insomnia.exe'
11
+ INSOMNIA = 'Insomnia.exe'
11
12
  PATH = 'insomnia/64-bit'
12
13
  COMMAND_SHUTDOWN = 'shutdown /s /t '
13
14
  COMMAND_CANCEL_SHUTDOWN = 'shutdown /a'
14
15
 
15
16
  def initialize(arguments)
16
- @time = nil
17
+
18
+ # Get the first arg as the time
19
+ @time = %w(-h --help -c).include?(arguments.first) ? nil : arguments.shift
20
+
17
21
  create_options_parser(arguments)
18
22
  end
19
23
 
20
24
  def create_options_parser(args)
21
25
  args.options do |opts|
22
- opts.banner = 'Usage: windows-shutdown-timer [OPTIONS]'
26
+ opts.banner = 'Usage: windows-shutdown-timer MINUTES_UNTIL_SHUTDOWN [OPTIONS]'
23
27
  opts.separator ''
24
28
  opts.separator 'Options'
25
- opts.on('-t', '--time', 'The amount of time in minutes before shutdown. 0 will cancel the shutdown') do |time|
26
- @time = time
29
+ opts.on('-c', '--cancel', 'Cancel a pending shutdown') do
30
+ @time = 0
27
31
  end
28
32
  opts.on('-h', '--help', 'Displays help') do
29
33
  puts opts.help
@@ -34,7 +38,7 @@ module WindowsShutdownTimer
34
38
  end
35
39
 
36
40
  def start_timer
37
- unless File.file?(EXE)
41
+ unless File.file?(INSOMNIA)
38
42
  download('dlaa.me', '/Samples/Insomnia/Insomnia.zip', 'Insomnia.zip')
39
43
  unzip('Insomnia.zip', 'insomnia')
40
44
  FileUtils.mv('insomnia/64-bit/Insomnia.exe', Dir.pwd + '/Insomnia.exe')
@@ -50,7 +54,7 @@ module WindowsShutdownTimer
50
54
  else
51
55
  time_in_seconds = @time.to_i * 60
52
56
  `#{COMMAND_SHUTDOWN} #{time_in_seconds}`
53
- `#{EXE}`
57
+ system(EXE)
54
58
  end
55
59
  end
56
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: windows-shutdown-timer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Carlson
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: 1.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
27
33
  description:
28
34
  email:
29
35
  - jawnnypoo@gmail.com