shrine-url 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5da2ca4ce8958271c422287cc7b8ee6fe7999526
4
- data.tar.gz: 1c9b02222b55b30bb63cb333fd73c4dc4e8951ab
3
+ metadata.gz: 6005a53a2bf9e49c2d06c4159fb19d7cddbcb7a8
4
+ data.tar.gz: b42fac9634edea7c8e3bd758071eabeac33d72f8
5
5
  SHA512:
6
- metadata.gz: cfe2bf454cbc951f7f7804a91098d5bb610b165810c4ca2370cf70d52e91519be8d643496b5b0937ca44ab611d9364b4139fc65e6971c149d8589d62a870a01f
7
- data.tar.gz: d085d268244090667a609831df75949ff1ea9569f0a2c24104b2ab9a26d0de0e9c7e5db4613d95cb8d613392bbbd1644da6e0fe3e2b9d7995f201b6dc0a029a0
6
+ metadata.gz: 91625d15988ee6b2550dc063b78469d6165bd270d895f08574f75def2834d02e211369d4e5e48f96d7f78a04fb81d05f0d279d7669acb1dcb73d7ab9f4d711b8
7
+ data.tar.gz: 9d74539f50a3428bb32e2e274d22afa18796f0c80b8cec5af0d6d9128c37510fd3ff799712ff48f99f331952aad1db09a0e03785b1e28b30dd24cb22405dcc93
@@ -18,12 +18,8 @@ class Shrine
18
18
  end
19
19
 
20
20
  def exists?(id)
21
- response = nil
22
- uri = URI(id)
23
- Net::HTTP.start(uri.host, uri.port) do |http|
24
- response = http.head(uri.request_uri)
25
- end
26
- response.code.to_i == 200
21
+ response = request(:head, id)
22
+ (200..299).cover?(response.code.to_i)
27
23
  end
28
24
 
29
25
  def url(id, **options)
@@ -31,11 +27,18 @@ class Shrine
31
27
  end
32
28
 
33
29
  def delete(id)
34
- # noop
30
+ request(:delete, id)
35
31
  end
36
32
 
37
- def clear!
38
- # noop
33
+ private
34
+
35
+ def request(method, url)
36
+ response = nil
37
+ uri = URI(url)
38
+ Net::HTTP.start(uri.host, uri.port) do |http|
39
+ response = http.send(method, uri.request_uri)
40
+ end
41
+ response
39
42
  end
40
43
  end
41
44
  end
data/shrine-url.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-url"
3
- gem.version = "0.1.1"
3
+ gem.version = "0.2.0"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_development_dependency "rake"
20
20
  gem.add_development_dependency "minitest"
21
+ gem.add_development_dependency "webmock"
21
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine-url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-06 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - janko.marohnic@gmail.com