cupsffi 0.0.1 → 0.0.2
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/COPYING +21 -0
- data/README +56 -0
- data/lib/cupsffi/lib.rb +11 -1
- data/lib/cupsffi/version.rb +1 -1
- metadata +6 -14
data/COPYING
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 Nathan Ehresman
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
CupsFFI is an FFI wrapper around libcups providing access to the Cups API
|
2
|
+
as well as the PPD API. It was written using Ruby 1.9.2 but has not been
|
3
|
+
tested with previous versions.
|
4
|
+
|
5
|
+
## License
|
6
|
+
|
7
|
+
CupsFFI is MIT licensed.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
gem install cupsffi
|
12
|
+
|
13
|
+
## Setup
|
14
|
+
|
15
|
+
Nothing required. libcups is used to find and read all configuration.
|
16
|
+
|
17
|
+
## Example usage
|
18
|
+
|
19
|
+
require 'cupsffi'
|
20
|
+
# Returns array of printer names:
|
21
|
+
# => ["HP-Officejet-7200-series", "test-printer"]
|
22
|
+
printers = CupsPrinter.get_all_printer_names
|
23
|
+
|
24
|
+
printer = CupsPrinter.new(printers.first)
|
25
|
+
|
26
|
+
# Returns a hash of the Cups printer options:
|
27
|
+
# => {"auth-info-required"=>"none",
|
28
|
+
# "copies"=>"1",
|
29
|
+
# "device-uri"=>"ipp://192.168.250.55/ipp/3000", ...
|
30
|
+
printer.attributes
|
31
|
+
|
32
|
+
# Return a hash of :state and :reasons.
|
33
|
+
# :state is :idle, :printing, or :stopped. For example:
|
34
|
+
# {:state=>:idle, :reasons=>["none"]}
|
35
|
+
printer.state
|
36
|
+
|
37
|
+
# Print a file (pdf, jpg, ps, etc.). You can pass in a hash of printer
|
38
|
+
# options if you want to override the printer's defaults. A CupsJob object
|
39
|
+
# is returned. CupsJob can be used to check on the job status.
|
40
|
+
job = printer.print_file('/tmp/example.jpg', {'InputSlot' => 'Upper', 'PageSize' => 'A4'})
|
41
|
+
|
42
|
+
# A job's status is a CupsFFI::IppJState enumeration:
|
43
|
+
# [:pending, :held, :processing, :stopped, :canceled, :aborted, :completed]
|
44
|
+
job.status
|
45
|
+
|
46
|
+
# Cancel a specific job
|
47
|
+
job.cancel
|
48
|
+
|
49
|
+
# Print a binary blob of data. The data should be in a String, and is
|
50
|
+
# passed to libcups as a char array. You must also specify the mime type.
|
51
|
+
# Like print_file, printer options are... optional. A CupsJob object is
|
52
|
+
# returned.
|
53
|
+
job = printer.print_data('hello world', 'text/plain')
|
54
|
+
|
55
|
+
# Cancel all outstanding jobs on the printer
|
56
|
+
printer.cancel_all_jobs
|
data/lib/cupsffi/lib.rb
CHANGED
@@ -24,7 +24,17 @@ require 'ffi'
|
|
24
24
|
|
25
25
|
module CupsFFI
|
26
26
|
extend FFI::Library
|
27
|
-
|
27
|
+
|
28
|
+
paths =
|
29
|
+
Array(
|
30
|
+
ENV['CUPS_LIB'] ||
|
31
|
+
Dir['/{opt,usr}/{,local/}lib{,64}/libcups.{dylib,so*}']
|
32
|
+
)
|
33
|
+
begin
|
34
|
+
ffi_lib(*paths)
|
35
|
+
rescue LoadError => le
|
36
|
+
raise LoadError, "Didn't find libcups on your system."
|
37
|
+
end
|
28
38
|
|
29
39
|
### cups.h API
|
30
40
|
|
data/lib/cupsffi/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cupsffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Nathan Ehresman
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-07 00:00:00 -05:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,8 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
24
|
version: "0"
|
31
25
|
type: :development
|
32
26
|
version_requirements: *id001
|
@@ -41,7 +35,9 @@ extra_rdoc_files: []
|
|
41
35
|
|
42
36
|
files:
|
43
37
|
- .gitignore
|
38
|
+
- COPYING
|
44
39
|
- Gemfile
|
40
|
+
- README
|
45
41
|
- Rakefile
|
46
42
|
- cupsffi.gemspec
|
47
43
|
- lib/cupsffi.rb
|
@@ -64,21 +60,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
60
|
requirements:
|
65
61
|
- - ">="
|
66
62
|
- !ruby/object:Gem::Version
|
67
|
-
segments:
|
68
|
-
- 0
|
69
63
|
version: "0"
|
70
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
65
|
none: false
|
72
66
|
requirements:
|
73
67
|
- - ">="
|
74
68
|
- !ruby/object:Gem::Version
|
75
|
-
segments:
|
76
|
-
- 0
|
77
69
|
version: "0"
|
78
70
|
requirements: []
|
79
71
|
|
80
72
|
rubyforge_project: cupsffi
|
81
|
-
rubygems_version: 1.
|
73
|
+
rubygems_version: 1.6.1
|
82
74
|
signing_key:
|
83
75
|
specification_version: 3
|
84
76
|
summary: FFI wrapper around libcups
|