cloudprint 0.3.0 → 0.3.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ba8810b498a449d87aac8faca6b8be162823469
4
- data.tar.gz: 0392e67e8c64ebcfb6914cdc46a73d357f160ce2
3
+ metadata.gz: 2638b58ecad39880d408b9c6793defe76fc15fc9
4
+ data.tar.gz: d287456404dd90388eb574f61e9fef3d0205b910
5
5
  SHA512:
6
- metadata.gz: a0cfd77c155223d8903109f1bec4dc564f2160c52991a7408b956e7392b70b73b5ad1b78d388aaef31bc9b252725957f717bb3cfc288a4a14a9a47fe5da4138a
7
- data.tar.gz: ca5036663d42da407548dbd9bfc107ab22b17936b4b70bd972c3a9fe72ec195145b9efcd9751702dedae9fb9058d732d6e7a116482a97faa7f47f19d05a2e0db
6
+ metadata.gz: a1be2a1705a7ceb82ee291a4f9b980d0b5c551ae0f883471fb4bbca60666369b0e55f639a0ecbe964f5095f79f476a4f73a716c3e91b411531424812eae4b41d
7
+ data.tar.gz: 47aea8c483e4540aeb16693f087dc84aaba604ea35d4bc04c60bc48d64700dc3e0d513fff7fd0055fb1d5d1c1c71b91d3a821d6493ac8afbfcdd9c6e234704e8
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  .bundle
3
+ .idea
3
4
  Gemfile.lock
4
5
  pkg/*
5
6
  tags
data/ChangeLog.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Cloudprint Change Log
2
2
 
3
+ ## [0.3.1] - 2016-03-10
4
+ ### Fixes
5
+ - Fix search_all delegating to an invalid query.
6
+ - Turn the method_missing magic inside PrinterCollection into simple explicit code.
3
7
  ## [0.3.0] - 2016-03-09
4
8
  ### Dependencies
5
9
  - Update oauth gem requirement since a lot of people were having issues with that.
@@ -18,7 +18,8 @@ module CloudPrint
18
18
  end
19
19
 
20
20
  def print(options)
21
- method = options[:content].is_a?(IO) ? :multipart_post : :post
21
+ content = options[:content]
22
+ method = content.is_a?(IO) || content.is_a?(StringIO) || content.is_a?(Tempfile) ? :multipart_post : :post
22
23
  response = client.connection.send(method, '/submit', :printerid => self.id, :title => options[:title], :content => options[:content], :ticket => options[:ticket].to_json, :contentType => options[:content_type]) || {}
23
24
  return nil if response.nil? || response["job"].nil?
24
25
  client.print_jobs.new_from_response response["job"]
@@ -14,7 +14,7 @@ module CloudPrint
14
14
  end
15
15
 
16
16
  def all
17
- search_all
17
+ search()
18
18
  end
19
19
 
20
20
  def search(query = nil, conditions = {})
@@ -23,13 +23,22 @@ module CloudPrint
23
23
  response = client.connection.get('/search', conditions)
24
24
  response['printers'].map { |p| new_printer_from_hash(p) }
25
25
  end
26
+ alias_method :search_all, :search
26
27
 
27
- def method_missing(meth, *args, &block)
28
- if meth =~ /^search_(#{Printer::CONNECTION_STATUSES.map(&:downcase).join('|')}|all)$/
29
- search args[0], connection_status: $1.upcase
30
- else
31
- super
32
- end
28
+ def search_online(q = nil, conditions = {})
29
+ search_with_status(q, 'ONLINE', conditions)
30
+ end
31
+
32
+ def search_unknown(q = nil, conditions = {})
33
+ search_with_status(q, 'UNKNOWN', conditions)
34
+ end
35
+
36
+ def search_offline(q = nil, conditions = {})
37
+ search_with_status(q, 'OFFLINE', conditions)
38
+ end
39
+
40
+ def search_dormant(q = nil, conditions = {})
41
+ search_with_status(q, 'DORMANT', conditions)
33
42
  end
34
43
 
35
44
  def new opts
@@ -49,5 +58,11 @@ module CloudPrint
49
58
  capabilities: hash['capabilities']
50
59
  )
51
60
  end
61
+
62
+ private
63
+
64
+ def search_with_status(q, status, conditions)
65
+ search(q, conditions.merge(connection_status: status))
66
+ end
52
67
  end
53
68
  end
@@ -1,3 +1,3 @@
1
1
  module Cloudprint
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/test/printer_test.rb CHANGED
@@ -95,6 +95,26 @@ class PrinterTest < Minitest::Test
95
95
  print_file
96
96
  end
97
97
 
98
+ should "print stringio" do
99
+ stringio = StringIO.new(ruby_png_fixture.read)
100
+
101
+ fake_connection.expects(:multipart_post).with('/submit', connection_print_file_params.merge(:content => stringio)).returns(empty_job)
102
+ stub_connection
103
+
104
+ printer = @client.printers.new(:id => 'printer')
105
+ printer.print(print_file_params.merge(:content => stringio))
106
+ end
107
+
108
+ should "print tempfile" do
109
+ Tempfile.open "cloundprint_test" do |tempfile|
110
+ fake_connection.expects(:multipart_post).with('/submit', connection_print_file_params.merge(:content => tempfile)).returns(empty_job)
111
+ stub_connection
112
+
113
+ printer = @client.printers.new(:id => 'printer')
114
+ printer.print(print_file_params.merge(:content => tempfile))
115
+ end
116
+ end
117
+
98
118
  should "print jobs returning an id and a status" do
99
119
  stub_connection
100
120
  fake_connection.expects(:post).with('/submit', connection_print_params).returns({"success" => true, "job" => {"id" => "job_id", "status" => 'status'}})
@@ -134,21 +154,21 @@ class PrinterTest < Minitest::Test
134
154
  context '.search_all' do
135
155
  setup { stub_connection }
136
156
 
137
- should "scope search by printers with any connection status" do
138
- fake_connection.expects(:get).with('/search', { :q => 'query', :connection_status => 'ALL' }).returns(one_printer_hash)
157
+ should "search printers regardless of connection status" do
158
+ fake_connection.expects(:get).with('/search', { :q => 'query' }).returns(one_printer_hash)
139
159
  @client.printers.search_all 'query'
140
160
  end
141
161
 
142
162
  should "return array of Printers" do
143
- fake_connection.stubs(:get).with('/search', { :connection_status => 'ALL' }).returns(one_printer_hash)
163
+ fake_connection.stubs(:get).with('/search', {}).returns(one_printer_hash)
144
164
  printers = @client.printers.search_all
145
165
  assert_equal 'my_printer', printers[0].id
146
166
  end
147
167
  end
148
168
 
149
169
  context '.all' do
150
- should 'call .search_all' do
151
- @client.printers.expects(:search_all)
170
+ should 'call .search with no query' do
171
+ @client.printers.expects(:search)
152
172
  @client.printers.all
153
173
  end
154
174
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudprint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Minciu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2