jackasset 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/config/environment.rb +1 -0
- data/lib/jackasset/assets_checker.rb +13 -13
- data/lib/jackasset/cli.rb +1 -1
- data/lib/jackasset/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30e617451c504ea4d654ef8284f613bc9d7c5ce6
|
4
|
+
data.tar.gz: b0a704af7d016785fc7d1cd035c48a73b89b5b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 735eee32366519f9c2be0bbdd49f80fc0ef9429d6324a625104318bfcf4a38aeb4db0b44b6c96e56ee73dfdb3d372240d20bfc21a323f3e943a507568cee4a3f
|
7
|
+
data.tar.gz: 6eadf73c72adc2f9e1ccac052cc10570277da80a0dba16add5f499a2d7721b473b7566af15c9cbdbb2e8212dd2a5c4bf54858e16e099da04edd6d21ac71dfb5a
|
data/README.md
CHANGED
@@ -2,13 +2,19 @@
|
|
2
2
|
|
3
3
|
A Ruby CLI for checking local static site assets.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Installation
|
6
6
|
|
7
|
+
```sh
|
8
|
+
gem install jackasset
|
7
9
|
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```sh
|
8
14
|
jackasset [-p PORT] path/to/html_files
|
9
15
|
```
|
10
16
|
|
11
|
-
```
|
17
|
+
```sh
|
12
18
|
$ jackasset path/to/html_files
|
13
19
|
200 OK http://localhost:8080/images/posts/deciphering-metrics/turbulence-d401c085.jpg
|
14
20
|
404 Not Found http://localhost:8080//platform.twitter.com/widgets.js
|
data/config/environment.rb
CHANGED
@@ -16,9 +16,9 @@ module Jackasset
|
|
16
16
|
|
17
17
|
def call
|
18
18
|
img_urls
|
19
|
-
threads = img_urls.each_with_object([]) do |url,
|
19
|
+
threads = img_urls.each_with_object([]) do |url, thread_list|
|
20
20
|
next unless url.match?(/\Ahttp/)
|
21
|
-
|
21
|
+
thread_list << Thread.new { check_url url }
|
22
22
|
end
|
23
23
|
threads.each(&:join)
|
24
24
|
puts "Finished checking #{img_urls.count} URLs and found #{num_issues} issues"
|
@@ -31,22 +31,22 @@ module Jackasset
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def clean_url(url)
|
34
|
-
cleaned_url = url.
|
35
|
-
cleaned_url.gsub!
|
36
|
-
cleaned_url.slice!
|
34
|
+
cleaned_url = url.sub('src=', '').delete('"').strip # Remove src, quotes, and whitespace
|
35
|
+
cleaned_url.gsub!(/\A\/\//, 'http://') # Set protocol if needed
|
36
|
+
cleaned_url.slice!(/\A\//) # Remove single leading slash
|
37
37
|
cleaned_url.match?(/\Ahttp/) ? cleaned_url : "#{host}/#{cleaned_url}"
|
38
38
|
end
|
39
39
|
|
40
40
|
def display_result(response)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
41
|
+
msg = " #{response.code} #{response.message} #{response.uri}\n"
|
42
|
+
case response
|
43
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
44
|
+
print msg.green
|
45
|
+
else
|
46
|
+
@num_issues += 1
|
47
|
+
print msg.red
|
49
48
|
end
|
49
|
+
end
|
50
50
|
|
51
51
|
def img_urls
|
52
52
|
@img_urls ||= Dir["#{source_dir}/**/*.html"].each_with_object([]) do |path, urls|
|
data/lib/jackasset/cli.rb
CHANGED
data/lib/jackasset/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackasset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McCormack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|