oode 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -60
- data/Rakefile +25 -11
- data/bin/oode +101 -98
- data/lib/oode.rb +18 -5
- data/lib/oode/domain/file.rb +27 -0
- data/lib/oode/domain/user.rb +16 -0
- data/lib/oode/ext/ext.rb +29 -0
- data/lib/oode/net/downloader.rb +8 -0
- data/lib/oode/net/session.rb +44 -0
- data/lib/oode/net/transferer.rb +10 -0
- data/lib/oode/net/uploader.rb +30 -0
- data/lib/oode/print/printer.rb +82 -0
- data/lib/oode/version.rb +1 -1
- data/man/index.txt +1 -0
- data/man/oode.1 +36 -55
- data/man/oode.1.html +127 -111
- data/man/oode.1.ronn +31 -33
- data/test/domain/oodefile_test.rb +59 -0
- data/test/domain/oodeuser_test.rb +20 -0
- data/test/helper.rb +24 -5
- data/test/net/oodedownloader_test.rb +20 -0
- data/test/net/oodesession_test.rb +21 -0
- data/test/net/oodeuploader_test.rb +23 -0
- data/test/print/oodeprinter_test.rb +255 -0
- metadata +37 -27
- data/lib/oode/colour.rb +0 -7
- data/lib/oode/file.rb +0 -28
- data/lib/oode/helper.rb +0 -20
- data/lib/oode/queue.rb +0 -118
- data/test/test_oodefile.rb +0 -8
data/README.md
CHANGED
@@ -1,69 +1,27 @@
|
|
1
|
-
oode
|
2
|
-
====
|
1
|
+
# oode
|
3
2
|
|
4
|
-
|
3
|
+
<a href="http://stillmaintained.com/xoebus/oode">
|
4
|
+
<img src="http://stillmaintained.com/xoebus/oode.png" />
|
5
|
+
</a>
|
5
6
|
|
6
|
-
`oode` makes
|
7
|
+
`oode` makes working in Appleton Tower with a laptop a little less soul
|
8
|
+
destroying.
|
7
9
|
|
8
|
-
##
|
10
|
+
## Getting Help
|
11
|
+
There are a couple of ways to get help for using `oode`.
|
9
12
|
|
10
|
-
|
11
|
-
* Print `file.pdf` to the printer `at3`.
|
13
|
+
1. If you use `gem man` then there is a man page avaliable.
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
* `oode -p at13c -u s08xxxxx -a passw0rd file.pdf`
|
17
|
-
* Print `file.pdf` to `at13c` as user `s08xxxxx` authenticating with password `passw0rd`.
|
15
|
+
2. Come on IRC and ask me a question. (I'm **xoebus** on *Freenode* and
|
16
|
+
*ImaginaryNet*.
|
18
17
|
|
19
|
-
|
18
|
+
3. Find me in Appleton Tower!
|
20
19
|
|
21
|
-
|
20
|
+
## Bugs
|
21
|
+
Report any you find here: <http://github.com/xoebus/oode/issues>
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
## Authors
|
24
|
+
* Chris Brown ([xoebus](http://github.com/xoebus/))
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
## OPTIONS
|
29
|
-
The following options and flags can be used with `oode`:
|
30
|
-
|
31
|
-
### Authentication
|
32
|
-
|
33
|
-
* `-u`, `--user`:
|
34
|
-
Your DICE username so that `oode` can authenticate.
|
35
|
-
|
36
|
-
* `-a`, `--password`:
|
37
|
-
Your DICE password so that `oode` can authenticate.
|
38
|
-
|
39
|
-
### Miscellaneous
|
40
|
-
|
41
|
-
* `-p`, `--printer`:
|
42
|
-
Use the printer, <PRINTER>, to print the <FILES>.
|
43
|
-
|
44
|
-
* `-f`, `--force`:
|
45
|
-
Force `oode` to use a certain printer even if it is not desired.
|
46
|
-
|
47
|
-
### Printing
|
48
|
-
|
49
|
-
* `-n`, `--number`:
|
50
|
-
Print <NUMBER> copies of the <FILES>.
|
51
|
-
|
52
|
-
* `-2`, `--two-up`:
|
53
|
-
Print the files in the 2-up style.
|
54
|
-
|
55
|
-
* `-4`, `--four-up`:
|
56
|
-
Print the files in the 4-up style.
|
57
|
-
|
58
|
-
## BUGS
|
59
|
-
|
60
|
-
<http://github.com/xoebus/oode/issues>
|
61
|
-
|
62
|
-
## AUTHOR
|
63
|
-
|
64
|
-
Chris Brown :: cb@tardis.ed.ac.uk :: @xoebus
|
65
|
-
|
66
|
-
## SEE ALSO
|
67
|
-
|
68
|
-
<http://github.com>,
|
69
|
-
<http://github.com/xoebus/oode>
|
26
|
+
## See Also
|
27
|
+
<http://github.com/xoebus>, <http://github.com/xoebus/oode>
|
data/Rakefile
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'metric_fu'
|
3
|
+
|
4
|
+
MetricFu::Configuration.run do |config|
|
5
|
+
config.metrics = [:churn, :flog, :roodi, :flay, :reek]
|
6
|
+
config.graphs = [:flog, :flay, :reek]
|
7
|
+
end
|
8
|
+
|
9
|
+
task :default => [:test]
|
10
|
+
|
1
11
|
#
|
2
12
|
# Helpers
|
3
13
|
#
|
4
|
-
|
5
14
|
def command?(command)
|
6
15
|
`type -t #{command}`
|
7
16
|
$?.success?
|
@@ -18,16 +27,14 @@ task :check_dirty do
|
|
18
27
|
end
|
19
28
|
end
|
20
29
|
|
21
|
-
|
22
30
|
#
|
23
31
|
# Tests
|
24
32
|
#
|
25
|
-
|
26
33
|
if command? :turn
|
27
34
|
desc "Run tests"
|
28
35
|
task :test do
|
29
36
|
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
|
30
|
-
sh "turn test
|
37
|
+
sh "turn -m test/**/*_test.rb #{suffix}"
|
31
38
|
end
|
32
39
|
else
|
33
40
|
Rake::TestTask.new do |t|
|
@@ -38,11 +45,9 @@ else
|
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
41
|
-
|
42
48
|
#
|
43
|
-
#
|
49
|
+
# Ronn
|
44
50
|
#
|
45
|
-
|
46
51
|
if command? :ronn
|
47
52
|
desc "Show the manual"
|
48
53
|
task :man => "man:build" do
|
@@ -51,15 +56,25 @@ if command? :ronn
|
|
51
56
|
|
52
57
|
desc "Build the manual"
|
53
58
|
task "man:build" do
|
54
|
-
sh "ronn -
|
59
|
+
sh "ronn -i --date=`date +%Y-%m-%d` --organization=Lolsoft --manual='Oode Manual' -sprint,toc -w man/*.ronn"
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
63
|
+
desc "Publish to GitHub Pages"
|
64
|
+
task :pages => [ "man:build", :check_dirty ] do
|
65
|
+
cp "man/oode.1.html", "html"
|
66
|
+
sh "git checkout gh-pages"
|
67
|
+
sh "mv html index.html"
|
68
|
+
sh "git add index.html"
|
69
|
+
sh "git commit -m 'update man page'"
|
70
|
+
sh "git push origin gh-pages"
|
71
|
+
sh "git checkout develop"
|
72
|
+
puts :done
|
73
|
+
end
|
58
74
|
|
59
75
|
#
|
60
|
-
#
|
76
|
+
# Gem
|
61
77
|
#
|
62
|
-
|
63
78
|
begin
|
64
79
|
require 'mg'
|
65
80
|
MG.new('oode.gemspec')
|
@@ -68,7 +83,6 @@ rescue LoadError
|
|
68
83
|
warn "Install it with: gem install mg"
|
69
84
|
end
|
70
85
|
|
71
|
-
|
72
86
|
desc "Push a new version."
|
73
87
|
task :publish => "gem:publish" do
|
74
88
|
require 'oode/version'
|
data/bin/oode
CHANGED
@@ -1,106 +1,109 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
require
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
3
|
+
require 'gli'
|
4
|
+
require 'gli_version'
|
5
|
+
require 'highline/import'
|
6
|
+
|
7
|
+
$: << File.expand_path(File.join('..', __FILE__, '/../lib'))
|
8
|
+
require 'oode'
|
9
|
+
|
10
|
+
include GLI
|
11
|
+
|
12
|
+
# Commands that require authentication
|
13
|
+
AUTH_COMMANDS = [:print, :push]
|
14
|
+
|
15
|
+
# Oode Information
|
16
|
+
version Oode::VERSION
|
17
|
+
config_file '.ooderc'
|
18
|
+
|
19
|
+
# Global Flags
|
20
|
+
desc 'DICE username'
|
21
|
+
arg_name 'username'
|
22
|
+
flag [:u, :username]
|
23
|
+
|
24
|
+
desc 'DICE password'
|
25
|
+
arg_name 'password'
|
26
|
+
flag [:p, :password]
|
27
|
+
|
28
|
+
# Print Command
|
29
|
+
desc 'Print files to DICE printers'
|
30
|
+
arg_name '[files]'
|
31
|
+
long_desc <<EOS
|
32
|
+
This command allows for the printing of local files to any of the
|
33
|
+
printers on the DICE network.
|
34
|
+
EOS
|
35
|
+
command [:print] do |c|
|
36
|
+
c.desc 'The printer to send the files to.'
|
37
|
+
c.arg_name 'NAME'
|
38
|
+
c.flag [:P, :printer]
|
39
|
+
|
40
|
+
c.desc 'Force the job to print no matter what state the printer is in.'
|
41
|
+
c.default_value false
|
42
|
+
c.switch [:f, :force]
|
43
|
+
|
44
|
+
c.desc 'The number of copies of each file yo would like to print.'
|
45
|
+
c.arg_name 'COPIES'
|
46
|
+
c.default_value 1
|
47
|
+
c.flag [:n, :number]
|
48
|
+
|
49
|
+
c.desc 'Print the document as four pages to a sheet.'
|
50
|
+
c.switch ['4', :four]
|
51
|
+
|
52
|
+
c.desc 'Print the document as two pages to a sheet.'
|
53
|
+
c.switch ['2', :two]
|
54
|
+
|
55
|
+
c.action do |global_options,options,args|
|
56
|
+
user = Oode::User.new(global_options[:username], global_options[:password])
|
57
|
+
print_session = Oode::Uploader.new(user)
|
58
|
+
|
59
|
+
config = Hash.new
|
60
|
+
|
61
|
+
if config[:two]
|
62
|
+
config[:format] = :two
|
63
|
+
elsif config[:four]
|
64
|
+
config[:format] = :four
|
65
|
+
end
|
66
|
+
|
67
|
+
config[:number] = options[:number] if options[:number] != 1
|
68
|
+
config[:force] = true if options[:force]
|
69
|
+
|
70
|
+
error "You must specify a printer." unless options[:printer]
|
71
|
+
|
72
|
+
printer = Oode::Printer.new(options[:printer], print_session, config)
|
73
|
+
|
74
|
+
files = Array.new
|
75
|
+
args.each do |arg|
|
76
|
+
files << Oode::File.new(arg, user)
|
77
|
+
end
|
78
|
+
|
79
|
+
files.each do |file|
|
80
|
+
print_session.upload!(file)
|
81
|
+
end
|
82
|
+
|
83
|
+
files.each do |file|
|
84
|
+
printer.print!(file)
|
85
|
+
end
|
86
|
+
|
87
|
+
print_session.clean!
|
63
88
|
end
|
64
|
-
|
65
|
-
opts.on( "-4", "--four-up", "Print the document as four pages to a sheet." ) do |opt|
|
66
|
-
options[:options][:four] = true
|
67
|
-
end
|
68
|
-
|
69
|
-
opts.on( "-2", "--two-up", "Print the document as two pages to a sheet." ) do |opt|
|
70
|
-
options[:options][:two] = true
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
optparse.parse!
|
75
|
-
|
76
|
-
if ARGV.empty?
|
77
|
-
puts optparse.help
|
78
|
-
exit
|
79
89
|
end
|
80
90
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
ARGV.each do |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
|
91
|
+
pre do |global_options,command,options,args|
|
92
|
+
if (!command.nil? && AUTH_COMMANDS.include?(command.name))
|
93
|
+
# No Username
|
94
|
+
if global_options[:username].nil?
|
95
|
+
username = ask("Username: ")
|
96
|
+
global_options.update({ :u => username, :username => username })
|
97
|
+
end
|
98
|
+
|
99
|
+
# No Password
|
100
|
+
if global_options[:password].nil?
|
101
|
+
password = ask("Password: ") { |q| q.echo = "*" * rand(3) }
|
102
|
+
global_options.update({ :p => password, :password => password })
|
103
|
+
end
|
101
104
|
end
|
105
|
+
|
106
|
+
true
|
102
107
|
end
|
103
108
|
|
104
|
-
|
105
|
-
print_queue.print
|
106
|
-
end
|
109
|
+
GLI.run(ARGV)
|
data/lib/oode.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
require
|
1
|
+
# Version
|
2
|
+
require 'oode/version'
|
3
|
+
|
4
|
+
# Extension Classes
|
5
|
+
require 'oode/ext/ext'
|
6
|
+
|
7
|
+
# Domain Models
|
8
|
+
require 'oode/domain/user'
|
9
|
+
require 'oode/domain/file'
|
10
|
+
|
11
|
+
# Network
|
12
|
+
require 'oode/net/session'
|
13
|
+
require 'oode/net/transferer'
|
14
|
+
require 'oode/net/uploader'
|
15
|
+
require 'oode/net/downloader'
|
16
|
+
|
17
|
+
# Printing
|
18
|
+
require 'oode/print/printer'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Oode
|
2
|
+
class File
|
3
|
+
attr_reader :path
|
4
|
+
attr_reader :user
|
5
|
+
|
6
|
+
def initialize(path, user)
|
7
|
+
@path = path
|
8
|
+
@user = user
|
9
|
+
end
|
10
|
+
|
11
|
+
def remote_path
|
12
|
+
::File.expand_path(::File.join(@user.home, ".oode", basename))
|
13
|
+
end
|
14
|
+
|
15
|
+
def extension
|
16
|
+
::File.extname(path).split(".")[1].to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def basename
|
20
|
+
::File.basename(path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def size
|
24
|
+
::File.size(::File.expand_path(path))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|