pax 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8478557656508b4f47516afc8513b839be50ebf4
4
+ data.tar.gz: 53945f67b8c14d20d2b58c63659c9b3c3a60df67
5
+ SHA512:
6
+ metadata.gz: 8fa6f3a66dc86fbb055a986936d9a67144bea81d6ea3c463e593d67c900ad7f100af20d1de15e3188bbc433737fc5391aaf7bd0ea7c7a0b418cd7c0a8b969f1a
7
+ data.tar.gz: 1140ad45c8f619b8928410a393bfe2e2afa16bf55f3adfddf961a8e910f3d966cc51a3c19e537e3b8770dfe3e61e0d0edb89d3681f8c03976d92065e0f855179
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.0.0"
4
+ # uncomment this line if your project needs to run something other than `rake`:
5
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+ ruby "2.0.0"
4
+
5
+ gem "mechanize"
6
+ gem "rspec"
7
+ gem "webmock"
8
+ gem 'coveralls', require: false
9
+ # gem "rails"
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ coveralls (0.7.0)
6
+ multi_json (~> 1.3)
7
+ rest-client
8
+ simplecov (>= 0.7)
9
+ term-ansicolor
10
+ thor
11
+ crack (0.4.1)
12
+ safe_yaml (~> 0.9.0)
13
+ diff-lcs (1.2.5)
14
+ docile (1.1.1)
15
+ domain_name (0.5.15)
16
+ unf (>= 0.0.5, < 1.0.0)
17
+ http-cookie (1.0.2)
18
+ domain_name (~> 0.5)
19
+ mechanize (2.7.3)
20
+ domain_name (~> 0.5, >= 0.5.1)
21
+ http-cookie (~> 1.0)
22
+ mime-types (~> 2.0)
23
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
24
+ net-http-persistent (~> 2.5, >= 2.5.2)
25
+ nokogiri (~> 1.4)
26
+ ntlm-http (~> 0.1, >= 0.1.1)
27
+ webrobots (>= 0.0.9, < 0.2)
28
+ mime-types (2.0)
29
+ mini_portile (0.5.2)
30
+ multi_json (1.8.2)
31
+ net-http-digest_auth (1.4)
32
+ net-http-persistent (2.9)
33
+ nokogiri (1.6.0)
34
+ mini_portile (~> 0.5.0)
35
+ ntlm-http (0.1.1)
36
+ rest-client (1.6.7)
37
+ mime-types (>= 1.16)
38
+ rspec (2.14.1)
39
+ rspec-core (~> 2.14.0)
40
+ rspec-expectations (~> 2.14.0)
41
+ rspec-mocks (~> 2.14.0)
42
+ rspec-core (2.14.7)
43
+ rspec-expectations (2.14.4)
44
+ diff-lcs (>= 1.1.3, < 2.0)
45
+ rspec-mocks (2.14.4)
46
+ safe_yaml (0.9.7)
47
+ simplecov (0.8.2)
48
+ docile (~> 1.1.0)
49
+ multi_json
50
+ simplecov-html (~> 0.8.0)
51
+ simplecov-html (0.8.0)
52
+ term-ansicolor (1.2.2)
53
+ tins (~> 0.8)
54
+ thor (0.18.1)
55
+ tins (0.13.1)
56
+ unf (0.1.3)
57
+ unf_ext
58
+ unf_ext (0.0.6)
59
+ webmock (1.16.0)
60
+ addressable (>= 2.2.7)
61
+ crack (>= 0.3.2)
62
+ webrobots (0.1.1)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ coveralls
69
+ mechanize
70
+ rspec
71
+ webmock
data/lib/pax.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'pax/event'
2
+ require 'pax/version'
data/lib/pax/event.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'mechanize'
2
+
3
+ module PAX
4
+ class Event
5
+ def initialize(location)
6
+ @site = Mechanize.new.get("http://#{location}.paxsite.com/")
7
+ end
8
+
9
+ def site
10
+ @site.body
11
+ end
12
+
13
+ def registration_open?
14
+ @site.search(".registration").to_html =~ /open/ ? true : false
15
+ end
16
+
17
+ def registration_closed?
18
+ !registration_open?
19
+ end
20
+
21
+ def sold_out?
22
+ @site.search(".soldOut").to_html =~ /Sold Out/ ? true : false
23
+ end
24
+
25
+ def available?
26
+ !sold_out?
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module PAX
2
+ VERSION = "0.0.1"
3
+ end
data/readme.md ADDED
@@ -0,0 +1 @@
1
+ [![Code Climate](https://codeclimate.com/github/hersha/pax.png)](https://codeclimate.com/github/hersha/pax) [![Build Status](https://travis-ci.org/hersha/pax.png)](https://travis-ci.org/hersha/pax)
@@ -0,0 +1,40 @@
1
+ require_relative '../../../lib/pax/event'
2
+ require 'spec_helper'
3
+
4
+ module PAX
5
+ describe Event do
6
+ let(:pax_prime) { Event.new('prime') }
7
+ let(:pax_east) { Event.new('east') }
8
+ let(:html_header) { {content_type: 'text/html'} }
9
+ it 'scrapes the PAX Prime website' do
10
+ stub_request(:get, 'prime.paxsite.com').to_return(body: 'prime')
11
+ pax_prime
12
+ WebMock.should have_requested(:get, 'prime.paxsite.com')
13
+ end
14
+ it 'scrapes the PAX East website' do
15
+ stub_request(:get, 'east.paxsite.com').to_return(body: 'east')
16
+ pax_east
17
+ WebMock.should have_requested(:get, 'east.paxsite.com')
18
+ end
19
+ describe '#registration_open?' do
20
+ it 'returns true if PAX prime registration is open' do
21
+ stub_request(:get, 'prime.paxsite.com').to_return(body: '<div class="registration">open</div>', headers: html_header)
22
+ pax_prime.registration_open?.should == true
23
+ end
24
+ it 'returns false if PAX prime registration is closed' do
25
+ stub_request(:get, 'prime.paxsite.com').to_return(body: '<div class="registration">closed</div>', headers: html_header)
26
+ pax_prime.registration_open?.should == false
27
+ end
28
+ end
29
+ describe '#sold_out?' do
30
+ it 'returns true if PAX is sold out' do
31
+ stub_request(:get, 'prime.paxsite.com').to_return(body: '<div class="soldOut">Sold Out</div>', headers: html_header)
32
+ pax_prime.sold_out?.should == true
33
+ end
34
+ it 'returns false if PAX is not sold out' do
35
+ stub_request(:get, 'prime.paxsite.com').to_return(body: '<div class="soldOut"></div>', headers: html_header)
36
+ pax_prime.sold_out?.should == false
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,21 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ #require 'coveralls'
8
+ #Coveralls.wear!
9
+
10
+ require 'webmock/rspec'
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = 'random'
21
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pax
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Neff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mechanize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A small gem to help with scraping the Penny Arcade Expo website.
28
+ email: patrick.neff@me.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .travis.yml
34
+ - Gemfile
35
+ - Gemfile.lock
36
+ - lib/pax.rb
37
+ - lib/pax/event.rb
38
+ - lib/pax/version.rb
39
+ - readme.md
40
+ - spec/lib/pax/event_spec.rb
41
+ - spec/spec_helper.rb
42
+ homepage: http://github.com/hersha/pax
43
+ licenses: []
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.9.3
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.0.3
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: pax
65
+ test_files:
66
+ - spec/lib/pax/event_spec.rb
67
+ - spec/spec_helper.rb