ufc_schedule 0.1.2 → 0.1.3
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 +4 -4
- data/lib/api.rb +5 -0
- data/lib/command_line_interface.rb +40 -37
- data/lib/event_fight.rb +4 -0
- data/lib/events.rb +8 -0
- data/lib/ufc_schedule/version.rb +1 -1
- data/ufc_schedule-0.1.2.gem +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af4f2f2548cb16fdd983eaf5fe3f688db2b49ab739bb80850be82f8627c65a69
|
4
|
+
data.tar.gz: cc24f1e462ab3fd42d747099248fc0e019c3fa9e8fd6b0743b861ddf5132da66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0de3885e07bf6a09f9e01c0f6219a6c3e6b93f7bdca219d52a6a19952e0a6bd33e9a40b3c9409f03623bd74076dd419c71c0d8ef7ad73648cfeda054889f622d
|
7
|
+
data.tar.gz: aaa004d6a53f4eacceff9f0177ea6ef470c5c8a481190bf976eb34ab22c31801b6f864c94198d3dd5869beed7ec80a0310776e8580882bb1d439ba36d01a6dcb
|
data/lib/api.rb
CHANGED
@@ -11,7 +11,9 @@ class Concerns::API
|
|
11
11
|
def self.scrape_fights(array_of_events)
|
12
12
|
#for each event id this will scrape event data iterate through the fights and create EventFight objects for each fight on the event and associate those fights to an event
|
13
13
|
#binding.pry
|
14
|
+
self.reset_data #resets fight.all for back funtionality
|
14
15
|
array_of_events.each do |event|
|
16
|
+
event.clear_fights #resets events.event_fights array
|
15
17
|
|
16
18
|
doc = Nokogiri::HTML(open("http://ufc-data-api.ufc.com/api/v1/us/events/#{event.id}"))
|
17
19
|
|
@@ -38,4 +40,7 @@ class Concerns::API
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
43
|
+
def self.reset_data
|
44
|
+
Concerns::EventFight.clear
|
45
|
+
end
|
41
46
|
end
|
@@ -9,7 +9,7 @@ extend Concerns::SharedCLIMethods
|
|
9
9
|
|
10
10
|
def greeting
|
11
11
|
#greets the user and makes a call to the UFC API to request schedule data
|
12
|
-
puts "Hello fight fan, welcome to your UFC gem! To view a list of upcoming UFC events enter '1'. To exit this gem at any time, enter 'exit'."
|
12
|
+
puts "Hello fight fan, welcome to your UFC gem! To view a list of upcoming UFC events enter '1'. To exit this gem at any time, enter 'exit'. To go back to the previous menu, enter 'back'."
|
13
13
|
puts ""
|
14
14
|
Concerns::API.get_categories
|
15
15
|
end
|
@@ -18,15 +18,15 @@ extend Concerns::SharedCLIMethods
|
|
18
18
|
#Takes user input and returns schedule if input == "1"
|
19
19
|
input = nil
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
input = gets.strip
|
22
|
+
if input == "1"
|
23
|
+
list_schedule
|
24
|
+
elsif input == "exit"
|
25
|
+
goodbye
|
26
|
+
exit
|
27
|
+
else
|
28
|
+
invalid_command_response
|
29
|
+
choose_to_view_schedule
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -42,25 +42,26 @@ extend Concerns::SharedCLIMethods
|
|
42
42
|
def choose_fight_card
|
43
43
|
#Scrapes all the fights from all of the events listed on the schedule and creates fight objects related to each event. Allows user to choose an event, if valid, it will list fights for that event
|
44
44
|
Concerns::API.scrape_fights(Concerns::Events.all)
|
45
|
-
|
46
|
-
input = nil
|
47
|
-
|
48
|
-
while input != "exit"
|
49
45
|
input = gets.strip
|
50
|
-
|
46
|
+
|
47
|
+
if input.to_i.between?(1, Concerns::Events.all.size)
|
51
48
|
list_fights(input.to_i)
|
52
|
-
|
49
|
+
elsif input == "back"
|
50
|
+
list_schedule
|
51
|
+
elsif input == "exit"
|
52
|
+
exit
|
53
|
+
else
|
53
54
|
invalid_command_response
|
55
|
+
choose_fight_card
|
54
56
|
end
|
55
|
-
end
|
56
57
|
end
|
57
58
|
|
58
59
|
def list_fights(input)
|
59
60
|
#finds an event and lists the fights on that event and calls the choose_fight function
|
60
61
|
find_event = Concerns::Events.all[input - 1]
|
61
62
|
|
62
|
-
|
63
|
-
|
63
|
+
find_event.event_fights.each_with_index do |fight, index|
|
64
|
+
puts "#{index + 1}. #{fight.red_name} vs. #{fight.blue_name} - #{fight.red_weight}"
|
64
65
|
end
|
65
66
|
choose_fight(find_event)
|
66
67
|
end
|
@@ -68,25 +69,27 @@ extend Concerns::SharedCLIMethods
|
|
68
69
|
def choose_fight(event)
|
69
70
|
#Allows user to choose a specific fight and pulls stats on fighters in that fight
|
70
71
|
puts ""
|
71
|
-
puts "To see stats of the fighters, enter the number of their corresponding fight"
|
72
|
+
puts "To see stats of the fighters, enter the number of their corresponding fight, or enter 'back' to go back to the schedule"
|
72
73
|
|
73
|
-
input =
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
74
|
+
input = gets.strip
|
75
|
+
#14.between?(10,20) # true
|
76
|
+
|
77
|
+
if input.to_i.between?(1, event.event_fights.count)
|
78
|
+
specific_fight = event.event_fights[input.to_i - 1]
|
79
|
+
puts "Name: #{specific_fight.red_name} #{specific_fight.blue_name}"
|
80
|
+
puts "Record: #{specific_fight.red_record} #{specific_fight.blue_record}"
|
81
|
+
puts "Height: #{specific_fight.red_height} #{specific_fight.blue_height}"
|
82
|
+
puts "Weight: #{specific_fight.red_weight} #{specific_fight.blue_weight}"
|
83
|
+
|
84
|
+
choose_fight(event)
|
85
|
+
elsif input == "exit"
|
86
|
+
goodbye
|
87
|
+
exit
|
88
|
+
elsif input == "back"
|
89
|
+
list_schedule
|
90
|
+
else
|
91
|
+
invalid_command_response
|
92
|
+
choose_fight(event)
|
90
93
|
end
|
91
94
|
end
|
92
95
|
|
data/lib/event_fight.rb
CHANGED
data/lib/events.rb
CHANGED
data/lib/ufc_schedule/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ufc_schedule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Quattrone
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/shared_methods/shared_cli_methods.rb
|
138
138
|
- lib/ufc_schedule.rb
|
139
139
|
- lib/ufc_schedule/version.rb
|
140
|
+
- ufc_schedule-0.1.2.gem
|
140
141
|
- ufc_schedule.gemspec
|
141
142
|
homepage: https://github.com/JoeQuattroneufc_schedule
|
142
143
|
licenses:
|