fitness_supplies 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c2c07a790b8826df9f5f3d74e7ef80ee416ec3b06e1fdebc01f3c0bcf109e98c
4
+ data.tar.gz: 82e4dbbf6690c2508819e03583c0fd472748db8d759057fe3d4178d779bf7cbf
5
+ SHA512:
6
+ metadata.gz: 1a2854a1c5ea24a17e4712c3998cc0a395b2d792b389ee450172750c285c606b1dea2a8510f9d71b1320b7fad6d5876b631dfda835f2e225795a7224da0958a1
7
+ data.tar.gz: 7515b2c98dfd6af7a27fb29224c85e58b73d1a64c818744b62b7f360fa88f6fe26195d74bff509a20857d7dd2b959dc680ca881788f5fdb61c0f662fb9026b8e
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../config/env.rb'
4
+
5
+ FitnessSupplies::CLI.new.call
@@ -0,0 +1,11 @@
1
+ # LIBRARIES
2
+
3
+ require "nokogiri"
4
+ require "open-uri"
5
+
6
+
7
+ # MAIN ENVIRONMENT FILES
8
+
9
+ require_relative "../lib/fitness_supplies/version"
10
+ require_relative "../lib/fitness_supplies/scraper"
11
+ require_relative "../lib/fitness_supplies/cli"
@@ -0,0 +1,6 @@
1
+ require_relative '../config/env.rb'
2
+
3
+ module FitnessSupplies
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,92 @@
1
+ class FitnessSupplies::CLI
2
+
3
+ def call
4
+ welcome
5
+ show_list
6
+ get_user_data
7
+ end
8
+
9
+ def welcome
10
+ puts "Hello, how are you today. Welcome to Fitness Supplies."
11
+ end
12
+
13
+ def show_list
14
+ puts "\nHere's a list of Fitness Equipment categories."
15
+
16
+ catg = ['Cardio','Vibration Training', 'Strength', 'Group Training', 'Flooring', 'Accessories']
17
+
18
+ catg.each.with_index(1) do |cg, index|
19
+ puts "\n#{index}. #{cg}"
20
+ end
21
+ puts "\nLoading products..."
22
+ end
23
+
24
+ def get_user_data
25
+
26
+ get = FitnessSupplies::Scraper.new
27
+ cardio = get.scraped_cardio
28
+ v_training = get.scraped_vibration_training
29
+ strength = get.scraped_strength
30
+ group_training = get.scraped_group_training
31
+ flooring = get.scraped_flooring
32
+ acc = get.scraped_accessories
33
+
34
+ puts "\nChoose the number of the category >"
35
+
36
+ while true
37
+ user_choice = gets.chomp.to_i
38
+ case user_choice
39
+ when 1
40
+ puts "\n=============== Cardio Equipment ==============="
41
+ puts
42
+ cardio.each.with_index(1) {|c_eq, index| puts "#{index}. #{c_eq}"}
43
+ puts "\n=============== End Cardio Equipment ==============="
44
+ when 2
45
+ puts "\n=============== Vibration Training Equipment ==============="
46
+ puts
47
+ v_training.each.with_index(1) {|c_eq, index| puts "#{index}. #{c_eq}"}
48
+ puts "\n=============== End Vibration Training Equipment ==============="
49
+ when 3
50
+ puts "\n=============== Strength Equipment ==============="
51
+ puts
52
+ strength.each.with_index(1) {|c_eq, index| puts "#{index}. #{c_eq}"}
53
+ puts "\n=============== End Strength Equipment ==============="
54
+ when 4
55
+ puts "\n=============== Group Training Equipment ==============="
56
+ puts
57
+ group_training.each.with_index(1) {|c_eq, index| puts "#{index}. #{c_eq}"}
58
+ puts "\n=============== End Group Training Equipment ==============="
59
+ when 5
60
+ puts "\n=============== Flooring Equipment ==============="
61
+ puts
62
+ flooring.each.with_index(1) {|c_eq, index| puts "#{index}. #{c_eq}"}
63
+ puts "\n=============== End Flooring Equipment ==============="
64
+ when 6
65
+ puts "\n=============== Accessories ==============="
66
+ puts
67
+ acc.each.with_index(1) {|c_eq, index| puts "#{index}. #{c_eq}"}
68
+ puts "\n=============== End Accessories ==============="
69
+ else
70
+ puts "\nThere is no such category"
71
+ end
72
+ another_cat?
73
+ end
74
+ end
75
+
76
+ def another_cat?
77
+ puts "\nWould you like to search another category?(y/n)"
78
+ user_choice = gets.chomp.to_s.downcase
79
+ if user_choice == 'y'
80
+ get_user_data
81
+ else
82
+ goodbye
83
+ end
84
+ end
85
+
86
+ def goodbye
87
+ puts "\nOk, come back again soon. Remember, your health is your wealth"
88
+ exit!
89
+ end
90
+
91
+
92
+ end
@@ -0,0 +1,73 @@
1
+ class FitnessSupplies::Scraper
2
+
3
+ def get_cat_page(category_choice, pg)
4
+ Nokogiri::HTML(open("https://www.gymsource.com/equipment/#{category_choice}?page=#{pg}"))
5
+ end
6
+
7
+ def scraped_cardio
8
+ cardio_prod = []
9
+ car_pg_num = 1
10
+ while car_pg_num <= 7
11
+ get_cat_page("cardio", car_pg_num).css("div.row .flex .card-product h3").each do |prod|
12
+ cardio_prod << "\nProduct Name: #{prod.text}\nLink To Product: https://www.gymsource.com#{prod.css('a').attribute('href').value}"
13
+ end
14
+ car_pg_num+=1
15
+ end
16
+ cardio_prod
17
+ end
18
+
19
+ def scraped_vibration_training
20
+ vibration_training_prod = []
21
+ vib_pg_num = 1
22
+ get_cat_page("vibration-training", vib_pg_num).css("div.row .flex .card-product h3").each do |prod|
23
+ vibration_training_prod << "\nProduct Name: #{prod.text}\nLink To Product: https://www.gymsource.com#{prod.css('a').attribute('href').value}"
24
+ end
25
+ vibration_training_prod
26
+ end
27
+
28
+ def scraped_strength
29
+ strength_prod = []
30
+ str_pg_num = 1
31
+ while str_pg_num <= 17
32
+ get_cat_page("strength", str_pg_num).css("div.row .flex .card-product h3").each do |prod|
33
+ strength_prod << "\nProduct Name: #{prod.text}\nLink To Product: https://www.gymsource.com#{prod.css('a').attribute('href').value}"
34
+ end
35
+ str_pg_num+=1
36
+ end
37
+ strength_prod
38
+ end
39
+
40
+ def scraped_group_training
41
+ group_training_prod = []
42
+ gr_pg_num = 1
43
+ while gr_pg_num <= 2
44
+ get_cat_page("group-training", gr_pg_num).css("div.row .flex .card-product h3").each do |prod|
45
+ group_training_prod << "\nProduct Name: #{prod.text}\nLink To Product: https://www.gymsource.com#{prod.css('a').attribute('href').value}"
46
+ end
47
+ gr_pg_num+=1
48
+ end
49
+ group_training_prod
50
+ end
51
+
52
+ def scraped_flooring
53
+ flooring_prod = []
54
+ flr_pg_num = 1
55
+ get_cat_page("flooring", flr_pg_num).css("div.row .flex .card-product h3").each do |prod|
56
+ flooring_prod << "\nProduct Name: #{prod.text}\nLink To Product: https://www.gymsource.com#{prod.css('a').attribute('href').value}"
57
+ end
58
+ flooring_prod
59
+ end
60
+
61
+ def scraped_accessories
62
+ accessories_prod = []
63
+ acc_pg_num = 1
64
+ while acc_pg_num <= 9
65
+ get_cat_page("accessories", acc_pg_num).css("div.row .flex .card-product h3").each do |prod|
66
+ accessories_prod << "\nProduct Name: #{prod.text}\nLink To Product: https://www.gymsource.com#{prod.css('a').attribute('href').value}"
67
+ end
68
+ acc_pg_num+=1
69
+ end
70
+ accessories_prod
71
+ end
72
+
73
+ end
@@ -0,0 +1,3 @@
1
+ module FitnessSupplies
2
+ VERSION = "0.1.3"
3
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fitness_supplies
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - "'Joey Luis Echevarria'"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-08 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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
+ description: Search our gym equipment database with ease
42
+ email:
43
+ - "'jechevarria719@gmail.com'"
44
+ executables:
45
+ - fitness_supplies
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - bin/fitness_supplies
50
+ - config/env.rb
51
+ - lib/fitness_supplies.rb
52
+ - lib/fitness_supplies/cli.rb
53
+ - lib/fitness_supplies/scraper.rb
54
+ - lib/fitness_supplies/version.rb
55
+ homepage: https://github.com/Joey0719/Fitness_Supplies.git
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.0.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Search our gym equipment database
78
+ test_files: []