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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bbac3afa95ece2628102ae3b506cccabb70bc13
4
- data.tar.gz: ea7dffdd2ae06384c0ec6028aae366552c07f66b
3
+ metadata.gz: 30e617451c504ea4d654ef8284f613bc9d7c5ce6
4
+ data.tar.gz: b0a704af7d016785fc7d1cd035c48a73b89b5b47
5
5
  SHA512:
6
- metadata.gz: 48843b2e7f6040aca68a88944938578dd533ddef1aa3f5cde2941588cdc208e11a70aa70dc86e691a98a81f5e2f82f55eb59bcbdc62815f7dae0a4e495b040af
7
- data.tar.gz: 15547d586c79a63c372793352451de5d58be92dd6df6f367390fcf0b9cb15da98008889ca633264f7b2abf1815ee6e88325528af455880c3c6153dbc16677af3
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
- ## Usage
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
@@ -5,6 +5,7 @@ require 'colorize'
5
5
  require 'csv'
6
6
  require 'net/http'
7
7
  require 'openssl'
8
+ require 'resolv-replace'
8
9
 
9
10
  require_relative '../lib/jackasset'
10
11
  require_relative '../lib/jackasset/assets_checker'
@@ -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, threads|
19
+ threads = img_urls.each_with_object([]) do |url, thread_list|
20
20
  next unless url.match?(/\Ahttp/)
21
- threads << Thread.new { check_url url }
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.gsub('src=', '').gsub('"', '').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
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
- msg = " #{response.code} #{response.message} #{response.uri.to_s}\n"
42
- case response
43
- when Net::HTTPSuccess, Net::HTTPRedirection
44
- print msg.green
45
- else
46
- @num_issues += 1
47
- print msg.red
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|
@@ -39,7 +39,7 @@ module Jackasset
39
39
  end
40
40
 
41
41
  def valid_port_arg?
42
- ARGV.first == '-p' && PORT_RANGE.include?(ARGV[1])
42
+ ARGV.first == '-p' && PORT_RANGE.include?(ARGV[1].to_i)
43
43
  end
44
44
  end
45
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jackasset
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
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.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-04-14 00:00:00.000000000 Z
11
+ date: 2017-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize