cloudprint 0.2.1 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDE5OGMzZjBmZGJlNTg1MWU2Mjg0NjI0YWE5MjdlNmYxY2E2ZTQ3MA==
5
- data.tar.gz: !binary |-
6
- MzMwNTlkZDBiMTAwMGE5MTUzNTE2MzI1ZTUwYjFiN2UxNWVkMjE1Ng==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- OWQxZDI3YjZjNGU2NGU0NWQyNmQwZTIxZTZjYWNlZmZlZmM2MzY3Y2JmMTFk
10
- YmJjODZhMzY4ODMzYjE5NWYwNzI1NWFhZDY3MGRkMjRiZmNmOGUyYmJjZjQ0
11
- Nzc2YTQyNjZlZjVmODBkYThiMjA2MjRlMDViY2Q5NDRkZGIwYjE=
12
- data.tar.gz: !binary |-
13
- NTA0NjI3ZDZhNDM0OWMyNWRlNDU0MDM1MTZhM2I1ZTE4ZjVkZTBjYjkyY2Fj
14
- NWU0YzU4MDMxMDViMDk2M2E5ZjI0NmQ5ZGViYjgzNDc1ZTNkMWI4NTliNjlm
15
- MDM5NGYwY2ZiNzFlYTdjNmVmNDA2ZjkxOTQ3Y2Y1MDZlOWJjNTM=
2
+ SHA1:
3
+ metadata.gz: 5ba8810b498a449d87aac8faca6b8be162823469
4
+ data.tar.gz: 0392e67e8c64ebcfb6914cdc46a73d357f160ce2
5
+ SHA512:
6
+ metadata.gz: a0cfd77c155223d8903109f1bec4dc564f2160c52991a7408b956e7392b70b73b5ad1b78d388aaef31bc9b252725957f717bb3cfc288a4a14a9a47fe5da4138a
7
+ data.tar.gz: ca5036663d42da407548dbd9bfc107ab22b17936b4b70bd972c3a9fe72ec195145b9efcd9751702dedae9fb9058d732d6e7a116482a97faa7f47f19d05a2e0db
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - 2.1.0
3
- - 2.0.0
4
- - 1.9.3
5
- - jruby-19mode
2
+ - 2.1.8
3
+ - 2.2.4
4
+ - 2.3.0
data/ChangeLog.md ADDED
@@ -0,0 +1,8 @@
1
+ # Cloudprint Change Log
2
+
3
+ ## [0.3.0] - 2016-03-09
4
+ ### Dependencies
5
+ - Update oauth gem requirement since a lot of people were having issues with that.
6
+ - Change test_unit to minitest due to my own issues with the build and test_unit being really old.
7
+ ### Fixes
8
+ - Removed a few warnings that were raised during the build.
data/cloudprint.gemspec CHANGED
@@ -9,19 +9,19 @@ Gem::Specification.new do |s|
9
9
  s.email = ["eugen@lesseverything.com"]
10
10
  s.homepage = "http://github.com/minciue/cloudprint"
11
11
  s.licenses = ["MIT"]
12
- s.summary = "This library provides a ruby-esque interface to Google Cloud Print."
12
+ s.summary = "This library provides a Ruby interface to Google Cloud Print."
13
13
  s.description = <<-DESC
14
- This library provides a ruby-esque interface to Google Cloud Print.
14
+ This library provides a Ruby interface to Google Cloud Print.
15
15
  cloudprint is a work in progress. I'll be adding documentation once all the basic GCP functionality is supported."
16
16
  DESC
17
17
 
18
- s.add_dependency 'oauth2', '~> 0.8.0'
18
+ s.add_dependency 'oauth2', '>= 1.0.0'
19
19
  s.add_dependency 'json'
20
20
 
21
21
  s.add_development_dependency 'mocha'
22
22
  s.add_development_dependency 'rake'
23
23
  s.add_development_dependency 'shoulda-context'
24
- s.add_development_dependency 'test-unit'
24
+ s.add_development_dependency 'minitest'
25
25
 
26
26
  s.rubyforge_project = "cloudprint"
27
27
 
@@ -7,8 +7,9 @@ module CloudPrint
7
7
  attr_reader :connection
8
8
  attr_reader :printers
9
9
  attr_reader :print_jobs
10
-
10
+
11
11
  def initialize(options = {})
12
+ @access_token = nil
12
13
  @refresh_token = options[:refresh_token]
13
14
  @client_id = options[:client_id]
14
15
  @client_secret = options[:client_secret]
@@ -17,7 +18,7 @@ module CloudPrint
17
18
  @printers = PrinterCollection.new(self)
18
19
  @print_jobs = PrintJobCollection.new(self)
19
20
  end
20
-
21
+
21
22
  def access_token
22
23
  (access_token_valid? && @access_token || renew_access_token!).token
23
24
  end
@@ -8,7 +8,7 @@ module CloudPrint
8
8
  def initialize client
9
9
  @client = client
10
10
  end
11
-
11
+
12
12
  def get(path, params = {})
13
13
  response = request(:get, path, params)
14
14
  parse_response(response)
@@ -37,7 +37,7 @@ module CloudPrint
37
37
 
38
38
  def request(method, path, params)
39
39
  url = full_url_for(path)
40
- response = make_http_request(:method => method, :url => url, :params => params)
40
+ make_http_request(:method => method, :url => url, :params => params)
41
41
  end
42
42
 
43
43
  def make_http_request(options = {})
@@ -49,7 +49,8 @@ module CloudPrint
49
49
  :create_time => Time.at(response_hash['createTime'].to_f / 1000),
50
50
  :update_time => Time.at(response_hash['updateTime'].to_f / 1000),
51
51
  :message => response_hash['message'],
52
- :tags => response_hash['tags']
52
+ :tags => response_hash['tags'],
53
+ :ticket => response_hash['ticket']
53
54
  }
54
55
  end
55
56
  end
@@ -1,10 +1,10 @@
1
1
  module CloudPrint
2
2
  class Printer
3
3
  CONNECTION_STATUSES = %w{ONLINE UNKNOWN OFFLINE DORMANT}
4
- CONFIG_OPTS = [:id, :status, :name, :tags, :display_name, :client, :connection_status, :description]
5
-
6
- attr_reader *CONFIG_OPTS
7
-
4
+ CONFIG_OPTS = [:id, :status, :name, :tags, :display_name, :client, :connection_status, :description, :capabilities]
5
+
6
+ CONFIG_OPTS.each { |opt| attr_reader(opt) }
7
+
8
8
  def initialize(options = {})
9
9
  @client = options[:client]
10
10
  @id = options[:id]
@@ -14,11 +14,12 @@ module CloudPrint
14
14
  @tags = options[:tags] || {}
15
15
  @connection_status = options[:connection_status] || 'UNKNOWN'
16
16
  @description = options[:description]
17
+ @capabilities = options[:capabilities]
17
18
  end
18
19
 
19
20
  def print(options)
20
21
  method = options[:content].is_a?(IO) ? :multipart_post : :post
21
- response = client.connection.send(method, '/submit', :printerid => self.id, :title => options[:title], :content => options[:content], :contentType => options[:content_type]) || {}
22
+ response = client.connection.send(method, '/submit', :printerid => self.id, :title => options[:title], :content => options[:content], :ticket => options[:ticket].to_json, :contentType => options[:content_type]) || {}
22
23
  return nil if response.nil? || response["job"].nil?
23
24
  client.print_jobs.new_from_response response["job"]
24
25
  end
@@ -45,7 +45,8 @@ module CloudPrint
45
45
  display_name: hash['displayName'],
46
46
  tags: hash['tags'],
47
47
  connection_status: hash['connectionStatus'],
48
- description: hash['description']
48
+ description: hash['description'],
49
+ capabilities: hash['capabilities']
49
50
  )
50
51
  end
51
52
  end
@@ -1,3 +1,3 @@
1
1
  module Cloudprint
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class CloudPrintTest < Test::Unit::TestCase
3
+ class CloudPrintTest < Minitest::Test
4
4
  def setup
5
5
  stub_access_token
6
6
  @client = new_client
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class ConnectionTest < Test::Unit::TestCase
3
+ class ConnectionTest < Minitest::Test
4
4
  def setup
5
5
  stub_access_token
6
6
  @connection = new_client.connection
data/test/helper.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  require 'cloudprint'
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
  require 'shoulda/context'
4
- require 'mocha/test_unit'
4
+ require 'mocha/mini_test'
5
5
 
6
- class Test::Unit::TestCase
6
+ class Minitest::Test
7
7
 
8
8
  def new_client
9
9
  CloudPrint::Client.new(refresh_token: "refresh_token")
10
10
  end
11
-
11
+
12
12
  def any_connection
13
13
  CloudPrint::Connection.any_instance
14
14
  end
@@ -64,4 +64,21 @@ class Test::Unit::TestCase
64
64
  def fixture_file(filename)
65
65
  File.join(File.dirname(__FILE__), 'fixtures', filename)
66
66
  end
67
+
68
+ # Adapted from minitest's assert_raises
69
+ def assert_nothing_raised(msg = nil)
70
+ begin
71
+ yield
72
+ pass # count assertion
73
+ rescue Minitest::Skip, Minitest::Assertion
74
+ # don't count assertion
75
+ raise
76
+ rescue SignalException, SystemExit
77
+ raise
78
+ rescue Exception => e
79
+ flunk proc {
80
+ exception_details(e, "#{e} exception not expected")
81
+ }
82
+ end
83
+ end
67
84
  end
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class PrintJobTest < Test::Unit::TestCase
3
+ class PrintJobTest < Minitest::Test
4
4
  def setup
5
5
  # TODO: Is it necessary to pass a fake token to #setup?
6
6
  @client = new_client
@@ -125,7 +125,7 @@ class PrintJobTest < Test::Unit::TestCase
125
125
  should "raise a RequestError on failure" do
126
126
  fake_connection.stubs(:get).with('/deletejob', { :jobid => 'job_id' }).returns({ 'success' => false, 'message' => 'This is an error', 'errorCode' => '123' })
127
127
 
128
- assert_raise(CloudPrint::RequestError, 'This is an error') do
128
+ assert_raises(CloudPrint::RequestError, 'This is an error') do
129
129
  @client.print_jobs.new(:id => 'job_id').delete!
130
130
  end
131
131
  end
data/test/printer_test.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "helper"
2
- class PrinterTest < Test::Unit::TestCase
2
+
3
+ class PrinterTest < Minitest::Test
3
4
  def setup
4
5
  @client = new_client
5
6
  end
@@ -180,11 +181,11 @@ class PrinterTest < Test::Unit::TestCase
180
181
  end
181
182
 
182
183
  def print_params
183
- { :title => "Hello World", :content => "<h1>ohai!</h1>", :content_type => "text/html" }
184
+ { :title => "Hello World", :content => "<h1>ohai!</h1>", :content_type => "text/html", :ticket => ticket_hash }
184
185
  end
185
186
 
186
187
  def connection_print_params
187
- { :printerid => 'printer', :title => "Hello World", :content => "<h1>ohai!</h1>", :contentType => "text/html" }
188
+ { :printerid => 'printer', :title => "Hello World", :content => "<h1>ohai!</h1>", :contentType => "text/html", :ticket => ticket_hash.to_json }
188
189
  end
189
190
 
190
191
  def print_file
@@ -193,11 +194,11 @@ class PrinterTest < Test::Unit::TestCase
193
194
  end
194
195
 
195
196
  def print_file_params
196
- { :title => "Ruby!", :content => ruby_png_fixture, :content_type => "image/png" }
197
+ { :title => "Ruby!", :content => ruby_png_fixture, :content_type => "image/png", :ticket => ticket_hash }
197
198
  end
198
199
 
199
200
  def connection_print_file_params
200
- { :printerid => 'printer', :title => "Ruby!", :content => ruby_png_fixture, :contentType => "image/png" }
201
+ { :printerid => 'printer', :title => "Ruby!", :content => ruby_png_fixture, :contentType => "image/png", :ticket => ticket_hash.to_json }
201
202
  end
202
203
 
203
204
  def one_printer_hash
@@ -211,6 +212,20 @@ class PrinterTest < Test::Unit::TestCase
211
212
  ]}
212
213
  end
213
214
 
215
+ def ticket_hash
216
+ { 'version' => '1.0',
217
+ 'print' => {
218
+ 'vendor_ticket_item' => [
219
+ {'id' => 'PageRegion', 'value' => "Letter"},
220
+ {'id' => 'BRMediaType', 'value' => 'Plain'},
221
+ {'id' => 'InputSlot', 'value' => 'Tray1'}
222
+ ],
223
+ 'page_orientation' => {'type' => 2},
224
+ 'fit_to_page' => {'type' => 3}
225
+ }
226
+ }
227
+ end
228
+
214
229
  def ruby_png_fixture
215
230
  @ruby_png_fixture ||= File.open(fixture_file('ruby.png'))
216
231
  end
metadata CHANGED
@@ -1,114 +1,112 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudprint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Minciu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-15 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.0
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.0
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mocha
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: shoulda-context
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: test-unit
84
+ name: minitest
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: ! 'This library provides a ruby-esque interface to Google Cloud Print.
98
-
99
- cloudprint is a work in progress. I''ll be adding documentation once all the basic
100
- GCP functionality is supported."
101
-
102
- '
97
+ description: |
98
+ This library provides a Ruby interface to Google Cloud Print.
99
+ cloudprint is a work in progress. I'll be adding documentation once all the basic GCP functionality is supported."
103
100
  email:
104
101
  - eugen@lesseverything.com
105
102
  executables: []
106
103
  extensions: []
107
104
  extra_rdoc_files: []
108
105
  files:
109
- - .document
110
- - .gitignore
111
- - .travis.yml
106
+ - ".document"
107
+ - ".gitignore"
108
+ - ".travis.yml"
109
+ - ChangeLog.md
112
110
  - Gemfile
113
111
  - LICENSE.txt
114
112
  - README.md
@@ -139,20 +137,20 @@ require_paths:
139
137
  - lib
140
138
  required_ruby_version: !ruby/object:Gem::Requirement
141
139
  requirements:
142
- - - ! '>='
140
+ - - ">="
143
141
  - !ruby/object:Gem::Version
144
142
  version: '0'
145
143
  required_rubygems_version: !ruby/object:Gem::Requirement
146
144
  requirements:
147
- - - ! '>='
145
+ - - ">="
148
146
  - !ruby/object:Gem::Version
149
147
  version: '0'
150
148
  requirements: []
151
149
  rubyforge_project: cloudprint
152
- rubygems_version: 2.0.6
150
+ rubygems_version: 2.2.2
153
151
  signing_key:
154
152
  specification_version: 4
155
- summary: This library provides a ruby-esque interface to Google Cloud Print.
153
+ summary: This library provides a Ruby interface to Google Cloud Print.
156
154
  test_files:
157
155
  - test/cloudprint_test.rb
158
156
  - test/connection_test.rb
@@ -160,3 +158,4 @@ test_files:
160
158
  - test/helper.rb
161
159
  - test/print_job_test.rb
162
160
  - test/printer_test.rb
161
+ has_rdoc: