times-terminal 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 886a597edd875d98e201e2b65c82d2eecde23d84
4
+ data.tar.gz: b44c18fb167f0b1dce02bc137c22cc868dcfbb4e
5
+ SHA512:
6
+ metadata.gz: 9ee15a44db280a651da6ec772e6149399c86fa036b53a39d4fce1086284b95310b06e6fdd174fdca727302d503ef23e22f4c284d18f2dc6fdb0fdaebae3b79a8
7
+ data.tar.gz: 02fddbff2ac40bad7a5578b6cccdca0090e5da4b22966a1407b1761eb17e1b5f8ec356edd37fa71dfa2b95c2caba12bffadf113074d17ccc505467d838f081db
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+ require 'times-terminal'
6
+
7
+ Headlines.new.call
@@ -0,0 +1,32 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ class Headlines
5
+
6
+ attr_accessor :doc, :list
7
+
8
+ def initialize
9
+ @doc = Nokogiri::HTML(open("http://www.nytimes.com/pages/todayspaper/index.html"))
10
+ @list = @doc.css("div.first h3 a")
11
+ end
12
+
13
+ def headlines
14
+ @list.each_with_index { |story, i| puts "#{i+1}. #{story.text.strip}" }
15
+ end
16
+
17
+ def open_story(index)
18
+ if index.to_i > 0 && index.to_i <= list.length
19
+ link = list[index.to_i-1].attribute("href").value
20
+ system "open #{link}"
21
+ end
22
+ end
23
+
24
+ def call
25
+ puts "TODAY'S NEW YORK TIMES HEADLINES"
26
+ headlines
27
+ puts "\nWould you like to open a story? (Enter index)"
28
+ i = gets.strip
29
+ open_story(i)
30
+ end
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: times-terminal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Amanda Chang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Access New York Times headlines from your command line
14
+ email: amanda.chang10@gmail.com
15
+ executables:
16
+ - times-terminal
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/times-terminal
21
+ - lib/times-terminal.rb
22
+ homepage:
23
+ licenses: []
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.7
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: News for the average hacker!
45
+ test_files: []