tinify 1.2.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +2 -0
- data/CHANGES.md +5 -0
- data/Gemfile.lock +5 -2
- data/LICENSE +1 -1
- data/lib/data/cacert.pem +1073 -2307
- data/lib/tinify/client.rb +33 -17
- data/lib/tinify/error.rb +3 -1
- data/lib/tinify/source.rb +5 -0
- data/lib/tinify/version.rb +1 -1
- data/lib/tinify.rb +13 -4
- data/test/examples/voormedia.png +0 -0
- data/test/helper.rb +1 -0
- data/test/integration.rb +50 -9
- data/test/tinify_client_test.rb +88 -7
- data/test/tinify_source_test.rb +158 -46
- data/test/tinify_test.rb +42 -1
- data/update-cacert.sh +17 -0
- metadata +18 -17
data/test/tinify_test.rb
CHANGED
@@ -34,6 +34,22 @@ describe Tinify do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
describe "proxy" do
|
38
|
+
before do
|
39
|
+
stub_request(:get, "https://api:abcde@api.tinify.com").to_return(status: 200)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should reset client with new proxy" do
|
43
|
+
Tinify.key = "abcde"
|
44
|
+
Tinify.proxy = "http://localhost"
|
45
|
+
Tinify.client
|
46
|
+
Tinify.proxy = "http://user:pass@localhost:8080"
|
47
|
+
Tinify.client.request(:get, "/")
|
48
|
+
assert_requested :get, "https://api:abcde@api.tinify.com",
|
49
|
+
headers: { "Proxy-Authorization" => "Basic dXNlcjpwYXNz" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
37
53
|
describe "client" do
|
38
54
|
describe "with key" do
|
39
55
|
it "should return client" do
|
@@ -49,6 +65,16 @@ describe Tinify do
|
|
49
65
|
end
|
50
66
|
end
|
51
67
|
end
|
68
|
+
|
69
|
+
describe "with invalid proxy" do
|
70
|
+
it "should raise error" do
|
71
|
+
assert_raises Tinify::ConnectionError do
|
72
|
+
Tinify.key = "abcde"
|
73
|
+
Tinify.proxy = "http-bad-url"
|
74
|
+
Tinify.client
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
52
78
|
end
|
53
79
|
|
54
80
|
describe "validate" do
|
@@ -58,7 +84,22 @@ describe Tinify do
|
|
58
84
|
|
59
85
|
stub_request(:post, "https://api:valid@api.tinify.com/shrink").to_return(
|
60
86
|
status: 400,
|
61
|
-
body: '{"error":"
|
87
|
+
body: '{"error":"Input missing","message":"No input"}'
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should return true" do
|
92
|
+
assert_equal true, Tinify.validate!
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "with limited key" do
|
97
|
+
before do
|
98
|
+
Tinify.key = "valid"
|
99
|
+
|
100
|
+
stub_request(:post, "https://api:valid@api.tinify.com/shrink").to_return(
|
101
|
+
status: 429,
|
102
|
+
body: '{"error":"Too many requests","message":"Your monthly limit has been exceeded"}'
|
62
103
|
)
|
63
104
|
end
|
64
105
|
|
data/update-cacert.sh
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
dir=lib/data
|
3
|
+
|
4
|
+
cert=0
|
5
|
+
curl --silent --fail https://curl.se/ca/cacert.pem | while read -r line; do
|
6
|
+
if [ "-----BEGIN CERTIFICATE-----" == "$line" ]; then
|
7
|
+
cert=1
|
8
|
+
echo "$line"
|
9
|
+
elif [ "-----END CERTIFICATE-----" == "$line" ]; then
|
10
|
+
cert=0
|
11
|
+
echo "$line"
|
12
|
+
else
|
13
|
+
if [ $cert == 1 ]; then
|
14
|
+
echo "$line"
|
15
|
+
fi
|
16
|
+
fi
|
17
|
+
done > "$dir/cacert.pem"
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rolf Timmermans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.6'
|
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
26
|
version: '2.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.7'
|
34
34
|
type: :development
|
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: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.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: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '5.5'
|
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: '5.5'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.20'
|
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: '1.20'
|
83
83
|
description: Ruby client for the Tinify API. Tinify compresses your images intelligently.
|
@@ -88,7 +88,8 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- .travis.yml
|
91
|
+
- ".travis.yml"
|
92
|
+
- CHANGES.md
|
92
93
|
- Gemfile
|
93
94
|
- Gemfile.lock
|
94
95
|
- LICENSE
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- test/tinify_source_test.rb
|
113
114
|
- test/tinify_test.rb
|
114
115
|
- tinify.gemspec
|
116
|
+
- update-cacert.sh
|
115
117
|
homepage: https://tinify.com/developers
|
116
118
|
licenses:
|
117
119
|
- MIT
|
@@ -122,17 +124,16 @@ require_paths:
|
|
122
124
|
- lib
|
123
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
126
|
requirements:
|
125
|
-
- -
|
127
|
+
- - ">="
|
126
128
|
- !ruby/object:Gem::Version
|
127
129
|
version: '0'
|
128
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
131
|
requirements:
|
130
|
-
- -
|
132
|
+
- - ">="
|
131
133
|
- !ruby/object:Gem::Version
|
132
134
|
version: '0'
|
133
135
|
requirements: []
|
134
|
-
|
135
|
-
rubygems_version: 2.4.5
|
136
|
+
rubygems_version: 3.0.8
|
136
137
|
signing_key:
|
137
138
|
specification_version: 4
|
138
139
|
summary: Ruby client for the Tinify API.
|