cdc_notices 0.1.3 → 0.1.5
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/cdc_notices.gemspec +1 -0
- data/lib/cdc_notices/cli.rb +1 -1
- data/lib/cdc_notices/version.rb +1 -1
- data/lib/cdc_notices.rb +1 -0
- data/lib/notice.rb +0 -1
- data/lib/scrape_notice.rb +60 -56
- data/lib/{warning.rb → warn.rb} +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18d5f653af44d06dca9e02699fba5d2ac77181b6
|
4
|
+
data.tar.gz: 5cfd133bcd4167f3d85a67b45e9efb34b3bdb841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 643d1a491b4c6a1db36ceab58e3ee7b583c10ed26e9e2038acc7918e760329d7b7eb563e0a466337a6ead93b43220534d5344dc49a50ca0e0df3789cbf157763
|
7
|
+
data.tar.gz: 58f03c4c7ce33c4df74115ddd34515dc45c38e37666a41483221bf8aa106d63aae9b616b7898f5a1b2c9ddf42f52ec73b85cd801aeb727987c45324ab299dec1
|
data/cdc_notices.gemspec
CHANGED
data/lib/cdc_notices/cli.rb
CHANGED
data/lib/cdc_notices/version.rb
CHANGED
data/lib/cdc_notices.rb
CHANGED
data/lib/notice.rb
CHANGED
data/lib/scrape_notice.rb
CHANGED
@@ -4,87 +4,91 @@ require 'openssl'
|
|
4
4
|
|
5
5
|
require_relative 'notice.rb'
|
6
6
|
require_relative 'alert.rb'
|
7
|
+
|
7
8
|
require_relative 'watch.rb'
|
8
|
-
require_relative '
|
9
|
+
require_relative 'warn.rb'
|
10
|
+
|
9
11
|
class Scraper
|
10
12
|
|
11
13
|
attr_accessor :url
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
def initialize(url)
|
16
|
+
@url = url
|
17
|
+
@notice = Notice.new
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_page
|
22
|
+
html = open(@url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
|
23
|
+
doc = Nokogiri::HTML(html)
|
16
24
|
|
17
|
-
end
|
18
25
|
|
19
|
-
|
20
|
-
html = open(@url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
|
21
|
-
doc = Nokogiri::HTML(html)
|
26
|
+
end
|
22
27
|
|
23
|
-
|
28
|
+
def set_attributes
|
29
|
+
array_alert = []
|
30
|
+
array_watch = []
|
31
|
+
array_warn = []
|
32
|
+
main_content = self.get_page.css('#contentArea')
|
24
33
|
|
25
|
-
|
26
|
-
array_alert = []
|
27
|
-
array_watch = []
|
28
|
-
array_warning = []
|
29
|
-
main_content = self.get_page.css('#contentArea')
|
34
|
+
notice_hash = {:alert => main_content.css('#alert'), :watch => main_content.css('#watch'), :warn => main_content.css('#warn')}
|
30
35
|
|
31
|
-
|
36
|
+
alerts = notice_hash[:alert].collect {|alert| alert.css('li')}
|
32
37
|
|
33
|
-
|
38
|
+
if alerts[0] != nil
|
39
|
+
alerts[0].each do |alert|
|
40
|
+
array_alert << alert
|
41
|
+
end
|
42
|
+
end
|
34
43
|
|
35
|
-
if alerts[0] != nil
|
36
|
-
alerts[0].each do |alert|
|
37
|
-
array_alert << alert
|
38
|
-
end
|
39
|
-
end
|
40
44
|
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
watches = notice_hash[:watch].collect {|watch| watch.css('li')}
|
47
|
+
if watches[0] != nil
|
48
|
+
watches[0].each do |watch|
|
49
|
+
array_watch << watch
|
50
|
+
end
|
51
|
+
end
|
48
52
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
warns = notice_hash[:warn].collect {|warn| warn.css('li')}
|
54
|
+
if warns[0] != nil
|
55
|
+
warns[0].each do |warn|
|
56
|
+
array_warn << warn
|
57
|
+
end
|
58
|
+
end
|
55
59
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
array_alert.each do |alert|
|
61
|
+
new_alert = Alert.new
|
62
|
+
new_alert.title = alert.css('a:not(.readmore)').text
|
63
|
+
new_alert.summary = alert.css('span').text
|
64
|
+
new_alert.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{alert.css('a').attr('href').text}"
|
61
65
|
|
62
|
-
|
63
|
-
|
66
|
+
@notice.add_alert(new_alert)
|
67
|
+
end
|
64
68
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
72
76
|
|
73
|
-
array_warning.each do |warn|
|
74
|
-
new_warning = Warning.new
|
75
|
-
new_warning.title = warn.css('a:not(.readmore)').text
|
76
|
-
new_warning.summary = warn.css('span').text
|
77
|
-
new_warning.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{warn.css('a').attr('href').text}"
|
78
|
-
@notice.add_warning(new_warning)
|
79
|
-
end
|
80
77
|
|
81
|
-
@notice
|
82
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
|
83
86
|
|
87
|
+
@notice
|
84
88
|
|
85
|
-
end
|
86
89
|
|
87
90
|
|
91
|
+
end
|
88
92
|
|
89
93
|
|
90
94
|
|
data/lib/{warning.rb → warn.rb}
RENAMED
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tahbristol
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,7 +122,7 @@ files:
|
|
122
122
|
- lib/cdc_notices/version.rb
|
123
123
|
- lib/notice.rb
|
124
124
|
- lib/scrape_notice.rb
|
125
|
-
- lib/
|
125
|
+
- lib/warn.rb
|
126
126
|
- lib/watch.rb
|
127
127
|
- spec.md
|
128
128
|
homepage:
|