live_paper 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/live_paper.rb +2 -2
- data/lib/live_paper/image.rb +16 -16
- data/lib/live_paper/version.rb +1 -1
- data/spec/live_paper/image_spec.rb +48 -0
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c4320a4fff367170dba5cd8daa539c6c5824cb4
|
4
|
+
data.tar.gz: 0707ddc9c784f3f2ba71629398a26a1084cc9c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3211494b2a9bc62edfa8b17c611a0ecd6bd15ca597f918b7343d0c5bfea772c1a925d402d8f4a5c880ad83758f4ee0c281eb618fb489f6d6be1948c682cafa
|
7
|
+
data.tar.gz: c672265db80b82db5078864510ce1d7925bfb53efae98350fc5dd45a649553f4b94dc9db68548a9e15d3a417dad9199cefb5057c0a4d6333f44f6163d7fe2cdd
|
data/lib/live_paper.rb
CHANGED
@@ -62,8 +62,8 @@ module LivePaper
|
|
62
62
|
t.download_qrcode
|
63
63
|
end
|
64
64
|
|
65
|
-
def watermark_bytes(dest,
|
66
|
-
image = Image.upload
|
65
|
+
def watermark_bytes(dest, image_uri)
|
66
|
+
image = Image.upload image_uri
|
67
67
|
|
68
68
|
t=WmTrigger.create(name: 'watermark', watermark: {strength: 10, resolution: 75, imageURL: image})
|
69
69
|
p=Payoff.create(name: 'name', type: Payoff::TYPE[:WEB], url: dest)
|
data/lib/live_paper/image.rb
CHANGED
@@ -8,25 +8,25 @@ module LivePaper
|
|
8
8
|
|
9
9
|
API_URL = 'https://storage.livepaperapi.com/objects/v1/files'
|
10
10
|
|
11
|
-
def self.upload(
|
11
|
+
def self.upload(image_uri)
|
12
12
|
# return the original img uri if it is LivePaper storage
|
13
|
-
if
|
14
|
-
return
|
13
|
+
if image_uri.include? API_URL
|
14
|
+
return image_uri
|
15
15
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
authorization: "Bearer #{$lpp_access_token}",
|
22
|
-
content_type: 'image/jpg'
|
23
|
-
response.headers[:location]
|
24
|
-
rescue Exception => e
|
25
|
-
puts "Exception! ******\n#{e}"
|
26
|
-
puts e.response
|
27
|
-
img
|
16
|
+
image_bytes = case
|
17
|
+
when image_uri.include?('http://') || image_uri.include?('https://')
|
18
|
+
RestClient.get(image_uri, Accept: 'image/jpg').body
|
19
|
+
else
|
20
|
+
File.binread(image_uri)
|
28
21
|
end
|
29
|
-
end
|
30
22
|
|
23
|
+
BaseObject.request_access_token unless $lpp_access_token
|
24
|
+
response = RestClient.post API_URL,
|
25
|
+
image_bytes,
|
26
|
+
authorization: "Bearer #{$lpp_access_token}",
|
27
|
+
content_type: 'image/jpg'
|
28
|
+
response.headers[:location]
|
29
|
+
|
30
|
+
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/live_paper/version.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LivePaper::Image do
|
4
|
+
let(:srcBytes) { 'YOURIMAGEBYTES' }
|
5
|
+
let(:lpp_img_uri) { 'ALLYOURBYTESAREBELONGTOUS' }
|
6
|
+
before do
|
7
|
+
$lpp_access_token = "YouBeenHacked"
|
8
|
+
|
9
|
+
stub_request(:post, LivePaper::Image::API_URL).
|
10
|
+
with(:body => "YOURIMAGEBYTES",
|
11
|
+
:headers => {'Accept'=>'*/*; q=0.5, application/xml', 'Accept-Encoding'=>'gzip, deflate', 'Authorization'=>'Bearer YouBeenHacked', 'Content-Length'=>'14', 'Content-Type'=>'image/jpg', 'User-Agent'=>'Ruby'}).
|
12
|
+
to_return(:status => 201, :body => "", :headers => {location: lpp_img_uri})
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'local file' do
|
16
|
+
let(:source_uri) { 'foo.jpg' }
|
17
|
+
|
18
|
+
before do
|
19
|
+
expect(File).to receive(:binread).with(source_uri).and_return(srcBytes)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'upload should return stored image url' do
|
23
|
+
expect(LivePaper::Image.upload(source_uri)).to eq(lpp_img_uri)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'web file' do
|
28
|
+
let(:source_uri) { 'http://anythingbutapiurl.com/anypath/internetphoto.jpg' }
|
29
|
+
|
30
|
+
before do
|
31
|
+
receiver = double('receiver')
|
32
|
+
expect(receiver).to receive(:body).and_return(srcBytes)
|
33
|
+
expect(RestClient).to receive(:get).with(source_uri, Accept: 'image/jpg').and_return(receiver)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'upload should return stored image url' do
|
37
|
+
expect(LivePaper::Image.upload(source_uri)).to eq(lpp_img_uri)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
context 'lpp stored image file' do
|
41
|
+
let(:source_uri) { "#{LivePaper::Image::API_URL}/path/already_uploaded.jpg" }
|
42
|
+
|
43
|
+
it 'upload should return original image url' do
|
44
|
+
expect(LivePaper::Image.upload(source_uri)).to eq(source_uri)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: live_paper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Whitmarsh
|
@@ -9,76 +9,76 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.6'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1.6'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - '>='
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: webmock
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - '>='
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
description: Ruby interface to use the Live Paper service by HP for creating watermarked
|
@@ -88,7 +88,7 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
-
|
91
|
+
- .gitignore
|
92
92
|
- Gemfile
|
93
93
|
- LICENSE.txt
|
94
94
|
- README.md
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/live_paper/wm_trigger.rb
|
106
106
|
- live_paper.gemspec
|
107
107
|
- spec/live_paper/base_object_spec.rb
|
108
|
+
- spec/live_paper/image_spec.rb
|
108
109
|
- spec/live_paper/link_spec.rb
|
109
110
|
- spec/live_paper/payoff_spec.rb
|
110
111
|
- spec/live_paper/trigger_spec.rb
|
@@ -121,22 +122,23 @@ require_paths:
|
|
121
122
|
- lib
|
122
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
124
|
requirements:
|
124
|
-
- -
|
125
|
+
- - '>='
|
125
126
|
- !ruby/object:Gem::Version
|
126
127
|
version: '0'
|
127
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
129
|
requirements:
|
129
|
-
- -
|
130
|
+
- - '>='
|
130
131
|
- !ruby/object:Gem::Version
|
131
132
|
version: '0'
|
132
133
|
requirements: []
|
133
134
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.4.6
|
135
136
|
signing_key:
|
136
137
|
specification_version: 4
|
137
138
|
summary: Ruby interface to the Live Paper service by HP.
|
138
139
|
test_files:
|
139
140
|
- spec/live_paper/base_object_spec.rb
|
141
|
+
- spec/live_paper/image_spec.rb
|
140
142
|
- spec/live_paper/link_spec.rb
|
141
143
|
- spec/live_paper/payoff_spec.rb
|
142
144
|
- spec/live_paper/trigger_spec.rb
|