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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dd925e33310631dd0a45b4248c63890fea2ee5d
4
- data.tar.gz: 32ea5ca62cdbc740b4d37de2c903ba72297dfb72
3
+ metadata.gz: 18d5f653af44d06dca9e02699fba5d2ac77181b6
4
+ data.tar.gz: 5cfd133bcd4167f3d85a67b45e9efb34b3bdb841
5
5
  SHA512:
6
- metadata.gz: ff0694ed1532cb4ccfdb3c6144e3ac691ae8ba15318f41d74092fc4d0ab08c6aa39004f8067338523fa8266999643a900c09caf9297b7911f87d52172053757b
7
- data.tar.gz: 2c4e42f88e69eaccf0928ab1734f0ecb3933c610a17176a504cfd6ba4b765ec483113e8c37dfc5797f34a4d367db84496f6965ed1cf7872620b034b15016e6d2
6
+ metadata.gz: 643d1a491b4c6a1db36ceab58e3ee7b583c10ed26e9e2038acc7918e760329d7b7eb563e0a466337a6ead93b43220534d5344dc49a50ca0e0df3789cbf157763
7
+ data.tar.gz: 58f03c4c7ce33c4df74115ddd34515dc45c38e37666a41483221bf8aa106d63aae9b616b7898f5a1b2c9ddf42f52ec73b85cd801aeb727987c45324ab299dec1
data/cdc_notices.gemspec CHANGED
@@ -36,5 +36,6 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "nokogiri", "~> 1.7.1"
37
37
  spec.add_development_dependency "rubysl-open-uri"
38
38
  spec.add_development_dependency "launchy"
39
+
39
40
  # spec.add_development_dependency "openssl", "~> 2.0.3"
40
41
  end
@@ -1,4 +1,4 @@
1
- require_relative '../scrape_notice'
1
+ require_relative '../scrape_notice.rb'
2
2
  require_relative '../notice.rb'
3
3
  require 'launchy'
4
4
  class CdcNotices::CLI
@@ -1,3 +1,3 @@
1
1
  module CdcNotices
2
- VERSION = "0.1.3" #still working, but pushed to ruby gems.
2
+ VERSION = "0.1.5" #still working, but pushed to ruby gems.
3
3
  end
data/lib/cdc_notices.rb CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  require_relative "./cdc_notices/version"
2
3
  require_relative "./cdc_notices/cli"
3
4
  module CdcNotices
data/lib/notice.rb CHANGED
@@ -105,5 +105,4 @@ class Notice
105
105
  end
106
106
 
107
107
 
108
-
109
108
  end
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 'warning.rb'
9
+ require_relative 'warn.rb'
10
+
9
11
  class Scraper
10
12
 
11
13
  attr_accessor :url
12
14
 
13
- def initialize(url)
14
- @url = url
15
- @notice = Notice.new
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
- def get_page
20
- html = open(@url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
21
- doc = Nokogiri::HTML(html)
26
+ end
22
27
 
23
- end
28
+ def set_attributes
29
+ array_alert = []
30
+ array_watch = []
31
+ array_warn = []
32
+ main_content = self.get_page.css('#contentArea')
24
33
 
25
- def set_attributes
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
- notice_hash = {:alert => main_content.css('#alert'), :watch => main_content.css('#watch'), :warning => main_content.css('#warning')}
36
+ alerts = notice_hash[:alert].collect {|alert| alert.css('li')}
32
37
 
33
- alerts = notice_hash[:alert].collect {|alert| alert.css('li')}
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
- watches = notice_hash[:watch].collect {|watch| watch.css('li')}
43
- if watches[0] != nil
44
- watches[0].each do |watch|
45
- array_watch << watch
46
- end
47
- end
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
- warnings = notice_hash[:warning].collect {|warning| warning.css('li')}
50
- if warnings[0] != nil
51
- warnings[0].each do |warning|
52
- array_warning << warning
53
- end
54
- end
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
- array_alert.each do |alert|
57
- new_alert = Alert.new
58
- new_alert.title = alert.css('a:not(.readmore)').text
59
- new_alert.summary = alert.css('span').text
60
- new_alert.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{alert.css('a').attr('href').text}"
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
- @notice.add_alert(new_alert)
63
- end
66
+ @notice.add_alert(new_alert)
67
+ end
64
68
 
65
- array_watch.each do |watch|
66
- new_watch = Watch.new
67
- new_watch.title = watch.css('a:not(.readmore)').text
68
- new_watch.summary = watch.css('span').text
69
- new_watch.readmore = "#{@url.gsub(/\/travel\/notices/, "")}#{watch.css('a').attr('href').text}"
70
- @notice.add_watch(new_watch)
71
- end
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
 
@@ -1,4 +1,5 @@
1
- class Warning
1
+ class Warn
2
2
 
3
3
  attr_accessor :title, :summary, :readmore
4
+
4
5
  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.3
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-05 00:00:00.000000000 Z
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/warning.rb
125
+ - lib/warn.rb
126
126
  - lib/watch.rb
127
127
  - spec.md
128
128
  homepage: