CLI_2 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a76d32fd32ff4ab12e819a0e268d24951529b77bc4b112ba60c7922cb049988a
4
- data.tar.gz: 92cbe4be4b1853c118cf7c442e01d44992f56cbd6eae13f21d6c599864b42318
3
+ metadata.gz: 13f02e0abff7b6caf511ae76fff2bb92e715273afc932d24f23d52e842bfef86
4
+ data.tar.gz: 6e3d21f227a26bfe9f9a6595607f9882c97655d5482266154b83d5fdd8f318ad
5
5
  SHA512:
6
- metadata.gz: c4f11a8cccf644dda98b23ca0423388b8569cdf2a199379030b4853128d40b0804206aaac010b9157fe818d07ee4a30bd7e298b1063dc2e8a5b664d4759b6585
7
- data.tar.gz: 1db103774fcf36fd721bd56cc04d7cb81fc6e21ede90181f1a0c4719be332cc0fd1993bd21c35f668bdf972607e7ace04e69515e81254a5e001a032df2fa1d16
6
+ metadata.gz: 835edbb29636f290bace867d5b1e906735085ef6beb5d3cd2a8ee9f7e57ff762f8ad042ce2ea292a03f7c28d07476cb36b36156dd9021cbd83ef6b082222df87
7
+ data.tar.gz: 02edb17d3218e0c38b3529ce7d6fd87277c41930ca1e81da6501a292838dbfb70da0f0fb2549f3d0ee9cf3bf284c65b285fe60cdfcebf0ad24bc6aba13747053
data/CLI_2-0.1.0.gem ADDED
Binary file
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ CLI_2 (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ method_source (0.9.0)
11
+ mini_portile (0.6.2)
12
+ nokogiri (1.6.6.2)
13
+ mini_portile (~> 0.6.0)
14
+ pry (0.11.3)
15
+ coderay (~> 1.1.0)
16
+ method_source (~> 0.9.0)
17
+ rake (10.5.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ CLI_2!
24
+ bundler (~> 1.16)
25
+ nokogiri (= 1.6.6.2)
26
+ pry
27
+ rake (~> 10.0)
28
+
29
+ BUNDLED WITH
30
+ 1.16.5
data/lib/CLI.rb CHANGED
@@ -1,9 +1,13 @@
1
- #this is the class that is responsible for interacting with the user
2
-
3
1
  require_relative "Scraper.rb"
4
2
  require_relative "Providers.rb"
5
3
  require_relative "Languages.rb"
6
4
  require_relative "Teams.rb"
5
+ require_relative "Printer.rb"
6
+ require_relative "UserInputExe.rb"
7
+
8
+
9
+ include Printer
10
+ include UserInputExe
7
11
 
8
12
  class CLI
9
13
 
@@ -11,34 +15,28 @@ class CLI
11
15
  Scraper.scrape_page(clinic_url)
12
16
  end
13
17
 
14
- def start(clinic_url = "http://callen-lorde.org/meet-our-providers/")
18
+
15
19
 
20
+ def start(clinic_url = "http://callen-lorde.org/meet-our-providers/")
16
21
 
17
- puts "Choose from the following menu:"
18
- puts "1) List of all providers"
19
- puts "2) Details on a specific provider"
20
- puts "3) List of providers by their team"
21
- puts "4) List of providers by their specialty"
22
- puts "5) List of providers by their languages"
23
- puts "6) Get a specific provider's team?"
22
+ Printer::menu_screen
24
23
 
25
24
  user_input = gets.strip.to_i
26
25
 
27
-
28
26
  valid?(user_input)
29
27
 
30
28
  if user_input == 1
31
- choice_1
29
+ UserInputExe::choice_1
32
30
  elsif user_input == 2
33
- choice_2
31
+ UserInputExe::choice_2
34
32
  elsif user_input == 3
35
- choice_3
33
+ UserInputExe::choice_3
36
34
  elsif user_input == 4
37
- choice_4
35
+ UserInputExe::choice_4
38
36
  elsif user_input == 5
39
- choice_5
37
+ UserInputExe::choice_5
40
38
  else
41
- choice_6
39
+ UserInputExe::choice_6
42
40
  end
43
41
 
44
42
  start
@@ -46,157 +44,14 @@ class CLI
46
44
  end
47
45
 
48
46
 
49
- #==========================executing on the choice the user made===========================#
50
- def choice_1
51
-
52
- name_array = Providers.all.map do |provider|
53
- provider.name
54
- end
55
- printer(name_array)
56
-
57
- end
58
-
59
-
60
- def choice_2
61
-
62
- puts "Which provider would you like to know more about?"
63
- user_input = gets.strip
64
-
65
- req_provider = Providers.all.detect do |provider|
66
- user_input == provider.name
67
- end
68
-
69
- return_validator(req_provider)
70
-
71
- puts "=============================="
72
- if Teams.team_by_provider_name(req_provider.name) != nil
73
- puts "#{req_provider.name}'s team: #{Teams.team_by_provider_name(req_provider.name)}"
74
- end
75
- puts "#{req_provider.name}'s specialties: #{req_provider.specialties}"
76
- puts "#{req_provider.name}'s languages: #{Languages.languages_by_provider(req_provider)}"
77
- puts "#{req_provider.name}'s qualifications: #{req_provider.qualifications}"
78
- if req_provider.title != nil
79
- puts "#{req_provider.name}'s title: #{req_provider.title}"
80
- end
81
- puts "=============================="
82
-
83
- end
84
-
85
- def choice_3
86
-
87
- instances_of_teams = Teams.all
88
-
89
- puts "These are all the current teams:"
90
- instances_of_teams.each do |team|
91
- #binding.pry
92
- puts team.name
93
- end
94
-
95
- puts "For which team would you like a list of providers?"
96
- user_input = gets.strip
97
-
98
- puts "Here is the list of providers for providers that are part of #{user_input} team:"
99
- printer(Teams.providers_by_team(user_input))
100
-
101
- end
102
-
103
- def choice_4
104
-
105
- puts "From what specialty: Adolescent Health, Family Practice, HIV, Adult Primary Care or Internal Medicine"
106
- user_input = gets.strip
107
-
108
- return_array = Array.new
109
-
110
- Providers.all.each do |provider|
111
- temp_arr = provider.specialties.split(",")
112
- i = 0
113
- while i < temp_arr.size
114
- if temp_arr[i].strip == user_input
115
- return_array << provider.name
116
- end
117
- i+=1
118
- end
119
- end
120
-
121
- return_validator(return_array)
122
- printer(return_array.uniq)
123
-
124
- end
125
-
126
- def choice_5
127
-
128
- instances_of_languages = Languages.all
129
-
130
- puts "These are all the languages that the current providers speak:"
131
- instances_of_languages.each do |language|
132
- puts language.name
133
- end
134
-
135
- puts "For which one would you like a list of providers?"
136
- user_input = gets.strip
137
-
138
- puts "Here is the list of providers for providers that speak #{user_input}:"
139
- instances_of_languages.each do |language|
140
- if language.name == user_input
141
- language.providers.each do |provider|
142
- puts provider.name
143
- end
144
- end
145
- end
146
-
147
- end
148
-
149
- def choice_6
150
-
151
- puts "The provider's name?"
152
- user_input = gets.strip
153
-
154
- puts "#{user_input}'s team is #{Teams.team_by_provider_name(user_input)}'"
155
-
156
-
157
- end
158
-
159
- #=================== Helper Methods ====================
160
47
 
161
48
  def valid?(user_input)
162
49
  if user_input >= 1 && user_input <= 6
163
50
  true
164
51
  else
165
- puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
166
- puts "!!!!!!!!!!!!! Please enter either 1, 2, 3 or 4 !!!!!!!!!!!!"
167
- puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
168
- start
169
- end
170
- end
171
-
172
- def return_validator(array_or_hash)
173
-
174
- if array_or_hash == nil
175
- puts "======================================================================================================"
176
- puts "!!!!!!!! The doctor, team or specialty that you have choosen does not exit in this clinic !!!!!!!!"
177
- puts "======================================================================================================"
52
+ list_right_options
178
53
  start
179
-
180
- elsif array_or_hash.instance_of?(Array) && array_or_hash.any? == false
181
- puts "======================================================================================================"
182
- puts "!!!!!!!! The doctor, team or specialty that you have choosen does not exit in this clinic !!!!!!!!"
183
- puts "======================================================================================================"
184
- start
185
-
186
- end
187
- end
188
-
189
- def printer(arry_to_print)
190
-
191
- puts "<<<<<<<<<<<< HERE IS THE LIST: >>>>>>>>>>>"
192
- i = 0
193
- while i < arry_to_print.size
194
- puts arry_to_print[i]
195
- i+=1
196
54
  end
197
- puts "^^^^^^ THE PROVIDERS ARE LISTED ABOVE ^^^^^^^"
198
- puts "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
199
-
200
55
  end
201
56
 
202
57
  end
data/lib/CLI_2/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CLI2
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/Languages.rb CHANGED
@@ -5,9 +5,10 @@ require_relative "Providers.rb"
5
5
  class Languages
6
6
 
7
7
  @@all = Array.new
8
-
9
8
  attr_accessor :name, :providers
10
9
 
10
+
11
+
11
12
  def initialize(name)
12
13
  @name = name
13
14
  @providers = Array.new
@@ -15,6 +16,7 @@ class Languages
15
16
  end
16
17
 
17
18
 
19
+
18
20
  def self.add_by_name(language_names, provider)
19
21
 
20
22
  ary = language_names.split(",")
@@ -33,7 +35,7 @@ class Languages
33
35
  end
34
36
 
35
37
 
36
- if our_language == false || our_language == nil || our_language.length == 0
38
+ if our_language.length == 0
37
39
  new_language = Languages.new(language_name)
38
40
  new_language.providers << provider
39
41
  language_instances_to_return << our_language
@@ -47,6 +49,8 @@ class Languages
47
49
  language_instances_to_return
48
50
  end
49
51
 
52
+
53
+
50
54
  def self.languages_by_provider(provider)
51
55
 
52
56
  provider_languages = Array.new
@@ -61,6 +65,8 @@ class Languages
61
65
  provider_languages.join(', ')
62
66
  end
63
67
 
68
+
69
+
64
70
  def self.all
65
71
  @@all
66
72
  end
data/lib/Printer.rb ADDED
@@ -0,0 +1,112 @@
1
+ require_relative "Specialites.rb"
2
+
3
+ module Printer
4
+
5
+
6
+
7
+ def warning_message
8
+ puts "======================================================================================================"
9
+ puts "!!!!!!!! The doctor, team or specialty that you have choosen does not exit in this clinic !!!!!!!!"
10
+ puts "======================================================================================================"
11
+ end
12
+
13
+
14
+
15
+ def warning_message_team
16
+ puts "======================================================================================================"
17
+ puts "!!!!!!!! You've chosen a doctor that either does not exist or is not part os any team !!!!!!!!"
18
+ puts "======================================================================================================"
19
+ end
20
+
21
+
22
+
23
+ def print_from_arr_of_s(array_to_print)
24
+
25
+ if array_to_print.length == 0
26
+ warning_message
27
+ else
28
+ puts "<<<<<<<<<<<< HERE IS THE LIST: >>>>>>>>>>>"
29
+ i = 0
30
+ while i < array_to_print.size
31
+ puts array_to_print[i]
32
+ i+=1
33
+ end
34
+ puts "^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^"
35
+ puts "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
36
+ end
37
+
38
+ end
39
+
40
+
41
+
42
+ def list_right_options
43
+ puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
44
+ puts "!!!!!!!!!!!!! Please enter either 1, 2, 3 or 4 !!!!!!!!!!!!"
45
+ puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
46
+ end
47
+
48
+
49
+
50
+ def menu_screen
51
+ puts "Choose from the following menu:"
52
+ puts "1) List of all providers"
53
+ puts "2) Details on a specific provider"
54
+ puts "3) List of providers by their team"
55
+ puts "4) List of providers by their specialty"
56
+ puts "5) List of providers by their languages"
57
+ puts "6) Get a specific provider's team?"
58
+ end
59
+
60
+
61
+
62
+ def print_from_arr_of_o(instances_of_objects)
63
+ puts "<<<<<<<<<<<< HERE IS THE LIST: >>>>>>>>>>>"
64
+ instances_of_objects.each do |object|
65
+ puts object.name
66
+ end
67
+ puts "^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^"
68
+ puts "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
69
+ end
70
+
71
+
72
+
73
+ def print_whole_profile(provider_instance)
74
+
75
+ puts "=============================="
76
+ if Teams.team_by_provider_name(provider_instance.name) != nil
77
+ puts "#{provider_instance.name}'s team: #{Teams.team_by_provider_name(provider_instance.name)}"
78
+ end
79
+ puts "#{provider_instance.name}'s languages: #{Specialites.specialties_by_provider(provider_instance)}"
80
+ #puts "#{provider_instance.name}'s specialties: #{provider_instance.specialties}"
81
+ puts "#{provider_instance.name}'s languages: #{Languages.languages_by_provider(provider_instance)}"
82
+ puts "#{provider_instance.name}'s qualifications: #{provider_instance.qualifications}"
83
+ if provider_instance.title != nil
84
+ puts "#{provider_instance.name}'s title: #{provider_instance.title}"
85
+ end
86
+ puts "=============================="
87
+
88
+ end
89
+
90
+
91
+
92
+ def get_provider_name
93
+ puts "Which provider?"
94
+ user_input = gets.strip
95
+ end
96
+
97
+
98
+
99
+ def get_choice_from_above
100
+ puts "Please choose from the list above to get the relevant providers:"
101
+ user_input = gets.strip
102
+ end
103
+
104
+
105
+
106
+ def print_this(for_printing)
107
+ puts "*****************************************************"
108
+ puts " #{for_printing} "
109
+ puts "*****************************************************"
110
+ end
111
+
112
+ end
data/lib/Providers.rb CHANGED
@@ -1,19 +1,24 @@
1
+ require_relative "Specialites.rb"
2
+
3
+
1
4
  class Providers
2
5
 
3
6
  @@all = Array.new
4
7
 
5
- attr_accessor :name, :team, :specialties, :languages, :title, :qualifications
8
+ attr_accessor :name, :team, :specialites, :languages, :title, :qualifications
6
9
 
7
10
  def initialize(attr_hash)
8
11
 
9
12
  @name = attr_hash[:name]
10
- @team = Teams.add_by_name(attr_hash[:team], self)
11
- @specialties = attr_hash[:specialties]
12
- @languages = Languages.add_by_name(attr_hash[:languages], self)
13
13
  @title = attr_hash[:title]
14
14
  @qualifications = attr_hash[:qualification]
15
15
 
16
+ @specialites = Specialites.add_by_name(attr_hash[:specialties], self)
17
+ @team = Teams.add_by_name(attr_hash[:team], self)
18
+ @languages = Languages.add_by_name(attr_hash[:languages], self)
19
+
16
20
  @@all << self
21
+
17
22
  end
18
23
 
19
24
  def self.all
@@ -0,0 +1,76 @@
1
+ require 'pry'
2
+
3
+ require_relative "Providers.rb"
4
+
5
+
6
+
7
+ class Specialites
8
+
9
+ @@all = Array.new
10
+ attr_accessor :name, :providers
11
+
12
+
13
+
14
+ def initialize(name)
15
+ @name = name
16
+ @providers = Array.new
17
+ @@all << self
18
+ end
19
+
20
+
21
+
22
+ def self.add_by_name(specialties, provider)
23
+
24
+ ary = specialties.split(",")
25
+ speciality_instances_to_return = Array.new
26
+
27
+ i = 0
28
+ while i < ary.size
29
+ ary[i] = ary[i].strip
30
+ i+=1
31
+ end
32
+
33
+ ary.each do |specialty|
34
+
35
+ our_specialty = @@all.select do |langu|
36
+ langu.name == specialty
37
+ end
38
+
39
+
40
+ if our_specialty == false || our_specialty == nil || our_specialty.length == 0
41
+ new_specialty = Specialites.new(specialty)
42
+ new_specialty.providers << provider
43
+ speciality_instances_to_return << new_specialty
44
+
45
+ else
46
+ our_specialty[0].providers << provider
47
+ speciality_instances_to_return << our_specialty
48
+ end
49
+
50
+ end
51
+ speciality_instances_to_return
52
+ end
53
+
54
+
55
+
56
+ def self.specialties_by_provider(provider)
57
+
58
+ provider_specialties = Array.new
59
+
60
+ @@all.each do |specialty|
61
+ specialty.providers.each do |prvdr|
62
+ if prvdr == provider
63
+ provider_specialties << specialty.name
64
+ end
65
+ end
66
+ end
67
+ provider_specialties.join(', ')
68
+ end
69
+
70
+
71
+
72
+ def self.all
73
+ @@all
74
+ end
75
+
76
+ end
data/lib/Teams.rb CHANGED
@@ -5,9 +5,10 @@ require_relative "Providers.rb"
5
5
  class Teams
6
6
 
7
7
  @@all = Array.new
8
-
9
8
  attr_accessor :name, :providers
10
9
 
10
+
11
+
11
12
  def initialize(name)
12
13
  @name = name
13
14
  @providers = Array.new
@@ -15,25 +16,23 @@ class Teams
15
16
  end
16
17
 
17
18
 
18
- def self.add_by_name(team_name, provider)
19
19
 
20
+ def self.add_by_name(team_name, provider)
20
21
 
21
22
  if team_name == nil
22
23
  nil
23
24
  else
24
-
25
25
  team_name = team_name.strip
26
+
26
27
  if team_name.length == 7 && team_name.include?("Purple")
27
28
  team_name = team_name.delete(team_name[0])
28
29
  end
29
30
 
30
-
31
-
32
31
  our_team = @@all.select do |team|
33
32
  team.name == team_name
34
33
  end
35
34
 
36
- if our_team == false || our_team == nil || our_team.length == 0
35
+ if our_team.length == 0
37
36
  new_team = Teams.new(team_name)
38
37
  new_team.providers << provider
39
38
  new_team
@@ -43,7 +42,6 @@ class Teams
43
42
  end
44
43
 
45
44
  end
46
-
47
45
  end
48
46
 
49
47
 
@@ -61,20 +59,28 @@ class Teams
61
59
  end
62
60
 
63
61
  list_of_providers
62
+
64
63
  end
65
64
 
65
+
66
+
67
+
66
68
  def self.team_by_provider_name(provider)
67
69
 
68
- @@all.each do |team|
69
- team.providers.each do |pvdr|
70
- if pvdr.name == provider
71
- return team.name
70
+ @@all.each do |team|
71
+ team.providers.each do |pvdr|
72
+ if pvdr.name == provider
73
+ return team.name
74
+ end
72
75
  end
73
76
  end
74
- end
77
+
78
+ nil
75
79
 
76
80
  end
77
81
 
82
+
83
+
78
84
  def self.all
79
85
  @@all
80
86
  end
@@ -0,0 +1,89 @@
1
+ module UserInputExe
2
+
3
+ def choice_1
4
+ Printer::print_from_arr_of_o(Providers.all)
5
+ end
6
+
7
+
8
+
9
+ def choice_2
10
+
11
+ user_input = Printer::get_provider_name
12
+
13
+ req_provider = Providers.all.detect do |provider|
14
+ user_input == provider.name
15
+ end
16
+
17
+ if req_provider == nil
18
+ Printer::warning_message
19
+ choice_2
20
+ else
21
+ Printer::print_whole_profile(req_provider)
22
+ end
23
+
24
+ end
25
+
26
+
27
+
28
+ def choice_3
29
+
30
+ instances_of_teams = Teams.all
31
+
32
+ Printer::print_from_arr_of_o(instances_of_teams)
33
+
34
+ user_input = Printer::get_choice_from_above
35
+ Printer::print_from_arr_of_s(Teams.providers_by_team(user_input))
36
+
37
+ end
38
+
39
+
40
+
41
+ def choice_4
42
+
43
+ instances_of_specialties = Specialites.all
44
+
45
+ Printer::print_from_arr_of_o(instances_of_specialties)
46
+
47
+ user_input = Printer::get_choice_from_above
48
+
49
+ instances_of_specialties.each do |specialty|
50
+ if specialty.name == user_input
51
+ Printer::print_from_arr_of_o(specialty.providers)
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+
58
+
59
+ def choice_5
60
+
61
+ instances_of_languages = Languages.all
62
+
63
+ Printer::print_from_arr_of_o(instances_of_languages)
64
+
65
+ user_input = Printer::get_choice_from_above
66
+
67
+ instances_of_languages.each do |language|
68
+ if language.name == user_input
69
+ Printer::print_from_arr_of_o(language.providers)
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+
76
+
77
+ def choice_6
78
+
79
+ user_input = Printer::get_provider_name
80
+
81
+ if Teams.team_by_provider_name(user_input) == nil
82
+ Printer::warning_message_team
83
+ else
84
+ Printer::print_this(Teams.team_by_provider_name(user_input))
85
+ end
86
+
87
+ end
88
+
89
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CLI_2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'ALEKSANDAR VUKASINOVIC'"
@@ -47,9 +47,11 @@ extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - ".gitignore"
50
+ - CLI_2-0.1.0.gem
50
51
  - CLI_2.gemspec
51
52
  - CODE_OF_CONDUCT.md
52
53
  - Gemfile
54
+ - Gemfile.lock
53
55
  - LICENSE.txt
54
56
  - README.md
55
57
  - Rakefile
@@ -59,9 +61,12 @@ files:
59
61
  - lib/CLI.rb
60
62
  - lib/CLI_2/version.rb
61
63
  - lib/Languages.rb
64
+ - lib/Printer.rb
62
65
  - lib/Providers.rb
63
66
  - lib/Scraper.rb
67
+ - lib/Specialites.rb
64
68
  - lib/Teams.rb
69
+ - lib/UserInputExe.rb
65
70
  homepage: https://github.com/alekvuka/CLI_2
66
71
  licenses:
67
72
  - MIT