top-headlines 0.2.3 → 0.2.4
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 +2 -0
- data/lib/top-headlines/cli.rb +17 -18
- data/lib/top-headlines/source.rb +1 -1
- data/lib/top-headlines/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f0e8b3b6cf9a151356422f0fe282c0ec4f13988
|
4
|
+
data.tar.gz: 6a06fae11f6722d00c7294b0f226481fbf0f6bad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6a18208ef7ff9ba6023ce49769195eb33578442e170d216aeeee7edaf7ba322eaae485396cba38848375de933a8807c970fdb5cbd8ec74dba488a5099873436
|
7
|
+
data.tar.gz: 576fab8cc7cf1942e968083eb8bacbeb365cf59f2c9787560f846a03fb85ff828267f0f2fe2ca58aee53b4e2ff131b860f6c75e0c35da807af4ca894357f1e63
|
data/README.md
CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
To use the gem, you'll need to `require 'top-headlines'`, instantiate a new TopHeadlines::CLI, and use the .call class method (e.g. `TopHeadlines::CLI.new.call`). You'll then be prompted by on-screen instructions.
|
24
|
+
|
23
25
|
In lib/top-headlines/source.rb, users will find a SOURCES hash. Users may add their own favorite news sources to the hash, so that the gem dynamically scrapes even more headlines.
|
24
26
|
```
|
25
27
|
If you'd like to view how I made the gem, here's a set of videos that captures almost all of it:
|
data/lib/top-headlines/cli.rb
CHANGED
@@ -10,7 +10,6 @@ class TopHeadlines::CLI
|
|
10
10
|
def menu
|
11
11
|
puts "Which source do you want to view? Alternatively, type 'all' to view all headlines or 'exit' to exit!"
|
12
12
|
print "YOUR SELECTION: "
|
13
|
-
@input = nil
|
14
13
|
while @input != "EXIT" && @num != "EXIT"
|
15
14
|
@input = gets.strip.upcase
|
16
15
|
menu_if_statement
|
@@ -18,23 +17,23 @@ class TopHeadlines::CLI
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def menu_if_statement
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
20
|
+
if @input == "ALL"
|
21
|
+
list_all_headlines_banner
|
22
|
+
list_all_headlines
|
23
|
+
all_headlines_open_in_browser
|
24
|
+
elsif @input == "SOURCES"
|
25
|
+
news_sources_banner
|
26
|
+
news_sources
|
27
|
+
puts request_input_full_menu
|
28
|
+
print "YOUR SELECTION: "
|
29
|
+
elsif source_includes?(@input)
|
30
|
+
list_headlines_from_source
|
31
|
+
headlines_from_source_open_in_browser
|
32
|
+
elsif @input != "EXIT"
|
33
|
+
invalid_entry
|
34
|
+
else
|
35
|
+
nil
|
36
|
+
end
|
38
37
|
end
|
39
38
|
|
40
39
|
def welcome_banner
|
data/lib/top-headlines/source.rb
CHANGED
@@ -160,7 +160,7 @@ class TopHeadlines::Source
|
|
160
160
|
|
161
161
|
doc = Nokogiri::HTML(open(page_url))
|
162
162
|
|
163
|
-
headlines = doc.css(headlines_selector).map {|headline| headline.text.gsub("â", "'").gsub(/\n/,"").gsub(/\t/,"").
|
163
|
+
headlines = doc.css(headlines_selector).map {|headline| headline.text.strip.gsub("â", "'").gsub(/\n/,"").gsub(/\t/,"").gsub(/\d+$/,"")}
|
164
164
|
end
|
165
165
|
|
166
166
|
def self.scrape_urls(source)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: top-headlines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Newburgh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|