sitemap-parser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/sitemap-parser.rb +21 -0
  3. metadata +58 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4400cd1c01a7ddd1e14138400cd7fe466a94a1e9
4
+ data.tar.gz: 521034f84d2c559faf186a3e878d1332bfcbcffb
5
+ SHA512:
6
+ metadata.gz: ce84140c6c7663b06d2543d14b9c032f32c3bc8d851e057a803854611a51c15029448c7b6fef30e6e325aab69644ed81f4e0b49b75fe0f5da4d8bc502e0122e7
7
+ data.tar.gz: 8a1f3564cc5e4e60e8d9544292cce7b8251ed24757648bb357483f119d20e8996f881ae6030081cd855420541022597eaad56c1a9b27cbb335c89a738953026b
@@ -0,0 +1,21 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ class SitemapParser
5
+
6
+ def initialize(url)
7
+ @url = url
8
+ end
9
+
10
+ def sitemap
11
+ @sitemap ||= Nokogiri::XML(open(@url))
12
+ end
13
+
14
+ def urls
15
+ sitemap.at("urlset").search("url")
16
+ end
17
+
18
+ def to_a
19
+ urls.map { |url| url.at("loc").content }
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sitemap-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ben Balter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.1
27
+ description: ''
28
+ email: ben.balter@github.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/sitemap-parser.rb
34
+ homepage: https://github.com/benbalter/sitemap-parser
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.2.0
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: ''
58
+ test_files: []