wol 0.3.0 → 0.3.1
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.
- data/Rakefile +11 -1
- data/VERSION +1 -1
- data/lib/wol/parsefile.rb +7 -1
- data/lib/wol/runner.rb +12 -1
- data/lib/wol/wakeonlan.rb +21 -13
- metadata +1 -1
data/Rakefile
CHANGED
@@ -35,11 +35,21 @@ task :spec => :check_dependencies
|
|
35
35
|
task :default => :spec
|
36
36
|
|
37
37
|
require 'rake/rdoctask'
|
38
|
+
gem 'rdoc'
|
39
|
+
require 'rdoc/rdoc'
|
40
|
+
|
38
41
|
Rake::RDocTask.new do |rdoc|
|
39
42
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
43
|
|
41
44
|
rdoc.rdoc_dir = 'rdoc'
|
42
|
-
rdoc.title = "
|
45
|
+
rdoc.title = "Ruby Wake-On-LAN #{version}"
|
43
46
|
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('COPYING')
|
48
|
+
rdoc.rdoc_files.include('LICENSE')
|
44
49
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
|
51
|
+
rdoc.options += [
|
52
|
+
'-HN',
|
53
|
+
'-f', 'darkfish',
|
54
|
+
]
|
45
55
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/wol/parsefile.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# Copyright (C) 2009 Matias Korhonen
|
2
|
+
#
|
3
|
+
# Licensed under the Ruby License: http://www.ruby-lang.org/en/LICENSE.txt
|
4
|
+
# and the GNU General Public License: http://www.gnu.org/copyleft/gpl.html
|
5
|
+
|
6
|
+
# Ruby Wake-On-LAN
|
2
7
|
module Wol
|
8
|
+
# Parse a text file containing hardware addresses, host names/addresses, and port numbers
|
3
9
|
module ParseFile
|
4
10
|
|
5
11
|
# Parse a given string and return a hash containing the results
|
data/lib/wol/runner.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
# Copyright (C) 2009 Matias Korhonen
|
2
|
+
#
|
3
|
+
# Licensed under the Ruby License: http://www.ruby-lang.org/en/LICENSE.txt
|
4
|
+
# and the GNU General Public License: http://www.gnu.org/copyleft/gpl.html
|
5
|
+
#
|
1
6
|
require 'optparse'
|
2
7
|
|
3
8
|
module Wol
|
9
|
+
# Run the Ruby-Wake-On-LAN command, +wol+, and parse the given options
|
4
10
|
module Runner
|
5
11
|
@sample_file = %{# File structure
|
6
12
|
# --------------
|
@@ -21,6 +27,7 @@ module Wol
|
|
21
27
|
07:09:09:0A:0B:0C example.com
|
22
28
|
0D:0E:0F:00:10:11}
|
23
29
|
|
30
|
+
# Parse the give arguments
|
24
31
|
def self.parse(args)
|
25
32
|
args = ["-h"] if args.empty?
|
26
33
|
|
@@ -102,10 +109,13 @@ module Wol
|
|
102
109
|
end
|
103
110
|
end
|
104
111
|
|
112
|
+
# Return the version string.
|
113
|
+
# TODO: Fix the way the version is defined.
|
105
114
|
def self.version
|
106
|
-
"Ruby Wake-On-LAN version 0.3.
|
115
|
+
"Ruby Wake-On-LAN version 0.3.1"
|
107
116
|
end
|
108
117
|
|
118
|
+
# Send WOL MagicPackets based on the parsed options
|
109
119
|
def self.wake(options = {})
|
110
120
|
begin
|
111
121
|
if options[:file]
|
@@ -132,6 +142,7 @@ module Wol
|
|
132
142
|
end
|
133
143
|
end
|
134
144
|
|
145
|
+
# Parse the command line options, then use them to wake up any given hosts.
|
135
146
|
def self.run!
|
136
147
|
options = parse(ARGV)
|
137
148
|
|
data/lib/wol/wakeonlan.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
# Copyright (C) 2000-
|
1
|
+
# Copyright (C) 2000-2009 K.Kodama, Matias Korhonen
|
2
2
|
# Original: http://www.math.kobe-u.ac.jp/~kodama/tips-WakeOnLAN.html
|
3
3
|
#
|
4
|
-
# Modified by Matias Korhonen (26.09.2009: Removed command line options, changed to
|
5
|
-
# send the magic packet straight to the IP, not the broadcast address)
|
6
|
-
#
|
7
4
|
# Licensed under the Ruby License: http://www.ruby-lang.org/en/LICENSE.txt
|
8
5
|
# and the GNU General Public License: http://www.gnu.org/copyleft/gpl.html
|
9
6
|
#
|
@@ -13,17 +10,28 @@ require "socket"
|
|
13
10
|
|
14
11
|
module Wol
|
15
12
|
class WakeOnLan
|
16
|
-
|
13
|
+
# Specify the destination MAC Address. Defaults to the broadcast MAC, "ff:ff:ff:ff:ff:ff"
|
14
|
+
attr_accessor :mac
|
15
|
+
|
16
|
+
# Specify the destination address. Either a IP or hostname. Defaults to "255.255.255.255"
|
17
|
+
attr_accessor :address
|
18
|
+
|
19
|
+
# The destination port. Defaults to the discard port, 9
|
20
|
+
attr_accessor :port
|
21
|
+
|
22
|
+
# How many times to send the MagicPacket. Defaults to 1
|
23
|
+
attr_accessor :count
|
24
|
+
|
25
|
+
# How many seconds to wait between sending packets. Defaults to 0.01
|
26
|
+
attr_accessor :delay
|
27
|
+
|
28
|
+
# What to return? Returns a string summary if false, else returns nil
|
29
|
+
attr_accessor :quiet
|
30
|
+
|
31
|
+
# The socket opened by WakeOnLan initialization
|
17
32
|
attr_reader :socket
|
18
33
|
|
19
|
-
# Create a new instance
|
20
|
-
# == Options
|
21
|
-
# * <tt>:mac => "ff:ff:ff:ff:ff:ff"</tt> - Specify the destination MAC Address. Defaults to the broadcast MAC, "ff:ff:ff:ff:ff:ff"
|
22
|
-
# * <tt>:address => "255.255.255.255"</tt> - Specify the destination address. Either a IP or hostname. Defaults to "255.255.255.255"
|
23
|
-
# * <tt>:port => 9</tt> - The destination port. Defaults to the discard port, 9
|
24
|
-
# * <tt>:count => 1</tt> - How many times to send the MagicPacket. Defaults to 1
|
25
|
-
# * <tt>:delay => 0.01</tt> - How many seconds to wait between sending packets. Defaults to 0.01
|
26
|
-
# * <tt>:quiet => false</tt> - What to return? Returns a string summary if false, else returns nil
|
34
|
+
# Create a new WakeOnLan instance. See the WakeOnLan class documentation for options.
|
27
35
|
def initialize(options = {})
|
28
36
|
@mac = options[:mac] ||= "ff:ff:ff:ff:ff:ff"
|
29
37
|
@address = options[:address] ||= "255.255.255.255"
|