ffi-cups 0.2.2 → 0.3.1

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: fce753f3f9c8d744368e9df26a335ffec7b1614fdc7fa40d550ef3e316438abe
4
- data.tar.gz: 4a602c610d3a515078fdfa6e7c0c1f2234a324db079b5e8450a1985ef19bf934
3
+ metadata.gz: af96b1939b903f31829bf99b8508ac0acf6c252198b517f1fb55ee0acb207011
4
+ data.tar.gz: 5147e3adc7509fc5ad8a688d19060b07d5e75d44d1e63b405393d20c06371f7b
5
5
  SHA512:
6
- metadata.gz: 6f0fcc75028fe6ba7e1b3a852cbf961ef639a586e61f6d77f59c81bcc874acadd74f50fc78482396cf5d01e95218ae331a5983833e121bafef876e152ede3e68
7
- data.tar.gz: 2c55185fe6e8a11461848a6136c456961eee8c9b40dadcd11e266844351c05de9e7cb1999083ecb2758227ce6df8a475bc28f56c818a80e534deab8d5d170824
6
+ metadata.gz: e3f44883fbd5dc010bedbaafd653783e082a169f930e63591b7348ef00c9df32879830466236f1602853e24c6d4d13e8e9f048c55666ffef403f6c5c9d76ffd7
7
+ data.tar.gz: 95b4367476047cf1c74a998dcdca8eddb838839b65740c7b0dd8c73d2b74f7f4b925b608228fa780d28d58feefbc0697328e1a3ae9e75457663a288cea906f96
data/Gemfile CHANGED
@@ -5,4 +5,3 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "rspec", "~> 3.0"
8
- gem 'byebug'
data/README.md CHANGED
@@ -35,8 +35,8 @@ printer.state_reasons
35
35
  # Print a file (PDF, JPG, etc) you can pass a hash of printing options if you
36
36
  # want to override the printer's default. See Cups::Constants for more options
37
37
  options = {
38
- Cups::CUPS_MEDIA => Cups::CUPS_MEDIA_A4,
39
- Cups::CUPS_ORIENTATION => Cups::CUPS_ORIENTATION_LANDSCAPE
38
+ Cups::MEDIA => Cups::MEDIA_A4,
39
+ Cups::ORIENTATION => Cups::ORIENTATION_LANDSCAPE
40
40
  }
41
41
 
42
42
  job = printer.print_file('/tmp/example.jpg', 'Title', options)
@@ -47,7 +47,7 @@ jobs = Cups::Job.get_jobs('Virtual_PDF_Printer')
47
47
  # [#<Cups::Job:0x0000563aa6359008 @id=1, @title="Test Print", @printer="Virtual_PDF_Printer", @format="text/plain", @state=:completed, @size=1, @completed_time=2021-04-08 07:06:23 -0500, @creation_time=2021-04-08 07:06:18 -0500, @processing_time=2021-04-08 07:06:18 -0500>, ...]
48
48
 
49
49
  # filtering job's query, see Constants file for more options
50
- jobs = Cups::Job.get_jobs('Virtual_PDF_Printer', Cups::CUPS_WHICHJOBS_ACTIVE)
50
+ jobs = Cups::Job.get_jobs('Virtual_PDF_Printer', Cups::WHICHJOBS_ACTIVE)
51
51
 
52
52
  # Query job with id and printer's name
53
53
  job = Cups::Job.get_job(10, 'Virtual_PDF_Printer')
@@ -75,7 +75,7 @@ Check out the documentation - [docs](https://www.rubydoc.info/gems/ffi-cups/0.2.
75
75
  ## License
76
76
  The MIT License
77
77
 
78
- Copyright (c) 2021 Hugo Marquez & Contributors
78
+ Copyright (c) 2022 Hugo Marquez & Contributors
79
79
 
80
80
  Permission is hereby granted, free of charge, to any person obtaining a copy
81
81
  of this software and associated documentation files (the "Software"), to deal
data/ffi-cups.gemspec CHANGED
@@ -23,4 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
 
25
25
  s.require_paths = ["lib"]
26
+
27
+ # development dependencies
28
+ s.add_development_dependency 'byebug', '~> 11.1.3'
26
29
  end
@@ -9,30 +9,30 @@ module Cups
9
9
  @port = port.nil? ? 631 : port
10
10
  end
11
11
 
12
- # Wrapper around {::FFI::Cups::Http#httpConnectEncrypt}
12
+ # Wrapper around {::Cups::Http#httpConnectEncrypt}
13
13
  # @deprecated Use {#httpConnect2} instead
14
14
  # @return [Pointer] a http pointer
15
15
  def httpConnectEncrypt
16
- http = FFI::Cups::Http.httpConnectEncrypt(hostname, port, FFI::Cups.cupsEncryption())
16
+ http = Cups::Http.httpConnectEncrypt(hostname, port, Cups.cupsEncryption())
17
17
  raise "Print server at #{hostname}:#{port} is not available" if http.null?
18
18
  return http
19
19
  end
20
20
  deprecate :httpConnectEncrypt, "This function is deprecated by CUPS, please use httpConnect2 instead", 2025, 12
21
21
 
22
- # Wrapper around {::FFI::Cups::Http#httpConnect2}
22
+ # Wrapper around {::Cups::Http#httpConnect2}
23
23
  # Creates a http connection to a print server
24
24
  # @return [Pointer] a http pointer
25
25
  def httpConnect2
26
- http = FFI::Cups::Http.httpConnect2(hostname, port, nil, 0, FFI::Cups.cupsEncryption(), 1, 30000, nil)
26
+ http = Cups::Http.httpConnect2(hostname, port, nil, 0, Cups.cupsEncryption(), 1, 30000, nil)
27
27
  raise "Print server at #{hostname}:#{port} is not available" if http.null?
28
28
  return http
29
29
  end
30
30
 
31
31
  # Closes the http connection and autoreleases the pointer
32
- # Wrapper around {::FFI::Cups::Http#httpClose}
32
+ # Wrapper around {::Cups::Http#httpClose}
33
33
  # @param http (Pointer)
34
34
  def self.close(http)
35
- FFI::Cups::Http.httpClose(http)
35
+ Cups::Http.httpClose(http)
36
36
  end
37
37
  end
38
38
  end
@@ -1,95 +1,95 @@
1
1
  module Cups
2
2
  # cups.h
3
- CUPS_FORMAT_JPEG = "image/jpeg"
4
- CUPS_FORMAT_PDF = "application/pdf"
5
- CUPS_FORMAT_TEXT = "text/plain"
6
- CUPS_JOBID_ALL = -1
7
- CUPS_WHICHJOBS_ALL = -1
8
- CUPS_WHICHJOBS_ACTIVE = 0
9
- CUPS_WHICHJOBS_COMPLETED = 1
10
- CUPS_HTTP_DEFAULT = nil
3
+ FORMAT_JPEG = "image/jpeg"
4
+ FORMAT_PDF = "application/pdf"
5
+ FORMAT_TEXT = "text/plain"
6
+ JOBID_ALL = -1
7
+ WHICHJOBS_ALL = -1
8
+ WHICHJOBS_ACTIVE = 0
9
+ WHICHJOBS_COMPLETED = 1
10
+ HTTP_DEFAULT = nil
11
11
 
12
12
  # Options and Values
13
- CUPS_COPIES = "copies"
14
- CUPS_COPIES_SUPPORTED = "copies-supported"
15
-
16
- CUPS_FINISHINGS = "CUPS_FINISHINGS"
17
- CUPS_FINISHINGS_SUPPORTED = "finishings-supported"
18
-
19
- CUPS_FINISHINGS_BIND = "7"
20
- CUPS_FINISHINGS_COVER = "6"
21
- CUPS_FINISHINGS_FOLD = "10"
22
- CUPS_FINISHINGS_NONE = "3"
23
- CUPS_FINISHINGS_PUNCH = "5"
24
- CUPS_FINISHINGS_STAPLE = "4"
25
- CUPS_FINISHINGS_TRIM = "11"
13
+ COPIES = "copies"
14
+ COPIES_SUPPORTED = "copies-supported"
26
15
 
27
- CUPS_MEDIA = "media"
28
- CUPS_MEDIA_READY = "media-ready"
29
- CUPS_MEDIA_SUPPORTED = "media-supported"
30
-
31
- CUPS_MEDIA_3X5 = "na_index-3x5_3x5in"
32
- CUPS_MEDIA_4X6 = "na_index-4x6_4x6in"
33
- CUPS_MEDIA_5X7 = "na_5x7_5x7in"
34
- CUPS_MEDIA_8X10 = "na_govt-letter_8x10in"
35
- CUPS_MEDIA_A3 = "iso_a3_297x420mm"
36
- CUPS_MEDIA_A4 = "iso_a4_210x297mm"
37
- CUPS_MEDIA_A5 = "iso_a5_148x210mm"
38
- CUPS_MEDIA_A6 = "iso_a6_105x148mm"
39
- CUPS_MEDIA_ENV10 = "na_number-10_4.125x9.5in"
40
- CUPS_MEDIA_ENVDL = "iso_dl_110x220mm"
41
- CUPS_MEDIA_LEGAL = "na_legal_8.5x14in"
42
- CUPS_MEDIA_LETTER = "na_letter_8.5x11in"
43
- CUPS_MEDIA_PHOTO_L = "oe_photo-l_3.5x5in"
44
- CUPS_MEDIA_SUPERBA3 = "na_super-b_13x19in"
45
- CUPS_MEDIA_TABLOID = "na_ledger_11x17in"
46
-
47
- CUPS_MEDIA_SOURCE = "media-source"
48
- CUPS_MEDIA_SOURCE_SUPPORTED = "media-source-supported"
49
-
50
- CUPS_MEDIA_SOURCE_AUTO = "auto"
51
- CUPS_MEDIA_SOURCE_MANUAL = "manual"
52
-
53
- CUPS_MEDIA_TYPE = "media-type"
54
- CUPS_MEDIA_TYPE_SUPPORTED = "media-type-supported"
55
-
56
- CUPS_MEDIA_TYPE_AUTO = "auto"
57
- CUPS_MEDIA_TYPE_ENVELOPE = "envelope"
58
- CUPS_MEDIA_TYPE_LABELS = "labels"
59
- CUPS_MEDIA_TYPE_LETTERHEAD = "stationery-letterhead"
60
- CUPS_MEDIA_TYPE_PHOTO = "photographic"
61
- CUPS_MEDIA_TYPE_PHOTO_GLOSSY = "photographic-glossy"
62
- CUPS_MEDIA_TYPE_PHOTO_MATTE = "photographic-matte"
63
- CUPS_MEDIA_TYPE_PLAIN = "stationery"
64
- CUPS_MEDIA_TYPE_TRANSPARENCY = "transparency"
65
-
66
- CUPS_NUMBER_UP = "number-up"
67
- CUPS_NUMBER_UP_SUPPORTED = "number-up-supported"
68
-
69
- CUPS_ORIENTATION = "orientation-requested"
70
- CUPS_ORIENTATION_SUPPORTED = "orientation-requested-supported"
71
-
72
- CUPS_ORIENTATION_PORTRAIT = "3"
73
- CUPS_ORIENTATION_LANDSCAPE = "4"
74
-
75
- CUPS_PRINT_COLOR_MODE = "print-color-mode"
76
- CUPS_PRINT_COLOR_MODE_SUPPORTED = "print-color-mode-supported"
77
-
78
- CUPS_PRINT_COLOR_MODE_AUTO = "auto"
79
- CUPS_PRINT_COLOR_MODE_MONOCHROME = "monochrome"
80
- CUPS_PRINT_COLOR_MODE_COLOR = "color"
81
-
82
- CUPS_PRINT_QUALITY = "print-quality"
83
- CUPS_PRINT_QUALITY_SUPPORTED = "print-quality-supported"
84
-
85
- CUPS_PRINT_QUALITY_DRAFT = "3"
86
- CUPS_PRINT_QUALITY_NORMAL = "4"
87
- CUPS_PRINT_QUALITY_HIGH = "5"
88
-
89
- CUPS_SIDES = "sides"
90
- CUPS_SIDES_SUPPORTED = "sides-supported"
91
-
92
- CUPS_SIDES_ONE_SIDED = "one-sided"
93
- CUPS_SIDES_TWO_SIDED_PORTRAIT = "two-sided-long-edge"
94
- CUPS_SIDES_TWO_SIDED_LANDSCAPE = "two-sided-short-edge"
16
+ FINISHINGS = "CUPS_FINISHINGS"
17
+ FINISHINGS_SUPPORTED = "finishings-supported"
18
+ FINISHINGS_BIND = "7"
19
+ FINISHINGS_COVER = "6"
20
+ FINISHINGS_FOLD = "10"
21
+ FINISHINGS_NONE = "3"
22
+ FINISHINGS_PUNCH = "5"
23
+ FINISHINGS_STAPLE = "4"
24
+ FINISHINGS_TRIM = "11"
25
+
26
+ # MEDIA
27
+ MEDIA = "media"
28
+ MEDIA_READY = "media-ready"
29
+ MEDIA_SUPPORTED = "media-supported"
30
+
31
+ MEDIA_3X5 = "na_index-3x5_3x5in"
32
+ MEDIA_4X6 = "na_index-4x6_4x6in"
33
+ MEDIA_5X7 = "na_5x7_5x7in"
34
+ MEDIA_8X10 = "na_govt-letter_8x10in"
35
+ MEDIA_A3 = "iso_a3_297x420mm"
36
+ MEDIA_A4 = "iso_a4_210x297mm"
37
+ MEDIA_A5 = "iso_a5_148x210mm"
38
+ MEDIA_A6 = "iso_a6_105x148mm"
39
+ MEDIA_ENV10 = "na_number-10_4.125x9.5in"
40
+ MEDIA_ENVDL = "iso_dl_110x220mm"
41
+ MEDIA_LEGAL = "na_legal_8.5x14in"
42
+ MEDIA_LETTER = "na_letter_8.5x11in"
43
+ MEDIA_PHOTO_L = "oe_photo-l_3.5x5in"
44
+ MEDIA_SUPERBA3 = "na_super-b_13x19in"
45
+ MEDIA_TABLOID = "na_ledger_11x17in"
46
+
47
+ MEDIA_SOURCE = "media-source"
48
+ MEDIA_SOURCE_SUPPORTED = "media-source-supported"
49
+
50
+ MEDIA_SOURCE_AUTO = "auto"
51
+ MEDIA_SOURCE_MANUAL = "manual"
52
+
53
+ MEDIA_TYPE = "media-type"
54
+ MEDIA_TYPE_SUPPORTED = "media-type-supported"
55
+
56
+ MEDIA_TYPE_AUTO = "auto"
57
+ MEDIA_TYPE_ENVELOPE = "envelope"
58
+ MEDIA_TYPE_LABELS = "labels"
59
+ MEDIA_TYPE_LETTERHEAD = "stationery-letterhead"
60
+ MEDIA_TYPE_PHOTO = "photographic"
61
+ MEDIA_TYPE_PHOTO_GLOSSY = "photographic-glossy"
62
+ MEDIA_TYPE_PHOTO_MATTE = "photographic-matte"
63
+ MEDIA_TYPE_PLAIN = "stationery"
64
+ MEDIA_TYPE_TRANSPARENCY = "transparency"
65
+
66
+ NUMBER_UP = "number-up"
67
+ NUMBER_UP_SUPPORTED = "number-up-supported"
68
+
69
+ ORIENTATION = "orientation-requested"
70
+ ORIENTATION_SUPPORTED = "orientation-requested-supported"
71
+
72
+ ORIENTATION_PORTRAIT = "3"
73
+ ORIENTATION_LANDSCAPE = "4"
74
+
75
+ PRINT_COLOR_MODE = "print-color-mode"
76
+ PRINT_COLOR_MODE_SUPPORTED = "print-color-mode-supported"
77
+
78
+ PRINT_COLOR_MODE_AUTO = "auto"
79
+ PRINT_COLOR_MODE_MONOCHROME = "monochrome"
80
+ PRINT_COLOR_MODE_COLOR = "color"
81
+
82
+ PRINT_QUALITY = "print-quality"
83
+ PRINT_QUALITY_SUPPORTED = "print-quality-supported"
84
+
85
+ PRINT_QUALITY_DRAFT = "3"
86
+ PRINT_QUALITY_NORMAL = "4"
87
+ PRINT_QUALITY_HIGH = "5"
88
+
89
+ SIDES = "sides"
90
+ SIDES_SUPPORTED = "sides-supported"
91
+
92
+ SIDES_ONE_SIDED = "one-sided"
93
+ SIDES_TWO_SIDED_PORTRAIT = "two-sided-long-edge"
94
+ SIDES_TWO_SIDED_LANDSCAPE = "two-sided-short-edge"
95
95
  end
@@ -1,8 +1,8 @@
1
- module FFI::Cups
1
+ module Cups
2
2
  module Array
3
3
  extend FFI::Library
4
4
 
5
- ffi_lib('cups')
5
+ ffi_lib(Cups.libcups)
6
6
 
7
7
  # @overload cupsArrayFirst(pointer)
8
8
  # @param pointer [Pointer] to _cups_array_s struct
@@ -2,11 +2,11 @@
2
2
  # {https://www.cups.org/doc/cupspm.html Programming Manual}
3
3
  # {https://github.com/apple/cups/blob/master/cups/cups.h cups.h source}
4
4
 
5
- module FFI::Cups
5
+ module Cups
6
6
  extend FFI::Library
7
-
8
- ffi_lib('cups')
9
7
 
8
+ ffi_lib(Cups.libcups)
9
+
10
10
  # Get the current encryption settings.
11
11
  # @return [Integer] encryption settings
12
12
  # {https://www.cups.org/doc/cupspm.html#cupsEncryption}
@@ -1,8 +1,8 @@
1
- module FFI::Cups
1
+ module Cups
2
2
  module Http
3
3
  extend FFI::Library
4
-
5
- ffi_lib('cups')
4
+
5
+ ffi_lib(Cups.libcups)
6
6
 
7
7
  # @overload httpConnectEncrypt(string, int, int)
8
8
  # @param hostname [String]
@@ -30,7 +30,7 @@ module FFI::Cups
30
30
  # @param port [Integer]
31
31
  # @param addrlist [Pointer] can be NULL
32
32
  # @param family [Integer] (AF_UNSPEC=0)
33
- # @param encryption_settings [Integer] from FFI::Cups.cupsEncryption()
33
+ # @param encryption_settings [Integer] from Cups.cupsEncryption()
34
34
  # @param blocking [Integer]
35
35
  # @param msec [Integer] use 5000 or less
36
36
  # @param cancel[Pointer] integer pointer, can be NULL
data/lib/ffi-cups/job.rb CHANGED
@@ -22,8 +22,8 @@ module Cups
22
22
  # @param connection [Cups::Connection]
23
23
  def cancel(purge=0, connection=nil)
24
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
25
+ r = Cups.cupsCancelJob2(connection, @printer, @id, purge)
26
+ raise Cups.cupsLastErrorString() if r == 0
27
27
  return r
28
28
  end
29
29
 
@@ -64,7 +64,7 @@ module Cups
64
64
  end
65
65
 
66
66
  private
67
- # Wrapper {::FFI::Cups#cupsGetJobs2}
67
+ # Wrapper {::Cups#cupsGetJobs2}
68
68
  # @param pointer [Pointer] pointer to the jobs
69
69
  # @param name [String] name of the destination or NULL
70
70
  # @param filter [Integer] see Constants for more filters
@@ -72,7 +72,7 @@ module Cups
72
72
  # @return [Array] array of job structs
73
73
  def self.cupsGetJobs2(pointer, name=nil, filter=-1, connection=nil)
74
74
  http = connection.nil? ? nil : connection.httpConnect2
75
- num_jobs = FFI::Cups.cupsGetJobs2(http, pointer, name, 0, filter)
75
+ num_jobs = Cups.cupsGetJobs2(http, pointer, name, 0, filter)
76
76
  size = Cups::Struct::Job.size
77
77
  jobs = []
78
78
 
@@ -33,10 +33,10 @@ module Cups
33
33
  http = @connection.nil? ? nil : @connection.httpConnect2
34
34
  # Get all destinations with cupsGetDests2
35
35
  dests = FFI::MemoryPointer.new :pointer
36
- num_dests = FFI::Cups.cupsGetDests2(http, dests)
36
+ num_dests = Cups.cupsGetDests2(http, dests)
37
37
 
38
38
  # Get the destination from name with cupsGetDest
39
- p_dest = FFI::Cups.cupsGetDest(@name, nil, num_dests, dests.get_pointer(0))
39
+ p_dest = Cups.cupsGetDest(@name, nil, num_dests, dests.get_pointer(0))
40
40
  dest = Cups::Struct::Destination.new(p_dest)
41
41
  raise "Destination with name: #{@name} not found!" if dest.null?
42
42
 
@@ -48,12 +48,12 @@ module Cups
48
48
  unless self.class.cupsCheckDestSupported(p_dest, k, v, http)
49
49
  raise "Option:#{k} #{v if v} not supported for printer: #{@name}"
50
50
  end
51
- num_options = FFI::Cups.cupsAddOption(k, v, num_options, p_options)
51
+ num_options = Cups.cupsAddOption(k, v, num_options, p_options)
52
52
  end
53
53
  p_options = p_options.get_pointer(0)
54
54
  end
55
55
 
56
- job_id = FFI::Cups.cupsPrintFile2(http, @name, filename, title, num_options, p_options)
56
+ job_id = Cups.cupsPrintFile2(http, @name, filename, title, num_options, p_options)
57
57
 
58
58
  if job_id.zero?
59
59
  last_error = Cups.cupsLastErrorString()
@@ -91,10 +91,10 @@ module Cups
91
91
  http = connection.nil? ? nil : connection.httpConnect2
92
92
  # Get all destinations with cupsGetDests2
93
93
  dests = FFI::MemoryPointer.new :pointer
94
- num_dests = FFI::Cups.cupsGetDests2(http, dests)
94
+ num_dests = Cups.cupsGetDests2(http, dests)
95
95
 
96
96
  # Get the destination from name with cupsGetDest
97
- p_dest = FFI::Cups.cupsGetDest(name, nil, num_dests, dests.get_pointer(0))
97
+ p_dest = Cups.cupsGetDest(name, nil, num_dests, dests.get_pointer(0))
98
98
  dest = Cups::Struct::Destination.new(p_dest)
99
99
  raise "Destination with name: #{name} not found!" if dest.null?
100
100
 
@@ -105,13 +105,13 @@ module Cups
105
105
  end
106
106
 
107
107
  private
108
- # Wrapper around {::FFI::Cups#cupsGetDests2}
108
+ # Wrapper around {::Cups#cupsGetDests2}
109
109
  # @param connection [Pointer] http pointer from {Cups::Connection#httpConnect2}
110
110
  # @param pointer [Pointer] pointer to the destinations
111
111
  # @return [Hash] hashmap of destination structs
112
112
  def self.cupsGetDests2(pointer, connection=nil)
113
113
  http = connection.nil? ? nil : connection.httpConnect2
114
- num_dests = FFI::Cups.cupsGetDests2(http, pointer)
114
+ num_dests = Cups.cupsGetDests2(http, pointer)
115
115
  size = Cups::Struct::Destination.size
116
116
  destinations = []
117
117
  num_dests.times do |i|
@@ -122,15 +122,15 @@ module Cups
122
122
  return destinations
123
123
  end
124
124
 
125
- # Wrapper around {::FFI::Cups#cupsCheckDestSupported}
125
+ # Wrapper around {::Cups#cupsCheckDestSupported}
126
126
  # @param dest [Pointer] pointer to the destination
127
127
  # @param option [String]
128
128
  # @param value [String]
129
129
  # @param connection [Pointer] http pointer from {Cups::Connection#httpConnect2}
130
130
  # @return [Boolean] true if supported, false otherwise
131
131
  def self.cupsCheckDestSupported(dest, option, value, connection=nil)
132
- info = FFI::Cups.cupsCopyDestInfo(connection, dest)
133
- i = FFI::Cups.cupsCheckDestSupported(connection, dest, info, option, value)
132
+ info = Cups.cupsCopyDestInfo(connection, dest)
133
+ i = Cups.cupsCheckDestSupported(connection, dest, info, option, value)
134
134
  return !i.zero?
135
135
  end
136
136
 
@@ -160,18 +160,18 @@ module Cups
160
160
  return options
161
161
  end
162
162
 
163
- # Wrapper around {::FFI::Cups#cupsFreeDests}
163
+ # Wrapper around {::Cups#cupsFreeDests}
164
164
  # @param num_dests [Integer]
165
165
  # @param pointer [Pointer] pointer to the destinations
166
166
  def self.cupsFreeDests(num_dests, pointer)
167
- FFI::Cups.cupsFreeDests(num_dests, pointer.get_pointer(0))
167
+ Cups.cupsFreeDests(num_dests, pointer.get_pointer(0))
168
168
  end
169
169
 
170
- # Wrapper around {::FFI::Cups#cupsFreeOptions}
170
+ # Wrapper around {::Cups#cupsFreeOptions}
171
171
  # @param num_opts [Integer]
172
172
  # @param pointer [Pointer] pointer to the options
173
173
  def self.cupsFreeOptions(num_opts, pointer)
174
- FFI::Cups.cupsFreeOptions(num_opts, pointer)
174
+ Cups.cupsFreeOptions(num_opts, pointer)
175
175
  end
176
176
  end
177
177
  end
@@ -1,3 +1,3 @@
1
1
  module Cups
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/ffi-cups.rb CHANGED
@@ -1,18 +1,16 @@
1
1
  require 'ffi'
2
- require 'byebug'
3
2
 
4
3
  module Cups
5
- extend FFI::Library
6
4
 
7
- begin
5
+ # Custom or default path for libcups.so
6
+ def self.libcups
8
7
  if ENV['CUPS_LIB']
9
- ffi_lib(ENV['CUPS_LIB'])
8
+ ENV['CUPS_LIB']
10
9
  else
11
- ffi_lib('cups')
10
+ 'cups'
12
11
  end
13
- rescue LoadError => e
14
- raise LoadError, "Didn't find libcups on your system."
15
12
  end
13
+
16
14
  end
17
15
 
18
16
  # Constants
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.2
4
+ version: 0.3.1
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-27 00:00:00.000000000 Z
12
+ date: 2023-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 1.15.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: byebug
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 11.1.3
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 11.1.3
28
42
  description: Simple wrapper around libcups to give CUPS printing capabilities to Ruby
29
43
  apps.
30
44
  email:
@@ -75,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
89
  - !ruby/object:Gem::Version
76
90
  version: '0'
77
91
  requirements: []
78
- rubygems_version: 3.1.2
92
+ rubygems_version: 3.1.6
79
93
  signing_key:
80
94
  specification_version: 4
81
95
  summary: FFI wrapper around libcups