verify_redirects 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6a0da269c22a7e718d62862af5e575de7fd77b4aec6b7808773069dd3343ba9c
4
+ data.tar.gz: 06aa4078b28993259ab1901fdd488fe29a1583143e5620383c56334250f1de04
5
+ SHA512:
6
+ metadata.gz: 15f14068cf835bb5e07df9a28896c3b4b5703274950aaec4d3ae64f0d63e2e45e5cc75e0b0494bcc33aed5f6d3ae17f75096266e922ce06ffde99df3966098a5
7
+ data.tar.gz: c879e2ade5678cb45e450a0ce994f4eff078cf620fc6a639a754bd62c5b279103a938f581673d550a5712bef87195612b3982737de433cdd032002d907724edc
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ Gemfile.lock
14
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ inherit_from: .ruby-style-guide.yml
2
+ AllCops:
3
+ UseCache: true
4
+ CacheRootDirectory: tmp
5
+ Exclude:
6
+ - 'tmp/*.rb'
@@ -0,0 +1,265 @@
1
+ Rails:
2
+ Enabled: false
3
+ AllCops:
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - "vendor/**/*"
7
+ UseCache: true
8
+ Style/CollectionMethods:
9
+ Description: Preferred collection methods.
10
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
11
+ Enabled: true
12
+ PreferredMethods:
13
+ collect: map
14
+ collect!: map!
15
+ find: detect
16
+ find_all: select
17
+ reduce: inject
18
+ Style/RedundantFreeze:
19
+ Description: "Checks usages of Object#freeze on immutable objects."
20
+ Enabled: false
21
+ Layout/DotPosition:
22
+ Description: Checks the position of the dot in multi-line method calls.
23
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
24
+ Enabled: true
25
+ EnforcedStyle: trailing
26
+ SupportedStyles:
27
+ - leading
28
+ - trailing
29
+ Naming/FileName:
30
+ Description: Use snake_case for source file names.
31
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
32
+ Enabled: false
33
+ Exclude: []
34
+ Naming/MemoizedInstanceVariableName:
35
+ Description: Memoized method name should match memo instance variable name.
36
+ Enabled: false
37
+ Naming/UncommunicativeMethodParamName:
38
+ Description: >-
39
+ Checks for method parameter names that contain capital letters,
40
+ end in numbers, or do not meet a minimal length.
41
+ Enabled: false
42
+ Style/GuardClause:
43
+ Description: Check for conditionals that can be replaced with guard clauses
44
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
45
+ Enabled: true
46
+ MinBodyLength: 3
47
+ Style/IfUnlessModifier:
48
+ Description: Favor modifier if/unless usage when you have a single-line body.
49
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
50
+ Enabled: false
51
+ Style/OptionHash:
52
+ Description: Don't use option hashes when you can use keyword arguments.
53
+ Enabled: false
54
+ Style/PercentLiteralDelimiters:
55
+ Description: Use `%`-literal delimiters consistently
56
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
57
+ Enabled: false
58
+ PreferredDelimiters:
59
+ "%": "()"
60
+ "%i": "()"
61
+ "%q": "()"
62
+ "%Q": "()"
63
+ "%r": "{}"
64
+ "%s": "()"
65
+ "%w": "()"
66
+ "%W": "()"
67
+ "%x": "()"
68
+ Naming/PredicateName:
69
+ Description: Check the names of predicate methods.
70
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
71
+ Enabled: true
72
+ NamePrefix:
73
+ - is_
74
+ - has_
75
+ - have_
76
+ NamePrefixBlacklist:
77
+ - is_
78
+ Exclude:
79
+ - spec/**/*
80
+ Style/RaiseArgs:
81
+ Description: Checks the arguments passed to raise/fail.
82
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
83
+ Enabled: false
84
+ EnforcedStyle: exploded
85
+ SupportedStyles:
86
+ - compact
87
+ - exploded
88
+ Style/SignalException:
89
+ Description: Checks for proper usage of fail and raise.
90
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
91
+ Enabled: false
92
+ EnforcedStyle: semantic
93
+ SupportedStyles:
94
+ - only_raise
95
+ - only_fail
96
+ - semantic
97
+ Style/SingleLineBlockParams:
98
+ Description: Enforces the names of some block params.
99
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
100
+ Enabled: false
101
+ Methods:
102
+ - reduce:
103
+ - a
104
+ - e
105
+ - inject:
106
+ - a
107
+ - e
108
+ Style/TrivialAccessors:
109
+ Enabled: false
110
+ Style/SingleLineMethods:
111
+ Description: Avoid single-line methods.
112
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
113
+ Enabled: false
114
+ AllowIfMethodIsEmpty: true
115
+ Style/StringLiterals:
116
+ Description: Checks if uses of quotes match the configured preference.
117
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
118
+ Enabled: true
119
+ EnforcedStyle: single_quotes
120
+ SupportedStyles:
121
+ - single_quotes
122
+ - double_quotes
123
+ Style/MixinUsage:
124
+ Enabled: true
125
+ Exclude:
126
+ - exe/*
127
+ Style/StringLiteralsInInterpolation:
128
+ Description: Checks if uses of quotes inside expressions in interpolated strings
129
+ match the configured preference.
130
+ Enabled: true
131
+ EnforcedStyle: single_quotes
132
+ SupportedStyles:
133
+ - single_quotes
134
+ - double_quotes
135
+ Style/TrailingCommaInArrayLiteral:
136
+ Description: Checks for trailing comma in parameter lists and literals.
137
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
138
+ Enabled: true
139
+ EnforcedStyleForMultiline: comma
140
+ Style/TrailingCommaInHashLiteral:
141
+ Description: Checks for trailing comma in parameter lists and literals.
142
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
143
+ Enabled: true
144
+ EnforcedStyleForMultiline: comma
145
+ Metrics/AbcSize:
146
+ Description: A calculated magnitude based on number of assignments, branches, and
147
+ conditions.
148
+ Enabled: false
149
+ Max: 15
150
+ Metrics/ClassLength:
151
+ Description: Avoid classes longer than 100 lines of code.
152
+ Enabled: false
153
+ CountComments: false
154
+ Max: 100
155
+ Metrics/ModuleLength:
156
+ CountComments: false
157
+ Max: 100
158
+ Description: Avoid modules longer than 100 lines of code.
159
+ Enabled: false
160
+ Metrics/CyclomaticComplexity:
161
+ Description: A complexity metric that is strongly correlated to the number of test
162
+ cases needed to validate a method.
163
+ Enabled: false
164
+ Max: 6
165
+ Metrics/MethodLength:
166
+ Description: Avoid methods longer than 10 lines of code.
167
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
168
+ Enabled: false
169
+ CountComments: false
170
+ Max: 10
171
+ Metrics/ParameterLists:
172
+ Description: Avoid parameter lists longer than three or four parameters.
173
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
174
+ Enabled: false
175
+ Max: 5
176
+ CountKeywordArgs: true
177
+ Metrics/PerceivedComplexity:
178
+ Description: A complexity metric geared towards measuring complexity for a human
179
+ reader.
180
+ Enabled: false
181
+ Max: 7
182
+ Metrics/LineLength:
183
+ Description: Maximum line length
184
+ Enabled: true
185
+ Max: 95
186
+ Exclude:
187
+ - exe/verify_redirects
188
+ - lib/verify_redirects/cli.rb
189
+ - Gemfile
190
+ - verify_redirects.gemspec
191
+ - spec/**/*
192
+ Metrics/BlockLength:
193
+ Enabled: true
194
+ Exclude:
195
+ - lib/verify_redirects/cli/*
196
+ - spec/**/*
197
+ Lint/AssignmentInCondition:
198
+ Description: Don't use assignment in conditions.
199
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
200
+ Enabled: false
201
+ AllowSafeAssignment: true
202
+ Style/InlineComment:
203
+ Description: Avoid inline comments.
204
+ Enabled: false
205
+ Naming/AccessorMethodName:
206
+ Description: Check the naming of accessor methods for get_/set_.
207
+ Enabled: false
208
+ Style/Alias:
209
+ Description: Use alias_method instead of alias.
210
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
211
+ Enabled: false
212
+ Style/Documentation:
213
+ Description: Document classes and non-namespace modules.
214
+ Enabled: false
215
+ Style/DoubleNegation:
216
+ Description: Checks for uses of double negation (!!).
217
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
218
+ Enabled: false
219
+ Style/EachWithObject:
220
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
221
+ Enabled: false
222
+ Style/EmptyLiteral:
223
+ Description: Prefer literals to Array.new/Hash.new/String.new.
224
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
225
+ Enabled: false
226
+ Style/ModuleFunction:
227
+ Description: Checks for usage of `extend self` in modules.
228
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
229
+ Enabled: false
230
+ Style/OneLineConditional:
231
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
232
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
233
+ Enabled: false
234
+ Style/PerlBackrefs:
235
+ Description: Avoid Perl-style regex back references.
236
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
237
+ Enabled: false
238
+ Style/Send:
239
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
240
+ may overlap with existing methods.
241
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
242
+ Enabled: false
243
+ Style/SpecialGlobalVars:
244
+ Description: Avoid Perl-style global variables.
245
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
246
+ Enabled: false
247
+ Style/VariableInterpolation:
248
+ Description: Don't interpolate global, instance and class variables directly in
249
+ strings.
250
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
251
+ Enabled: false
252
+ Style/WhenThen:
253
+ Description: Use when x then ... for one-line cases.
254
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
255
+ Enabled: false
256
+ Lint/EachWithObjectArgument:
257
+ Description: Check for immutable argument given to each_with_object.
258
+ Enabled: true
259
+ Lint/HandleExceptions:
260
+ Description: Don't suppress exception.
261
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
262
+ Enabled: false
263
+ Lint/LiteralInInterpolation:
264
+ Description: Checks for literals used in interpolation.
265
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in verify_redirects.gemspec
8
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Jacob Burenstam Linder
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,76 @@
1
+ # VerifyRedirects - Verify HTTP redirects
2
+
3
+ Verify HTTP redirects - comes with CLI and CSV support (you can of course use plain Ruby too).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'verify_redirects'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install verify_redirects
20
+
21
+ ## CLI usage
22
+
23
+ ```
24
+ Usage: verify_redirects --help
25
+ --input=val0 CSV file path (required) - must be a file with two columns: from_url, to_url
26
+ --output=val0 CSV output path (optional)
27
+ --[no-]debug Print debug output (default: false)
28
+ -h, --help How to use
29
+ ```
30
+
31
+ ## Ruby usage
32
+
33
+ Use the verifier directly
34
+ ```ruby
35
+ verifier = Verifier.new
36
+
37
+ [
38
+ # from_url, to_url
39
+ %w[http://example.com/jacobburenstam https://jacobburenstam.com/]
40
+ # ...
41
+ ].each do |data|
42
+ from, to = data
43
+ result = verifier.call(from, to)
44
+
45
+ result.success # => false
46
+ result.start_url # => 'http://example.com/jacobburenstam'
47
+ result.expected_redirect # => 'https://jacobburenstam.com/'
48
+ result.redirected_to # => nil
49
+ end
50
+
51
+ verifier.results.length # => 1
52
+ ```
53
+
54
+ From CSV-files
55
+
56
+ ```ruby
57
+ VerifyRedirects.from_csv(input_path: input_path, output_path: output_path) do |result|
58
+ unless result.success
59
+ puts "Failed redirect for #{result.start_url}"
60
+ end
61
+ end
62
+ ```
63
+
64
+ ## Development
65
+
66
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
67
+
68
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
+
70
+ ## Contributing
71
+
72
+ Bug reports and pull requests are welcome on GitHub at https://github.com/buren/verify_redirects.
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'verify_redirects'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # USAGE:
5
+ # $ verify_redirects --help
6
+
7
+ # for dev purposes
8
+ require 'bundler/setup' if ENV['VERIFY_REDIRECTS_GEM_DEV']
9
+
10
+ require 'verify_redirects'
11
+ require 'verify_redirects/cli'
12
+
13
+ options = VerifyRedirects::CLI.parse(argv: ARGV, name: 'verify_redirects')
14
+
15
+ input_path = options[:input] || fail(ArgumentError, '--input required - CSV file path must be provided')
16
+ output_path = options[:output] || input_path.gsub(/\.csv/, '-redirect-results.csv')
17
+ debug = options.fetch(:debug, false)
18
+
19
+ VerifyRedirects.configure { |c| c.debug = debug }
20
+
21
+ VerifyRedirects.from_csv(input_path: input_path, output_path: output_path) do |result|
22
+ unless result.success
23
+ loc_part = if result.redirected_to
24
+ "instead redirected to #{result.redirected_to}"
25
+ else
26
+ "didn't redirect"
27
+ end
28
+ puts "[FAILED] #{result.start_url} should redirect to #{result.expected_redirect} but #{loc_part}."
29
+ end
30
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'verify_redirects/version'
4
+ require 'verify_redirects/verifier'
5
+
6
+ module VerifyRedirects
7
+ def self.from_csv(input_path:, output_path:)
8
+ verifier = Verifier.new
9
+
10
+ input_csv = HoneyFormat::CSV.new(File.read(input_path))
11
+
12
+ header = %w[success from redirected_to expected_redirect]
13
+ rows = input_csv.rows.map do |row|
14
+ result = verifier.call(row.from_url, row.to_url)
15
+ yield(result) if block_given?
16
+ result.to_a
17
+ end
18
+ output_csv = HoneyFormat::Matrix.new(rows, header: header).to_csv
19
+
20
+ File.write(output_path, output_csv)
21
+ end
22
+
23
+ def self.configuration
24
+ @configuration ||= Configuration.new
25
+ end
26
+
27
+ def self.config
28
+ configuration
29
+ end
30
+
31
+ def self.configure
32
+ yield(configuration) if block_given?
33
+ configuration
34
+ end
35
+
36
+ class Configuration
37
+ attr_accessor :debug
38
+
39
+ def initialize
40
+ @debug = false
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
4
+
5
+ module VerifyRedirects
6
+ class CLI
7
+ def self.parse(argv:, name:)
8
+ options = {}
9
+ OptionParser.new do |parser|
10
+ parser.banner = "Usage: #{name} --help"
11
+ parser.default_argv = argv
12
+
13
+ parser.on('--input=val0', String, 'CSV file path (required) - must be a file with two columns: from_url, to_url') do |string|
14
+ options[:input] = string
15
+ end
16
+
17
+ parser.on('--output=val0', String, 'CSV output path (optional)') do |string|
18
+ options[:output] = string
19
+ end
20
+
21
+ parser.on('--[no-]debug', 'Print debug output (default: false)') do |boolean|
22
+ options[:debug] = boolean
23
+ end
24
+
25
+ parser.on('-h', '--help', 'How to use') do
26
+ puts parser
27
+ exit
28
+ end
29
+ end.parse!
30
+
31
+ options
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'csv'
4
+
5
+ module VerifyRedirects
6
+ class Result
7
+ attr_reader :success, :start_url, :redirected_to, :expected_redirect
8
+
9
+ def initialize(success:, start_url:, redirected_to:, expected_redirect:)
10
+ @success = success
11
+ @start_url = start_url
12
+ @redirected_to = redirected_to
13
+ @expected_redirect = expected_redirect
14
+ end
15
+
16
+ def to_a
17
+ [success, start_url, redirected_to, expected_redirect]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'honey_format'
4
+ require 'http'
5
+
6
+ require 'verify_redirects/result'
7
+
8
+ module VerifyRedirects
9
+ class Verifier
10
+ attr_reader :results
11
+
12
+ def initialize
13
+ @results = []
14
+ end
15
+
16
+ def call(from_url, expected_to)
17
+ url = to_url(from_url)
18
+ expected_redirect = remove_spaces(expected_to)&.force_encoding('UTF-8')
19
+
20
+ puts "GET #{url}" if debug?
21
+ response = Http.get(url)
22
+ # Paths can contain scary characters: 'sa-far-du-ersatt\xE2\x80\xA6marens-flygstrul/'
23
+ redirected_to = response.headers['Location']&.force_encoding('UTF-8')
24
+ success = redirected_to == expected_redirect # if both are nil - no redirect is the success case
25
+
26
+ Result.new(
27
+ success: success,
28
+ start_url: url,
29
+ redirected_to: redirected_to,
30
+ expected_redirect: expected_redirect
31
+ ).tap { |r| @results << r }
32
+ end
33
+
34
+ private
35
+
36
+ def debug?
37
+ VerifyRedirects.config.debug
38
+ end
39
+
40
+ def remove_spaces(string)
41
+ string.to_s.gsub(/[[:space:]]/, '')
42
+ end
43
+
44
+ def to_url(url, scheme: 'http://')
45
+ url = remove_spaces(url)
46
+ return url if %w[http:// https://].any? { |s| url.start_with?(s) }
47
+
48
+ "#{scheme}#{url}"
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VerifyRedirects
4
+ VERSION = '0.1.1'.freeze
5
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'verify_redirects/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'verify_redirects'
9
+ spec.version = VerifyRedirects::VERSION
10
+ spec.authors = ['Jacob Burenstam']
11
+ spec.email = ['burenstam@gmail.com']
12
+
13
+ spec.summary = 'Verify HTTP redirects.'
14
+ spec.description = 'Verify HTTP redirects - comes with CLI and CSV support (you can of course use plain Ruby too).'
15
+ spec.homepage = 'https://github.com/buren/verify_redirects'
16
+ spec.license = 'MIT'
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_dependency 'honey_format', '~> 0.18'
28
+ spec.add_dependency 'http', '~> 3.3'
29
+
30
+ spec.add_development_dependency 'byebug'
31
+ spec.add_development_dependency 'bundler', '~> 1.16'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.0'
34
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: verify_redirects
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jacob Burenstam
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: honey_format
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: http
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
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: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: Verify HTTP redirects - comes with CLI and CSV support (you can of course
98
+ use plain Ruby too).
99
+ email:
100
+ - burenstam@gmail.com
101
+ executables:
102
+ - verify_redirects
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".rubocop.yml"
109
+ - ".ruby-style-guide.yml"
110
+ - ".travis.yml"
111
+ - Gemfile
112
+ - LICENSE
113
+ - README.md
114
+ - Rakefile
115
+ - bin/console
116
+ - bin/setup
117
+ - exe/verify_redirects
118
+ - lib/verify_redirects.rb
119
+ - lib/verify_redirects/cli.rb
120
+ - lib/verify_redirects/result.rb
121
+ - lib/verify_redirects/verifier.rb
122
+ - lib/verify_redirects/version.rb
123
+ - verify_redirects.gemspec
124
+ homepage: https://github.com/buren/verify_redirects
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.7.6
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Verify HTTP redirects.
148
+ test_files: []