tmxnews 0.1.0
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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/tmxnews +6 -0
- data/lib/tmxnews.rb +11 -0
- data/lib/tmxnews/article.rb +18 -0
- data/lib/tmxnews/cli.rb +32 -0
- data/lib/tmxnews/hello_goodbye.rb +18 -0
- data/lib/tmxnews/scraper.rb +22 -0
- data/lib/tmxnews/version.rb +3 -0
- data/tmxnews.gemspec +38 -0
- metadata +130 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 80a27dea5968910e89acdb6c4dae668c4faf81fd
|
|
4
|
+
data.tar.gz: c55698633e43ea80f0e6c1078cee767bba83af60
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c318f7a4542ff56578afe85148d221225dc4382eb79eedf9ee94684ddb23418dfa57da63277e81cee9fe2c1d448ca78d160d9f9a7d3f211dcc21c9e22ab6f4a9
|
|
7
|
+
data.tar.gz: a3cf1ad66ec086812bf646daa01d596688672559cf15c2092dbbf388f563853490ecd3b77f493dc910f4c335c9b9d2d477e4ae752a3351bceef22946cca772d1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at tmax818@mac.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Tmxnews
|
|
2
|
+
|
|
3
|
+
This gem provides a CLI that displays the top headlines from the New York Times and the Wall Street Journal. These publications were selected because of their reputations for excellence in journalism as well as being known for representing opposite ends of the political spectrum.
|
|
4
|
+
|
|
5
|
+
(1) is the headline from the lead article from the New York Times website.
|
|
6
|
+
(2) is the headline for the lead article from the Wall Street Journal.
|
|
7
|
+
|
|
8
|
+
Selecting each option will provide a brief summary of the article as well as a link to the complete article.
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'tmxnews'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
$ gem install tmxnews
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
TODO: Write usage instructions here
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
33
|
+
|
|
34
|
+
## Contributing
|
|
35
|
+
|
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tmax818/tmxnews. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
37
|
+
|
|
38
|
+
## Code of Conduct
|
|
39
|
+
|
|
40
|
+
Everyone interacting in the Tmxnews project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/tmax818/tmxnews/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "tmxnews"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/tmxnews
ADDED
data/lib/tmxnews.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# this file is acting as the environment...
|
|
2
|
+
require 'open-uri'
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
require "pry"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
require_relative "./tmxnews/version"
|
|
8
|
+
require_relative './tmxnews/cli'
|
|
9
|
+
require_relative './tmxnews/article'
|
|
10
|
+
require_relative './tmxnews/scraper'
|
|
11
|
+
require_relative './tmxnews/hello_goodbye'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class Tmxnews::Article
|
|
2
|
+
|
|
3
|
+
@@all = []
|
|
4
|
+
|
|
5
|
+
def self.articles
|
|
6
|
+
@@all << Tmxnews::Scraper.scrape_nyt
|
|
7
|
+
@@all << Tmxnews::Scraper.scrape_wsj
|
|
8
|
+
@@all
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.list_articles
|
|
12
|
+
articles.each.with_index(1) do |article, i|
|
|
13
|
+
puts "#{i}. #{article.title}"
|
|
14
|
+
puts
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
data/lib/tmxnews/cli.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require_relative 'hello_goodbye'
|
|
2
|
+
|
|
3
|
+
class Tmxnews::CLI
|
|
4
|
+
|
|
5
|
+
include HelloGoodbye
|
|
6
|
+
|
|
7
|
+
def call
|
|
8
|
+
menu
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def menu
|
|
12
|
+
hello
|
|
13
|
+
@article = Tmxnews::Article.list_articles
|
|
14
|
+
input = nil
|
|
15
|
+
while input != "exit"
|
|
16
|
+
puts "Enter the number of the article you would like to read or type 'exit' to end the program."
|
|
17
|
+
input = gets.strip.downcase
|
|
18
|
+
|
|
19
|
+
if input.to_i > 0
|
|
20
|
+
the_article = @article[input.to_i-1]
|
|
21
|
+
puts "Headline: #{the_article.title}"
|
|
22
|
+
puts "Summary: #{the_article.text}"
|
|
23
|
+
puts "URL: #{the_article.url}"
|
|
24
|
+
elsif input == "exit"
|
|
25
|
+
good_bye
|
|
26
|
+
else
|
|
27
|
+
puts "Please type 'exit' or select an article number."
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module HelloGoodbye
|
|
2
|
+
|
|
3
|
+
def hello
|
|
4
|
+
puts <<~HEREDOC
|
|
5
|
+
This gem provides a CLI that displays the top headlines from the New York Times and the Wall Street Journal. These publications were selected because of their reputations for excellence in journalism as well as being known for representing opposite ends of the political spectrum.
|
|
6
|
+
|
|
7
|
+
\t(1) is the headline from the lead article from the New York Times website.
|
|
8
|
+
\t(2) is the headline for the lead article from the Wall Street Journal.
|
|
9
|
+
|
|
10
|
+
Selecting each option will provide a brief summary of the article as well as a link to the complete article.\n
|
|
11
|
+
HEREDOC
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def good_bye
|
|
15
|
+
puts "Thank you for using Tmxnews! Check in tomorrow for the headlines."
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class Tmxnews::Scraper
|
|
2
|
+
attr_accessor :title, :text, :url
|
|
3
|
+
|
|
4
|
+
def self.scrape_nyt
|
|
5
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com"))
|
|
6
|
+
article = self.new
|
|
7
|
+
article.title = doc.search("h2.story-heading").first.text
|
|
8
|
+
article.text = doc.search("article").css("ul li").text
|
|
9
|
+
article.url = doc.search("h2.story-heading").first.css("a").attr("href").value
|
|
10
|
+
article
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.scrape_wsj
|
|
14
|
+
doc = Nokogiri::HTML(open("https://www.wsj.com"))
|
|
15
|
+
article = self.new
|
|
16
|
+
article.title = doc.search("h3.wsj-headline").first.text
|
|
17
|
+
article.text = doc.search("p.wsj-summary").first.text
|
|
18
|
+
article.url = doc.search("h3.wsj-headline").first.css("a").attr("href").value
|
|
19
|
+
article
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
data/tmxnews.gemspec
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "tmxnews/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "tmxnews"
|
|
8
|
+
spec.version = Tmxnews::VERSION
|
|
9
|
+
spec.authors = ["Tyler Maxwell"]
|
|
10
|
+
spec.email = ["tmax818@mac.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{News reader - List articles, read article.}
|
|
13
|
+
spec.description = %q{News reader - List articles, read article.}
|
|
14
|
+
spec.homepage = "https://github.com/tmax818/tmxnews-cli-app/tree/master/tmxnews"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
# if spec.respond_to?(:metadata)
|
|
19
|
+
# spec.metadata["allowed_push_host"] =
|
|
20
|
+
# else
|
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
22
|
+
# "public gem pushes."
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = "exe"
|
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
|
35
|
+
spec.add_development_dependency "pry"
|
|
36
|
+
|
|
37
|
+
spec.add_dependency "nokogiri"
|
|
38
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tmxnews
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tyler Maxwell
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-02-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.15'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.2'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.2'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: nokogiri
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: News reader - List articles, read article.
|
|
84
|
+
email:
|
|
85
|
+
- tmax818@mac.com
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".gitignore"
|
|
91
|
+
- ".rspec"
|
|
92
|
+
- ".travis.yml"
|
|
93
|
+
- CODE_OF_CONDUCT.md
|
|
94
|
+
- Gemfile
|
|
95
|
+
- README.md
|
|
96
|
+
- Rakefile
|
|
97
|
+
- bin/console
|
|
98
|
+
- bin/setup
|
|
99
|
+
- bin/tmxnews
|
|
100
|
+
- lib/tmxnews.rb
|
|
101
|
+
- lib/tmxnews/article.rb
|
|
102
|
+
- lib/tmxnews/cli.rb
|
|
103
|
+
- lib/tmxnews/hello_goodbye.rb
|
|
104
|
+
- lib/tmxnews/scraper.rb
|
|
105
|
+
- lib/tmxnews/version.rb
|
|
106
|
+
- tmxnews.gemspec
|
|
107
|
+
homepage: https://github.com/tmax818/tmxnews-cli-app/tree/master/tmxnews
|
|
108
|
+
licenses: []
|
|
109
|
+
metadata: {}
|
|
110
|
+
post_install_message:
|
|
111
|
+
rdoc_options: []
|
|
112
|
+
require_paths:
|
|
113
|
+
- lib
|
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
requirements: []
|
|
125
|
+
rubyforge_project:
|
|
126
|
+
rubygems_version: 2.5.2.1
|
|
127
|
+
signing_key:
|
|
128
|
+
specification_version: 4
|
|
129
|
+
summary: News reader - List articles, read article.
|
|
130
|
+
test_files: []
|