linksta 0.1.0
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/linksta +9 -0
- data/bin/setup +8 -0
- data/lib/linksta/cli.rb +30 -0
- data/lib/linksta/javascript/snap.js +88 -0
- data/lib/linksta/version.rb +3 -0
- data/lib/linksta.rb +158 -0
- data/linksta.gemspec +26 -0
- data/spec/linksta_spec.rb +9 -0
- data/spec/spec_helper.rb +14 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 258c58c07cfc7e86b2b7246c78bcf846b9536716
|
4
|
+
data.tar.gz: a3967cbe9b049c0de5ec97a0e29093d58ff74613
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 583139f151dcd1d111a5fb459f9bf448d6c46951376889b1bbad1278035bc16e1d78465841b39ce0eb7511c8be52a9ead185cfcbc0c573a20ae7acabd4cf70e5
|
7
|
+
data.tar.gz: df11fa88a0b0f84636a364cf367ee3aa22a445f496715807265ab611aaaa488fca7a4b9717695e2485ce68a21a6dd4579b296b114c73599d79a514b78bc32701
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at anthony.kaluuma@bbc.co.uk. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
linksta (0.1.0)
|
5
|
+
thor
|
6
|
+
typhoeus
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
coderay (1.1.2)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
ethon (0.10.1)
|
14
|
+
ffi (>= 1.3.0)
|
15
|
+
ffi (1.9.18)
|
16
|
+
method_source (0.9.0)
|
17
|
+
pry (0.11.3)
|
18
|
+
coderay (~> 1.1.0)
|
19
|
+
method_source (~> 0.9.0)
|
20
|
+
rake (12.1.0)
|
21
|
+
rspec (3.7.0)
|
22
|
+
rspec-core (~> 3.7.0)
|
23
|
+
rspec-expectations (~> 3.7.0)
|
24
|
+
rspec-mocks (~> 3.7.0)
|
25
|
+
rspec-core (3.7.0)
|
26
|
+
rspec-support (~> 3.7.0)
|
27
|
+
rspec-expectations (3.7.0)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.7.0)
|
30
|
+
rspec-mocks (3.7.0)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.7.0)
|
33
|
+
rspec-support (3.7.0)
|
34
|
+
thor (0.20.0)
|
35
|
+
typhoeus (1.3.0)
|
36
|
+
ethon (>= 0.9.0)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
linksta!
|
43
|
+
pry
|
44
|
+
rake
|
45
|
+
rspec
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Anthony Kalu Uma
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# Linkey
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/linkey) [](https://rubygems.org/gems/linkey) [](https://travis-ci.org/DaveBlooman/linkey) [](https://codeclimate.com/github/DaveBlooman/linkey)
|
4
|
+
|
5
|
+
**Link checker for BBC Radio & Music sites.**
|
6
|
+
|
7
|
+
The idea is to quickly check a page for broken links by doing a status check on all the relative URL's on the page.
|
8
|
+
|
9
|
+
There are 4 parts to this tool, the URL, the base URL, the regex and the filename.
|
10
|
+
|
11
|
+
* **URL** is the page that you want to check for broken links, e.g `www.bbc.co.uk/radi04`
|
12
|
+
* **Base URL** is used with the relative URL from the regex to create a full URL, e.g `www.bbc.co.uk`
|
13
|
+
* **Regex** is the point of the URL that you want to keep from the regex, e.g `bbc.co.uk/radio/new`, specifying `/radio` would create `/radio/new`.
|
14
|
+
* **Filename** is markdown (.md) file where all the page links are stored, this can be useful for manual checks, e.g `file.md`
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
gem install linkey
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### Command Line
|
23
|
+
|
24
|
+
```
|
25
|
+
linkey check <url> <base_url> <regex> <filename>
|
26
|
+
```
|
27
|
+
|
28
|
+
**Examples**
|
29
|
+
|
30
|
+
```
|
31
|
+
linkey check http://www.bbc.co.uk/radio http://www.bbc.co.uk/radio radio.md
|
32
|
+
```
|
33
|
+
|
34
|
+
```
|
35
|
+
linkey check http://www.theguardian.com/technology/2014/feb/15/year-of-code-needs-reboot-teachers http://theguardian.com /technology news.md
|
36
|
+
```
|
37
|
+
**Output**
|
38
|
+
|
39
|
+
Once running, you'll see either a 200 with `Status is 200 for <URL>` or `Status is NOT GOOD for <URL>`.
|
40
|
+
|
41
|
+
### Script It
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'linkey'
|
45
|
+
|
46
|
+
url = 'http://www.live.bbc.co.uk/radio'
|
47
|
+
base = 'http://www.live.bbc.co.uk'
|
48
|
+
reg = '/radio'
|
49
|
+
filename = 'arabic.md'
|
50
|
+
|
51
|
+
page = Linkey::SaveLinks.new(url, filename)
|
52
|
+
status = Linkey::CheckResponse.new(url, base, reg, filename)
|
53
|
+
|
54
|
+
page.capture_links
|
55
|
+
status.check_links
|
56
|
+
```
|
57
|
+
|
58
|
+
### From a File
|
59
|
+
|
60
|
+
If you have a lot of URLs that you want to check all the time using from a file is an alternative option. This will utilise the smoke option, then point to a YAML file with the extension. In some situations, we are deploying applications that we don't want public facing, so ensuring they 404 is essential. There is a status code option to allow a specific status code to be set against a group of URL's, ensuring builds fail if the right code conditions are met.
|
61
|
+
|
62
|
+
```
|
63
|
+
linkey smoke test.yaml
|
64
|
+
```
|
65
|
+
|
66
|
+
Example YAML Config:
|
67
|
+
|
68
|
+
```yaml
|
69
|
+
base: 'http://www.bbc.co.uk'
|
70
|
+
|
71
|
+
concurrency: 100
|
72
|
+
|
73
|
+
headers:
|
74
|
+
-
|
75
|
+
X-content-override: 'https://example.com'
|
76
|
+
|
77
|
+
status_code: 200
|
78
|
+
|
79
|
+
paths:
|
80
|
+
- /radio
|
81
|
+
- /radio/new
|
82
|
+
```
|
83
|
+
|
84
|
+
Via a Ruby script:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
require 'linkey'
|
88
|
+
|
89
|
+
tests = Linkey::Checker.new("path/to.yaml")
|
90
|
+
tests.smoke
|
91
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "linksta"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/linksta
ADDED
data/bin/setup
ADDED
data/lib/linksta/cli.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "linksta"
|
3
|
+
|
4
|
+
class Linkey::CLI < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
desc "scan", "Save some URL's"
|
8
|
+
def scan(url, filename)
|
9
|
+
html = Linkey::SaveLinks.new(url, filename)
|
10
|
+
html.capture_links
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "status", "checks links for errors"
|
14
|
+
def status(url, base, reg, filename)
|
15
|
+
status = Linkey::CheckResponse.new(url, base, reg, filename)
|
16
|
+
status.check_links
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "check URL Base_URL Regex File", "A full linksta job"
|
20
|
+
def check(url, base, reg, filename)
|
21
|
+
scan(url, filename)
|
22
|
+
status(url, base, reg, filename)
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "smoke [path/to/file]", "A linksta job using predetermined URL's"
|
26
|
+
def smoke(file)
|
27
|
+
check = Linkey::Checker.new(file)
|
28
|
+
check.smoke
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
var system = require('system');
|
2
|
+
var page = require('webpage').create();
|
3
|
+
var fs = require('fs');
|
4
|
+
|
5
|
+
var url = system.args[1];
|
6
|
+
var lastRequestTimeout;
|
7
|
+
var finalTimeout;
|
8
|
+
var currentRequests = 0;
|
9
|
+
|
10
|
+
// You can place custom headers here, example below.
|
11
|
+
// page.customHeaders = {
|
12
|
+
|
13
|
+
// 'X-Candy-OVERRIDE': 'https://api.live.bbc.co.uk/',
|
14
|
+
// 'X-Country': 'cn'
|
15
|
+
|
16
|
+
// };
|
17
|
+
|
18
|
+
// If you want to set a cookie, just add your details below in the following way.
|
19
|
+
|
20
|
+
phantom.addCookie({
|
21
|
+
'name': 'ckns_policy',
|
22
|
+
'value': '111',
|
23
|
+
'domain': '.bbc.co.uk'
|
24
|
+
});
|
25
|
+
phantom.addCookie({
|
26
|
+
'name': 'locserv',
|
27
|
+
'value': '1#l1#i=6691484:n=Oxford+Circus:h=e@w1#i=8:p=London@d1#1=l:2=e:3=e:4=2@n1#r=40',
|
28
|
+
'domain': '.bbc.co.uk'
|
29
|
+
});
|
30
|
+
|
31
|
+
var checkLinks = function checkLinks () {
|
32
|
+
page.evaluate(function() {
|
33
|
+
var anchorsArray = Array.prototype.slice.call(document.querySelectorAll("a"));
|
34
|
+
|
35
|
+
anchorsArray.forEach(function(anchor) {
|
36
|
+
console.log(anchor.pathname);
|
37
|
+
});
|
38
|
+
|
39
|
+
window.callPhantom();
|
40
|
+
});
|
41
|
+
};
|
42
|
+
|
43
|
+
var debouncedCheckFinish = function debouncedCheckFinish () {
|
44
|
+
clearTimeout(lastRequestTimeout);
|
45
|
+
clearTimeout(finalTimeout);
|
46
|
+
|
47
|
+
if (currentRequests < 1) {
|
48
|
+
clearTimeout(finalTimeout);
|
49
|
+
lastRequestTimeout = setTimeout(function() {
|
50
|
+
// Page has finished loading all resources
|
51
|
+
// Do stuff here
|
52
|
+
checkLinks();
|
53
|
+
}, 1000);
|
54
|
+
}
|
55
|
+
|
56
|
+
finalTimeout = setTimeout(function() {
|
57
|
+
// Page is tired of waiting for resources to load
|
58
|
+
// Exit but do stuff anyway
|
59
|
+
|
60
|
+
checkLinks();
|
61
|
+
}, 9000);
|
62
|
+
};
|
63
|
+
|
64
|
+
page.onResourceRequested = function(req) {
|
65
|
+
currentRequests += 1;
|
66
|
+
};
|
67
|
+
|
68
|
+
page.onResourceReceived = function(res) {
|
69
|
+
if (res.stage === 'end') {
|
70
|
+
currentRequests -= 1;
|
71
|
+
debouncedCheckFinish();
|
72
|
+
}
|
73
|
+
};
|
74
|
+
|
75
|
+
page.onConsoleMessage = function(msg) {
|
76
|
+
console.log(msg);
|
77
|
+
};
|
78
|
+
|
79
|
+
page.onCallback = function() {
|
80
|
+
phantom.exit();
|
81
|
+
};
|
82
|
+
|
83
|
+
page.open(url, function(status) {
|
84
|
+
if (status === 'fail') {
|
85
|
+
console.error('Couldn\'t load url');
|
86
|
+
phantom.exit(1);
|
87
|
+
}
|
88
|
+
});
|
data/lib/linksta.rb
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
require "linksta/version"
|
2
|
+
require "yaml"
|
3
|
+
require "typhoeus"
|
4
|
+
|
5
|
+
module Linksta
|
6
|
+
autoload :CLI, "linksta/cli"
|
7
|
+
|
8
|
+
class CheckResponse
|
9
|
+
attr_accessor :url, :base, :reg, :file_name
|
10
|
+
|
11
|
+
def initialize(url, base, reg, file_name)
|
12
|
+
@url = url
|
13
|
+
@base = base
|
14
|
+
@reg = reg
|
15
|
+
@file_name = file_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_links
|
19
|
+
links_list = File.read(file_name).split(",")
|
20
|
+
links(links_list)
|
21
|
+
end
|
22
|
+
|
23
|
+
def links(links)
|
24
|
+
links.each do |url_links|
|
25
|
+
scan(url_links)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def scan(page_links)
|
30
|
+
urls = page_links.scan(/^#{Regexp.quote(reg)}(?:|.+)?$/)
|
31
|
+
Getter.new(urls, base, 100, 200, {}).check
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class SaveLinks
|
36
|
+
attr_accessor :url, :file_name
|
37
|
+
|
38
|
+
def initialize(url, file_name)
|
39
|
+
@url = url
|
40
|
+
@file_name = file_name
|
41
|
+
end
|
42
|
+
|
43
|
+
def js_file
|
44
|
+
File.expand_path("linksta/javascript/snap.js", File.dirname(__FILE__))
|
45
|
+
end
|
46
|
+
|
47
|
+
def capture_links
|
48
|
+
puts `phantomjs "#{js_file}" "#{url}" > "#{file_name}"`
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Checker
|
53
|
+
attr_accessor :config
|
54
|
+
|
55
|
+
def initialize(config)
|
56
|
+
@config = YAML.load(File.open("#{config}"))
|
57
|
+
end
|
58
|
+
|
59
|
+
def base
|
60
|
+
config["base"]
|
61
|
+
end
|
62
|
+
|
63
|
+
def concurrency
|
64
|
+
config["concurrency"] ? config["concurrency"] : 100
|
65
|
+
end
|
66
|
+
|
67
|
+
def status_code
|
68
|
+
config["status_code"] ? config["status_code"] : 200
|
69
|
+
end
|
70
|
+
|
71
|
+
def smoke
|
72
|
+
urls = config["paths"]
|
73
|
+
options = config["headers"]
|
74
|
+
headers = Hash[*options]
|
75
|
+
Getter.new(urls, base, concurrency, status_code, { :headers => headers }).check
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Getter
|
80
|
+
def initialize(paths, base, concurrency, status, headers)
|
81
|
+
@paths = paths
|
82
|
+
@base = base
|
83
|
+
@headers = headers
|
84
|
+
@status = status
|
85
|
+
|
86
|
+
@hydra = Typhoeus::Hydra.new(:max_concurrency => concurrency)
|
87
|
+
end
|
88
|
+
|
89
|
+
def check
|
90
|
+
puts "Checking..."
|
91
|
+
|
92
|
+
paths.each do |path|
|
93
|
+
begin
|
94
|
+
Typhoeus::Request.new(url(path), options).tap do |req|
|
95
|
+
req.on_complete { |r| parse_response(r, status) }
|
96
|
+
hydra.queue req
|
97
|
+
end
|
98
|
+
rescue URI::InvalidURIError
|
99
|
+
puts "Error with URL #{path}, please check config."
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
hydra.run
|
104
|
+
check_for_broken
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
attr_reader :base, :headers, :paths, :status, :concurrency, :hydra
|
110
|
+
|
111
|
+
def check_for_broken
|
112
|
+
puts "Checking"
|
113
|
+
if output.empty?
|
114
|
+
puts 'URL\'s are good, All Done!'
|
115
|
+
exit 0
|
116
|
+
else
|
117
|
+
puts "Buddy, you got a bad link"
|
118
|
+
puts output
|
119
|
+
exit 1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def make_request(url, status, status_code)
|
124
|
+
if status != status_code
|
125
|
+
puts "Status is NOT GOOD for #{url}, response is #{status}"
|
126
|
+
output << url
|
127
|
+
else
|
128
|
+
puts "Status is #{status} for #{url}"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def options
|
133
|
+
{
|
134
|
+
:followlocation => true,
|
135
|
+
:ssl_verifypeer => false,
|
136
|
+
:headers => headers[:headers]
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def output
|
141
|
+
@output ||= []
|
142
|
+
end
|
143
|
+
|
144
|
+
def parse_response(resp, status)
|
145
|
+
make_request(
|
146
|
+
resp.options[:effective_url],
|
147
|
+
resp.code,
|
148
|
+
status
|
149
|
+
)
|
150
|
+
rescue
|
151
|
+
puts "Unable to get status code"
|
152
|
+
end
|
153
|
+
|
154
|
+
def url(path)
|
155
|
+
"#{base}#{path}"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
data/linksta.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "linksta/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "linksta"
|
8
|
+
spec.version = Linksta::VERSION
|
9
|
+
spec.authors = ["CAP Testers"]
|
10
|
+
spec.email = ["anthony.kaluuma@bbc.co.uk"]
|
11
|
+
spec.summary = "linksta"
|
12
|
+
spec.description = "linksta"
|
13
|
+
spec.homepage = "https://www.test.bbc.co.uk/radio/play/live:radio1"
|
14
|
+
spec.license = "Apache 2"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency "thor"
|
21
|
+
spec.add_runtime_dependency "typhoeus"
|
22
|
+
|
23
|
+
spec.add_development_dependency "pry"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "linksta"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: linksta
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- CAP Testers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: typhoeus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
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'
|
83
|
+
description: linksta
|
84
|
+
email:
|
85
|
+
- anthony.kaluuma@bbc.co.uk
|
86
|
+
executables:
|
87
|
+
- console
|
88
|
+
- linksta
|
89
|
+
- setup
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".gitignore"
|
94
|
+
- ".rspec"
|
95
|
+
- ".travis.yml"
|
96
|
+
- CODE_OF_CONDUCT.md
|
97
|
+
- Gemfile
|
98
|
+
- Gemfile.lock
|
99
|
+
- LICENSE.txt
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- bin/console
|
103
|
+
- bin/linksta
|
104
|
+
- bin/setup
|
105
|
+
- lib/linksta.rb
|
106
|
+
- lib/linksta/cli.rb
|
107
|
+
- lib/linksta/javascript/snap.js
|
108
|
+
- lib/linksta/version.rb
|
109
|
+
- linksta.gemspec
|
110
|
+
- spec/linksta_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
homepage: https://www.test.bbc.co.uk/radio/play/live:radio1
|
113
|
+
licenses:
|
114
|
+
- Apache 2
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.6.12
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: linksta
|
136
|
+
test_files: []
|