cdc_notices 0.1.5 → 0.1.6
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/README.md +5 -2
- data/bin/cdc-notices +2 -1
- data/exe/cdc-notices +0 -0
- data/lib/cdc_notices/version.rb +1 -1
- data/lib/concerns/make_new.rb +35 -0
- data/lib/scrape_notice.rb +21 -56
- metadata +4 -4
- data/lib/cdc_notices.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67ec9bd9fe5e76a9dc45ee684e9fef41f39d42ac
|
4
|
+
data.tar.gz: a7aea7afecc2914adcc77216b8ef626db240adff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57a06b363b3aa5e79bcd0f1db3ee2883ec3d0542581b268ff0bcbe5720b5a45c3db92d81c1748016e49a77125dbbf556f5bea7f4c624608a1aa858c368e0ff97
|
7
|
+
data.tar.gz: 72b4e43e7c458ae46e9280fc781330b40237e4e3aa04cb39c909146b1fc85eab8624489ef6657478971db9261ad769d0cbd38e944e31ae2b448a2c1a7846b308
|
data/README.md
CHANGED
@@ -22,7 +22,11 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
1. Download gem.
|
26
|
+
2. In the terminal, navigate to the downloaded folder.
|
27
|
+
3. Run 'bundle install'. (this will require the bundler gem
|
28
|
+
installed on the system)
|
29
|
+
4. Run 'ruby bin/cdc-notices'
|
26
30
|
|
27
31
|
## Development
|
28
32
|
|
@@ -38,4 +42,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
38
42
|
## License
|
39
43
|
|
40
44
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/bin/cdc-notices
CHANGED
data/exe/cdc-notices
CHANGED
File without changes
|
data/lib/cdc_notices/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module MakeNew
|
2
|
+
module InstanceMethods
|
3
|
+
def make(array)
|
4
|
+
type = array[0].split("_").last
|
5
|
+
array.shift
|
6
|
+
|
7
|
+
if type == "alert"
|
8
|
+
array.each do |alert|
|
9
|
+
new_alert = Alert.new
|
10
|
+
new_alert.title = alert.css('a:not(.readmore)').text
|
11
|
+
new_alert.summary = alert.css('span').text
|
12
|
+
new_alert.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{alert.css('.readmore').attr('href').text}"
|
13
|
+
@notice.add_alert(new_alert)
|
14
|
+
end
|
15
|
+
elsif type == "warn"
|
16
|
+
array.each do |warn|
|
17
|
+
new_warn = warn.new
|
18
|
+
new_warn.title = warn.css('a:not(.readmore)').text
|
19
|
+
new_warn.summary = warn.css('span').text
|
20
|
+
new_warn.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{warn.css('.readmore').attr('href').text}"
|
21
|
+
@notice.add_warn(new_warn)
|
22
|
+
end
|
23
|
+
|
24
|
+
elsif type == "watch"
|
25
|
+
array.each do |watch|
|
26
|
+
new_watch = Watch.new
|
27
|
+
new_watch.title = watch.css('a:not(.readmore)').text
|
28
|
+
new_watch.summary = watch.css('span').text
|
29
|
+
new_watch.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{watch.css('.readmore').attr('href').text}"
|
30
|
+
@notice.add_watch(new_watch)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/scrape_notice.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'openssl'
|
4
|
-
|
4
|
+
require 'pry'
|
5
5
|
require_relative 'notice.rb'
|
6
6
|
require_relative 'alert.rb'
|
7
|
-
|
8
7
|
require_relative 'watch.rb'
|
9
8
|
require_relative 'warn.rb'
|
10
|
-
|
9
|
+
require_relative 'concerns/make_new'
|
11
10
|
class Scraper
|
12
|
-
|
11
|
+
include MakeNew::InstanceMethods
|
13
12
|
attr_accessor :url
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def initialize(url)
|
15
|
+
@url = url
|
16
|
+
@notice = Notice.new
|
18
17
|
|
19
|
-
|
18
|
+
end
|
20
19
|
|
21
20
|
def get_page
|
22
21
|
html = open(@url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
|
@@ -26,72 +25,38 @@ class Scraper
|
|
26
25
|
end
|
27
26
|
|
28
27
|
def set_attributes
|
29
|
-
array_alert = []
|
30
|
-
array_watch = []
|
31
|
-
array_warn = []
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
array_alert = ["array_alert"]
|
29
|
+
array_watch = ["array_watch"]
|
30
|
+
array_warn = ["array_warn"]
|
31
|
+
|
32
|
+
main_content = self.get_page.css('#contentArea')
|
33
|
+
notice_hash = {:alert => main_content.css('#alert'), :watch => main_content.css('#watch'), :warn => main_content.css('#warn')}
|
34
|
+
alerts = notice_hash[:alert].collect {|alert| alert.css('li')}
|
35
|
+
watches = notice_hash[:watch].collect {|watch| watch.css('li')}
|
36
|
+
warns = notice_hash[:warn].collect {|warn| warn.css('li')}
|
38
37
|
if alerts[0] != nil
|
39
38
|
alerts[0].each do |alert|
|
40
39
|
array_alert << alert
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
watches = notice_hash[:watch].collect {|watch| watch.css('li')}
|
47
43
|
if watches[0] != nil
|
48
44
|
watches[0].each do |watch|
|
49
45
|
array_watch << watch
|
50
46
|
end
|
51
47
|
end
|
52
48
|
|
53
|
-
warns = notice_hash[:warn].collect {|warn| warn.css('li')}
|
54
49
|
if warns[0] != nil
|
55
50
|
warns[0].each do |warn|
|
56
51
|
array_warn << warn
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
new_alert.summary = alert.css('span').text
|
64
|
-
new_alert.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{alert.css('a').attr('href').text}"
|
65
|
-
|
66
|
-
@notice.add_alert(new_alert)
|
67
|
-
end
|
68
|
-
|
69
|
-
array_watch.each do |watch|
|
70
|
-
new_watch = Watch.new
|
71
|
-
new_watch.title = watch.css('a:not(.readmore)').text
|
72
|
-
new_watch.summary = watch.css('span').text
|
73
|
-
new_watch.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{watch.css('a').attr('href').text}"
|
74
|
-
@notice.add_watch(new_watch)
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
array_warn.each do |warn|
|
80
|
-
new_warn = warn.new
|
81
|
-
new_warn.title = warn.css('a:not(.readmore)').text
|
82
|
-
new_warn.summary = warn.css('span').text
|
83
|
-
new_warn.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{warn.css('a').attr('href').text}"
|
84
|
-
@notice.add_warn(new_warn)
|
85
|
-
end
|
86
|
-
|
87
|
-
@notice
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
|
55
|
+
make(array_alert)
|
56
|
+
make(array_warn)
|
57
|
+
make(array_watch)
|
95
58
|
|
59
|
+
@notice
|
60
|
+
end
|
96
61
|
|
97
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdc_notices
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tahbristol
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,9 +117,9 @@ files:
|
|
117
117
|
- cdc_notices.gemspec
|
118
118
|
- exe/cdc-notices
|
119
119
|
- lib/alert.rb
|
120
|
-
- lib/cdc_notices.rb
|
121
120
|
- lib/cdc_notices/cli.rb
|
122
121
|
- lib/cdc_notices/version.rb
|
122
|
+
- lib/concerns/make_new.rb
|
123
123
|
- lib/notice.rb
|
124
124
|
- lib/scrape_notice.rb
|
125
125
|
- lib/warn.rb
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.6.
|
148
|
+
rubygems_version: 2.6.7
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: Displays currrent infectious disease travel notices from the Centers for
|