alephant-scout 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -23
- data/Rakefile +1 -4
- data/alephant-scout.gemspec +3 -0
- data/lib/alephant/scout/url.rb +3 -3
- data/lib/alephant/scout/version.rb +1 -1
- data/spec/integration/spec_helper.rb +1 -0
- data/spec/integration/url_spec.rb +15 -0
- data/spec/url_spec.rb +30 -17
- metadata +48 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85b78e083608aaed93af7260ac8161a2b98fc790
|
4
|
+
data.tar.gz: f0ad36b38085673ef343c9de31dd3630258a7743
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef71e5fd065d54f3005f4ec9c1ce2e6713c736f6bb679d11052f7dbfc8066ade82855f6415f7c7ddae75e9ece7aab048ec9b8383cc2a7619e7445bbfab0d4815
|
7
|
+
data.tar.gz: 566c5d263ae1c292c4b24b7cdc4b7413945712c0c55888437a8a3da460c24222784ce7e746f04bee15a43aad895080c2089ffb55d4467e6437b0c39522e7e059
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Alephant::Scout
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/alephant-scout.svg)](http://badge.fury.io/rb/alephant-scout)
|
4
|
+
|
3
5
|
This is a gem to allow Alephant based applications to check the validity of an arbitrary URL / URI
|
4
6
|
before enqueuing messages to render content based on the content of said URL / URI, thereby protecting
|
5
7
|
render nodes from having to handle bogus URLs / URIs.
|
@@ -23,33 +25,17 @@ Or install it yourself as:
|
|
23
25
|
```rb
|
24
26
|
require 'alephant-scout'
|
25
27
|
|
28
|
+
Alephant::Scout::Url.valid? 'http://bbc.co.uk/persian/world'
|
26
29
|
# => true
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
# => "http://www.bbc.co.uk/persian/world"
|
31
|
-
|
32
|
-
bad_url = 'http://www.bbc.co.uk/persian/lobster-hatstand'
|
33
|
-
|
34
|
-
# => "http://www.bbc.co.uk/persian/lobster-hatstand"
|
35
|
-
|
36
|
-
url_scout = Alephant::Scout::Url.new()
|
37
|
-
|
38
|
-
# = > #<Alephant::Scout::Url:[ObjectId]>
|
39
|
-
|
40
|
-
url_scout.valid?(good_url)
|
41
|
-
|
42
|
-
# => true
|
43
|
-
|
44
|
-
url_scout.valid?(bad_url)
|
45
|
-
|
31
|
+
Alephant::Scout::Url.valid? 'http://bbc.co.uk/batman'
|
46
32
|
# => false
|
47
33
|
```
|
48
34
|
|
49
35
|
## Contributing
|
50
36
|
|
51
|
-
1. Fork it
|
52
|
-
2. Create your feature branch
|
53
|
-
3. Commit your changes
|
54
|
-
4. Push to the branch
|
55
|
-
5. Create new Pull Request
|
37
|
+
1. [Fork it!](https://github.com/bbc-news/alephant-scout/fork)
|
38
|
+
2. Create your feature branch: `git checkout -b my-new-feature`
|
39
|
+
3. Commit your changes: `git commit -am 'Add some feature'`
|
40
|
+
4. Push to the branch: `git push origin my-new-feature`
|
41
|
+
5. Create new [Pull Request](https://github.com/bbc-news/alephant-scout/pulls).
|
data/Rakefile
CHANGED
data/alephant-scout.gemspec
CHANGED
@@ -20,6 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", ">= 3.1"
|
24
|
+
spec.add_development_dependency "rspec-nc"
|
25
|
+
spec.add_development_dependency "rake-rspec"
|
23
26
|
|
24
27
|
spec.add_runtime_dependency "httparty", "~> 0.13.1"
|
25
28
|
spec.add_runtime_dependency "alephant-logger"
|
data/lib/alephant/scout/url.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../spec_helper'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alephant::Scout::Url do
|
4
|
+
describe '.valid?' do
|
5
|
+
context 'using a valid URL' do
|
6
|
+
let(:url) { 'http://bbc.co.uk/persian/world' }
|
7
|
+
specify { expect(described_class.valid? url).to be }
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'using an invalid URL' do
|
11
|
+
let(:url) { 'http://bbc.co.uk/batman' }
|
12
|
+
specify { expect(described_class.valid? url).to be false}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/url_spec.rb
CHANGED
@@ -1,30 +1,43 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Alephant::Scout::Url do
|
4
|
-
describe
|
4
|
+
describe '.valid?' do
|
5
5
|
let(:response) { double('HTTParty::Response') }
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
|
7
|
+
context 'using a valid URL' do
|
8
|
+
let(:url) { 'http://a-valid-url.com' }
|
9
|
+
before do
|
10
|
+
allow(HTTParty).to receive(:head).once.with(url).and_return(response)
|
11
|
+
allow(response).to receive(:code).once.and_return(200)
|
12
|
+
end
|
13
|
+
specify { expect(described_class.valid? url).to be }
|
10
14
|
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
context 'using a valid URL with a server error' do
|
17
|
+
let(:url) { 'http://a-valid-url.com/error' }
|
18
|
+
before do
|
19
|
+
allow(HTTParty).to receive(:head).once.with(url).and_return(response)
|
20
|
+
allow(response).to receive(:code).once.and_return(500)
|
21
|
+
end
|
22
|
+
specify { expect(described_class.valid? url).to be false}
|
16
23
|
end
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
25
|
+
context 'using a valid URL with a missing resource' do
|
26
|
+
let(:url) { 'http://a-valid-url.com/missing.gif' }
|
27
|
+
before do
|
28
|
+
allow(HTTParty).to receive(:head).once.with(url).and_return(response)
|
29
|
+
allow(response).to receive(:code).once.and_return(404)
|
30
|
+
end
|
31
|
+
specify { expect(described_class.valid? url).to be false}
|
22
32
|
end
|
23
33
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
context 'using an invalid URL' do
|
35
|
+
let(:url) { 'http://an-invalid-url.com' }
|
36
|
+
before do
|
37
|
+
allow(HTTParty).to receive(:head).once.with(url).and_return(response)
|
38
|
+
allow(response).to receive(:code).once.and_return(500)
|
39
|
+
end
|
40
|
+
specify { expect(described_class.valid? url).to be false}
|
28
41
|
end
|
29
42
|
end
|
30
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-scout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C. Oliver Godby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,48 @@ dependencies:
|
|
38
38
|
version: '0'
|
39
39
|
prerelease: false
|
40
40
|
type: :development
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.1'
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-nc
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake-rspec
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
84
|
name: httparty
|
43
85
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -97,6 +139,8 @@ files:
|
|
97
139
|
- lib/alephant/scout.rb
|
98
140
|
- lib/alephant/scout/url.rb
|
99
141
|
- lib/alephant/scout/version.rb
|
142
|
+
- spec/integration/spec_helper.rb
|
143
|
+
- spec/integration/url_spec.rb
|
100
144
|
- spec/spec_helper.rb
|
101
145
|
- spec/url_spec.rb
|
102
146
|
homepage: ''
|
@@ -124,5 +168,7 @@ signing_key:
|
|
124
168
|
specification_version: 4
|
125
169
|
summary: '"Scout URLs to see if they are valid"'
|
126
170
|
test_files:
|
171
|
+
- spec/integration/spec_helper.rb
|
172
|
+
- spec/integration/url_spec.rb
|
127
173
|
- spec/spec_helper.rb
|
128
174
|
- spec/url_spec.rb
|