seo_report 0.1.1 → 0.1.2

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: e43cca8581863cf2f96787c1bc7d5540e1cbbb65
4
- data.tar.gz: 48da9cc13c59920b22fbfecfc64196dd1d2b1eea
3
+ metadata.gz: 0a0fa771b74ecf5037cc397b72df2e54bc651566
4
+ data.tar.gz: 3819ea29b3f5d13986927d1a33e57fcb95967b28
5
5
  SHA512:
6
- metadata.gz: b02574fbbcd9c1b22986f466e500a2b4147d7e2efdb79536f4f6ad3975e42717a9ca5c8400ec9e7080e630ee3c983c7783c215c42cbd60eeb86df94ae39fff54
7
- data.tar.gz: 922908e117fd759c82e6a12a6fc035a5672f4672b324a0d9527d099bb79815d588feb32b427b2e1355a286cf0452b77be763ae4b0cff9625e0b42041c8c256e7
6
+ metadata.gz: d8b6a81345d083b7aaacc45986b0568644ae7f0f079ae4a4f6d73c68b576bf6fd5dd5fe1beafae2a8d006dc7b5f9b00fc330011aec169abec90cc45ffef4a393
7
+ data.tar.gz: cd899d9827fc44b60836846406bebf1a93e7e9431fad5d2e31b275a5315a2efe491d6012246ba0cf93e799e21b8dbbc138bd4d6ced69f933c65092d76b52b2e1
@@ -42,6 +42,8 @@ module SeoReport::Representation
42
42
  location =
43
43
  if request[:location] == request[:request_url]
44
44
  red_color(request[:location], bold: true)
45
+ elsif request[:location].start_with?("/")
46
+ yellow_color(request[:location], bold: true)
45
47
  else
46
48
  request[:location]
47
49
  end
@@ -109,22 +111,26 @@ module SeoReport::Representation
109
111
  io.print(white_color(text))
110
112
  end
111
113
 
112
- def white_color(text, bold: true)
113
- color_with_code(text, code: 37, bold: bold)
114
+ def red_color(text, bold: false)
115
+ color_with_code(text, code: 31, bold: bold)
114
116
  end
115
117
 
116
118
  def green_color(text, bold: false)
117
119
  color_with_code(text, code: 32, bold: bold)
118
120
  end
119
121
 
120
- def red_color(text, bold: false)
121
- color_with_code(text, code: 31, bold: bold)
122
+ def yellow_color(text, bold: false)
123
+ color_with_code(text, code: 33, bold: bold)
122
124
  end
123
125
 
124
126
  def blue_color(text, bold: false)
125
127
  color_with_code(text, code: 34, bold: bold)
126
128
  end
127
129
 
130
+ def white_color(text, bold: true)
131
+ color_with_code(text, code: 37, bold: bold)
132
+ end
133
+
128
134
  def color_with_code(text, code:, bold: false)
129
135
  bold_val = bold ? 1 : 0
130
136
  "\033[#{bold_val};#{code}m#{text}\033[0m"
@@ -6,7 +6,7 @@ module SeoReport
6
6
  class Error < ::StandardError; end
7
7
  class NoRequestPerformedYetError < Error; end
8
8
 
9
- attr_reader :url, :headers
9
+ attr_reader :url
10
10
 
11
11
  def initialize(url, headers = {})
12
12
  @url = URI(url)
@@ -31,6 +31,12 @@ module SeoReport
31
31
  @response or raise NoRequestPerformedYetError.new(url)
32
32
  end
33
33
 
34
+ def headers
35
+ {
36
+ "User-Agent" => "seo-report/#{SeoReport::VERSION} Net::HTTP"
37
+ }.merge(@headers || {})
38
+ end
39
+
34
40
  protected
35
41
  def http_request
36
42
  @http_request ||= Net::HTTP::Get.new(url.request_uri, headers)
@@ -13,7 +13,7 @@ module SeoReport
13
13
  last_request.perform
14
14
  if has_redirection_response?(last_request)
15
15
  break if request_chain.length >= 10
16
- request_chain << Request.new(last_request.response["Location"])
16
+ request_chain << build_new_request
17
17
  else
18
18
  @terminal_request = request_chain.last
19
19
  break
@@ -26,9 +26,26 @@ module SeoReport
26
26
  request_chain.last
27
27
  end
28
28
 
29
+ def build_new_request
30
+ location = last_request.response["Location"]
31
+ url = build_url(last_request.url, location).to_s
32
+ Request.new(url)
33
+ end
34
+
29
35
  def has_redirection_response?(request)
30
36
  code = request.response.code.to_i
31
37
  code >= 300 && code < 400
32
38
  end
39
+
40
+ def build_url(base_url, url)
41
+ new_url = URI(url)
42
+ if new_url.relative?
43
+ base = URI(base_url)
44
+ new_url.scheme = base.scheme
45
+ new_url.host = base.host
46
+ new_url.port = base.port
47
+ end
48
+ new_url
49
+ end
33
50
  end
34
51
  end
@@ -1,3 +1,3 @@
1
1
  module SeoReport
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/seo_report.gemspec CHANGED
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "nokogiri", "~> 1.6.8"
23
- spec.add_dependency "json", "~> 2.0.1"
22
+ spec.add_dependency "nokogiri", "~> 1.6", ">= 1.6.8"
23
+ spec.add_dependency "json", "~> 2.0", ">= 2.0.1"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.10"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec"
28
- spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "rspec", "~> 3.5"
28
+ spec.add_development_dependency "pry", "~> 0.10"
29
29
  end
metadata CHANGED
@@ -1,20 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seo_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Reddehase
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-07 00:00:00.000000000 Z
11
+ date: 2016-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
22
  version: 1.6.8
20
23
  type: :runtime
@@ -22,6 +25,9 @@ dependencies:
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - - ">="
25
31
  - !ruby/object:Gem::Version
26
32
  version: 1.6.8
27
33
  - !ruby/object:Gem::Dependency
@@ -29,6 +35,9 @@ dependencies:
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ - - ">="
32
41
  - !ruby/object:Gem::Version
33
42
  version: 2.0.1
34
43
  type: :runtime
@@ -36,6 +45,9 @@ dependencies:
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.0'
50
+ - - ">="
39
51
  - !ruby/object:Gem::Version
40
52
  version: 2.0.1
41
53
  - !ruby/object:Gem::Dependency
@@ -70,30 +82,30 @@ dependencies:
70
82
  name: rspec
71
83
  requirement: !ruby/object:Gem::Requirement
72
84
  requirements:
73
- - - ">="
85
+ - - "~>"
74
86
  - !ruby/object:Gem::Version
75
- version: '0'
87
+ version: '3.5'
76
88
  type: :development
77
89
  prerelease: false
78
90
  version_requirements: !ruby/object:Gem::Requirement
79
91
  requirements:
80
- - - ">="
92
+ - - "~>"
81
93
  - !ruby/object:Gem::Version
82
- version: '0'
94
+ version: '3.5'
83
95
  - !ruby/object:Gem::Dependency
84
96
  name: pry
85
97
  requirement: !ruby/object:Gem::Requirement
86
98
  requirements:
87
- - - ">="
99
+ - - "~>"
88
100
  - !ruby/object:Gem::Version
89
- version: '0'
101
+ version: '0.10'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
93
105
  requirements:
94
- - - ">="
106
+ - - "~>"
95
107
  - !ruby/object:Gem::Version
96
- version: '0'
108
+ version: '0.10'
97
109
  description: Get a report with seo relevant data for a given URL, like redirects,
98
110
  canonical, robots, Soc. Med. data and so on.
99
111
  email:
@@ -108,7 +120,6 @@ files:
108
120
  - ".travis.yml"
109
121
  - Gemfile
110
122
  - LICENSE
111
- - LICENSE.txt
112
123
  - README.md
113
124
  - Rakefile
114
125
  - bin/console
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Tim Reddehase
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.