train_hard 0.1.0

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: 43adaac86e858f10f0358821d858e52b29a822e4
4
+ data.tar.gz: 01246b521b7902c6fa2d4ba45c4b383abc4d524a
5
+ SHA512:
6
+ metadata.gz: 08a0804c7b68e2f0a0b9d67dfd49065bb57b12e20200c487c980294f26838bb1fa814e3e7f70f6c0e4eafc70496d7e9ea819a027b06d47bc50f1721c58d883e0
7
+ data.tar.gz: 5a39a9d1686dd117a74d056755250db11a66fa0feb47e6b489a371cc18f78226b3e217ce40382608bc1c2a25629f94857e973bf0d8c3cf8567c46b6c8516abfe
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in train_hard.gemspec
4
+ gemspec
5
+ gem 'pry'
6
+ gem 'nokogiri'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 James Novak
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,41 @@
1
+ # TrainHard
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/train_hard`. 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 'train_hard'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install train_hard
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]/train_hard.
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
+
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,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "train_hard"
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
+ require "pry"
15
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/bin/train_hard ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "train_hard"
5
+
6
+ TrainHard::CLI.new.start
@@ -0,0 +1,31 @@
1
+ module Getable
2
+
3
+ def get_biceps
4
+ Nokogiri::HTML(open("http://www.bodybuilding.com/exercises/list/muscle/selected/biceps"))
5
+ end
6
+
7
+ def get_chest
8
+ Nokogiri::HTML(open("http://www.bodybuilding.com/exercises/list/muscle/selected/chest"))
9
+ end
10
+
11
+ def get_hamstrings
12
+ Nokogiri::HTML(open("http://www.bodybuilding.com/exercises/list/muscle/selected/hamstrings"))
13
+ end
14
+
15
+ def get_lats
16
+ Nokogiri::HTML(open("http://www.bodybuilding.com/exercises/list/muscle/selected/lats"))
17
+ end
18
+
19
+ def get_quads
20
+ Nokogiri::HTML(open("http://www.bodybuilding.com/exercises/list/muscle/selected/quadriceps"))
21
+ end
22
+
23
+ def get_shoulders
24
+ Nokogiri::HTML(open("http://www.bodybuilding.com/exercises/list/muscle/selected/shoulders"))
25
+ end
26
+
27
+ def get_triceps
28
+ Nokogiri::HTML(open("http://www.bodybuilding.com/exercises/list/muscle/selected/triceps"))
29
+ end
30
+
31
+ end
data/lib/.DS_Store ADDED
Binary file
data/lib/train_hard.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'pry'
4
+
5
+ require_relative "../concerns/getable"
6
+ require_relative "./train_hard/scraper"
7
+ require_relative "./train_hard/muscle"
8
+ require_relative "./train_hard/exercise"
9
+ require_relative "./train_hard/cli"
10
+
11
+ module TrainHard
12
+ end
@@ -0,0 +1,71 @@
1
+ class TrainHard::CLI
2
+
3
+ def initialize
4
+ TrainHard::Muscle.make_muscle_from_index
5
+ TrainHard::Muscle.make_and_add_exercises
6
+ end
7
+
8
+ def start
9
+ display_menu
10
+ pick
11
+ go_back
12
+ end
13
+
14
+ def display_menu
15
+ puts "Which muscle group are you training today? (enter number):"
16
+ TrainHard::Muscle.list_muscle
17
+ end
18
+
19
+ def pick
20
+ puts "Enter number of the muscle you would like to train or type menu to display menu:"
21
+ input = nil
22
+ while input != "exit"
23
+ input = gets.strip
24
+ case input
25
+ when "1"
26
+ puts "Exercises for #{TrainHard::Muscle.all[0].name}:"
27
+ TrainHard::Muscle.all[0].exercises.each {|e| puts e.inspect}
28
+ go_back
29
+ when "2"
30
+ puts "Exercises for #{TrainHard::Muscle.all[1].name}:"
31
+ TrainHard::Muscle.all[1].exercises.each {|e| puts e.inspect}
32
+ go_back
33
+ when "3"
34
+ puts "Exercises for #{TrainHard::Muscle.all[2].name}:"
35
+ TrainHard::Muscle.all[2].exercises.each {|e| puts e.inspect}
36
+ go_back
37
+ when "4"
38
+ puts "Exercises for #{TrainHard::Muscle.all[3].name}:"
39
+ TrainHard::Muscle.all[3].exercises.each {|e| puts e.inspect}
40
+ go_back
41
+ when "5"
42
+ puts "Exercises for #{TrainHard::Muscle.all[4].name}:"
43
+ TrainHard::Muscle.all[4].exercises.each {|e| puts e.inspect}
44
+ go_back
45
+ when "6"
46
+ puts "Exercises for #{TrainHard::Muscle.all[5].name}:"
47
+ TrainHard::Muscle.all[5].exercises.each {|e| puts e.inspect}
48
+ go_back
49
+ when "7"
50
+ puts "Exercises for #{TrainHard::Muscle.all[6].name}:"
51
+ TrainHard::Muscle.all[6].exercises.each {|e| puts e.inspect}
52
+ go_back
53
+ when "8"
54
+ puts "Exercises for #{TrainHard::Muscle.all[7].name}:"
55
+ TrainHard::Muscle.all[7].exercises.each {|e| puts e.inspect}
56
+ go_back
57
+ when "menu"
58
+ display_menu
59
+ else
60
+ puts "Not sure what you meant.. type menu or exit" if input != "exit"
61
+ end
62
+ end
63
+ end
64
+
65
+ def go_back
66
+ puts "Type menu if you would like to see more, or any key to quit"
67
+ input = gets.strip
68
+ input == "menu" ? start : exit
69
+ end
70
+
71
+ end
@@ -0,0 +1,12 @@
1
+ class TrainHard::Exercise
2
+ attr_accessor :name, :muscle
3
+
4
+ @@all = []
5
+
6
+ def initialize(name = nil, muscle = nil)
7
+ @name = name
8
+ @muscle = muscle
9
+ @@all << self
10
+ end
11
+
12
+ end
@@ -0,0 +1,37 @@
1
+ class TrainHard::Muscle
2
+ attr_accessor :name, :exercises
3
+
4
+ @@all = []
5
+
6
+ SCRAPED_MUSCLES = TrainHard::Scraper.scrape_muscles_index
7
+ SCRAPED_EXERCISES = TrainHard::Scraper.scrape_exercises
8
+
9
+ def initialize(name = nil)
10
+ @name = name
11
+ @exercises = []
12
+ @@all << self
13
+ end
14
+
15
+ def self.all
16
+ @@all
17
+ end
18
+
19
+ def self.make_muscle_from_index
20
+ SCRAPED_MUSCLES.each {|muscle| TrainHard::Muscle.new(muscle)}
21
+ end
22
+
23
+ def self.list_muscle
24
+ @@all.each_with_index {|item, index| puts "#{index + 1}. #{item.name}"}
25
+ end
26
+
27
+ def self.make_and_add_exercises
28
+ @@all[0].exercises = SCRAPED_EXERCISES[0].each {|exercise| TrainHard::Exercise.new(exercise, @@all[0])}
29
+ @@all[1].exercises = SCRAPED_EXERCISES[1].each {|exercise| TrainHard::Exercise.new(exercise, @@all[1])}
30
+ @@all[2].exercises = SCRAPED_EXERCISES[2].each {|exercise| TrainHard::Exercise.new(exercise, @@all[2])}
31
+ @@all[3].exercises = SCRAPED_EXERCISES[3].each {|exercise| TrainHard::Exercise.new(exercise, @@all[3])}
32
+ @@all[4].exercises = SCRAPED_EXERCISES[4].each {|exercise| TrainHard::Exercise.new(exercise, @@all[4])}
33
+ @@all[5].exercises = SCRAPED_EXERCISES[5].each {|exercise| TrainHard::Exercise.new(exercise, @@all[5])}
34
+ @@all[6].exercises = SCRAPED_EXERCISES[6].each {|exercise| TrainHard::Exercise.new(exercise, @@all[6])}
35
+ @@all[7].exercises = SCRAPED_EXERCISES[7].each {|exercise| TrainHard::Exercise.new(exercise, @@all[7])}
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ class TrainHard::Scraper
2
+ extend Getable
3
+
4
+ def self.get_page
5
+ Nokogiri::HTML(open("http://www.bodybuilding.com/exercises/list/muscle/selected/abdominals"))
6
+ end
7
+
8
+ def self.scrape_muscles_index
9
+ muscles = []
10
+ muscles.push(
11
+ self.get_page.css('.muscle-pagination li')[0].text,
12
+ self.get_page.css('.muscle-pagination li')[3].text,
13
+ self.get_page.css('.muscle-pagination li')[5].text,
14
+ self.get_page.css('.muscle-pagination li')[8].text,
15
+ self.get_page.css('.muscle-pagination li')[9].text,
16
+ self.get_page.css('.muscle-pagination li')[13].text,
17
+ self.get_page.css('.muscle-pagination li')[14].text,
18
+ self.get_page.css('.muscle-pagination li')[16].text
19
+ )
20
+ end
21
+
22
+ def self.scrape_exercises
23
+ exercises = []
24
+ exercises.push(
25
+ self.get_page.css('.exerciseName h3 a').collect {|exercise| exercise.text.strip!},
26
+ self.get_biceps.css('.exerciseName h3 a').collect {|exercise| exercise.text.strip!},
27
+ self.get_chest.css('.exerciseName h3 a').collect {|exercise| exercise.text.strip!},
28
+ self.get_hamstrings.css('.exerciseName h3 a').collect {|exercise| exercise.text.strip!},
29
+ self.get_lats.css('.exerciseName h3 a').collect {|exercise| exercise.text.strip!},
30
+ self.get_quads.css('.exerciseName h3 a').collect {|exercise| exercise.text.strip!},
31
+ self.get_shoulders.css('.exerciseName h3 a').collect {|exercise| exercise.text.strip!},
32
+ self.get_triceps.css('.exerciseName h3 a').collect {|exercise| exercise.text.strip!}
33
+ )
34
+ end
35
+ end
36
+
@@ -0,0 +1,3 @@
1
+ module TrainHard
2
+ VERSION = "0.1.0"
3
+ end
@@ -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 'train_hard/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "train_hard"
8
+ spec.version = TrainHard::VERSION
9
+ spec.authors = ["James Novak"]
10
+ spec.email = ["jamesnovak90@gmail.com"]
11
+
12
+ spec.summary = %q{Choose from a list of muscles to get their exercises!}
13
+ spec.description = %q{Scraper CLI that retrieves a list of muscles and their corresponding exercises}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem 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.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: train_hard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Novak
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-14 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: '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
+ description: Scraper CLI that retrieves a list of muscles and their corresponding
56
+ exercises
57
+ email:
58
+ - jamesnovak90@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".DS_Store"
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/setup
73
+ - bin/train_hard
74
+ - concerns/getable.rb
75
+ - lib/.DS_Store
76
+ - lib/train_hard.rb
77
+ - lib/train_hard/cli.rb
78
+ - lib/train_hard/exercise.rb
79
+ - lib/train_hard/muscle.rb
80
+ - lib/train_hard/scraper.rb
81
+ - lib/train_hard/version.rb
82
+ - train_hard.gemspec
83
+ homepage: ''
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.6
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Choose from a list of muscles to get their exercises!
107
+ test_files: []