family_wellness_daily 0.0.2

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: 766c6b56fd8e5669214d55d25960c07db6e13bcc
4
+ data.tar.gz: 08d6b0b306d9171c6966894004f0664c24c5ada0
5
+ SHA512:
6
+ metadata.gz: 65d383b9631cb54668350c155f7220fd5e68591ea550ba9bedbc7f42a3d9ab38a318a9e8fae436c0702a00e05730aae75b9de21df6fafc0961584cfd71ab4f54
7
+ data.tar.gz: 2c49abce436067e0aafc979ac55e672a37ab8aa9d78a0af379b5241e5bfadf825871bb9c12504e2888f8bf869431c16e7ab52005804607926f8f97b9572575dc
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in family_wellness_daily.gemspec
4
+
5
+ gem 'family_wellness_daily'
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ childprocess (0.5.9)
5
+ ffi (~> 1.0, >= 1.0.11)
6
+ commonwatir (4.0.0)
7
+ family_wellness_daily (0.1.0)
8
+ nokogiri
9
+ phantomjs
10
+ watir
11
+ ffi (1.9.10)
12
+ mini_portile (0.6.2)
13
+ multi_json (1.12.1)
14
+ nokogiri (1.6.6.2)
15
+ mini_portile (~> 0.6.0)
16
+ phantomjs (2.1.1.0)
17
+ rubyzip (1.2.0)
18
+ selenium-webdriver (2.52.0)
19
+ childprocess (~> 0.5)
20
+ multi_json (~> 1.0)
21
+ rubyzip (~> 1.0)
22
+ websocket (~> 1.0)
23
+ watir (5.0.0)
24
+ commonwatir (~> 4)
25
+ watir-webdriver
26
+ watir-webdriver (0.9.1)
27
+ selenium-webdriver (>= 2.46.2)
28
+ websocket (1.2.3)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ family_wellness_daily
35
+
36
+ BUNDLED WITH
37
+ 1.12.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 kaileeagray
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # FamilyWellnessDaily
2
+
3
+ Welcome to your Family Wellness Daily. This gem scrapes the Family Wellness schedule to provide a daily digest of fitness classes by category.
4
+
5
+ ## Installation
6
+
7
+ Add to your Gemfile:
8
+
9
+ gem 'family_wellness_daily'
10
+
11
+ Or install from RubyGems:
12
+
13
+ gem install family_wellness_daily
14
+
15
+ ## Usage
16
+
17
+ Require the Gem:
18
+
19
+ require 'family_wellness_daily'
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kaileeagray/family_wellness_cli_gem.
30
+
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "family_wellness_daily"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "family_wellness_daily"
4
+
5
+ FamilyWellnessDaily::CLI.new.call
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'family_wellness_daily/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "family_wellness_daily"
8
+ spec.version = FamilyWellnessDaily::VERSION
9
+ spec.authors = ["kaileeagray"]
10
+ spec.email = ["kaileeagray@gmail.com"]
11
+
12
+ spec.summary = "A command line interface to view daily classes at Family Wellness in Fargo by category."
13
+ spec.homepage = "https://github.com/kaileeagray/family_wellness_cli_gem"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ # end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.12"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "pry", '~> 0.10', ">= 0.10.1"
33
+ spec.add_runtime_dependency "nokogiri", '~> 1.6', ">= 1.6.6.2"
34
+ spec.add_runtime_dependency "phantomjs", '~> 2.1', ">= 2.1.1.0"
35
+ spec.add_runtime_dependency "watir", '~> 5.0', ">= 5.0.0"
36
+
37
+ end
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in family_wellness_daily.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 kaileeagray
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # FamilyWellnessDaily
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/family_wellness_daily`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'family_wellness_daily'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install family_wellness_daily
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/family_wellness_daily.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -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,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "family_wellness_daily"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'family_wellness_daily/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "family_wellness_daily"
8
+ spec.version = FamilyWellnessDaily::VERSION
9
+ spec.authors = ["kaileeagray"]
10
+ spec.email = ["kaileeagray@gmail.com"]
11
+
12
+ spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
13
+ spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "TODO: Put your gem's website or public repo URL here."
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ end
@@ -0,0 +1,5 @@
1
+ require "family_wellness_daily/version"
2
+
3
+ module FamilyWellnessDaily
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module FamilyWellnessDaily
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe FamilyWellnessDaily do
4
+ it 'has a version number' do
5
+ expect(FamilyWellnessDaily::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'family_wellness_daily'
@@ -0,0 +1,14 @@
1
+ require 'open-uri'
2
+ #open-uri is part of standard lib so you don't need to include it in gemspec
3
+
4
+ require 'nokogiri'
5
+ require 'pry'
6
+ require 'date'
7
+ require 'watir'
8
+
9
+
10
+ #this file acts as my environment
11
+ require_relative "./family_wellness_daily/version"
12
+ require_relative './family_wellness_daily/cli'
13
+ require_relative './family_wellness_daily/fitness_class'
14
+ require_relative './family_wellness_daily/scraper'
@@ -0,0 +1,125 @@
1
+ #Our CLI controller. input, welcoming - deal with user
2
+
3
+ class FamilyWellnessDaily::CLI
4
+
5
+ def call
6
+ puts "Please wait while the classes load. This may take up to 1 minute.\n\n"
7
+ #get classes from site
8
+ FamilyWellnessDaily::Scraper.new
9
+ #after classes have loaded, ask user how to view classes
10
+ menu
11
+ goodbye
12
+ end
13
+
14
+ def menu
15
+ input = nil
16
+
17
+ until input == "exit"
18
+ puts "Enter any fitness class category to view classes of that category. Enter help to view categories. Enter exit to leave."
19
+ input = gets.strip.downcase
20
+ puts "----------------------------------------------------------------\n\n"
21
+
22
+ if input == "help"
23
+ puts "Enter any of the following categories to see which classes of that category are offered today."
24
+ list_all_categories
25
+ puts "You can also enter view all to see all the classes at Family Wellness today or you can type exit.\n\n"
26
+ elsif input == "view all" || input == "view_all" || input == "view-all"
27
+ list_all_classes
28
+ elsif input != "exit" && FamilyWellnessDaily::FitnessClass.categories.include?(input)
29
+ @current_category = input
30
+ view_by_category
31
+ elsif input != "exit"
32
+ puts "Not sure what to input? Type help to get more info. Type exit to leave. Type view all to see all classes."
33
+ elsif input == "exit"
34
+ #added to allow menu to keep looping but not force user to type exit more than once
35
+ goodbye
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ def list_all_categories
43
+ puts "----------------------------------------------------------------"
44
+
45
+ FamilyWellnessDaily::FitnessClass.categories.each do |category|
46
+ puts category
47
+ end
48
+
49
+ puts "----------------------------------------------------------------"
50
+ end
51
+
52
+ def view_by_category
53
+ @classes = FamilyWellnessDaily::FitnessClass.collect_by_category(@current_category)
54
+
55
+ if @classes.count > 0
56
+ puts "\n\nToday's #{@current_category} fitness classes at Family Wellness include:"
57
+ list_classes
58
+ else
59
+ puts "\n\nSorry there are no #{@current_category} classes today."
60
+ puts "----------------------------------------------------------------\n\n"
61
+ menu
62
+ end
63
+
64
+ end
65
+
66
+ def list_all_classes
67
+ puts "Today's fitness classes at Family Wellness in Fargo:"
68
+
69
+ @classes = FamilyWellnessDaily::FitnessClass.all
70
+
71
+ if @classes.count > 0
72
+ list_classes
73
+ else
74
+ puts "\n\nSorry there are no classes today."
75
+ puts "----------------------------------------------------------------\n\n"
76
+ menu
77
+ end
78
+
79
+ end
80
+
81
+ def list_classes
82
+ puts "----------------------------------------------------------------"
83
+ @classes.each.with_index(1) do |fitclass, i|
84
+ puts "#{i}. #{fitclass.name} - #{fitclass.time}"
85
+ end
86
+
87
+ more_info
88
+ end
89
+
90
+
91
+ def more_info
92
+ input = nil
93
+
94
+ until input == "exit"
95
+ puts "\n\nEnter the number of the class you'd like more information on, type menu to return to starting menu, or type exit:"
96
+ input = gets.strip.downcase
97
+ puts "----------------------------------------------------------------\n\n"
98
+
99
+ if input.to_i > 0 && input.to_i <= @classes.count
100
+ fitclass = @classes[input.to_i - 1]
101
+ puts "Name: #{fitclass.name} \nStudio: #{fitclass.studio} \nInstructor: #{fitclass.instructor} \nTime: #{fitclass.time}"
102
+ tags = ""
103
+ fitclass.categories.each do |category|
104
+ tags << category + ", "
105
+ end
106
+ puts "This class has the following tags: #{tags.chop.chop}"
107
+ elsif input == "menu"
108
+ menu
109
+ elsif input == "exit"
110
+ #added to allow more_info to keep looping but not force user to type exit more than once
111
+ goodbye
112
+ else
113
+ puts "Not sure what you want? Type menu, exit, or the number of of class you'd like more info about." unless input == "exit"
114
+ end
115
+ end
116
+
117
+ end
118
+
119
+ def goodbye
120
+ puts "Have fun at class! You'll feel great after! See you tomorrow!\n\n"
121
+ exit!
122
+ end
123
+
124
+
125
+ end
@@ -0,0 +1,49 @@
1
+ class FamilyWellnessDaily::FitnessClass
2
+ attr_accessor :name, :time, :instructor, :categories, :studio
3
+ @@all = []
4
+ @@hash_title_categories = {"Circuit"=>["interval training", "cardio", "strength"], "Spinsanity"=>["cycling", "cardio"],
5
+ "Zumba ®"=>["dance", "cardio"], "Hydro Power"=>["water exercise", "strength", "cardio"],
6
+ "Hydro Fitness"=>["water exercise", "strength", "cardio"], "Gold N Fit"=>["senior fitness"],
7
+ "Indoor Cycling"=>["cycling", "cardio"], "Tabata Toning"=>["interval training", "cardio", "strength"],
8
+ "Parkinson's Program"=>["medical"], "Mat Pilates"=>["pilates", "strength"], "PD FIT"=>["medical"], "BODYPUMP ™"=>["bodypump", "strength"],
9
+ "Yoga Level 1"=>["yoga"], "Raw Groove"=>["dance", "cardio"], "R.I.P.P.E.D. ®"=>["interval training", "cardio", "strength"],
10
+ "Cycle Craze"=>["cycling", "cardio"], "Family Circuit"=>["interval training", "cardio", "strength"], "Abs, Back, & Booty"=>["strength"],
11
+ "Tabata Toning (30 min)"=>["interval training", "cardio", "strength"], "OULA"=>["dance", "cardio"],
12
+ "BODYPUMP ™ Support Instructor"=>["bodypump", "strength"], "Muscle Fitness"=>["strength"], "SilverSneakers ® Classic"=>["senior fitness"],
13
+ "Yogalates"=>["pilates", "yoga"], "Barre-latte'"=>["barre", "strength", "cardio"], "SilverSneakers ® Splash"=>["senior fitness", "water exercise"],
14
+ "Barre Fitness"=>["barre", "strength", "cardio"], "Turbo Kick"=>["boxing", "cardio"], "Yoga Mixed Level"=>["yoga"], "Step"=>["dance", "cardio"],
15
+ "Mat Pilates II"=>["pilates", "strength"], "Tabata Booty"=>["interval training", "cardio", "strength"], "Deck of Cards"=>["interval training", "cardio", "strength"],
16
+ "Tabata Power"=>["interval training", "cardio", "strength"], "Yoga Strength"=>["yoga", "strength"], "INSANITY (30 min)"=>["interval training", "cardio", "strength"],
17
+ "Yogaflow"=>["yoga", "cardio"], "Cycle Sculpt"=>["cycling", "strength", "cardio"], "Candle Light Yoga"=>["yoga"], "Zumba Step"=>["dance", "cardio"]}
18
+
19
+
20
+ def self.all
21
+ @@all
22
+ end
23
+
24
+ def self.categories
25
+ @@hash_title_categories.values.flatten.uniq
26
+ end
27
+
28
+ def self.collect_by_category(category)
29
+ @@all.select do |fitclass|
30
+ fitclass.categories.include?(category)
31
+ end
32
+ end
33
+
34
+ def self.find_by_name_time(name, time)
35
+ @@all.detect do |fitclass|
36
+ fitclass.name == name && fitclass.time == time
37
+ end
38
+ end
39
+
40
+ def save
41
+ @@all << self
42
+ end
43
+
44
+ def assign_categories
45
+ #class titles taken from website by scraping all titles and then manually assigning categories in console
46
+ self.categories = @@hash_title_categories[self.name]
47
+ end
48
+
49
+ end
@@ -0,0 +1,49 @@
1
+ class FamilyWellnessDaily::Scraper
2
+
3
+ def initialize
4
+ scrape_family_wellness
5
+ FamilyWellnessDaily::FitnessClass.all
6
+ end
7
+
8
+ def get_document(url)
9
+ # http://stackoverflow.com/questions/30746397/can-nokogiri-interpret-javascript-web-scraping for approach
10
+ # with Watir, phantomjs
11
+ browser = Watir::Browser.new(:phantomjs)
12
+ browser.goto(url)
13
+ Nokogiri::HTML(browser.html)
14
+ end
15
+
16
+
17
+ def get_day
18
+ # first get day of the week to move to that section of the schedule. require 'date' to use Date
19
+ #.strftime info http://ruby-doc.org/stdlib-2.1.1/libdoc/date/rdoc/Date.html#method-i-strftime
20
+ Date.today.strftime("%A")
21
+ end
22
+
23
+
24
+ def scrape_family_wellness
25
+ # go to family wellness, find the day and classes
26
+ # instantiate a class for each class offered that day
27
+ document = get_document("http://www.familywellnessfargo.org/fitness/group-fitness/")
28
+
29
+
30
+ document.css("div#GXP#{get_day}").css("div.GXPEntry").each do |fitclass|
31
+ # the bodypump class has two instructors but is listed as two classes. add conditional to combine instructors into one class.
32
+ #in case there are two bodypump classes at different times, we'll check that the name and time match
33
+ if fitclass.css("div.GXPTitle").text.strip == "BODYPUMP ™ Support Instructor"
34
+ bodypump_class = FamilyWellnessDaily::FitnessClass.find_by_name_time("BODYPUMP ™", fitclass.css("div.GXPTime").text.strip)
35
+ bodypump_class.instructor += " & " + fitclass.css("div.GXPInstructor").text.strip unless bodypump_class == nil
36
+ else
37
+ new_class = FamilyWellnessDaily::FitnessClass.new
38
+ new_class.name = fitclass.css("div.GXPTitle").text.strip
39
+ new_class.time = fitclass.css("div.GXPTime").text.strip
40
+ new_class.instructor = fitclass.css("div.GXPInstructor").text.strip
41
+ new_class.studio = fitclass.css("div.GXPStudio").text.strip
42
+ new_class.assign_categories
43
+ new_class.save
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,3 @@
1
+ module FamilyWellnessDaily
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: family_wellness_daily
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - kaileeagray
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-17 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 0.10.1
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '0.10'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.10.1
75
+ - !ruby/object:Gem::Dependency
76
+ name: nokogiri
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.6'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 1.6.6.2
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '1.6'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 1.6.6.2
95
+ - !ruby/object:Gem::Dependency
96
+ name: phantomjs
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '2.1'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 2.1.1.0
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '2.1'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 2.1.1.0
115
+ - !ruby/object:Gem::Dependency
116
+ name: watir
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '5.0'
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 5.0.0
125
+ type: :runtime
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '5.0'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 5.0.0
135
+ description:
136
+ email:
137
+ - kaileeagray@gmail.com
138
+ executables: []
139
+ extensions: []
140
+ extra_rdoc_files: []
141
+ files:
142
+ - Gemfile
143
+ - Gemfile.lock
144
+ - LICENSE.txt
145
+ - README.md
146
+ - Rakefile
147
+ - bin/console
148
+ - bin/family_wellness_daily
149
+ - bin/setup
150
+ - family_wellness_daily-0.0.1.gem
151
+ - family_wellness_daily.gemspec
152
+ - family_wellness_daily/.gitignore
153
+ - family_wellness_daily/.rspec
154
+ - family_wellness_daily/.travis.yml
155
+ - family_wellness_daily/Gemfile
156
+ - family_wellness_daily/LICENSE.txt
157
+ - family_wellness_daily/README.md
158
+ - family_wellness_daily/Rakefile
159
+ - family_wellness_daily/bin/console
160
+ - family_wellness_daily/bin/setup
161
+ - family_wellness_daily/family_wellness_daily.gemspec
162
+ - family_wellness_daily/lib/family_wellness_daily.rb
163
+ - family_wellness_daily/lib/family_wellness_daily/version.rb
164
+ - family_wellness_daily/spec/family_wellness_daily_spec.rb
165
+ - family_wellness_daily/spec/spec_helper.rb
166
+ - lib/family_wellness_daily.rb
167
+ - lib/family_wellness_daily/cli.rb
168
+ - lib/family_wellness_daily/fitness_class.rb
169
+ - lib/family_wellness_daily/scraper.rb
170
+ - lib/family_wellness_daily/version.rb
171
+ homepage: https://github.com/kaileeagray/family_wellness_cli_gem
172
+ licenses:
173
+ - MIT
174
+ metadata: {}
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubyforge_project:
191
+ rubygems_version: 2.4.5.1
192
+ signing_key:
193
+ specification_version: 4
194
+ summary: A command line interface to view daily classes at Family Wellness in Fargo
195
+ by category.
196
+ test_files: []