dev_to 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 00c1116d92a442206cf0e0d7d380e83a71453658df4b526c7918e6a25501d0b5
4
- data.tar.gz: 4b4fc958448b9c5c8da8dae7bcb9d3ffc909aada8b2089203fc51235d92e26a0
3
+ metadata.gz: 634c48b237c94fda45d5b012654767719130c24dfcb705d6c2017ecd26c9bfdb
4
+ data.tar.gz: 49a4e5ea3ceeacf8139c46ec25388df50a7e81405382cb2254a8a5d85df5253d
5
5
  SHA512:
6
- metadata.gz: 076ffbadd91cf6c018ce6b5d858a8c525cdb2867ba3ebdbd22bea4f87d476dc8f6cf7a9725ae386e6aa4b2122d39fbcd126bd49f020fdc5c755bb2473193fd45
7
- data.tar.gz: 43a0528020b469ee2b045f7dab3f66475485da3bae9b7cf16c1910674d049e2cac22b371c0f8573141c0586235795c53d42c93ff73d5f4ecb92cdd63cce46907
6
+ metadata.gz: aedc5efc701c996d64d7ebba46ace75019d80cd51afa23155aab9ebaf3bb9b8270a883b1328dda1915cecae0138163bcccc1212fb3129ded46d776fc7551ccae
7
+ data.tar.gz: 21db14182ebd0a3420226c3169bc10035978737936149d8c73dbe75bb8cfdf3092de69abba4da056c164aaf5a462dab407e1453ef2cd2fdba8e07b88c7ee99ef
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_to
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PRbsas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-08 00:00:00.000000000 Z
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,7 +100,8 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: 0.8.1
103
- description: Get Posts from dev.to
103
+ description: Application that provides a Command Line Interface (CLI) to read Posts
104
+ from The DEV Community, https://dev.to/
104
105
  email:
105
106
  - paularamirez0316@gmail.com
106
107
  executables:
@@ -108,26 +109,7 @@ executables:
108
109
  extensions: []
109
110
  extra_rdoc_files: []
110
111
  files:
111
- - ".gitignore"
112
- - ".rspec"
113
- - ".travis.yml"
114
- - CODE_OF_CONDUCT.md
115
- - Gemfile
116
- - Gemfile.lock
117
- - LICENSE.txt
118
- - README.md
119
- - Rakefile
120
- - bin/console
121
112
  - bin/devto
122
- - bin/setup
123
- - config/environment.rb
124
- - dev_to.gemspec
125
- - lib/dev_to.rb
126
- - lib/dev_to/cli.rb
127
- - lib/dev_to/post.rb
128
- - lib/dev_to/scraper.rb
129
- - lib/dev_to/version.rb
130
- - spec.md
131
113
  homepage: https://github.com/PRbsas/devto-cli-gem
132
114
  licenses:
133
115
  - MIT
@@ -151,5 +133,5 @@ rubyforge_project:
151
133
  rubygems_version: 2.7.0
152
134
  signing_key:
153
135
  specification_version: 4
154
- summary: Get Posts from The DEV Community
136
+ summary: Get Posts in yout CLI from The DEV Community
155
137
  test_files: []
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.3
5
- before_install: gem install bundler -v 1.16.0
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
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 https://github.com/PRbsas. 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 DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in dev_to.gemspec
6
- gemspec
data/Gemfile.lock DELETED
@@ -1,47 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- dev_to (0.1.0)
5
- colorize (~> 0.8.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- coderay (1.1.2)
11
- colorize (0.8.1)
12
- diff-lcs (1.3)
13
- method_source (0.9.0)
14
- mini_portile2 (2.3.0)
15
- nokogiri (1.8.1)
16
- mini_portile2 (~> 2.3.0)
17
- pry (0.11.2)
18
- coderay (~> 1.1.0)
19
- method_source (~> 0.9.0)
20
- rake (10.5.0)
21
- rspec (3.7.0)
22
- rspec-core (~> 3.7.0)
23
- rspec-expectations (~> 3.7.0)
24
- rspec-mocks (~> 3.7.0)
25
- rspec-core (3.7.0)
26
- rspec-support (~> 3.7.0)
27
- rspec-expectations (3.7.0)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.7.0)
30
- rspec-mocks (3.7.0)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.7.0)
33
- rspec-support (3.7.0)
34
-
35
- PLATFORMS
36
- ruby
37
-
38
- DEPENDENCIES
39
- bundler (~> 1.16)
40
- dev_to!
41
- nokogiri (~> 1.6, >= 1.6.8)
42
- pry (~> 0.11.2)
43
- rake (~> 10.0)
44
- rspec (~> 3.0)
45
-
46
- BUNDLED WITH
47
- 1.16.0
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 PRbsas
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 DELETED
@@ -1,27 +0,0 @@
1
- # DevTo
2
-
3
- This Ruby Gem provides a CLI to view posts from The DEV Community, [dev.to](https://dev.to/).
4
-
5
- ## Installation
6
-
7
- $ gem install dev_to
8
-
9
- ## Usage
10
-
11
- Type the below and follow the on screen prompts.
12
-
13
- $ dev_to
14
-
15
- ## Development
16
-
17
- 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.
18
-
19
- 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).
20
-
21
- ## Contributing
22
-
23
- Bug reports and pull requests are welcome on GitHub at https://github.com/PRbsas/dev_to. 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.
24
-
25
- ## License
26
-
27
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "dev_to"
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 DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,9 +0,0 @@
1
- require 'pry'
2
- require 'nokogiri'
3
- require 'open-uri'
4
- require 'colorize'
5
-
6
- require_relative '../lib/dev_to/version'
7
- require_relative '../lib/dev_to/cli'
8
- require_relative '../lib/dev_to/post'
9
- require_relative '../lib/dev_to/scraper'
data/dev_to.gemspec DELETED
@@ -1,29 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "dev_to/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "dev_to"
8
- spec.version = DevTo::VERSION
9
- spec.authors = ["PRbsas"]
10
- spec.email = ["paularamirez0316@gmail.com"]
11
-
12
- spec.summary = %q{Get Posts from The DEV Community}
13
- spec.description = %q{Get Posts from dev.to}
14
- spec.homepage = "https://github.com/PRbsas/devto-cli-gem"
15
- spec.license = "MIT"
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
18
- end
19
-
20
- spec.executables << 'devto'
21
- spec.require_paths = ["lib/dev_to.rb, config/environment.rb"]
22
-
23
- spec.add_development_dependency "bundler", "~> 1.16"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "nokogiri", "~> 1.6", ">= 1.6.8"
27
- spec.add_development_dependency "pry", "~> 0.11.2"
28
- spec.add_dependency "colorize", "~> 0.8.1"
29
- end
data/lib/dev_to/cli.rb DELETED
@@ -1,60 +0,0 @@
1
- class DevTo::CLI
2
-
3
- def call
4
- DevTo::Scraper.new.make_posts
5
- puts
6
- puts "< Welcome to your DEV Community FEED >".colorize(:color => :light_white, :background => :red)
7
- puts
8
- list_posts
9
- start
10
- end
11
-
12
- def list_posts
13
- DevTo::Post.all.each.with_index(1) do |post, i|
14
- puts
15
- puts "#{i}. #{post.title} - #{post.author}"
16
- puts " -------- #{post.tags.join(" · ")} \u{1F4AC} #{post.comments} \u{2764} #{post.likes}"
17
- end
18
- end
19
-
20
- def print_post(post)
21
- puts
22
- puts
23
- puts "#{post.title}".colorize(:color => :light_white, :background => :red)
24
- puts " ---- #{post.author} ---- #{post.date}"
25
- puts
26
- puts "#{post.content}"
27
- puts
28
- puts " ---- #{post.tags.join(" · ")} \u{1F4AC} #{post.comments} \u{2764} #{post.likes}"
29
- puts " ---- #{post.url}"
30
- puts
31
- end
32
-
33
- def start
34
- input = nil
35
- post = nil
36
- while input != "exit"
37
- puts
38
- puts "< Type post NUMBER to read it >"
39
- puts "< Type LIST to see the posts again >"
40
- puts "< Type EXIT to end program >"
41
-
42
- input = gets.strip.downcase
43
- if input == "list"
44
- list_posts
45
- elsif input.to_i.between?(1, DevTo::Post.all.size)
46
- post = DevTo::Post.find(input)
47
- DevTo::Scraper.new.make_content(post)
48
- print_post(post)
49
- puts "< Type OPEN to see it in the browser >"
50
- post
51
- elsif input.to_i > DevTo::Post.all.size
52
- puts
53
- puts " -------- Please select a valid option:"
54
- elsif input == "open" && post != nil
55
- system("open #{post.url}")
56
- end
57
- end
58
- puts " -------- See you soon for more DEV Posts"
59
- end
60
- end
data/lib/dev_to/post.rb DELETED
@@ -1,17 +0,0 @@
1
- class DevTo::Post
2
- attr_accessor :title, :author, :tags, :url, :comments, :likes, :date, :content
3
-
4
- @@all = []
5
-
6
- def initialize
7
- self.class.all << self
8
- end
9
-
10
- def self.find(id)
11
- self.all[id.to_i-1]
12
- end
13
-
14
- def self.all
15
- @@all
16
- end
17
- end
@@ -1,29 +0,0 @@
1
- class DevTo::Scraper
2
-
3
- def get_page
4
- Nokogiri::HTML(open("https://dev.to/"))
5
- end
6
-
7
- def get_posts
8
- self.get_page.css(".articles-list .substories .single-article")
9
- end
10
-
11
- def make_posts
12
- self.get_posts.each do |data|
13
- post = DevTo::Post.new
14
- post.title = data.search(".content h3 span").remove
15
- post.title = data.search(".content h3").text.strip.gsub(/[[:space:]]+/," ")
16
- post.author = data.search("h4").text.strip
17
- post.tags = data.search(".tags .tag").collect { |tag| tag.text.strip}
18
- post.url = "https://dev.to" + data.search("a").last.attr("href")
19
- post.comments = data.search(".engagement-count-number").first.text.strip
20
- post.likes = data.search(".engagement-count-number").last.text.strip
21
- end
22
- end
23
-
24
- def make_content(post)
25
- post_page = Nokogiri::HTML(open("#{post.url}"))
26
- post.content = post_page.search("body #article-body").text.strip
27
- post.date = post_page.search("#main-title .published-at").text.strip
28
- end
29
- end
@@ -1,3 +0,0 @@
1
- module DevTo
2
- VERSION = "0.1.0"
3
- end
data/lib/dev_to.rb DELETED
@@ -1,4 +0,0 @@
1
- require_relative '../config/environment'
2
-
3
- module DevTo
4
- end
data/spec.md DELETED
@@ -1,13 +0,0 @@
1
- # Specifications for the CLI Assessment
2
-
3
- Specs:
4
-
5
- - [X] Have a CLI for interfacing with the application
6
- The user interacts with the application through the CLI. Getting prompted for input from the start of the program.
7
-
8
- - [X] Pull data from an external source
9
- The data the CLI shows is scraped with Nokogiri and open-uri from [dev.to](https://dev.to/)
10
-
11
- - [X] Implement both list and detail views
12
- When the program runs, the Scraper class gets called with the method #make-posts that instantiates new instances of Post. The CLI method #list-posts then iterates through the instances of Post and prints them for the user.
13
- When the user types in a post number to read, the CLI uses the Post #find method to find the Post. It then calls the Scraper method #make-content to scrape the content of the post and prints it for the user with the #print-post method.