gimme_poc 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2765f0ef20a443c6c37e7ffc7f2cfa83454ec6b
4
- data.tar.gz: 9761000cf90a2aba6549dfa774a5aff7f6daebff
3
+ metadata.gz: 6984d721d974f11b5dab3136323f68d924867ad6
4
+ data.tar.gz: 78503da039ce280bb1bb69898065b5d60a2d5463
5
5
  SHA512:
6
- metadata.gz: 48f94a4ecd20ab3db3197abcedecabeb8fb8a0fe7b4274fbff3d23bea395363bae69fe7bd3f42b56a5e701599e4780c367cae513b2ad95f9622167d99844011f
7
- data.tar.gz: 132fad4c4fdc308a0cc3b630314525d17e197e0dcc568f5690ffdcfd351e434b8a9b2d5d1a0e9be613077b155c7cd51ed2f17c7a3ad1e2919121c88a0126dc78
6
+ metadata.gz: 52770e7b95a98abc5638e7b017674f5c58b61b22bbed847bb009cc5092aea3f533922f0da9bd0a571c5e40050f26779c5734bb21c308f065742c66994f0faf16
7
+ data.tar.gz: b8405f565d973365c4bd05d6cab1f52295bd4b83c0fac858654e87d738cb3cf758096b6f5e2402716a2c768e11182479b71a6cad7c18869751a0fdadd9e6a7cf
@@ -1,3 +1,3 @@
1
1
  module Gimme
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/gimme_poc.rb CHANGED
@@ -9,7 +9,7 @@ module Gimme
9
9
 
10
10
  # Simple regex that looks for ###.#### or ###-####
11
11
  PHONE_REGEX = /\d{3}[-]\d{4}|\d{3}[.]\d{4}/
12
-
12
+
13
13
  # Captures http:// and https://
14
14
  HTTP_REGEX = /\A\bhttps:\/\/|\bhttp:\/\//
15
15
 
@@ -64,14 +64,15 @@ module Gimme
64
64
  puts '-' * 50
65
65
  puts "starting: #{url}"
66
66
  next if get(url).nil?
67
- puts "now looking for contact pages"
67
+ puts 'now looking for contact pages'
68
68
  start_contact_links
69
69
  mechpage = go_to_contact_page
70
+ next if mechpage.nil?
70
71
  save_available_contacts(mechpage.uri.to_s)
71
72
  end
72
73
  Search.all_sites
73
74
  end
74
-
75
+
75
76
  # Mechanize needs absolute urls to work.
76
77
  # If http:// or https:// isn't present, append http://.
77
78
  def format_url(str)
@@ -115,7 +116,7 @@ module Gimme
115
116
  def contact_page
116
117
  contact_link = link_with_href(/contact|Contact/)
117
118
  contact_test_page = merged_link('../contact')
118
-
119
+
119
120
  case
120
121
  when !contact_link.nil?
121
122
  puts "#{'success:'.green} Found contact link!\n"
@@ -138,32 +139,30 @@ module Gimme
138
139
  english_link = page.link_with(href: /english|English/)
139
140
  test_en_page = merged_link('../en')
140
141
  test_english_page = merged_link('../english')
141
-
142
+
142
143
  case
143
144
  when !english_link.nil?
144
145
  puts "#{'success:'.green} found english link!"
145
146
  get(merged(english_link)) # already merged link
146
147
  else
147
148
  blind_test(test_en_page) || blind_test(test_english_page)
148
- puts "ready to start again"
149
+ puts 'ready to start again'
149
150
  contact_page
150
151
  end
151
152
  end
152
153
 
153
- # TODO: Sometimes DNS will do a redirect and not give a 404.
154
+ # TODO: Sometimes DNS will do a redirect and not give a 404.
154
155
  # Need to prevent redirects.
155
156
  #
156
157
  # Blindly tests to see if a url goes through. If there is a 404 error,
157
158
  # this will return nil.
158
159
  def blind_test(url)
159
- begin
160
- puts "\nblind testing: #{url}"
161
- get(url)
162
- rescue Mechanize::ResponseCodeError
163
- puts "#{'404 Error:'.red} #{url}"
164
- end
160
+ puts "\nblind testing: #{url}"
161
+ get(url)
162
+ rescue Mechanize::ResponseCodeError
163
+ puts "#{'404 Error:'.red} #{url}"
165
164
  end
166
-
165
+
167
166
  ##
168
167
  # Used in case of relative paths. Merging guarantees correct url.
169
168
  # This needs a url string as argument to work.
@@ -180,7 +179,7 @@ module Gimme
180
179
  def link_with_href(str)
181
180
  merged_link(page.link_with(href: /\b#{str}/).uri.to_s)
182
181
  rescue
183
- nil
182
+ nil
184
183
  end
185
184
 
186
185
  ##
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimme_poc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mason
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.4.3
115
+ rubygems_version: 2.4.5
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Get a point of contact. Given a url or array of urls, extracts social media