va_timetable 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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/lib/va_timetable.rb +5 -0
- data/lib/va_timetable/timetable.rb +67 -0
- data/lib/va_timetable/version.rb +3 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/aldersgate.html +1164 -0
- data/spec/support/islington.html +2057 -0
- data/spec/timetable_spec.rb +81 -0
- data/va_timetable.gemspec +26 -0
- metadata +118 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Timetable do
|
|
4
|
+
let(:timetable) { Timetable.new('SomeClubName') }
|
|
5
|
+
let(:microsite) { File.open(File.dirname(__FILE__) + '/support/aldersgate.html', 'rb').read }
|
|
6
|
+
let(:clubsite) { File.open(File.dirname(__FILE__) + '/support/islington.html', 'rb').read }
|
|
7
|
+
|
|
8
|
+
before(:each) do
|
|
9
|
+
Time.stub(:now).and_return(Time.new(2014,05,06,10,30,40))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "returns empty array when club not found" do
|
|
13
|
+
timetable.stub(:open).and_raise(:SocketError)
|
|
14
|
+
expect(timetable.classes).to be_empty
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context "when club has a microsite" do
|
|
18
|
+
before(:each) do
|
|
19
|
+
timetable.stub(:open).and_return(microsite)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "returns correct number of class entries" do
|
|
23
|
+
expect(timetable.classes.count).to eql(90)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "has the correct club name for the first class" do
|
|
27
|
+
expect(timetable.classes[0].club).to eql('Someclubname')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "has the correct name for the first class" do
|
|
31
|
+
expect(timetable.classes[0].name).to eql('Body Pump')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "has the correct start time for the first class" do
|
|
35
|
+
expect(timetable.classes[0].start.strftime('%Y%m%d%H%M%S')).to eql('20140527070000')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "has the correct finish time for the first class" do
|
|
39
|
+
expect(timetable.classes[0].finish.strftime('%Y%m%d%H%M%S')).to eql('20140527074500')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "has the correct booking required status for the first class" do
|
|
43
|
+
expect(timetable.classes[0].booking_required).to be_false
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context "when club does not have a microsite" do
|
|
48
|
+
before(:each) do
|
|
49
|
+
timetable.stub(:open).and_return(clubsite)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "returns correct number of class entries" do
|
|
53
|
+
expect(timetable.classes.count).to eql(112)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "has the correct club name for the first class" do
|
|
57
|
+
expect(timetable.classes[2].club).to eql('Someclubname')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "has the correct name for the third class" do
|
|
61
|
+
expect(timetable.classes[2].name).to eql('Hatha Yoga')
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "has the correct start time for the third class" do
|
|
65
|
+
expect(timetable.classes[2].start.strftime('%Y%m%d%H%M%S')).to eql('20140506070000')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "has the correct finish time for the third class" do
|
|
69
|
+
expect(timetable.classes[2].finish.strftime('%Y%m%d%H%M%S')).to eql('20140506080000')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "has the correct booking required status for the third class" do
|
|
73
|
+
expect(timetable.classes[2].booking_required).to be_true
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "increments the month when dates span a month" do
|
|
78
|
+
timetable.stub(:open).and_return(microsite)
|
|
79
|
+
expect(timetable.classes[89].start.strftime('%Y%m%d%H%M%S')).to eql('20140602150500')
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'va_timetable/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "va_timetable"
|
|
8
|
+
spec.version = VaTimetable::VERSION
|
|
9
|
+
spec.date = "2014-05-07"
|
|
10
|
+
spec.authors = ["Paul Jackson"]
|
|
11
|
+
spec.email = ["pjackson@mbs-projects.com"]
|
|
12
|
+
spec.summary = "Return Virgin Active workout classes"
|
|
13
|
+
spec.description = "Uses Nokogiri for parsing classes from the Virgin Active website(s)"
|
|
14
|
+
spec.homepage = "http://github.com/jacksop/va_timetable"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
|
23
|
+
spec.add_development_dependency "rake"
|
|
24
|
+
spec.add_development_dependency "rspec"
|
|
25
|
+
spec.add_runtime_dependency "nokogiri"
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: va_timetable
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Paul Jackson
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.5'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.5'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: nokogiri
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description: Uses Nokogiri for parsing classes from the Virgin Active website(s)
|
|
70
|
+
email:
|
|
71
|
+
- pjackson@mbs-projects.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- Gemfile
|
|
78
|
+
- LICENSE.txt
|
|
79
|
+
- README.md
|
|
80
|
+
- Rakefile
|
|
81
|
+
- lib/va_timetable.rb
|
|
82
|
+
- lib/va_timetable/timetable.rb
|
|
83
|
+
- lib/va_timetable/version.rb
|
|
84
|
+
- spec/spec_helper.rb
|
|
85
|
+
- spec/support/aldersgate.html
|
|
86
|
+
- spec/support/islington.html
|
|
87
|
+
- spec/timetable_spec.rb
|
|
88
|
+
- va_timetable.gemspec
|
|
89
|
+
homepage: http://github.com/jacksop/va_timetable
|
|
90
|
+
licenses:
|
|
91
|
+
- MIT
|
|
92
|
+
metadata: {}
|
|
93
|
+
post_install_message:
|
|
94
|
+
rdoc_options: []
|
|
95
|
+
require_paths:
|
|
96
|
+
- lib
|
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0'
|
|
107
|
+
requirements: []
|
|
108
|
+
rubyforge_project:
|
|
109
|
+
rubygems_version: 2.2.1
|
|
110
|
+
signing_key:
|
|
111
|
+
specification_version: 4
|
|
112
|
+
summary: Return Virgin Active workout classes
|
|
113
|
+
test_files:
|
|
114
|
+
- spec/spec_helper.rb
|
|
115
|
+
- spec/support/aldersgate.html
|
|
116
|
+
- spec/support/islington.html
|
|
117
|
+
- spec/timetable_spec.rb
|
|
118
|
+
has_rdoc:
|