Class: Snackhack2::SiteMap
- Inherits:
-
Object
- Object
- Snackhack2::SiteMap
- Defined in:
- lib/snackhack2/sitemap.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize ⇒ SiteMap
constructor
A new instance of SiteMap.
- #run ⇒ Object
Constructor Details
#initialize ⇒ SiteMap
Returns a new instance of SiteMap.
8 9 10 |
# File 'lib/snackhack2/sitemap.rb', line 8 def initialize @site = site end |
Instance Attribute Details
#site ⇒ Object
Returns the value of attribute site.
7 8 9 |
# File 'lib/snackhack2/sitemap.rb', line 7 def site @site end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/snackhack2/sitemap.rb', line 12 def run # adds `sitemap.xml` to the site given # defined in `@site` instance variable. sm = Snackhack2.get(File.join(@site, 'sitemap.xml')) # site returns 200 status code if sm.code.to_i.eql?(200) # checks the body of the page to detetmine if the words # `Not Found` is it unless sm.body.include?('Not Found') # the page did not include "Not Found". Saving the contents of the sitemap.xml # to a file. Snackhack2.file_save(@site, 'site.xml', sm.body) else puts "[+] Eh. I don't think the site has a sitemap. Manually check just in case... :(\n\n" end else puts "[+] Status Code: #{sm.code}" end end |