top-headlines 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c88668ec85c6c26dff66038f0f954c04eb10bfa
4
- data.tar.gz: 0cd78d10749f7bf9d911a43be3f234461a5a0869
3
+ metadata.gz: 19cfb1ab3fbb5072c0a8cf152e586320e54503f2
4
+ data.tar.gz: ae26dc172f3c7f1be00eac01fa8f3655fe8a3246
5
5
  SHA512:
6
- metadata.gz: 87138d600b6568d5534924a0a33ab2733dea4d425f89eb9c83dd933c5c0ba7a93b86a3d048cd68b018e31529113a285f2d8a341accb95ceff30288af66595432
7
- data.tar.gz: 7749ecadb7de1f85a57eb0a31be441ed9f4170012410f37b8bfb7c4eabf3b659591761c0a167759a56707e558ef1cc86e7b17cceb9d7e6d0261112ae267e85a7
6
+ metadata.gz: 9ebad380cbe2c270e1ab0deecd65b2acaa3981b97bde7df59f52bc4c17c6c252b267356d57f7ad2c34bf1cc1e9db88f108dedd5c29e1fcfe4975ac48a349f779
7
+ data.tar.gz: 66ddef15c291fa00fd5b1a5c59f1c59c9769bffd3a2873c90e481b2d6de392284baa2804b7ec3b9971ecd03b742d99073b198f75a2f4444b8f91254f547f3a74
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TopHeadlines
2
2
 
3
- This gem allows users to view the top headlines from major news sources. Users can open the headlines in the browser directly from the command line. Functionality includes: AP, BBC, Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington Post, and Yahoo.
3
+ This gem allows users to view the top headlines from major news sources. Users can open the headlines in the browser directly from the command line. Functionality includes: AP, BBC, Bloomberg, CNN, Daily Beast, FiveThirtyEight, Forbes, Fox News, Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington Post, and Yahoo News.
4
4
 
5
5
  ## Installation
6
6
 
@@ -13,6 +13,11 @@ class TopHeadlines::CLI
13
13
  @input = nil
14
14
  while @input != "EXIT" && @num != "EXIT"
15
15
  @input = gets.strip.upcase
16
+ menu_if_statement
17
+ end
18
+ end
19
+
20
+ def menu_if_statement
16
21
  if @input == "ALL"
17
22
  list_all_headlines_banner
18
23
  list_all_headlines
@@ -24,7 +29,7 @@ class TopHeadlines::CLI
24
29
  news_sources
25
30
  puts request_input_full_menu
26
31
  print "YOUR SELECTION: "
27
- elsif TopHeadlines::Source.all.keys.include?(@input)
32
+ elsif source_includes?(@input)
28
33
  list_headlines_from_source
29
34
  open_headline_in_browser
30
35
  elsif @input != "EXIT"
@@ -32,7 +37,6 @@ class TopHeadlines::CLI
32
37
  else
33
38
  nil
34
39
  end
35
- end
36
40
  end
37
41
 
38
42
  def welcome_banner
@@ -69,6 +73,10 @@ class TopHeadlines::CLI
69
73
  "Select a source, type 'sources' to view sources, type 'all' to view all headlines, or type 'exit' to exit."
70
74
  end
71
75
 
76
+ def source_includes?(input)
77
+ TopHeadlines::Source.all.keys.include?(input)
78
+ end
79
+
72
80
  def news_sources_banner
73
81
  puts "\n"
74
82
  puts "NEWS SOURCES"
@@ -84,10 +92,25 @@ class TopHeadlines::CLI
84
92
  end
85
93
 
86
94
  def open_headline_in_browser
87
- puts "Select headline number to open the full article in the browser."
88
- print "YOUR SELECTION: "
95
+ puts "Select headline number to open the full article in the browser. \n\nAlternatively, #{request_input_full_menu.downcase}"
96
+ print "\nYOUR SELECTION: "
89
97
  @num = gets.strip.upcase
90
- while @num.to_i.between?(1,5)
98
+ while @num.to_i.between?(1,5) && !num_included_in_menu_if_statements
99
+ # if @input == "ALL"
100
+ # @input == TopHeadlines::Source.all.keys[@num/3]
101
+ # headline = TopHeadlines::Source.scrape_headlines(@input)[@num.to_i-1]
102
+ # puts "=> Opening..."
103
+
104
+ # sleep(2)
105
+ # url = TopHeadlines::Source.scrape_urls(@input)[@num.to_i-1]
106
+ # system("open", url)
107
+
108
+ # sleep(1)
109
+ # puts "\nSelect another headline number to open full article in the browser."
110
+ # print "YOUR SELECTION: "
111
+ # @num = gets.strip.upcase
112
+ # @input = @num if @num == "EXIT"
113
+ # else
91
114
  headline = TopHeadlines::Source.scrape_headlines(@input)[@num.to_i-1]
92
115
  puts "\n=> You selected the #{@num.to_i.ordinalize} headline: '#{headline}'."
93
116
  puts "=> Opening..."
@@ -97,12 +120,19 @@ class TopHeadlines::CLI
97
120
  system("open", url)
98
121
 
99
122
  sleep(1)
100
- puts "\nSelect another headline number to open full article in the browser."
101
- print "YOUR SELECTION: "
123
+ puts "\nSelect another headline number to open full article in the browser. \n\nAlternatively, #{request_input_full_menu.downcase}"
124
+ print "\nYOUR SELECTION: "
102
125
  @num = gets.strip.upcase
103
- @input = @num if @num == "EXIT"
126
+ @input = @num if num_included_in_menu_if_statements
127
+ # end
104
128
  end
105
- invalid_entry unless @input == "EXIT"
129
+ invalid_entry unless num_included_in_menu_if_statements
130
+ @input = @num if num_included_in_menu_if_statements
131
+ menu_if_statement
132
+ end
133
+
134
+ def num_included_in_menu_if_statements
135
+ @num == "EXIT" || @num == "ALL" || @num == "SOURCES" || source_includes?(@num)
106
136
  end
107
137
 
108
138
  def invalid_entry
@@ -147,7 +147,7 @@ class TopHeadlines::Source
147
147
  child_selector = source[:child_selector]
148
148
 
149
149
  doc = Nokogiri::HTML(open(page_url))
150
- page_url = page_url[0...-5] if page_url[-4...-1]+page_url[-1] == "news" ### BBC CORNER CASE
150
+ page_url = page_url[0...-5] if page_url[-4...-1]+page_url[-1] == "news" ### EDGE CASES (BBC & YAHOO)
151
151
  urls = doc.css(urls_selector).children.css(child_selector).map {|url| url.attribute('href').value[0] == 'h' ? url.attribute('href').value : page_url + url.attribute('href').value}
152
152
  end
153
153
  end
@@ -1,3 +1,3 @@
1
1
  module TopHeadlines
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["zachnewburgh"]
10
10
  spec.email = ["zach.newburgh@gmail.com"]
11
11
 
12
- spec.summary = %q{This gem allows users to view the top headlines from major news sources. Users can open the headlines in the browser directly from the command line for articles from AP, BBC, Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington Post, and Yahoo.}
12
+ spec.summary = %q{This gem allows users to view the top headlines from major news sources. Users can open the headlines in the browser directly from the command line for articles from AP, BBC, Bloomberg, CNN, Daily Beast, FiveThirtyEight, Forbes, Fox News, Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington Post, and Yahoo News.}
13
13
  spec.homepage = "https://github.com/zachnewburgh/top-headlines-cli-gem"
14
14
  spec.license = "MIT"
15
15
 
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.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - zachnewburgh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-02 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,8 +103,6 @@ files:
103
103
  - lib/top-headlines/cli.rb
104
104
  - lib/top-headlines/source.rb
105
105
  - lib/top-headlines/version.rb
106
- - top-headlines-0.1.0.gem
107
- - top-headlines-0.1.1.gem
108
106
  - top-headlines.gemspec
109
107
  homepage: https://github.com/zachnewburgh/top-headlines-cli-gem
110
108
  licenses:
@@ -132,7 +130,7 @@ signing_key:
132
130
  specification_version: 4
133
131
  summary: This gem allows users to view the top headlines from major news sources.
134
132
  Users can open the headlines in the browser directly from the command line for articles
135
- from AP, BBC, Bloomberg, CNN, The Daily Beast, FiveThirtyEight, Forbes, Fox News,
136
- The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal,
137
- Washington Post, and Yahoo.
133
+ from AP, BBC, Bloomberg, CNN, Daily Beast, FiveThirtyEight, Forbes, Fox News, Guardian,
134
+ Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, Washington
135
+ Post, and Yahoo News.
138
136
  test_files: []
Binary file
Binary file