kdnuggets_roundup 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 +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/kdnuggets +6 -0
- data/bin/setup +8 -0
- data/kdnuggets_roundup.gemspec +37 -0
- data/lib/article.rb +42 -0
- data/lib/datawrassler.rb +51 -0
- data/lib/kdnuggets_roundup.rb +174 -0
- data/lib/kdnuggets_roundup/version.rb +3 -0
- data/spec.md +15 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e0482a6416c7bf1a135a52332ef66d7c90a66160
|
4
|
+
data.tar.gz: 1d82da742169ee579e80149fbbcef94436807e9c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f3516ee91a728e9e1c64dd4c94a1dbe31f9f75a423e39d868154dcd9569e7c91a2f79b29c62bd84f0b2391311d65e533e8905be436591866a0a8787ca951ecfc
|
7
|
+
data.tar.gz: 3069281008b350597b43f987a6ca43440f85edd428a039d95713f2638ac58b1f1a06bac8c41933b589ac3addd64903415b4a33b641d98dd310bd350e57b31661
|
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 emily.jirles@gmail.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/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kdnuggets_roundup (0.1.0)
|
5
|
+
nokogiri (~> 1.8, >= 1.8.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.2)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
method_source (0.9.0)
|
13
|
+
mini_portile2 (2.3.0)
|
14
|
+
nokogiri (1.8.2)
|
15
|
+
mini_portile2 (~> 2.3.0)
|
16
|
+
pry (0.11.3)
|
17
|
+
coderay (~> 1.1.0)
|
18
|
+
method_source (~> 0.9.0)
|
19
|
+
rake (10.5.0)
|
20
|
+
rspec (3.7.0)
|
21
|
+
rspec-core (~> 3.7.0)
|
22
|
+
rspec-expectations (~> 3.7.0)
|
23
|
+
rspec-mocks (~> 3.7.0)
|
24
|
+
rspec-core (3.7.1)
|
25
|
+
rspec-support (~> 3.7.0)
|
26
|
+
rspec-expectations (3.7.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.7.0)
|
29
|
+
rspec-mocks (3.7.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.7.0)
|
32
|
+
rspec-support (3.7.1)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
bundler (~> 1.16)
|
39
|
+
kdnuggets_roundup!
|
40
|
+
pry (~> 0.11.3)
|
41
|
+
rake (~> 10.0)
|
42
|
+
rspec (~> 3.0)
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jirles
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# KnuggetsRoundup
|
2
|
+
|
3
|
+
Kdnuggets Roundup is a command-line interface gem that delivers the top articles from [Kdnuggets] (https://www.kdnuggets.com/) directly to your terminal. See the rankings, read excerpts, and, if something catches your eye, open the article in your browser.
|
4
|
+
|
5
|
+
Kdnuggets is a leading website in Data Science, Business Analytics, Big Data, Data Mining, and Machine Learning. It's [award-winning coverage](https://www.kdnuggets.com/about/index.html) is viewed by over 500,000 unique monthly visitors, and over 200,000 subscribers.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'kdnuggets_roundup'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install kdnuggets_roundup
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
After initiating the program you'll be guided by menu prompts. Don't worry if you misspell a command! The CLI will prompt you again.
|
26
|
+
|
27
|
+
To exit the program, navigate back to the main menu and type 'quit'.
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
|
+
|
33
|
+
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).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Jirles/kdnuggets-roundup. 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.
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
42
|
+
|
43
|
+
## Code of Conduct
|
44
|
+
|
45
|
+
Everyone interacting in the KnuggetsRoundup project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Jirles/kdnuggets-roundup/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 "kdnuggets_roundup"
|
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/kdnuggets
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "kdnuggets_roundup/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "kdnuggets_roundup"
|
8
|
+
spec.version = KdnuggetsRoundup::VERSION
|
9
|
+
spec.authors = ["Jirles"]
|
10
|
+
spec.email = ["emily.jirles@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Get last week's top data science articles from KDnuggets.com. Yee haw!}
|
13
|
+
spec.homepage = "https://github.com/Jirles/kdnuggets-roundup"
|
14
|
+
spec.license = "MIT"
|
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"] = "https://rubygems.org"
|
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.16"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_development_dependency 'pry', '~> 0.11.3'
|
36
|
+
spec.add_dependency 'nokogiri', '~> 1.8', '>= 1.8.2'
|
37
|
+
end
|
data/lib/article.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
class KdnuggetsRoundup::Article
|
2
|
+
|
3
|
+
attr_accessor :title, :author, :tags, :url, :summary, :excerpt, :popular, :shared
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def initialize(title, url)
|
7
|
+
@title = title
|
8
|
+
@url = url
|
9
|
+
@popular = false
|
10
|
+
@shared = false
|
11
|
+
@@all << self
|
12
|
+
end
|
13
|
+
|
14
|
+
def assign_attributes(attribute_hash)
|
15
|
+
attribute_hash.each{|k, v| self.send("#{k}=", v)}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_by_title(title)
|
19
|
+
all.detect{|story| story.title == title}
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_to_popular
|
23
|
+
@popular = true
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_to_shared
|
27
|
+
@shared = true
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.popular
|
31
|
+
all.select{|a| a.popular}
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.shared
|
35
|
+
all.select{|a| a.shared}
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.all
|
39
|
+
@@all
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/lib/datawrassler.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
class KdnuggetsRoundup::DataWrassler
|
6
|
+
#web scraper class
|
7
|
+
|
8
|
+
BASE_URL = 'https://www.kdnuggets.com'
|
9
|
+
TOP_STORIES_PATH = '/news/top-stories.html'
|
10
|
+
|
11
|
+
def wrassle_top_stories #=> Note there are 7 stories in both most popular and most shared each week
|
12
|
+
doc = Nokogiri::HTML(open(BASE_URL + TOP_STORIES_PATH))
|
13
|
+
stories = doc.css('ol.three_ol li')
|
14
|
+
counter = 0
|
15
|
+
stories.each do |story|
|
16
|
+
counter += 1
|
17
|
+
url = BASE_URL + story.css('a').attribute('href').text
|
18
|
+
title = story.css('b').text
|
19
|
+
if KdnuggetsRoundup::Article.find_by_title(title) #=> there are always 14 stories, but there are often duplicates
|
20
|
+
article = KdnuggetsRoundup::Article.find_by_title(title)
|
21
|
+
else
|
22
|
+
article = KdnuggetsRoundup::Article.new(title, url)
|
23
|
+
article.assign_attributes(wrassle_article_attributes(url))
|
24
|
+
end
|
25
|
+
counter < 8 ? article.add_to_popular : article.add_to_shared #=> top stories shows the 7 most popular and 7 most shared articles
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def wrassle_article_attributes(article_url)
|
30
|
+
#helper method to be called inside wrassle_top_stories
|
31
|
+
doc = Nokogiri::HTML(open(article_url))
|
32
|
+
tags = doc.css('div.tag-data a')
|
33
|
+
tags = tags.collect{|tag| tag.text}
|
34
|
+
summary = doc.css('p.excerpt').text
|
35
|
+
author = doc.css('#post- b').text.match(/\S*\s\S*[[:punct:]]/)[0].gsub(/[0-9[[:punct:]]]/, '')
|
36
|
+
article = doc.css('p, ol, ul')
|
37
|
+
counter = 0
|
38
|
+
excerpt = []
|
39
|
+
article.each do |paragraph|
|
40
|
+
counter += 1
|
41
|
+
if counter < 3 #=> first two elements are normally bylines or other fluff
|
42
|
+
next
|
43
|
+
elsif counter > 8 #=> ensures only 5 elements make it through
|
44
|
+
break
|
45
|
+
end
|
46
|
+
excerpt << paragraph.text
|
47
|
+
end
|
48
|
+
#excerpt = excerpt.delete_if{|x| x ==''}
|
49
|
+
{author: author, tags: tags, summary: summary, excerpt: excerpt}
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require "kdnuggets_roundup/version"
|
2
|
+
require "datawrassler"
|
3
|
+
require "article"
|
4
|
+
|
5
|
+
module KdnuggetsRoundup
|
6
|
+
|
7
|
+
class RoundupCLI
|
8
|
+
#formatting methods
|
9
|
+
def breakline_space_only
|
10
|
+
puts ""
|
11
|
+
end
|
12
|
+
|
13
|
+
def breakline_title
|
14
|
+
puts ". . ."
|
15
|
+
breakline_space_only
|
16
|
+
end
|
17
|
+
|
18
|
+
def gun_graphic
|
19
|
+
puts ' \\\__________'
|
20
|
+
puts " | ______-/ ---------------------------------------- =>"
|
21
|
+
puts " / { }"
|
22
|
+
puts "/__/"
|
23
|
+
end
|
24
|
+
|
25
|
+
#article / collection display methods
|
26
|
+
|
27
|
+
def list(collection)
|
28
|
+
collection.each_with_index do |article, i|
|
29
|
+
puts "#{i + 1}. #{article.title}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def display_article(article)
|
34
|
+
puts <<-DOC
|
35
|
+
#{article.title}
|
36
|
+
By: #{article.author}
|
37
|
+
Tags: #{article.tags.dup.join(', ')}
|
38
|
+
|
39
|
+
Summary
|
40
|
+
-------
|
41
|
+
#{article.summary}
|
42
|
+
DOC
|
43
|
+
end
|
44
|
+
|
45
|
+
def display_rankings
|
46
|
+
puts "Most Popular"
|
47
|
+
list(KdnuggetsRoundup::Article.popular)
|
48
|
+
puts ""
|
49
|
+
puts "Most Shared"
|
50
|
+
list(KdnuggetsRoundup::Article.shared)
|
51
|
+
puts ""
|
52
|
+
end
|
53
|
+
|
54
|
+
def read_excerpt(article)
|
55
|
+
article.excerpt.each do |paragraph|
|
56
|
+
puts paragraph
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def call
|
61
|
+
breakline_space_only
|
62
|
+
puts "Howdy, stranger!"
|
63
|
+
breakline_title
|
64
|
+
puts "The Kdnuggets Roundup is your source for the top articles in data science, as curated by KDnuggets.com."
|
65
|
+
puts "Let's see what we can wrassle up..."
|
66
|
+
KdnuggetsRoundup::DataWrassler.new.wrassle_top_stories
|
67
|
+
main_menu
|
68
|
+
end
|
69
|
+
|
70
|
+
def main_menu
|
71
|
+
input = nil
|
72
|
+
while input != 'quit'
|
73
|
+
breakline_title
|
74
|
+
puts "Pick yer poison, friend."
|
75
|
+
breakline_space_only
|
76
|
+
puts "Choose:"
|
77
|
+
puts "'rank' to see the articles ranked by most popular and most shared,"
|
78
|
+
puts "'article' to look more closely at a particular article, or"
|
79
|
+
puts "'quit' to exit the program."
|
80
|
+
gun_graphic
|
81
|
+
input = gets.chomp.downcase
|
82
|
+
breakline_space_only
|
83
|
+
case input
|
84
|
+
when "rank"
|
85
|
+
display_rankings
|
86
|
+
when "article"
|
87
|
+
article_selection_menu
|
88
|
+
when 'quit'
|
89
|
+
break
|
90
|
+
else
|
91
|
+
puts "Sorry, partner. Didn't catch that."
|
92
|
+
end
|
93
|
+
end
|
94
|
+
puts "Time to be hittin' th' ol' dusty trail..."
|
95
|
+
puts "* * * * * * * * * * * * *"
|
96
|
+
puts breakline_space_only
|
97
|
+
end
|
98
|
+
|
99
|
+
#submenu methods
|
100
|
+
def article_selection_menu
|
101
|
+
breakline_space_only
|
102
|
+
avail_choices = (1..KdnuggetsRoundup::Article.all.count).collect{ |num| num.to_s }
|
103
|
+
input = nil
|
104
|
+
while input != 'menu'
|
105
|
+
breakline_title
|
106
|
+
list(KdnuggetsRoundup::Article.all)
|
107
|
+
breakline_space_only
|
108
|
+
puts "Enter an article number and I'll lasso it up for ya."
|
109
|
+
breakline_space_only
|
110
|
+
puts "You can also choose:"
|
111
|
+
puts "'rank' to see the articles ranked by most popular and most shared, or "
|
112
|
+
puts "'menu' to return to the main menu."
|
113
|
+
gun_graphic
|
114
|
+
input = gets.chomp.downcase
|
115
|
+
breakline_space_only
|
116
|
+
if avail_choices.include?(input)
|
117
|
+
puts "Here's that article you asked for:"
|
118
|
+
breakline_space_only
|
119
|
+
chosen_article = KdnuggetsRoundup::Article.all[input.to_i - 1]
|
120
|
+
display_article(chosen_article)
|
121
|
+
article_selection_submenu(chosen_article)
|
122
|
+
elsif input == "rank"
|
123
|
+
rank_submenu
|
124
|
+
elsif input == "menu"
|
125
|
+
break
|
126
|
+
else
|
127
|
+
puts "Sorry, partner. Didn't catch that."
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def rank_submenu
|
133
|
+
input = nil
|
134
|
+
until input == 'menu'
|
135
|
+
breakline_title
|
136
|
+
display_rankings
|
137
|
+
puts "When you're ready to return to the article menu, type 'menu'."
|
138
|
+
gun_graphic
|
139
|
+
input = gets.chomp.downcase
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def article_selection_submenu(chosen_article)
|
144
|
+
input = nil
|
145
|
+
while input != 'other'
|
146
|
+
breakline_title
|
147
|
+
puts "Like what you see?"
|
148
|
+
breakline_space_only
|
149
|
+
puts "Choose:"
|
150
|
+
puts "'ex' to read an excerpt from the original article,"
|
151
|
+
puts "'www' to navigate to the original article in your browser,"
|
152
|
+
puts "'menu' to return to the article selection menu."
|
153
|
+
gun_graphic
|
154
|
+
input = gets.chomp.downcase
|
155
|
+
breakline_space_only
|
156
|
+
case input
|
157
|
+
when 'ex'
|
158
|
+
read_excerpt(chosen_article)
|
159
|
+
when 'www'
|
160
|
+
puts "Hold on to yer britches, we're headed to the World Wide Web!"
|
161
|
+
system("open " + chosen_article.url)
|
162
|
+
when 'menu'
|
163
|
+
break #=> breaks out to submenu
|
164
|
+
else
|
165
|
+
puts "Sorry, partner. Didn't catch that."
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
end
|
data/spec.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Specifications for the CLI Assessment
|
2
|
+
|
3
|
+
Specs:
|
4
|
+
|
5
|
+
[X] Have a CLI for interfacing with the application
|
6
|
+
|
7
|
+
* application has multiple menus that ask for input and provide the user with the appropriate input.
|
8
|
+
|
9
|
+
[X] Pull data from an external source
|
10
|
+
|
11
|
+
* pulls data from [kdnuggets.com](https://www.kdnuggets.com/) to show the last week's top articles in the field of data science, machine learning, AI, and others.
|
12
|
+
|
13
|
+
[X] Implement both list and detail views
|
14
|
+
|
15
|
+
* the user can choose to list all of the articles, see them ranked by most popular and most shared, or choose to look at the details of a particular article.
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kdnuggets_roundup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jirles
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-14 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
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.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
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.11.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.11.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.8'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.8.2
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.8'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.8.2
|
89
|
+
description:
|
90
|
+
email:
|
91
|
+
- emily.jirles@gmail.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- ".gitignore"
|
97
|
+
- ".rspec"
|
98
|
+
- ".travis.yml"
|
99
|
+
- CODE_OF_CONDUCT.md
|
100
|
+
- Gemfile
|
101
|
+
- Gemfile.lock
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.md
|
104
|
+
- Rakefile
|
105
|
+
- bin/console
|
106
|
+
- bin/kdnuggets
|
107
|
+
- bin/setup
|
108
|
+
- kdnuggets_roundup.gemspec
|
109
|
+
- lib/article.rb
|
110
|
+
- lib/datawrassler.rb
|
111
|
+
- lib/kdnuggets_roundup.rb
|
112
|
+
- lib/kdnuggets_roundup/version.rb
|
113
|
+
- spec.md
|
114
|
+
homepage: https://github.com/Jirles/kdnuggets-roundup
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata:
|
118
|
+
allowed_push_host: https://rubygems.org
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.5.2
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Get last week's top data science articles from KDnuggets.com. Yee haw!
|
139
|
+
test_files: []
|