CLI_2 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 +7 -0
- data/.gitignore +8 -0
- data/CLI_2.gemspec +37 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +2 -0
- data/bin/console +22 -0
- data/bin/run +10 -0
- data/bin/setup +8 -0
- data/lib/CLI.rb +202 -0
- data/lib/CLI_2/version.rb +3 -0
- data/lib/Languages.rb +68 -0
- data/lib/Providers.rb +23 -0
- data/lib/Scraper.rb +83 -0
- data/lib/Teams.rb +82 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a76d32fd32ff4ab12e819a0e268d24951529b77bc4b112ba60c7922cb049988a
|
4
|
+
data.tar.gz: 92cbe4be4b1853c118cf7c442e01d44992f56cbd6eae13f21d6c599864b42318
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c4f11a8cccf644dda98b23ca0423388b8569cdf2a199379030b4853128d40b0804206aaac010b9157fe818d07ee4a30bd7e298b1063dc2e8a5b664d4759b6585
|
7
|
+
data.tar.gz: 1db103774fcf36fd721bd56cc04d7cb81fc6e21ede90181f1a0c4719be332cc0fd1993bd21c35f668bdf972607e7ace04e69515e81254a5e001a032df2fa1d16
|
data/.gitignore
ADDED
data/CLI_2.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "CLI_2/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "CLI_2"
|
8
|
+
spec.version = CLI2::VERSION
|
9
|
+
spec.authors = ["'ALEKSANDAR VUKASINOVIC'"]
|
10
|
+
spec.email = ["'alekvuka@gmail.com'"]
|
11
|
+
|
12
|
+
spec.summary = %q{Write a short summary, because RubyGems requires one.}
|
13
|
+
spec.description = %q{ Write a longer description or delete this line.}
|
14
|
+
spec.homepage = "https://github.com/alekvuka/CLI_2"
|
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"] = "http://mygemserver.com"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "bin"
|
32
|
+
spec.executables = ["run"]
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
end
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at 'alekvuka@gmail.com'. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 'ALEKSANDAR VUKASINOVIC'
|
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,43 @@
|
|
1
|
+
# CLI2
|
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/CLI_2`. 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 'CLI_2'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install CLI_2
|
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. 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/'alekvuka'/CLI_2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the CLI2 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'alekvuka'/CLI_2/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "CLI_2"
|
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(__FILE__)
|
15
|
+
|
16
|
+
#------------------------------
|
17
|
+
|
18
|
+
puts "What clinic website would like information from?"
|
19
|
+
|
20
|
+
web_url = gets.strip
|
21
|
+
|
22
|
+
CLI.new(web_url)
|
data/bin/run
ADDED
data/bin/setup
ADDED
data/lib/CLI.rb
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
#this is the class that is responsible for interacting with the user
|
2
|
+
|
3
|
+
require_relative "Scraper.rb"
|
4
|
+
require_relative "Providers.rb"
|
5
|
+
require_relative "Languages.rb"
|
6
|
+
require_relative "Teams.rb"
|
7
|
+
|
8
|
+
class CLI
|
9
|
+
|
10
|
+
def initialize(clinic_url = "http://callen-lorde.org/meet-our-providers/")
|
11
|
+
Scraper.scrape_page(clinic_url)
|
12
|
+
end
|
13
|
+
|
14
|
+
def start(clinic_url = "http://callen-lorde.org/meet-our-providers/")
|
15
|
+
|
16
|
+
|
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?"
|
24
|
+
|
25
|
+
user_input = gets.strip.to_i
|
26
|
+
|
27
|
+
|
28
|
+
valid?(user_input)
|
29
|
+
|
30
|
+
if user_input == 1
|
31
|
+
choice_1
|
32
|
+
elsif user_input == 2
|
33
|
+
choice_2
|
34
|
+
elsif user_input == 3
|
35
|
+
choice_3
|
36
|
+
elsif user_input == 4
|
37
|
+
choice_4
|
38
|
+
elsif user_input == 5
|
39
|
+
choice_5
|
40
|
+
else
|
41
|
+
choice_6
|
42
|
+
end
|
43
|
+
|
44
|
+
start
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
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
|
+
|
161
|
+
def valid?(user_input)
|
162
|
+
if user_input >= 1 && user_input <= 6
|
163
|
+
true
|
164
|
+
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 "======================================================================================================"
|
178
|
+
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
|
+
end
|
197
|
+
puts "^^^^^^ THE PROVIDERS ARE LISTED ABOVE ^^^^^^^"
|
198
|
+
puts "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
data/lib/Languages.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
require_relative "Providers.rb"
|
4
|
+
|
5
|
+
class Languages
|
6
|
+
|
7
|
+
@@all = Array.new
|
8
|
+
|
9
|
+
attr_accessor :name, :providers
|
10
|
+
|
11
|
+
def initialize(name)
|
12
|
+
@name = name
|
13
|
+
@providers = Array.new
|
14
|
+
@@all << self
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def self.add_by_name(language_names, provider)
|
19
|
+
|
20
|
+
ary = language_names.split(",")
|
21
|
+
language_instances_to_return = Array.new
|
22
|
+
|
23
|
+
i = 0
|
24
|
+
while i < ary.size
|
25
|
+
ary[i] = ary[i].strip
|
26
|
+
i+=1
|
27
|
+
end
|
28
|
+
|
29
|
+
ary.each do |language_name|
|
30
|
+
|
31
|
+
our_language = @@all.select do |langu|
|
32
|
+
langu.name == language_name
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
if our_language == false || our_language == nil || our_language.length == 0
|
37
|
+
new_language = Languages.new(language_name)
|
38
|
+
new_language.providers << provider
|
39
|
+
language_instances_to_return << our_language
|
40
|
+
|
41
|
+
else
|
42
|
+
our_language[0].providers << provider
|
43
|
+
language_instances_to_return << our_language
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
language_instances_to_return
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.languages_by_provider(provider)
|
51
|
+
|
52
|
+
provider_languages = Array.new
|
53
|
+
|
54
|
+
@@all.each do |language|
|
55
|
+
language.providers.each do |prvdr|
|
56
|
+
if prvdr == provider
|
57
|
+
provider_languages << language.name
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
provider_languages.join(', ')
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.all
|
65
|
+
@@all
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/lib/Providers.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
class Providers
|
2
|
+
|
3
|
+
@@all = Array.new
|
4
|
+
|
5
|
+
attr_accessor :name, :team, :specialties, :languages, :title, :qualifications
|
6
|
+
|
7
|
+
def initialize(attr_hash)
|
8
|
+
|
9
|
+
@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
|
+
@title = attr_hash[:title]
|
14
|
+
@qualifications = attr_hash[:qualification]
|
15
|
+
|
16
|
+
@@all << self
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.all
|
20
|
+
@@all
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/Scraper.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
require_relative "Providers.rb"
|
6
|
+
|
7
|
+
|
8
|
+
class Scraper
|
9
|
+
|
10
|
+
def self.scrape_page(clinic_url = "http://callen-lorde.org/meet-our-providers/")
|
11
|
+
html = open(clinic_url)
|
12
|
+
doc = Nokogiri::HTML(html)
|
13
|
+
|
14
|
+
#name_qualifications_title = doc.css(".middleColumn_three").css('h3').first.text.split(",")
|
15
|
+
#name = name_qualifications_title[0]
|
16
|
+
#qualification = name_qualifications_title[1]
|
17
|
+
#title = name_qualifications_title[2]
|
18
|
+
|
19
|
+
#team_specialties_languages = doc.css(".middleColumn_three").css('ul').first.text
|
20
|
+
#t_s_l_array = team_specialties_languages.split("\n").reject { |n| n == "" }
|
21
|
+
|
22
|
+
#cleaned_t_s_l_array = t_s_l_array.map do |ele|
|
23
|
+
# ele.gsub(/\w+[:]/, "").strip
|
24
|
+
#end
|
25
|
+
|
26
|
+
#team = cleaned_t_s_l_array[0]
|
27
|
+
#specialties = cleaned_t_s_l_array[1]
|
28
|
+
#languages = cleaned_t_s_l_array[2]
|
29
|
+
|
30
|
+
|
31
|
+
attr_hash = Hash.new
|
32
|
+
array_of_providers = Array.new
|
33
|
+
|
34
|
+
|
35
|
+
#getting name, qualification and title attributes for a secific provider
|
36
|
+
doc.css(".middleColumn_three").css('h3').each do |provider|
|
37
|
+
new_hash = Hash.new
|
38
|
+
name_qualification_title = provider.text.split(",")
|
39
|
+
new_hash[:name] = name_qualification_title[0].gsub(/\w+[MD]/, "").strip
|
40
|
+
new_hash[:qualification] = name_qualification_title[1].strip
|
41
|
+
if name_qualification_title[2] != nil
|
42
|
+
new_hash[:title] = name_qualification_title[2].strip
|
43
|
+
end
|
44
|
+
array_of_providers << new_hash
|
45
|
+
end
|
46
|
+
|
47
|
+
#getting the team, specialties and languages attributes for a specific provider
|
48
|
+
i = 0
|
49
|
+
doc.css(".middleColumn_three").css('ul').each do |provider|
|
50
|
+
team_specialties_languanges = provider.text.split("\n").reject { |n| n == "" }
|
51
|
+
|
52
|
+
#remove words that end with ":"
|
53
|
+
team_specialties_languanges = team_specialties_languanges.map do |ele|
|
54
|
+
ele.gsub(/\w+[:]/, "").strip
|
55
|
+
end
|
56
|
+
|
57
|
+
#accointing for use case where attribute team is missing
|
58
|
+
if team_specialties_languanges.size == 2
|
59
|
+
array_of_providers[i][:specialties] = team_specialties_languanges[0].strip
|
60
|
+
array_of_providers[i][:languages] = team_specialties_languanges[1]
|
61
|
+
|
62
|
+
else
|
63
|
+
array_of_providers[i][:team] = team_specialties_languanges[0]
|
64
|
+
array_of_providers[i][:specialties] = team_specialties_languanges[1]
|
65
|
+
array_of_providers[i][:languages] = team_specialties_languanges[2]
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
if i < 46
|
70
|
+
i += 1
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
#creatign instances from our array of hashes
|
76
|
+
array_of_providers.each do |provider|
|
77
|
+
Providers.new(provider)
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/lib/Teams.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
require_relative "Providers.rb"
|
4
|
+
|
5
|
+
class Teams
|
6
|
+
|
7
|
+
@@all = Array.new
|
8
|
+
|
9
|
+
attr_accessor :name, :providers
|
10
|
+
|
11
|
+
def initialize(name)
|
12
|
+
@name = name
|
13
|
+
@providers = Array.new
|
14
|
+
@@all << self
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def self.add_by_name(team_name, provider)
|
19
|
+
|
20
|
+
|
21
|
+
if team_name == nil
|
22
|
+
nil
|
23
|
+
else
|
24
|
+
|
25
|
+
team_name = team_name.strip
|
26
|
+
if team_name.length == 7 && team_name.include?("Purple")
|
27
|
+
team_name = team_name.delete(team_name[0])
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
our_team = @@all.select do |team|
|
33
|
+
team.name == team_name
|
34
|
+
end
|
35
|
+
|
36
|
+
if our_team == false || our_team == nil || our_team.length == 0
|
37
|
+
new_team = Teams.new(team_name)
|
38
|
+
new_team.providers << provider
|
39
|
+
new_team
|
40
|
+
else
|
41
|
+
our_team[0].providers << provider
|
42
|
+
our_team
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
def self.providers_by_team(team_name)
|
52
|
+
|
53
|
+
list_of_providers = Array.new
|
54
|
+
|
55
|
+
@@all.each do |team|
|
56
|
+
if team.name == team_name
|
57
|
+
team.providers.each do |prvdr|
|
58
|
+
list_of_providers << prvdr.name
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
list_of_providers
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.team_by_provider_name(provider)
|
67
|
+
|
68
|
+
@@all.each do |team|
|
69
|
+
team.providers.each do |pvdr|
|
70
|
+
if pvdr.name == provider
|
71
|
+
return team.name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.all
|
79
|
+
@@all
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: CLI_2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "'ALEKSANDAR VUKASINOVIC'"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
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: " Write a longer description or delete this line."
|
42
|
+
email:
|
43
|
+
- "'alekvuka@gmail.com'"
|
44
|
+
executables:
|
45
|
+
- run
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- CLI_2.gemspec
|
51
|
+
- CODE_OF_CONDUCT.md
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/run
|
58
|
+
- bin/setup
|
59
|
+
- lib/CLI.rb
|
60
|
+
- lib/CLI_2/version.rb
|
61
|
+
- lib/Languages.rb
|
62
|
+
- lib/Providers.rb
|
63
|
+
- lib/Scraper.rb
|
64
|
+
- lib/Teams.rb
|
65
|
+
homepage: https://github.com/alekvuka/CLI_2
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.7.7
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Write a short summary, because RubyGems requires one.
|
89
|
+
test_files: []
|