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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63c1079a34a2ba53dd1ba0a0be14738700cfc17540ebfffd517674bfe67c9525
4
- data.tar.gz: c6bd62d2efc4bce337b774becb392012c899cc345ed7df8fb34b4548d3f53c85
3
+ metadata.gz: fce753f3f9c8d744368e9df26a335ffec7b1614fdc7fa40d550ef3e316438abe
4
+ data.tar.gz: 4a602c610d3a515078fdfa6e7c0c1f2234a324db079b5e8450a1985ef19bf934
5
5
  SHA512:
6
- metadata.gz: 23e2d001e8eb819b52940584b984bedd4f380ff5d41b0fcff97abd36168ffe561dc611ce8e3d1f21ccb70f47c00ef05e381f001493a8dca159ce43f3d55723ea
7
- data.tar.gz: e31273be32df34f501b27542b894c7bd73b34cbd18a93af65466a27d3184a0c96e76d10b598f3737215e1634c38eca32c68c762224cc41ead11c317056a547fb
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
- This gem ffi-cups is a FFI bindings for libcups providing access to the Cups API through Ruby.
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.9)
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
@@ -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
- attach_function 'cupsCancelJob', [:string, :int], :void, blocking: true
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
- attach_function 'cupsCancelJob2', [:pointer, :string, :int], :void, blocking: true
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
@@ -17,7 +17,7 @@ module Cups
17
17
  when '3' then :idle
18
18
  when '4' then :printing
19
19
  when '5' then :stopped
20
- else :unkown
20
+ else :unknown
21
21
  end
22
22
  end
23
23
 
@@ -1,3 +1,3 @@
1
1
  module Cups
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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-19 00:00:00.000000000 Z
12
+ date: 2021-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi