ffi-cups 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -6
- data/lib/ffi-cups/ffi/cups.rb +5 -2
- data/lib/ffi-cups/job.rb +18 -0
- data/lib/ffi-cups/printer.rb +1 -1
- data/lib/ffi-cups/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fce753f3f9c8d744368e9df26a335ffec7b1614fdc7fa40d550ef3e316438abe
|
4
|
+
data.tar.gz: 4a602c610d3a515078fdfa6e7c0c1f2234a324db079b5e8450a1985ef19bf934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f0fcc75028fe6ba7e1b3a852cbf961ef639a586e61f6d77f59c81bcc874acadd74f50fc78482396cf5d01e95218ae331a5983833e121bafef876e152ede3e68
|
7
|
+
data.tar.gz: 2c55185fe6e8a11461848a6136c456961eee8c9b40dadcd11e266844351c05de9e7cb1999083ecb2758227ce6df8a475bc28f56c818a80e534deab8d5d170824
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# FFI-Cups
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/ffi-cups.svg)](https://badge.fury.io/rb/ffi-cups)
|
3
3
|
|
4
|
-
|
4
|
+
ffi-cups is a FFI bindings for libcups providing access to the Cups API through Ruby.
|
5
5
|
|
6
6
|
CUPS is the standards-based, open source printing system developed by Apple Inc. for macOS® and other UNIX®-like operating systems. CUPS uses the Internet Printing Protocol (IPP) to support printing to local and network printers. - from http://www.cups.org/
|
7
7
|
|
@@ -66,11 +66,7 @@ remote_printers = Cups::Printer.get_destinations(connection)
|
|
66
66
|
```
|
67
67
|
|
68
68
|
## Documentation
|
69
|
-
Check out the documentation - [docs](https://www.rubydoc.info/gems/ffi-cups/0.1
|
70
|
-
|
71
|
-
## TODO
|
72
|
-
- Connection to not be a singleton class
|
73
|
-
- Cancel jobs function
|
69
|
+
Check out the documentation - [docs](https://www.rubydoc.info/gems/ffi-cups/0.2.1)
|
74
70
|
|
75
71
|
## Authors
|
76
72
|
- Hugo Marquez @ www.hugomarquez.mx
|
data/lib/ffi-cups/ffi/cups.rb
CHANGED
@@ -94,14 +94,17 @@ module FFI::Cups
|
|
94
94
|
# @overload cupsCancelJob(string, int)
|
95
95
|
# @param name [String] of the destination
|
96
96
|
# @param id [Ingeger] of the job
|
97
|
-
|
97
|
+
# @return [Integer] 1 if canceled, 0 otherwise
|
98
|
+
attach_function 'cupsCancelJob', [:string, :int], :int, blocking: true
|
98
99
|
|
99
100
|
# Cancel a job on a destination
|
100
101
|
# @overload cupsCancelJob2(pointer, string, int)
|
101
102
|
# @param pointer [Pointer] of the http connection
|
102
103
|
# @param name [String] of the destination
|
103
104
|
# @param id [Ingeger] of the job
|
104
|
-
|
105
|
+
# @param purge [Integer] 1 to purge, 0 to cancel
|
106
|
+
# @return [Enum] Cups::Enun::IPP::Status
|
107
|
+
attach_function 'cupsCancelJob2', [:pointer, :string, :int, :int], Cups::Enum::IPP::Status, blocking: true
|
105
108
|
|
106
109
|
# Get the jobs from a connection
|
107
110
|
# @overload cupsGetJobs2(pointer, pointer, string, int, int)
|
data/lib/ffi-cups/job.rb
CHANGED
@@ -10,6 +10,23 @@ module Cups
|
|
10
10
|
@printer = printer
|
11
11
|
end
|
12
12
|
|
13
|
+
# get a updated job's state
|
14
|
+
# @param connection [Cups::Connection]
|
15
|
+
# @return [Symbol] job's state
|
16
|
+
def status(connection=nil)
|
17
|
+
job = self.class.get_job(@id, @printer, -1, connection)
|
18
|
+
self.state = job.state if job
|
19
|
+
end
|
20
|
+
|
21
|
+
# Cancel or purge a job
|
22
|
+
# @param connection [Cups::Connection]
|
23
|
+
def cancel(purge=0, connection=nil)
|
24
|
+
job = self.class.get_job(@id, @printer, -1, connection)
|
25
|
+
r = FFI::Cups.cupsCancelJob2(connection, @printer, @id, purge)
|
26
|
+
raise FFI::Cups.cupsLastErrorString() if r == 0
|
27
|
+
return r
|
28
|
+
end
|
29
|
+
|
13
30
|
# Get jobs by filter or destination name
|
14
31
|
# @param name [String]
|
15
32
|
# @param filter [Integer] see Constants
|
@@ -43,6 +60,7 @@ module Cups
|
|
43
60
|
jobs.each do |j|
|
44
61
|
return j if j.id == id
|
45
62
|
end
|
63
|
+
raise "Job with id: #{id} not found!"
|
46
64
|
end
|
47
65
|
|
48
66
|
private
|
data/lib/ffi-cups/printer.rb
CHANGED
data/lib/ffi-cups/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-cups
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hugo Marquez
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-04-
|
12
|
+
date: 2021-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|