cups 0.1.5 → 0.1.6

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.
Files changed (3) hide show
  1. data/ext/cups.c +5 -2
  2. data/test/cups_test.rb +11 -2
  3. metadata +4 -2
data/ext/cups.c CHANGED
@@ -109,20 +109,22 @@ static VALUE cups_print(VALUE self)
109
109
  {
110
110
  int job_id;
111
111
  VALUE file = rb_iv_get(self, "@filename");
112
+ VALUE rname = rb_iv_get(self, "@title");
112
113
  VALUE printer = rb_iv_get(self, "@printer");
113
114
  VALUE url_path = rb_iv_get(self, "@url_path");
114
115
 
115
116
  char *fname = RSTRING_PTR(file); // Filename
117
+ char *title = T_STRING == TYPE(rname) ? RSTRING_PTR(rname) : "rCups";
116
118
  char *target = RSTRING_PTR(printer); // Target printer string
117
119
  char *url = RSTRING_PTR(url_path); // Server URL address
118
120
  int port = 631; // Default CUPS port
119
-
121
+
120
122
  VALUE job_options = rb_iv_get(self, "@job_options");
121
123
 
122
124
  // Create an array of the keys from the job_options hash
123
125
  VALUE job_options_keys = rb_ary_new();
124
126
  rb_hash_foreach(job_options, cups_keys_i, job_options_keys);
125
-
127
+
126
128
  VALUE iter;
127
129
  int num_options = 0;
128
130
  cups_option_t *options = NULL;
@@ -520,6 +522,7 @@ void Init_cups() {
520
522
  rb_define_attr(printJobs, "url_path", 1, 0);
521
523
  rb_define_attr(printJobs, "job_id", 1, 0);
522
524
  rb_define_attr(printJobs, "job_options", 1, 0);
525
+ rb_define_attr(printJobs, "title", 1, 1);
523
526
 
524
527
  // Cups::PrintJob Methods
525
528
  rb_define_method(printJobs, "initialize", job_init, -1);
@@ -110,14 +110,23 @@ class CupsTest < Test::Unit::TestCase
110
110
  def test_dest_options_raises_exception_if_not_real
111
111
  assert_raise(RuntimeError, "The printer or destination doesn't exist!") { Cups.options_for("bollocks_printer") }
112
112
  end
113
-
113
+
114
114
  def test_job_failed_boolean
115
115
  pj = Cups::PrintJob.new(sample, @printer)
116
116
  pj.print
117
117
  pj.cancel
118
118
  assert !pj.failed?
119
119
  end
120
-
120
+
121
+ def test_job_title
122
+ pj = Cups::PrintJob.new(sample, @printer)
123
+ pj.title = 'a-test-job'
124
+ pj.print
125
+ job = Cups.all_jobs(@printer)[ pj.job_id ]
126
+ assert_equal 'a-test-job', job[:title]
127
+ pj.cancel
128
+ end
129
+
121
130
  def test_returns_failure_string_on_cancellation
122
131
  pj = Cups::PrintJob.new(blank_sample, @printer)
123
132
  pj.print
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
+ - Nathan Stitt
8
9
  - Tadej Murovec
9
10
  - Ivan Turkovic
10
11
  - Chris Mowforth
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2013-04-28 00:00:00.000000000 Z
15
+ date: 2013-06-27 00:00:00.000000000 Z
15
16
  dependencies: []
16
17
  description: ! ' Ruby CUPS provides a wrapper for the Common UNIX Printing System,
17
18
  allowing rubyists to perform basic tasks like printer discovery, job submission
@@ -19,6 +20,7 @@ description: ! ' Ruby CUPS provides a wrapper for the Common UNIX Printing Sy
19
20
 
20
21
  '
21
22
  email:
23
+ - nathan@stitt.org
22
24
  - tadej.murovec@gmail.com
23
25
  - me@ivanturkovic.com
24
26
  - chris@mowforth.com