oode 0.1.6 → 0.2.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.
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oode
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 6
9
- version: 0.1.6
4
+ prerelease:
5
+ version: 0.2.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Chris Brown
@@ -14,18 +10,16 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-05-01 00:00:00 +01:00
18
- default_executable:
13
+ date: 2011-04-24 00:00:00 Z
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
16
  name: net-ssh
22
17
  prerelease: false
23
18
  requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
23
  version: "0"
30
24
  type: :runtime
31
25
  version_requirements: *id001
@@ -33,11 +27,10 @@ dependencies:
33
27
  name: net-sftp
34
28
  prerelease: false
35
29
  requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
36
31
  requirements:
37
32
  - - ">="
38
33
  - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
34
  version: "0"
42
35
  type: :runtime
43
36
  version_requirements: *id002
@@ -45,15 +38,25 @@ dependencies:
45
38
  name: highline
46
39
  prerelease: false
47
40
  requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
48
42
  requirements:
49
43
  - - ">="
50
44
  - !ruby/object:Gem::Version
51
- segments:
52
- - 0
53
45
  version: "0"
54
46
  type: :runtime
55
47
  version_requirements: *id003
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"
48
+ - !ruby/object:Gem::Dependency
49
+ name: gli
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :runtime
58
+ version_requirements: *id004
59
+ description: " `oode` makes working in Appleton Tower much easier from laptops\n by automating some of the tediousness from the sequence of tasks\n required.\n"
57
60
  email: cb@tardis.ed.ac.uk
58
61
  executables:
59
62
  - oode
@@ -67,19 +70,28 @@ files:
67
70
  - LICENSE
68
71
  - CONTRIBUTORS
69
72
  - HISTORY.md
70
- - lib/oode/colour.rb
71
- - lib/oode/file.rb
72
- - lib/oode/helper.rb
73
- - lib/oode/queue.rb
73
+ - lib/oode/domain/file.rb
74
+ - lib/oode/domain/user.rb
75
+ - lib/oode/ext/ext.rb
76
+ - lib/oode/net/downloader.rb
77
+ - lib/oode/net/session.rb
78
+ - lib/oode/net/transferer.rb
79
+ - lib/oode/net/uploader.rb
80
+ - lib/oode/print/printer.rb
74
81
  - lib/oode/version.rb
75
82
  - lib/oode.rb
76
83
  - bin/oode
84
+ - man/index.txt
77
85
  - man/oode.1
78
86
  - man/oode.1.html
79
87
  - man/oode.1.ronn
88
+ - test/domain/oodefile_test.rb
89
+ - test/domain/oodeuser_test.rb
80
90
  - test/helper.rb
81
- - test/test_oodefile.rb
82
- has_rdoc: true
91
+ - test/net/oodedownloader_test.rb
92
+ - test/net/oodesession_test.rb
93
+ - test/net/oodeuploader_test.rb
94
+ - test/print/oodeprinter_test.rb
83
95
  homepage: http://github.com/xoebus/oode
84
96
  licenses: []
85
97
 
@@ -89,25 +101,23 @@ rdoc_options: []
89
101
  require_paths:
90
102
  - lib
91
103
  required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
92
105
  requirements:
93
106
  - - ">="
94
107
  - !ruby/object:Gem::Version
95
- segments:
96
- - 0
97
108
  version: "0"
98
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
99
111
  requirements:
100
112
  - - ">="
101
113
  - !ruby/object:Gem::Version
102
- segments:
103
- - 0
104
114
  version: "0"
105
115
  requirements: []
106
116
 
107
117
  rubyforge_project:
108
- rubygems_version: 1.3.6
118
+ rubygems_version: 1.7.2
109
119
  signing_key:
110
120
  specification_version: 3
111
- summary: oode prints to AT printers from laptops
121
+ summary: oode makes working with a laptop in AT less soul-crushing
112
122
  test_files: []
113
123
 
@@ -1,7 +0,0 @@
1
- # This wonderful code taken from http://github.com/michaeldv/awesome_print.
2
- class String
3
- [:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white].each_with_index do |color, offset|
4
- define_method color do "\033[1;#{30+offset}m#{self}\033[0m" end
5
- define_method :"#{color}ish" do "\033[0;#{30+offset}m#{self}\033[0m" end
6
- end
7
- end
@@ -1,28 +0,0 @@
1
- module Oode
2
- class OodeFile
3
- def initialize filename
4
- @filename = filename
5
- @remote_filename = @filename.gsub(" ", "-")
6
- end
7
-
8
- def upload session, destination
9
- session.upload! File.expand_path(@filename), File.join(destination, @remote_filename)
10
- end
11
-
12
- def print session, directory, printer, args
13
- path = File.join directory, @remote_filename
14
- command = "lpr -P #{printer} #{args}#{path}"
15
- session.exec!("ssh student.login #{command}")
16
- # puts command.blue
17
- end
18
-
19
- def check_size
20
- limit = 5242880 # 5MB
21
- file_size = File.size(@filename)
22
-
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
26
- end
27
- end
28
- end
@@ -1,20 +0,0 @@
1
- def error message
2
- abort "ERROR: #{message}".red
3
- end
4
-
5
- def notify message
6
- puts "INFO: #{message}".yellow
7
- end
8
-
9
- def warning message
10
- puts "WARN: #{message}".purple
11
- end
12
-
13
- class Numeric
14
- def to_human
15
- units = %w{B KB MB GB TB}
16
- e = (Math.log(self)/Math.log(1024)).floor
17
- s = "%.3f" % (to_f / 1024**e)
18
- s.sub(/\.?0*$/, units[e])
19
- end
20
- end
@@ -1,118 +0,0 @@
1
- module Oode
2
- class OodeQueue
3
- attr_reader :queue
4
-
5
- def initialize(user, password, printer, options = {})
6
- @queue = []
7
- @user = user
8
- @password = password
9
- @printer = printer
10
- @options = options
11
-
12
- args_from_options @options
13
-
14
- begin
15
- notify "Connecting to remote server..."
16
- @ssh = Net::SSH.start('ssh.inf.ed.ac.uk', @user, :password => @password)
17
- @sftp = @ssh.sftp
18
- rescue Net::SSH::AuthenticationFailed
19
- error "Your login credentials were incorrect. Please fix this and try again."
20
- rescue Net::SSH::Exception
21
- error "Something went wrong with your SSH connection. Please file a bug report at:\nhttp://github.com/xoebus/oode/issues"
22
- end
23
- end
24
-
25
- def print
26
- check_server
27
- check_printer
28
- upload_files
29
-
30
- notify "Printing files on #{@printer.red}#{"...".yellow}"
31
- @queue.each do |file|
32
- file.check_size
33
- file.print @ssh, remote_oode_path, @printer, @args
34
- end
35
-
36
- # Make sure the job has been sent to the printer.
37
- sleep 1
38
-
39
- clean
40
- end
41
-
42
- def upload_files
43
- notify "Uploading files for printing..."
44
- @queue.each do |file|
45
- file.upload @sftp, remote_oode_path
46
- end
47
- end
48
-
49
- def check_server
50
- notify "Checking remote server..."
51
- unless @sftp.dir.entries(remote_user_path).map { |d| d.name }.include? ".oode"
52
- @sftp.mkdir! remote_oode_path
53
- end
54
- end
55
-
56
- def args_from_options options
57
- @args = ""
58
- @args if options.empty?
59
-
60
- if options.has_key? :copies
61
- @args << "-# #{options[:copies]} "
62
- end
63
-
64
- if options.has_key? :four
65
- @args << "-Z 4up "
66
- elsif options.has_key? :two
67
- @args << "-Z 2up "
68
- end
69
- end
70
-
71
- def check_printer
72
- unless @options.has_key? :force
73
- notify "Checking your printer is working..."
74
-
75
- command = "lpq -P #{@printer}"
76
- output = @ssh.exec!("ssh student.login #{command}")
77
- print_jobs = output.split("\n").length - 2
78
-
79
- if (print_jobs > 5) || !(output =~ /is not ready/).nil?
80
- error "#{@printer} isn't doing too well at the moment. Try another printer."
81
- end
82
- end
83
- end
84
-
85
- def remote_user_path
86
- "/home/#{@user}"
87
- end
88
-
89
- def clean
90
- notify "Cleaning up this mess..."
91
-
92
- command = "rm -r /home/#{@user}/.oode"
93
- @ssh.exec!("ssh student.login #{command}")
94
- # puts command.blue
95
- end
96
-
97
- def remote_oode_path
98
- File.join remote_user_path, ".oode"
99
- end
100
-
101
- def length
102
- @queue.length
103
- end
104
-
105
- def empty?
106
- length.zero?
107
- end
108
-
109
- def enqueue(filename)
110
- file = OodeFile.new(filename)
111
- @queue.push file
112
- end
113
-
114
- def clear
115
- @queue.clear
116
- end
117
- end
118
- end
@@ -1,8 +0,0 @@
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