readonce 1.0.7 → 1.0.8

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: b21289cc22aaae5a2f6c02eac64433a2aa8b5e16
4
- data.tar.gz: 7b85eba3fb59661e52f92f316f89fefd35f02526
3
+ metadata.gz: f9eaa341ecf2f2c9523ca977ad805c6caa7205ba
4
+ data.tar.gz: e8fae4d833420964454bdbbeba1269e92038e80f
5
5
  SHA512:
6
- metadata.gz: fc6ea880ad4819acb4f7c267af238d1433115414496eee212ddd2a378d1efd606c10651b8505cf08f5ebbbc1076ed5d7bfd26e43fd748a263d2102087370bb33
7
- data.tar.gz: b182d6b7ada4820711782718a7998bc2eb7ccb42a4dfd6580f87ce6acd5deb6425a09644a42e7526bbe13707e8406688e009c23bc28fe81195e9a83b013f5f73
6
+ metadata.gz: 7d8d679f239efe70ac27e2166929b008fd5fb62fa08791f97041ce6a66a3ffd164a053bb48209055e60f32f293a10e273bf2889f6a362d1562232df879102dea
7
+ data.tar.gz: c34fc9306f979e46889cb9261f5f2f3bbe0c7b68a440c24c4195c47451ef2fc1f954ac1f5b9acaf3c22f7236a83379333f27b3a36cbe0e308b0ce19469c8b244
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://readonce-production.herokuapp.com/status/3df816347dc99e28c4159885f8757dcf
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: 'OK '
14
+ headers:
15
+ content-type:
16
+ - text/plain;charset=utf-8
17
+ content-length:
18
+ - '66'
19
+ x-content-type-options:
20
+ - nosniff
21
+ server:
22
+ - WEBrick/1.3.1 (Ruby/2.1.3/2014-09-19)
23
+ date:
24
+ - Thu, 05 May 2016 03:57:46 GMT
25
+ connection:
26
+ - close
27
+ body:
28
+ encoding: UTF-8
29
+ string: '{"accessed_at":"2016-05-04 23:56:36 -0400","accessed_by_ip":"::1"}'
30
+ http_version: '1.1'
31
+ recorded_at: Thu, 05 May 2016 03:57:46 GMT
32
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://readonce-production.herokuapp.com/status/dc37debdfa040fe469e9aa248815c81f
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: 'OK '
14
+ headers:
15
+ content-type:
16
+ - text/plain;charset=utf-8
17
+ content-length:
18
+ - '42'
19
+ x-content-type-options:
20
+ - nosniff
21
+ server:
22
+ - WEBrick/1.3.1 (Ruby/2.1.3/2014-09-19)
23
+ date:
24
+ - Thu, 05 May 2016 03:57:46 GMT
25
+ connection:
26
+ - close
27
+ body:
28
+ encoding: UTF-8
29
+ string: '{"accessed_at":null,"accessed_by_ip":null}'
30
+ http_version: '1.1'
31
+ recorded_at: Thu, 05 May 2016 03:57:46 GMT
32
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://readonce-production.herokuapp.com/status/244d26b5cc62b18f29f86065995442e5
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: 'OK '
14
+ headers:
15
+ connection:
16
+ - close
17
+ content-type:
18
+ - text/plain;charset=utf-8
19
+ content-length:
20
+ - '42'
21
+ x-content-type-options:
22
+ - nosniff
23
+ server:
24
+ - WEBrick/1.3.1 (Ruby/2.2.4/2015-12-16)
25
+ date:
26
+ - Thu, 05 May 2016 04:11:13 GMT
27
+ via:
28
+ - 1.1 vegur
29
+ body:
30
+ encoding: UTF-8
31
+ string: '{"accessed_at":null,"accessed_by_ip":null}'
32
+ http_version: '1.1'
33
+ recorded_at: Thu, 05 May 2016 04:11:13 GMT
34
+ recorded_with: VCR 3.0.1
@@ -2,43 +2,31 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://readonce-production.herokuapp.com/status/a2b7385319449527d87468a3833365c4
5
+ uri: https://readonce-production.herokuapp.com/status/foobarfake
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
- headers:
10
- accept-encoding:
11
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
- accept:
13
- - "*/*"
14
- user-agent:
15
- - Ruby
9
+ headers: {}
16
10
  response:
17
11
  status:
18
12
  code: 404
19
13
  message: 'Not Found '
20
14
  headers:
21
- connection:
22
- - close
23
15
  content-type:
24
- - text/html;charset=utf-8
16
+ - text/plain;charset=utf-8
25
17
  content-length:
26
18
  - '9'
27
- x-xss-protection:
28
- - 1; mode=block
29
19
  x-content-type-options:
30
20
  - nosniff
31
- x-frame-options:
32
- - SAMEORIGIN
33
21
  server:
34
- - WEBrick/1.3.1 (Ruby/2.2.4/2015-12-16)
22
+ - WEBrick/1.3.1 (Ruby/2.1.3/2014-09-19)
35
23
  date:
36
- - Sun, 01 May 2016 04:51:20 GMT
37
- via:
38
- - 1.1 vegur
24
+ - Thu, 05 May 2016 03:57:46 GMT
25
+ connection:
26
+ - close
39
27
  body:
40
28
  encoding: UTF-8
41
29
  string: Not found
42
30
  http_version: '1.1'
43
- recorded_at: Sun, 01 May 2016 04:51:19 GMT
31
+ recorded_at: Thu, 05 May 2016 03:57:46 GMT
44
32
  recorded_with: VCR 3.0.1
@@ -2,43 +2,31 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://readonce-production.herokuapp.com/status/63d2e85319449527d87468a3833365c4
5
+ uri: https://readonce-production.herokuapp.com/status/93645a5302b2d65b858d8056c781844c
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
- headers:
10
- accept-encoding:
11
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
- accept:
13
- - "*/*"
14
- user-agent:
15
- - Ruby
9
+ headers: {}
16
10
  response:
17
11
  status:
18
12
  code: 200
19
13
  message: 'OK '
20
14
  headers:
21
- connection:
22
- - close
23
15
  content-type:
24
- - text/html;charset=utf-8
16
+ - text/plain;charset=utf-8
25
17
  content-length:
26
- - '5'
27
- x-xss-protection:
28
- - 1; mode=block
18
+ - '42'
29
19
  x-content-type-options:
30
20
  - nosniff
31
- x-frame-options:
32
- - SAMEORIGIN
33
21
  server:
34
- - WEBrick/1.3.1 (Ruby/2.2.4/2015-12-16)
22
+ - WEBrick/1.3.1 (Ruby/2.1.3/2014-09-19)
35
23
  date:
36
- - Sun, 01 May 2016 04:51:20 GMT
37
- via:
38
- - 1.1 vegur
24
+ - Thu, 05 May 2016 03:57:46 GMT
25
+ connection:
26
+ - close
39
27
  body:
40
28
  encoding: UTF-8
41
- string: Found
29
+ string: '{"accessed_at":null,"accessed_by_ip":null}'
42
30
  http_version: '1.1'
43
- recorded_at: Sun, 01 May 2016 04:51:19 GMT
31
+ recorded_at: Thu, 05 May 2016 03:57:46 GMT
44
32
  recorded_with: VCR 3.0.1
data/lib/readonce.rb CHANGED
@@ -22,13 +22,23 @@ class ReadOnce
22
22
  "#{BASE_URI}/#{key}"
23
23
  end
24
24
 
25
+ def read?
26
+ response = HTTParty.get "#{BASE_URI}/status/#{key}"
27
+ !JSON.parse(response.body)['accessed_at'].nil?
28
+ end
29
+
25
30
  def exists?
26
31
  response = HTTParty.get "#{BASE_URI}/status/#{key}"
27
32
  response.code == 200
28
33
  end
29
34
 
30
- def block_while_exists
31
- while exists? do
35
+ def status
36
+ response = HTTParty.get "#{BASE_URI}/status/#{key}"
37
+ JSON.parse(response.body)
38
+ end
39
+
40
+ def block_until_read
41
+ until read? do
32
42
  sleep 1
33
43
  end
34
44
  end
@@ -1,3 +1,3 @@
1
1
  module Readonce
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readonce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robby Grossman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-01 00:00:00.000000000 Z
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -110,7 +110,10 @@ files:
110
110
  - README.md
111
111
  - Rakefile
112
112
  - bin/readonce
113
+ - fixtures/vcr_cassettes/bag-read.yml
114
+ - fixtures/vcr_cassettes/bag-unread.yml
113
115
  - fixtures/vcr_cassettes/create-file.yml
116
+ - fixtures/vcr_cassettes/get-status.yml
114
117
  - fixtures/vcr_cassettes/key-does-not-exist.yml
115
118
  - fixtures/vcr_cassettes/key-exists.yml
116
119
  - lib/readonce.rb