top-headlines 0.1.3 → 0.1.4

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: 91a85320ddf1e1dfb1ef6257baf266070180eeaa
4
- data.tar.gz: de02bc13c32b193267c599e8d7489141f0f556f6
3
+ metadata.gz: 1542f55042bc77f2f1aa23ecd4c89abb2c0ec9b8
4
+ data.tar.gz: 4850f0ae649a5d26a92bee8798fa4ba4d7299cde
5
5
  SHA512:
6
- metadata.gz: 80da15c19be9f0a1e6a17e086daadf15c705fde0aa5afac9801a516dfae137351a8c7b62d8cf6a45cc27eecf7855ee1b69951950c6a9adab29f969d815bc7407
7
- data.tar.gz: 8e1409a0543282d6ef4dd61bc686d79883cdcf2bfce88d279d4fed04a915b649ab5b52a9e8f3e67151ed5ecfbdd72d5b6dd700194a284817e1fe960fb3fabd1c
6
+ metadata.gz: ad8ae4281a36bb7e7d6e8be29277998b62c46832b1918e5939839731a8234cb5bde867c8d04652047281ff15749d1234fa1c9b8d2a65e26d4dcd448e39d6d9cb
7
+ data.tar.gz: f583a444d894e18090028ce75ee4551f113a42a7c620ee0ade4d43ae6807032ff95dc0a2224d594f40d61d8d00aeb16b31a747cdfaea164cde6f8f7f49f31973
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 directly from the command line. Functionality includes: Bloomberg, CNN, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, and Wall Street Journal.
3
+ This gem allows users to view the top headlines from major news sources. Users can open the headlines directly from the command line. Functionality includes: BBC, Bloomberg, CNN, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, and Washington Post.
4
4
 
5
5
  ## Installation
6
6
 
@@ -54,19 +54,37 @@ class TopHeadlines::Source
54
54
  headlines_selector: "a.wsj-headline-link",
55
55
  urls_selector: "div.cb-col",
56
56
  child_selector: "a.wsj-headline-link"
57
- },
57
+ },
58
+ "POLITICO" => {
59
+ url: "http://www.politico.com/",
60
+ headlines_selector: "ul.headline-list a",
61
+ urls_selector: "ul.headline-list",
62
+ child_selector: "a"
63
+ },
64
+ "FIVETHIRTYEIGHT" => {
65
+ url: "http://fivethirtyeight.com/",
66
+ headlines_selector: "div#primary h3 a",
67
+ urls_selector: "div#primary h3",
68
+ child_selector: "a"
69
+ },
70
+ "WASHINGTON POST" => {
71
+ url: "https://www.washingtonpost.com/",
72
+ headlines_selector: "section#main-content a",
73
+ urls_selector: "section#main-content",
74
+ child_selector: "a"
75
+ },
76
+ "BBC" => {
77
+ url: "http://www.bbc.com/news",
78
+ headlines_selector: "div.column--primary span.title-link__title-text",
79
+ urls_selector: "div.column--primary",
80
+ child_selector: "a.title-link"
81
+ },
58
82
  # "REDDIT" => { ## 429 Error
59
83
  # url: "https://www.reddit.com/r/news/",
60
84
  # headlines_selector: "p.title a.title.may-blank",
61
85
  # urls_selector: "p.title",
62
86
  # child_selector: "a"
63
87
  # },
64
- # "BBC" => {
65
- # url: "http://www.bbc.com/news",
66
- # headlines_selector: "div.column--primary span.title-link__title-text",
67
- # urls_selector: "div.column--primary",
68
- # child_selector: "a.title-link" ## NEEDS WORK returns e.g. /news/world-middle-east-36180184
69
- # },
70
88
  # "CBS" => {
71
89
  # url: "http://www.cbsnews.com/",
72
90
  # headlines_selector: "div.col-5.nocontent h3.title",
@@ -99,6 +117,7 @@ class TopHeadlines::Source
99
117
  headlines_selector = source[:headlines_selector]
100
118
 
101
119
  doc = Nokogiri::HTML(open(page_url))
120
+
102
121
  headlines = doc.css(headlines_selector).map {|headline| headline.text.gsub("â", "'").gsub(/\n/,"").gsub(/\t/,"").strip}
103
122
  end
104
123
 
@@ -109,6 +128,7 @@ class TopHeadlines::Source
109
128
  child_selector = source[:child_selector]
110
129
 
111
130
  doc = Nokogiri::HTML(open(page_url))
131
+ page_url = page_url[0...-5] if page_url[-4...-1]+page_url[-1] == "news" ### BBC CORNER CASE
112
132
  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}
113
133
  end
114
134
  end
@@ -1,3 +1,3 @@
1
1
  module TopHeadlines
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
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 directly from the command line for articles from Bloomberg, CNN, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, and Wall Street Journal.}
12
+ spec.summary = %q{This gem allows users to view the top headlines from major news sources. Users can open the headlines directly from the command line for articles from BBC, Bloomberg, CNN, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, Politico, Wall Street Journal, and Washington Post.}
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.3
4
+ version: 0.1.4
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-01 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,7 +131,7 @@ rubygems_version: 2.4.5.1
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: This gem allows users to view the top headlines from major news sources.
134
- Users can open the headlines directly from the command line for articles from Bloomberg,
135
- CNN, Forbes, Fox News, The Guardian, Huffington Post, MSNBC, New York Times, and
136
- Wall Street Journal.
134
+ Users can open the headlines directly from the command line for articles from BBC,
135
+ Bloomberg, CNN, FiveThirtyEight, Forbes, Fox News, The Guardian, Huffington Post,
136
+ MSNBC, New York Times, Politico, Wall Street Journal, and Washington Post.
137
137
  test_files: []