owasp_ri_scraper 0.0.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
+ SHA1:
3
+ metadata.gz: dbf591f8e7127156b0284bd8e90405b1b70c2594
4
+ data.tar.gz: b9a94cc3fa74f108e9fcc5e39ec266f6c85e63ba
5
+ SHA512:
6
+ metadata.gz: ba1d7e7e287385968d6daa232e8c8a3819b9ea13d41edc006b62cea31e17d67d5737a7c28161003d8731eecf1440d6781d78dfa19c4ba8ea9af375a56cb5286f
7
+ data.tar.gz: 623efca2c9475006e39cda9c6bb3055dbd845ce1476ff1c6f9965365a5ff93a5ba38d6277dfae523e03583fe5c13f9d85d01222fbcc343665810cfdf59d23a1d
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in owasp_ri_scraper.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matt Gillooly
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # OwaspRiScraper
2
+
3
+ Scrape currently scheduled event from [OWASP RI](https://www.owasp.org/index.php/Rhode_Island).
4
+ Built for automating updates to [PVDTechEvents.com](http://pvdtechevents.com/).
5
+
6
+ NOTE: Current implementation is extremely fragile, and will very likely break if any changes are made to the source page's layout.
7
+ Use at your own risk.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'owasp_ri_scraper'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install owasp_ri_scraper
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require 'owasp_ri_scraper'
27
+ event = OwaspRiScraper.scheduled_event
28
+ event.start_time #=> 2014-02-12 17:45:00 -0500
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ module OwaspRiScraper
2
+
3
+ class Event < Struct.new(:start_time, :end_time, :description)
4
+ end
5
+
6
+ end
@@ -0,0 +1,26 @@
1
+ require 'owasp_ri_scraper/event'
2
+ require 'nokogiri'
3
+
4
+ module OwaspRiScraper
5
+
6
+ class EventParser
7
+
8
+ # This method is extremely fragile, but so far OWASP.org has been sticking to
9
+ # the same format, so that may be okay.
10
+ def parse(content)
11
+ doc = Nokogiri::HTML.parse(content)
12
+ event_node = doc.css('div#mw-content-text pre').first
13
+
14
+ start_time = event_node.css('b').text
15
+ description = event_node.children.select(&:text?).map(&:text).join("\n").strip
16
+
17
+ Event.new(
18
+ Time.parse(start_time),
19
+ nil,
20
+ description
21
+ )
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,15 @@
1
+ require 'open-uri'
2
+
3
+ module OwaspRiScraper
4
+
5
+ class Homepage
6
+ def initialize(url='https://www.owasp.org/index.php/Rhode_Island')
7
+ @url = url
8
+ end
9
+
10
+ def content
11
+ open(@url).read
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,3 @@
1
+ module OwaspRiScraper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ require "owasp_ri_scraper/version"
2
+ require "owasp_ri_scraper/homepage"
3
+ require "owasp_ri_scraper/event_parser"
4
+
5
+ module OwaspRiScraper
6
+
7
+ def self.scheduled_event
8
+ homepage = Homepage.new
9
+ parser = EventParser.new
10
+ parser.parse(homepage.content)
11
+ end
12
+
13
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'owasp_ri_scraper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "owasp_ri_scraper"
8
+ spec.version = OwaspRiScraper::VERSION
9
+ spec.authors = ["Matt Gillooly"]
10
+ spec.email = ["matt@mattgillooly.com"]
11
+ spec.description = %q{Scrape currently scheduled event from OWASP.org for PVDTechEvents.com}
12
+ spec.summary = %q{OWASP.org event scraper}
13
+ spec.homepage = "http://pvdtechevents.com/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'nokogiri'
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "vcr"
26
+ spec.add_development_dependency "webmock"
27
+ spec.add_development_dependency "timecop"
28
+ end