cloudprint 0.1.3 → 0.2.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 +15 -0
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/README.md +121 -0
- data/Rakefile +3 -1
- data/cloudprint.gemspec +2 -2
- data/lib/cloudprint.rb +4 -71
- data/lib/cloudprint/client.rb +48 -0
- data/lib/cloudprint/connection.rb +7 -3
- data/lib/cloudprint/exceptions.rb +6 -0
- data/lib/cloudprint/print_job.rb +44 -38
- data/lib/cloudprint/print_job_collection.rb +39 -0
- data/lib/cloudprint/printer.rb +15 -19
- data/lib/cloudprint/printer_collection.rb +52 -0
- data/lib/cloudprint/version.rb +1 -1
- data/test/cloudprint_test.rb +47 -51
- data/test/connection_test.rb +2 -2
- data/test/helper.rb +7 -3
- data/test/print_job_test.rb +65 -13
- data/test/printer_test.rb +82 -17
- metadata +17 -33
- data/Gemfile.lock +0 -38
- data/README.rdoc +0 -19
data/test/printer_test.rb
CHANGED
@@ -1,48 +1,47 @@
|
|
1
1
|
require "helper"
|
2
2
|
class PrinterTest < Test::Unit::TestCase
|
3
3
|
def setup
|
4
|
-
|
5
|
-
CloudPrint.setup(:refresh_token => 'refresh_token')
|
4
|
+
@client = new_client
|
6
5
|
end
|
7
6
|
|
8
7
|
should "initialize a printer" do
|
9
|
-
printer =
|
8
|
+
printer = @client.printers.new(:id => 'printer_id', :status => 'online', :name => "My Printer")
|
10
9
|
assert_equal 'printer_id', printer.id
|
11
10
|
assert_equal 'online', printer.status
|
12
11
|
assert_equal 'My Printer', printer.name
|
13
12
|
end
|
14
13
|
|
15
14
|
should "have tags" do
|
16
|
-
printer =
|
15
|
+
printer = @client.printers.new(:id => 'printer_id', :status => 'online', :name => "My Printer")
|
17
16
|
assert_equal printer.tags, {}
|
18
17
|
|
19
|
-
printer =
|
18
|
+
printer = @client.printers.new(:id => 'printer_id', :status => 'online', :name => "My Printer", :tags => {"email" => 'a@b.com'})
|
20
19
|
assert_equal printer.tags, {"email" => "a@b.com"}
|
21
20
|
end
|
22
21
|
|
23
22
|
should "get a connection when finding a printer by its id" do
|
24
23
|
fake_connection.stubs(:get).returns(one_printer_hash)
|
25
24
|
|
26
|
-
|
27
|
-
|
25
|
+
@client.expects(:connection).returns(fake_connection)
|
26
|
+
@client.printers.find('printer')
|
28
27
|
end
|
29
28
|
|
30
29
|
should "call a remote request when finding a printer by its id" do
|
31
30
|
fake_connection.expects(:get).returns(one_printer_hash)
|
32
31
|
stub_connection
|
33
|
-
|
32
|
+
@client.printers.find('printer')
|
34
33
|
end
|
35
34
|
|
36
35
|
should "call a remote request with the proper params when finding a printer" do
|
37
|
-
fake_connection.expects(:get).with('/printer', :printerid => 'printer').returns(one_printer_hash)
|
36
|
+
fake_connection.expects(:get).with('/printer', :printerid => 'printer', :printer_connection_status => true).returns(one_printer_hash)
|
38
37
|
stub_connection
|
39
|
-
|
38
|
+
@client.printers.find('printer')
|
40
39
|
end
|
41
40
|
|
42
41
|
should "initialize a new object when finding a printer" do
|
43
42
|
fake_connection.stubs(:get).returns(one_printer_hash)
|
44
43
|
stub_connection
|
45
|
-
printer =
|
44
|
+
printer = @client.printers.find('my_printer')
|
46
45
|
assert_equal 'my_printer', printer.id
|
47
46
|
assert_equal 'online', printer.status
|
48
47
|
assert_equal 'My Printer', printer.name
|
@@ -52,7 +51,7 @@ class PrinterTest < Test::Unit::TestCase
|
|
52
51
|
should "initialize an array of printers when finding all printers" do
|
53
52
|
fake_connection.stubs(:get).returns(multiple_printer_hash)
|
54
53
|
stub_connection
|
55
|
-
printers =
|
54
|
+
printers = @client.printers.all
|
56
55
|
first_printer = printers[0]
|
57
56
|
second_printer = printers[1]
|
58
57
|
assert_equal 'first_printer', first_printer.id
|
@@ -61,7 +60,8 @@ class PrinterTest < Test::Unit::TestCase
|
|
61
60
|
assert_equal 'Second Printer', second_printer.name
|
62
61
|
assert_equal 'First Printer (display name)', first_printer.display_name
|
63
62
|
assert_equal 'Second Printer (display name)', second_printer.display_name
|
64
|
-
|
63
|
+
assert_equal 'First printer description', first_printer.description
|
64
|
+
assert_equal 'Second printer description', second_printer.description
|
65
65
|
end
|
66
66
|
|
67
67
|
should "print stuff" do
|
@@ -103,6 +103,71 @@ class PrinterTest < Test::Unit::TestCase
|
|
103
103
|
assert_equal 'status', job.status
|
104
104
|
end
|
105
105
|
|
106
|
+
%w{ONLINE UNKNOWN OFFLINE DORMANT}.each do |status|
|
107
|
+
should "recognize a printer as #{status.downcase}" do
|
108
|
+
printer = @client.printers.new(:connection_status => status)
|
109
|
+
|
110
|
+
assert printer.send(status.downcase + '?')
|
111
|
+
|
112
|
+
%w{ONLINE UNKNOWN OFFLINE DORMANT}.reject{ |s| s == status}.each do |other_statuses|
|
113
|
+
assert !printer.send(other_statuses.downcase + '?')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context ".search_#{status.downcase}" do
|
118
|
+
should "scope search by connection status '#{status}'" do
|
119
|
+
stub_connection
|
120
|
+
fake_connection.expects(:get).with('/search', { :q => 'query', :connection_status => status.upcase }).returns(one_printer_hash)
|
121
|
+
@client.printers.send("search_#{status.downcase}", 'query')
|
122
|
+
end
|
123
|
+
|
124
|
+
should "return array of Printers" do
|
125
|
+
stub_connection
|
126
|
+
fake_connection.stubs(:get).with('/search', { :connection_status => status }).returns(one_printer_hash)
|
127
|
+
printers = @client.printers.send("search_#{status.downcase}")
|
128
|
+
assert_equal 'my_printer', printers[0].id
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context '.search_all' do
|
134
|
+
setup { stub_connection }
|
135
|
+
|
136
|
+
should "scope search by printers with any connection status" do
|
137
|
+
fake_connection.expects(:get).with('/search', { :q => 'query', :connection_status => 'ALL' }).returns(one_printer_hash)
|
138
|
+
@client.printers.search_all 'query'
|
139
|
+
end
|
140
|
+
|
141
|
+
should "return array of Printers" do
|
142
|
+
fake_connection.stubs(:get).with('/search', { :connection_status => 'ALL' }).returns(one_printer_hash)
|
143
|
+
printers = @client.printers.search_all
|
144
|
+
assert_equal 'my_printer', printers[0].id
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context '.all' do
|
149
|
+
should 'call .search_all' do
|
150
|
+
@client.printers.expects(:search_all)
|
151
|
+
@client.printers.all
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context '.search' do
|
156
|
+
setup do
|
157
|
+
stub_connection
|
158
|
+
fake_connection.expects(:get).with('/search', { :q => 'query' }).returns(one_printer_hash)
|
159
|
+
end
|
160
|
+
|
161
|
+
should "not scope printer search by connection status" do
|
162
|
+
@client.printers.search 'query'
|
163
|
+
end
|
164
|
+
|
165
|
+
should "return array of Printers" do
|
166
|
+
printers = @client.printers.search 'query'
|
167
|
+
assert_equal 'my_printer', printers[0].id
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
106
171
|
private
|
107
172
|
|
108
173
|
def empty_job
|
@@ -110,7 +175,7 @@ class PrinterTest < Test::Unit::TestCase
|
|
110
175
|
end
|
111
176
|
|
112
177
|
def print_stuff
|
113
|
-
printer =
|
178
|
+
printer = @client.printers.new(:id => 'printer')
|
114
179
|
printer.print(print_params)
|
115
180
|
end
|
116
181
|
|
@@ -123,7 +188,7 @@ class PrinterTest < Test::Unit::TestCase
|
|
123
188
|
end
|
124
189
|
|
125
190
|
def print_file
|
126
|
-
printer =
|
191
|
+
printer = @client.printers.new(:id => 'printer')
|
127
192
|
printer.print(print_file_params)
|
128
193
|
end
|
129
194
|
|
@@ -141,8 +206,8 @@ class PrinterTest < Test::Unit::TestCase
|
|
141
206
|
|
142
207
|
def multiple_printer_hash
|
143
208
|
{'printers' =>[
|
144
|
-
{'id' => 'first_printer', 'status' => 'online', 'name' => "First Printer", 'displayName' => 'First Printer (display name)'},
|
145
|
-
{'id' => 'second_printer', 'status' => 'online', 'name' => "Second Printer", 'displayName' => 'Second Printer (display name)'}
|
209
|
+
{'id' => 'first_printer', 'status' => 'online', 'name' => "First Printer", 'displayName' => 'First Printer (display name)', 'description' => 'First printer description'},
|
210
|
+
{'id' => 'second_printer', 'status' => 'online', 'name' => "Second Printer", 'displayName' => 'Second Printer (display name)', 'description' => 'Second printer description'}
|
146
211
|
]}
|
147
212
|
end
|
148
213
|
|
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Eugen Minciu
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: oauth2
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
19
|
+
version: 0.8.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
26
|
+
version: 0.8.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: json
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,23 +41,20 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: mocha
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: 0.10.0
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
54
|
+
version: 0.10.0
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: shoulda-context
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: test-unit
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ! '>='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ! '>='
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -121,16 +108,20 @@ extra_rdoc_files: []
|
|
121
108
|
files:
|
122
109
|
- .document
|
123
110
|
- .gitignore
|
111
|
+
- .travis.yml
|
124
112
|
- Gemfile
|
125
|
-
- Gemfile.lock
|
126
113
|
- LICENSE.txt
|
127
|
-
- README.
|
114
|
+
- README.md
|
128
115
|
- Rakefile
|
129
116
|
- cloudprint.gemspec
|
130
117
|
- lib/cloudprint.rb
|
118
|
+
- lib/cloudprint/client.rb
|
131
119
|
- lib/cloudprint/connection.rb
|
120
|
+
- lib/cloudprint/exceptions.rb
|
132
121
|
- lib/cloudprint/print_job.rb
|
122
|
+
- lib/cloudprint/print_job_collection.rb
|
133
123
|
- lib/cloudprint/printer.rb
|
124
|
+
- lib/cloudprint/printer_collection.rb
|
134
125
|
- lib/cloudprint/version.rb
|
135
126
|
- test/cloudprint_test.rb
|
136
127
|
- test/connection_test.rb
|
@@ -141,33 +132,26 @@ files:
|
|
141
132
|
homepage: http://github.com/minciue/cloudprint
|
142
133
|
licenses:
|
143
134
|
- MIT
|
135
|
+
metadata: {}
|
144
136
|
post_install_message:
|
145
137
|
rdoc_options: []
|
146
138
|
require_paths:
|
147
139
|
- lib
|
148
140
|
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
141
|
requirements:
|
151
142
|
- - ! '>='
|
152
143
|
- !ruby/object:Gem::Version
|
153
144
|
version: '0'
|
154
|
-
segments:
|
155
|
-
- 0
|
156
|
-
hash: 2978791594374137830
|
157
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
-
none: false
|
159
146
|
requirements:
|
160
147
|
- - ! '>='
|
161
148
|
- !ruby/object:Gem::Version
|
162
149
|
version: '0'
|
163
|
-
segments:
|
164
|
-
- 0
|
165
|
-
hash: 2978791594374137830
|
166
150
|
requirements: []
|
167
151
|
rubyforge_project: cloudprint
|
168
|
-
rubygems_version:
|
152
|
+
rubygems_version: 2.0.6
|
169
153
|
signing_key:
|
170
|
-
specification_version:
|
154
|
+
specification_version: 4
|
171
155
|
summary: This library provides a ruby-esque interface to Google Cloud Print.
|
172
156
|
test_files:
|
173
157
|
- test/cloudprint_test.rb
|
data/Gemfile.lock
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
cloudprint (0.1.3)
|
5
|
-
json
|
6
|
-
oauth2 (~> 0.5.2)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: http://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.2.7)
|
12
|
-
faraday (0.7.6)
|
13
|
-
addressable (~> 2.2)
|
14
|
-
multipart-post (~> 1.1)
|
15
|
-
rack (~> 1.1)
|
16
|
-
json (1.6.6)
|
17
|
-
metaclass (0.0.1)
|
18
|
-
mocha (0.10.5)
|
19
|
-
metaclass (~> 0.0.1)
|
20
|
-
multi_json (1.3.2)
|
21
|
-
multipart-post (1.1.5)
|
22
|
-
oauth2 (0.5.2)
|
23
|
-
faraday (~> 0.7)
|
24
|
-
multi_json (~> 1.0)
|
25
|
-
rack (1.4.1)
|
26
|
-
rake (0.9.2.2)
|
27
|
-
shoulda-context (1.0.0)
|
28
|
-
test-unit (2.4.8)
|
29
|
-
|
30
|
-
PLATFORMS
|
31
|
-
ruby
|
32
|
-
|
33
|
-
DEPENDENCIES
|
34
|
-
cloudprint!
|
35
|
-
mocha
|
36
|
-
rake
|
37
|
-
shoulda-context
|
38
|
-
test-unit
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= cloudprint
|
2
|
-
|
3
|
-
This library provides a ruby-esque interface to Google Cloud Print.
|
4
|
-
cloudprint is a work in progress. I'll be adding documentation once all the basic GCP functionality is supported.
|
5
|
-
|
6
|
-
== Contributing to cloudprint
|
7
|
-
|
8
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
9
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
10
|
-
* Fork the project
|
11
|
-
* Start a feature/bugfix branch
|
12
|
-
* Commit and push until you are happy with your contribution
|
13
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
14
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
15
|
-
|
16
|
-
== Copyright
|
17
|
-
|
18
|
-
Copyright (c) 2012 Eugen Minciu. See LICENSE.txt for
|
19
|
-
further details.
|