oode 0.1.5 → 0.1.6

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/CONTRIBUTORS ADDED
@@ -0,0 +1,6 @@
1
+ Contributors
2
+ ============
3
+
4
+ * Chris Brown (xoebus)
5
+
6
+ For an up to date list see here: http://github.com/xoebus/oode/contributors.
data/HISTORY.md ADDED
@@ -0,0 +1,39 @@
1
+ ## 0.1.6 (2010-05-01)
2
+
3
+ * Don't try and print directories.
4
+ * More house keeping.
5
+
6
+ ## 0.1.5 (2010-04-30)
7
+
8
+ * Warn the user that the file is very large when they print it.
9
+
10
+ ## 0.1.4 (2010-04-30)
11
+
12
+ * Better error messages.
13
+ * Check printers before printing.
14
+ * Added -4 and -2 printing options.
15
+
16
+ ## 0.1.2 (2010-04-29)
17
+
18
+ * Added --number argument.
19
+ * Fixed a bug that stopped files being printed if they had spaces in.
20
+
21
+ ## 0.1.1 (2010-04-28)
22
+
23
+ * New prompts for user and password.
24
+
25
+ ## 0.1.0 (2010-04-28)
26
+
27
+ * Lots of housekeeping.
28
+
29
+ ## 0.0.3 (2010-04-26)
30
+
31
+ * Fixed a bug that was caused by the gateway not printing files.
32
+
33
+ ## 0.0.2 (2010-04-26)
34
+
35
+ * Code now works.
36
+
37
+ ## 0.0.1 (2010-04-26)
38
+
39
+ * First release
data/README.md CHANGED
@@ -1,43 +1,44 @@
1
- oode(1) -- print from a laptop to an AT printer
2
- ===============================================
1
+ oode
2
+ ====
3
3
 
4
- ## SYNOPSIS
4
+ *print from a laptop to an AT printer*
5
5
 
6
- `oode` [<OPTIONS>] <FILE>...<br>
6
+ `oode` makes printing to the printers in Appleton Tower much easier from laptops by automating some of the tediousness from the sequence of tasks required.
7
7
 
8
- ## DESCRIPTION
8
+ ## SAMPLE USAGE
9
9
 
10
- `oode` makes printing to the printers in Appleton Tower much easier
11
- from laptops by automating some of the tediousness from the sequence
12
- of tasks required.
10
+ * `oode -p at3 file.pdf`
11
+ * Print `file.pdf` to the printer `at3`.
13
12
 
14
- ## CONFIGURATION
13
+ * `oode -p at13c -4 -n 5 file.pdf`
14
+ * Print 5 copies of `file.pdf` to printer `at13c` using the 4-up layout.
15
+
16
+ * `oode -p at13c -u s08xxxxx -a passw0rd file.pdf`
17
+ * Print `file.pdf` to `at13c` as user `s08xxxxx` authenticating with password `passw0rd`.
18
+
19
+ ## CONFIGURATION FILE
15
20
 
16
- `oode` can read SSH authentication usernames and passwords from a
17
- configuration file so you don't have to type them in every time. A
18
- file called `.ooderc` should be placed in your home directory with
19
- the following contents:
21
+ `oode` can read SSH authentication usernames and passwords from a configuration file so you don't have to type them in every time. A file called `.ooderc` should be placed in your home directory with the following contents:
20
22
 
21
23
  :user: <username>
22
24
  :password: <password>
23
25
 
24
- Either of these can be missed if you would rather enter them yourself
25
- each time.
26
+ Either of these can be missed if you would rather enter them yourself each time.
26
27
 
27
28
  ## OPTIONS
28
29
  The following options and flags can be used with `oode`:
29
30
 
30
31
  ### Authentication
31
32
 
32
- * `-u`, `--user`=<USERNAME>:
33
+ * `-u`, `--user`:
33
34
  Your DICE username so that `oode` can authenticate.
34
35
 
35
- * `-a`, `--password`=<PASSWORD>:
36
+ * `-a`, `--password`:
36
37
  Your DICE password so that `oode` can authenticate.
37
38
 
38
39
  ### Miscellaneous
39
40
 
40
- * `-p`, `--printer`=<PRINTER>:
41
+ * `-p`, `--printer`:
41
42
  Use the printer, <PRINTER>, to print the <FILES>.
42
43
 
43
44
  * `-f`, `--force`:
@@ -45,7 +46,7 @@ The following options and flags can be used with `oode`:
45
46
 
46
47
  ### Printing
47
48
 
48
- * `-n`, `--number`=<NUMBER>:
49
+ * `-n`, `--number`:
49
50
  Print <NUMBER> copies of the <FILES>.
50
51
 
51
52
  * `-2`, `--two-up`:
data/bin/oode CHANGED
@@ -21,13 +21,18 @@ end
21
21
 
22
22
  optparse = OptionParser.new do |opts|
23
23
  opts.banner = "Usage: oode [options] filename"
24
+ opts.program_name = "oode"
25
+ opts.version = Oode::Version
24
26
  options[:options] = {}
25
-
27
+
26
28
  opts.on( "-h", "--help", "Display this screen." ) do
27
29
  puts opts
28
30
  exit
29
31
  end
30
32
 
33
+ opts.separator ""
34
+ opts.separator "General"
35
+
31
36
  options[:printer] = nil
32
37
  opts.on( "-p", "--printer PRINTER", "The printer to send the file to." ) do |printer|
33
38
  options[:printer] = printer
@@ -36,21 +41,27 @@ optparse = OptionParser.new do |opts|
36
41
  opts.on( "-f", "--force", "Force the print job no matter what state the printer is in." ) do |force|
37
42
  options[:options][:force] = true
38
43
  end
39
-
40
- opts.on( "-n", "--number COPIES", "The number of copies of FILE you would like to print." ) do |copies|
41
- options[:options][:copies] = copies
42
- end
44
+
45
+ opts.separator ""
46
+ opts.separator "Authentication"
43
47
 
44
48
  options[:user] = config[:user]
45
49
  opts.on( "-u", "--user USER", "The user to log into DICE with." ) do |user|
46
50
  options[:user] = user
47
51
  end
48
-
52
+
49
53
  options[:password] = config[:password]
50
54
  opts.on( "-a", "--password PASSWORD", "The password to log into DICE with." ) do |password|
51
55
  options[:password] = password
52
56
  end
53
-
57
+
58
+ opts.separator ""
59
+ opts.separator "Printing Options"
60
+
61
+ opts.on( "-n", "--number COPIES", "The number of copies of FILE you would like to print." ) do |copies|
62
+ options[:options][:copies] = copies
63
+ end
64
+
54
65
  opts.on( "-4", "--four-up", "Print the document as four pages to a sheet." ) do |opt|
55
66
  options[:options][:four] = true
56
67
  end
@@ -62,6 +73,11 @@ end
62
73
 
63
74
  optparse.parse!
64
75
 
76
+ if ARGV.empty?
77
+ puts optparse.help
78
+ exit
79
+ end
80
+
65
81
  if options[:printer].nil?
66
82
  error "No printer was specified.\nPlease specify one with the '--printer' or '-p' flags."
67
83
  end
@@ -77,7 +93,14 @@ end
77
93
  print_queue = Oode::OodeQueue.new options[:user], options[:password], options[:printer], options[:options]
78
94
 
79
95
  ARGV.each do |filename|
80
- print_queue.enqueue filename
96
+ unless File.directory?(filename)
97
+ print_queue.enqueue filename
98
+ else
99
+ warning "#{filename} is a directory and will not be printed..."
100
+ exit
101
+ end
81
102
  end
82
103
 
83
- print_queue.print
104
+ unless print_queue.empty?
105
+ print_queue.print
106
+ end
data/lib/oode/file.rb CHANGED
@@ -13,18 +13,16 @@ module Oode
13
13
  path = File.join directory, @remote_filename
14
14
  command = "lpr -P #{printer} #{args}#{path}"
15
15
  session.exec!("ssh student.login #{command}")
16
- #puts command.blue
16
+ # puts command.blue
17
17
  end
18
18
 
19
19
  def check_size
20
20
  limit = 5242880 # 5MB
21
21
  file_size = File.size(@filename)
22
22
 
23
- warning "Your file is pretty big (#{file_size.to_human}). It may take a while to print..."
24
- end
25
-
26
- def remote_path
27
- File.join File.expand_path("/home/.oode/"), @filename
23
+ if file_size > limit
24
+ warning "Your file is pretty big (#{file_size.to_human}). It may take a while to print..."
25
+ end
28
26
  end
29
27
  end
30
28
  end
data/lib/oode/queue.rb CHANGED
@@ -27,7 +27,7 @@ module Oode
27
27
  check_printer
28
28
  upload_files
29
29
 
30
- notify "Printing files on #{@printer.red}..."
30
+ notify "Printing files on #{@printer.red}#{"...".yellow}"
31
31
  @queue.each do |file|
32
32
  file.check_size
33
33
  file.print @ssh, remote_oode_path, @printer, @args
@@ -36,7 +36,7 @@ module Oode
36
36
  # Make sure the job has been sent to the printer.
37
37
  sleep 1
38
38
 
39
- clean @ssh
39
+ clean
40
40
  end
41
41
 
42
42
  def upload_files
@@ -86,12 +86,12 @@ module Oode
86
86
  "/home/#{@user}"
87
87
  end
88
88
 
89
- def clean session
89
+ def clean
90
90
  notify "Cleaning up this mess..."
91
91
 
92
92
  command = "rm -r /home/#{@user}/.oode"
93
- session.exec!("ssh student.login #{command}")
94
- #puts command.blue
93
+ @ssh.exec!("ssh student.login #{command}")
94
+ # puts command.blue
95
95
  end
96
96
 
97
97
  def remote_oode_path
@@ -101,6 +101,10 @@ module Oode
101
101
  def length
102
102
  @queue.length
103
103
  end
104
+
105
+ def empty?
106
+ length.zero?
107
+ end
104
108
 
105
109
  def enqueue(filename)
106
110
  file = OodeFile.new(filename)
data/lib/oode/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oode
2
- Version = VERSION = '0.1.5'
2
+ Version = VERSION = '0.1.6'
3
3
  end
data/man/oode.1 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.5
2
2
  .\" http://github.com/rtomayko/ronn/
3
3
  .
4
- .TH "OODE" "1" "April 2010" "XOEBUS" "Oode Manual"
4
+ .TH "OODE" "1" "May 2010" "XOEBUS" "Oode Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBoode\fR \-\- print from a laptop to an AT printer
@@ -16,6 +16,20 @@
16
16
  from laptops by automating some of the tediousness from the sequence
17
17
  of tasks required.
18
18
  .
19
+ .SH "SAMPLE USAGE"
20
+ .
21
+ .TP
22
+ \fBoode \-p at3 file.pdf\fR
23
+ Print \fBfile.pdf\fR to the printer \fBat3\fR.
24
+ .
25
+ .TP
26
+ \fBoode \-p at13c \-4 \-n 5 file.pdf\fR
27
+ Print 5 copies of \fBfile.pdf\fR to printer \fBat13c\fR using the 4\-up layout.
28
+ .
29
+ .TP
30
+ \fBoode \-p at13c \-u s08xxxxx \-a passw0rd file.pdf\fR
31
+ Print \fBfile.pdf\fR to \fBat13c\fR as user \fBs08xxxxx\fR authenticating with password \fBpassw0rd\fR.
32
+ .
19
33
  .SH "CONFIGURATION"
20
34
  \fBoode\fR can read SSH authentication usernames and passwords from a
21
35
  configuration file so you don't have to type them in every time. A
data/man/oode.1.html CHANGED
@@ -75,6 +75,15 @@
75
75
  from laptops by automating some of the tediousness from the sequence
76
76
  of tasks required.</p>
77
77
 
78
+ <h2>SAMPLE USAGE</h2>
79
+
80
+ <dl>
81
+ <dt><code>oode -p at3 file.pdf</code></dt><dd><p> Print <code>file.pdf</code> to the printer <code>at3</code>.</p></dd>
82
+ <dt><code>oode -p at13c -4 -n 5 file.pdf</code></dt><dd><p> Print 5 copies of <code>file.pdf</code> to printer <code>at13c</code> using the 4-up layout.</p></dd>
83
+ <dt><code>oode -p at13c -u s08xxxxx -a passw0rd file.pdf</code></dt><dd><p> Print <code>file.pdf</code> to <code>at13c</code> as user <code>s08xxxxx</code> authenticating with password <code>passw0rd</code>.</p></dd>
84
+ </dl>
85
+
86
+
78
87
  <h2>CONFIGURATION</h2>
79
88
 
80
89
  <p><code>oode</code> can read SSH authentication usernames and passwords from a
@@ -134,7 +143,7 @@ each time.</p>
134
143
 
135
144
  <ol class='foot man'>
136
145
  <li class='tl'>XOEBUS</li>
137
- <li class='tc'>April 2010</li>
146
+ <li class='tc'>May 2010</li>
138
147
  <li class='tr'>oode(1)</li>
139
148
  </ol>
140
149
 
data/man/oode.1.ronn CHANGED
@@ -11,6 +11,17 @@ oode(1) -- print from a laptop to an AT printer
11
11
  from laptops by automating some of the tediousness from the sequence
12
12
  of tasks required.
13
13
 
14
+ ## SAMPLE USAGE
15
+
16
+ * `oode -p at3 file.pdf`:
17
+ Print `file.pdf` to the printer `at3`.
18
+
19
+ * `oode -p at13c -4 -n 5 file.pdf`:
20
+ Print 5 copies of `file.pdf` to printer `at13c` using the 4-up layout.
21
+
22
+ * `oode -p at13c -u s08xxxxx -a passw0rd file.pdf`:
23
+ Print `file.pdf` to `at13c` as user `s08xxxxx` authenticating with password `passw0rd`.
24
+
14
25
  ## CONFIGURATION
15
26
 
16
27
  `oode` can read SSH authentication usernames and passwords from a
data/test/helper.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'test/unit'
2
+
3
+ begin
4
+ require 'redgreen'
5
+ rescue LoadError
6
+ end
7
+
8
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
9
+ require 'oode'
10
+
11
+ class Test::Unit::TestCase
12
+ # Asserts that `haystack` includes `needle`.
13
+ def assert_includes(needle, haystack)
14
+ assert haystack.include?(needle)
15
+ end
16
+
17
+ # Asserts that `haystack` does not include `needle`.
18
+ def assert_not_includes(needle, haystack)
19
+ assert !haystack.include?(needle)
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift File.dirname(__FILE__)
2
+ require 'helper'
3
+
4
+ class OodeFileTest < Test::Unit::TestCase
5
+ def test_test
6
+ assert_equal true, true
7
+ end
8
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
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-30 00:00:00 +01:00
17
+ date: 2010-05-01 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -53,7 +53,7 @@ dependencies:
53
53
  version: "0"
54
54
  type: :runtime
55
55
  version_requirements: *id003
56
- description: oode prints to AT printers from laptops
56
+ description: " `oode` makes printing to the printers in Appleton Tower much\n easier from laptops by automating some of the tediousness\n from the sequence of tasks required.\n"
57
57
  email: cb@tardis.ed.ac.uk
58
58
  executables:
59
59
  - oode
@@ -65,6 +65,8 @@ files:
65
65
  - README.md
66
66
  - Rakefile
67
67
  - LICENSE
68
+ - CONTRIBUTORS
69
+ - HISTORY.md
68
70
  - lib/oode/colour.rb
69
71
  - lib/oode/file.rb
70
72
  - lib/oode/helper.rb
@@ -75,6 +77,8 @@ files:
75
77
  - man/oode.1
76
78
  - man/oode.1.html
77
79
  - man/oode.1.ronn
80
+ - test/helper.rb
81
+ - test/test_oodefile.rb
78
82
  has_rdoc: true
79
83
  homepage: http://github.com/xoebus/oode
80
84
  licenses: []