oode 0.1.1 → 0.1.3

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/bin/oode CHANGED
@@ -32,6 +32,11 @@ optparse = OptionParser.new do |opts|
32
32
  options[:printer] = printer
33
33
  end
34
34
 
35
+ options[:options] = {}
36
+ opts.on( "-n", "--number COPIES", "The number of copies of FILE you would like to print." ) do |copies|
37
+ options[:options][:copies] = copies
38
+ end
39
+
35
40
  options[:user] = config[:user]
36
41
  opts.on( "-u", "--user USER", "The user to log into DICE with." ) do |user|
37
42
  options[:user] = user
@@ -60,7 +65,7 @@ if options[:password].nil?
60
65
  options[:password] = ask("Password: ") { |q| q.echo = false}
61
66
  end
62
67
 
63
- print_queue = Oode::OodeQueue.new options[:user], options[:password], options[:printer]
68
+ print_queue = Oode::OodeQueue.new options[:user], options[:password], options[:printer], options[:options]
64
69
 
65
70
  ARGV.each do |filename|
66
71
  print_queue.enqueue filename
@@ -2,23 +2,20 @@ module Oode
2
2
  class OodeFile
3
3
  def initialize filename
4
4
  @filename = filename
5
+ @remote_filename = @filename.gsub(" ", "-")
5
6
  end
6
7
 
7
8
  def upload session, destination
8
- session.upload! File.expand_path(@filename), File.join(destination, @filename)
9
+ session.upload! File.expand_path(@filename), File.join(destination, @remote_filename)
9
10
  end
10
11
 
11
- def print session, directory, printer
12
- path = File.join directory, @filename
13
- command = "lpr -P #{printer} #{path}"
12
+ def print session, directory, printer, args
13
+ path = File.join directory, @remote_filename
14
+ command = "lpr -P #{printer} #{args}#{path}"
14
15
  session.exec!("ssh student.login #{command}")
16
+ #puts command.blue
15
17
  end
16
-
17
- def clean session, directory
18
- command = "rm -r #{directory}"
19
- session.exec!("ssh student.login #{command}")
20
- end
21
-
18
+
22
19
  def remote_path
23
20
  File.join File.expand_path("/home/.oode/"), @filename
24
21
  end
@@ -2,11 +2,13 @@ module Oode
2
2
  class OodeQueue
3
3
  attr_reader :queue
4
4
 
5
- def initialize(user, password, printer)
5
+ def initialize(user, password, printer, options = {})
6
6
  @queue = []
7
7
  @user = user
8
8
  @password = password
9
9
  @printer = printer
10
+
11
+ args_from_options options
10
12
  end
11
13
 
12
14
  def print
@@ -25,28 +27,40 @@ module Oode
25
27
 
26
28
  puts "Printing files on #{@printer.red}...".yellow
27
29
  @queue.each do |file|
28
- file.print ssh, remote_oode_path, @printer
30
+ file.print ssh, remote_oode_path, @printer, @args
29
31
  end
30
32
 
31
33
  # Make sure the job has been sent to the printer.
32
34
  sleep 1
33
35
 
34
36
  puts "Cleaning up this mess...".yellow
35
- @queue.each do |file|
36
- file.clean ssh, remote_oode_path
37
- end
37
+ clean ssh, remote_oode_path
38
+ end
39
+ end
40
+
41
+ def args_from_options options
42
+ @args = ""
43
+ @args if options.empty?
44
+
45
+ if options.has_key? :copies
46
+ @args << "-# #{options[:copies]} "
38
47
  end
48
+
49
+ @args
39
50
  end
40
51
 
41
52
  def remote_user_path
42
53
  "/home/#{@user}"
43
54
  end
44
55
 
45
- def remote_oode_path
46
- File.join remote_user_path, ".oode"
56
+ def clean session, directory
57
+ command = "rm -r #{directory}"
58
+ session.exec!("ssh student.login #{command}")
59
+ #puts command.blue
47
60
  end
48
61
 
49
- def clean
62
+ def remote_oode_path
63
+ File.join remote_user_path, ".oode"
50
64
  end
51
65
 
52
66
  def length
@@ -1,3 +1,3 @@
1
1
  module Oode
2
- Version = VERSION = '0.1.1'
2
+ Version = VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Chris Brown
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-28 00:00:00 +01:00
17
+ date: 2010-04-29 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency