cupsffi 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: dbc08d6e444be4d168fa260c3cbf956173b8406d
4
- data.tar.gz: afb009dba1a0297adb2d0ac7f00c1bc6e1c47b65
3
+ metadata.gz: 0a5cd6973b7ece239ff8614b8c3384b899e7a4e8
4
+ data.tar.gz: 77f55e3774e3756b12c62296e41f46fb530e662a
5
5
  SHA512:
6
- metadata.gz: 5f338d344ed18fa3c5807288df26597ac566bea57f08f092110c09c348f459aceeda6173a0cf90042a974da8cb7c1c369d7dae46cbdda2f577de715bb9f6584d
7
- data.tar.gz: a2f491527db5a40bc39da4e5144f0b0394cfdfa8f604b19a5d826d1963d17281dcf32d307bb5658debe184211a35933d054543a73f3a936c74ff5d4e4f9fc88a
6
+ metadata.gz: 8f78e1817e9bd0f32e2b1180226491c82571e01513dcc7343170f98a4ed18e0efb1da4f5f520bab8cb27e095fd484bd5435ba5bf625047313c0247e2e7ff6118
7
+ data.tar.gz: 3104a28ae4f212e82e0000b5a46e4afc175d0fbe2057480cbcb9039d32aaacfd8537de0e0917b14d00e66da71d62dd4446f7a2d40f789320fdea2fe69eb7de72
@@ -20,6 +20,8 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
+ require 'date'
24
+
23
25
  class CupsPrinter
24
26
  attr_reader :name, :connection
25
27
 
@@ -100,6 +102,7 @@ class CupsPrinter
100
102
  hash[options[:name].dup] = options[:value].dup
101
103
  end
102
104
  end
105
+ hash
103
106
  end
104
107
 
105
108
  def state
@@ -183,6 +186,33 @@ class CupsPrinter
183
186
  raise CupsFFI::cupsLastErrorString() if r == 0
184
187
  end
185
188
 
189
+ def get_all_jobs(which = CupsFFI::CUPS_WHICHJOBS_ACTIVE)
190
+ pointer = FFI::MemoryPointer.new :pointer
191
+ job_count = CupsFFI::cupsGetJobs(pointer, @name, 0, which)
192
+
193
+ jobs = []
194
+ job_count.times do |i|
195
+ job = CupsFFI::CupsJobS.new(pointer.get_pointer(0) + (CupsFFI::CupsJobS.size * i))
196
+
197
+ jobs << {
198
+ :completed_time => job[:completed_time].nil? ? nil : DateTime.strptime(job[:completed_time].to_s, "%s"),
199
+ :creation_time => job[:creation_time].nil? ? nil : DateTime.strptime(job[:creation_time].to_s, "%s"),
200
+ :processing_time => job[:processing_time].nil? ? nil : DateTime.strptime(job[:processing_time].to_s, "%s"),
201
+ :dest => job[:dest].nil? ? nil : job[:dest].dup,
202
+ :format => job[:format].nil? ? nil : job[:format].dup,
203
+ :id => job[:id],
204
+ :priority => job[:priority],
205
+ :size => job[:size],
206
+ :title => job[:title].nil? ? nil : job[:title].dup,
207
+ :user => job[:user].nil? ? nil : job[:user].dup,
208
+ :state => job[:state].nil? ? nil : job[:state]
209
+ }
210
+ end
211
+
212
+ CupsFFI::cupsFreeJobs(job_count, pointer.get_pointer(0))
213
+ jobs
214
+ end
215
+
186
216
 
187
217
  private
188
218
  def validate_options(options)
@@ -1,3 +1,3 @@
1
1
  module Cupsffi
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cupsffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ehresman