broken_link_finder 0.9.3 → 0.11.1

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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: broken_link_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Telford
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-20 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,42 +100,42 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.20.3
103
+ version: '0.20'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.20.3
110
+ version: '0.20'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: thread
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.2.0
117
+ version: '0.2'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.2.0
124
+ version: '0.2'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: wgit
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.4.1
131
+ version: '0.9'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.4.1
138
+ version: '0.9'
139
139
  description: Finds a website's broken links using the 'wgit' gem and reports back
140
140
  to you with a summary.
141
141
  email: michael.telford@live.com
@@ -159,7 +159,10 @@ files:
159
159
  - exe/broken_link_finder
160
160
  - lib/broken_link_finder.rb
161
161
  - lib/broken_link_finder/finder.rb
162
- - lib/broken_link_finder/reporter.rb
162
+ - lib/broken_link_finder/link_manager.rb
163
+ - lib/broken_link_finder/reporter/html_reporter.rb
164
+ - lib/broken_link_finder/reporter/reporter.rb
165
+ - lib/broken_link_finder/reporter/text_reporter.rb
163
166
  - lib/broken_link_finder/version.rb
164
167
  - lib/broken_link_finder/wgit_extensions.rb
165
168
  - load.rb
@@ -168,6 +171,9 @@ licenses:
168
171
  - MIT
169
172
  metadata:
170
173
  source_code_uri: https://github.com/michaeltelford/broken-link-finder
174
+ changelog_uri: https://github.com/michaeltelford/broken-link-finder/blob/master/CHANGELOG.md
175
+ bug_tracker_uri: https://github.com/michaeltelford/broken-link-finder/issues
176
+ documentation_uri: https://www.rubydoc.info/gems/broken_link_finder
171
177
  allowed_push_host: https://rubygems.org
172
178
  post_install_message: Added the executable 'broken_link_finder' to $PATH
173
179
  rdoc_options: []
@@ -184,8 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
190
  - !ruby/object:Gem::Version
185
191
  version: '0'
186
192
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.7.6
193
+ rubygems_version: 3.1.2
189
194
  signing_key:
190
195
  specification_version: 4
191
196
  summary: Finds a website's broken links and reports back to you with a summary.
@@ -1,116 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BrokenLinkFinder
4
- class Reporter
5
- # The amount of pages/links to display when verbose is false.
6
- NUM_VALUES = 3
7
-
8
- # Creates a new Reporter instance.
9
- # stream is any Object that responds to :puts.
10
- def initialize(stream, sort, broken_links, ignored_links)
11
- raise 'stream must respond_to? :puts' unless stream.respond_to?(:puts)
12
- raise "sort by either :page or :link, not #{sort}" \
13
- unless %i[page link].include?(sort)
14
-
15
- @stream = stream
16
- @sort = sort
17
- @broken_links = broken_links
18
- @ignored_links = ignored_links
19
- end
20
-
21
- # Pretty print a report detailing the link summary.
22
- def pretty_print_link_report(broken_verbose: true, ignored_verbose: false)
23
- report_broken_links(verbose: broken_verbose)
24
- report_ignored_links(verbose: ignored_verbose)
25
-
26
- nil
27
- end
28
-
29
- private
30
-
31
- # Report a summary of the broken links.
32
- def report_broken_links(verbose: true)
33
- if @broken_links.empty?
34
- print 'Good news, there are no broken links!'
35
- else
36
- num_pages, num_links = get_hash_stats(@broken_links)
37
- print "Found #{num_links} broken link(s) across #{num_pages} page(s):"
38
-
39
- @broken_links.each do |key, values|
40
- msg = sort_by_page? ?
41
- "The following broken links were found on '#{key}':" :
42
- "The broken link '#{key}' was found on the following pages:"
43
- nprint msg
44
-
45
- if verbose || (values.length <= NUM_VALUES)
46
- values.each { |value| print value }
47
- else # Only print N values and summarise the rest.
48
- NUM_VALUES.times { |i| print values[i] }
49
-
50
- objects = sort_by_page? ? 'link(s)' : 'page(s)'
51
- print "+ #{values.length - NUM_VALUES} other #{objects}, remove --concise to see them all"
52
- end
53
- end
54
- end
55
- end
56
-
57
- # Report a summary of the ignored links.
58
- def report_ignored_links(verbose: false)
59
- if @ignored_links.any?
60
- num_pages, num_links = get_hash_stats(@ignored_links)
61
- nprint "Ignored #{num_links} unsupported link(s) across #{num_pages} page(s), which you should check manually:"
62
-
63
- @ignored_links.each do |key, values|
64
- msg = sort_by_page? ?
65
- "The following links were ignored on '#{key}':" :
66
- "The link '#{key}' was ignored on the following pages:"
67
- nprint msg
68
-
69
- if verbose || (values.length <= NUM_VALUES)
70
- values.each { |value| print value }
71
- else # Only print N values and summarise the rest.
72
- NUM_VALUES.times { |i| print values[i] }
73
-
74
- objects = sort_by_page? ? 'link(s)' : 'page(s)'
75
- print "+ #{values.length - NUM_VALUES} other #{objects}, use --verbose to see them all"
76
- end
77
- end
78
- end
79
- end
80
-
81
- # Return true if the sort is by page.
82
- def sort_by_page?
83
- @sort == :page
84
- end
85
-
86
- # Returns the key/value statistics of hash e.g. the number of keys and
87
- # combined values. The hash should be of the format: { 'str' => [...] }.
88
- # Use like: `num_pages, num_links = get_hash_stats(links)`.
89
- def get_hash_stats(hash)
90
- num_keys = hash.keys.length
91
- values = hash.values.flatten
92
- num_values = sort_by_page? ? values.length : values.uniq.length
93
-
94
- sort_by_page? ?
95
- [num_keys, num_values] :
96
- [num_values, num_keys]
97
- end
98
-
99
- # Prints the text + \n. Defaults to a blank line.
100
- def print(text = '')
101
- @stream.puts(text)
102
- end
103
-
104
- # Prints text + \n\n.
105
- def printn(text)
106
- print(text)
107
- print
108
- end
109
-
110
- # Prints \n + text + \n.
111
- def nprint(text)
112
- print
113
- print(text)
114
- end
115
- end
116
- end