newest_kickstarter 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +17 -0
- data/NOTES.md +14 -0
- data/README.md +2 -0
- data/bin/newest-kickstarter +7 -0
- data/config/environment.rb +11 -0
- data/lib/newest_kickstarter/cli.rb +73 -0
- data/lib/newest_kickstarter/project.rb +52 -0
- data/lib/newest_kickstarter/version.rb +1 -1
- data/newest_kickstarter-0.1.0.gem +0 -0
- data/newest_kickstarter.gemspec +2 -2
- data/pkg/newest_kickstarter-0.1.0.gem +0 -0
- metadata +11 -4
- data/.gitignore +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a9c2ac6553cc98c67a59461b4c72be6672d59d9
|
4
|
+
data.tar.gz: 71d7d1c86ce97b8801a0a2b0fd4eff38edde6380
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c4f2b50cc0e86772fc47ba2d944915b835f23f325c091b9b98780b9578f4e24ff48732490bdda7c42a89e3756120fee1163ae93d76eb2785f240fda9c445557
|
7
|
+
data.tar.gz: b7d96627e5b0059f7c520d173649c136c5c889cd9ed2d2fa7ce51e0692930446725513ddc59310c506eb39e7cb495a58c8f51159f885e10683253724678adef3
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
mini_portile2 (2.0.0)
|
5
|
+
newest_kickstarter (0.1.0)
|
6
|
+
nokogiri
|
7
|
+
nokogiri (1.6.7.2)
|
8
|
+
mini_portile2 (~> 2.0.0.rc2)
|
9
|
+
|
10
|
+
PLATFORMS
|
11
|
+
ruby
|
12
|
+
|
13
|
+
DEPENDENCIES
|
14
|
+
newest_kickstarter
|
15
|
+
|
16
|
+
BUNDLED WITH
|
17
|
+
1.11.2
|
data/NOTES.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
A simple command line interface to access the top 20 newest kickstarter projects, and find basic info on them.
|
2
|
+
|
3
|
+
source: https://www.kickstarter.com/discover/advanced?recommended=false&sort=newest
|
4
|
+
|
5
|
+
Files Altered:
|
6
|
+
newest-kickstarter
|
7
|
+
environment.rb
|
8
|
+
newest_kickstarter.rb
|
9
|
+
cli.rb
|
10
|
+
project.rb
|
11
|
+
newest_kickstarter.gemspec
|
12
|
+
Notes
|
13
|
+
Readme
|
14
|
+
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# NewestKickstarter
|
2
2
|
|
3
|
+
https://rubygems.org/gems/newest_kickstarter
|
4
|
+
|
3
5
|
This ruby gem is a simple command line interface (CLI) to access the top 20 newest projects on Kickstarter.com.This gem also allows you to recieve basic information about those projects and a link to their project page.
|
4
6
|
|
5
7
|
## Installation
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#This page was setup to make code easier to read and access, using standard folder structure (config) and descriptive file name (environment)
|
2
|
+
|
3
|
+
require 'pry' # for testing
|
4
|
+
require 'nokogiri' # for scraping kickstarter website
|
5
|
+
require 'open-uri' # for scraping kickstarter website
|
6
|
+
|
7
|
+
# require all files in lib directory
|
8
|
+
require_relative '../lib/newest_kickstarter/version'
|
9
|
+
require_relative '../lib/newest_kickstarter/project'
|
10
|
+
require_relative '../lib/newest_kickstarter/cli'
|
11
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class NewestKickstarter::CLI
|
2
|
+
|
3
|
+
def start # Dictates the flow and order of my gem
|
4
|
+
list # Call Scraping Method
|
5
|
+
menu # Call Interactive Method
|
6
|
+
goodbye # Call Closing Method
|
7
|
+
end
|
8
|
+
|
9
|
+
def list # Scraping Method
|
10
|
+
puts "" #Skips Line
|
11
|
+
puts "************* (Top 20) Newest Kickstarter Projects *************" # List Title
|
12
|
+
puts "" #Skips Line
|
13
|
+
#Call .all method on Project Class, take each with index and puts
|
14
|
+
NewestKickstarter::Project.all.each.with_index(1) do |project, i|
|
15
|
+
puts "#{i}. #{project.name}"
|
16
|
+
#format: 1. blahblah (then skips line, for each project)
|
17
|
+
end
|
18
|
+
puts "" #Skips Line
|
19
|
+
end
|
20
|
+
|
21
|
+
def menu # Interactive Method
|
22
|
+
input = nil # Define input for while method on next line
|
23
|
+
while input != "exit" #run this code unless user inputs exit
|
24
|
+
# Ask user for specific input
|
25
|
+
puts "Enter the number of the project you would like more info on, or type list for projects, or type exit"
|
26
|
+
#recieve user input, remove whitespace, and make lowercase
|
27
|
+
input = gets.strip.downcase
|
28
|
+
# Start Case Method based on user input
|
29
|
+
case input
|
30
|
+
when "list"
|
31
|
+
list # Run list method, then prompt question again
|
32
|
+
else #check if its a number, and add if statment
|
33
|
+
new_input = nil # Define new_input in case next line breaks
|
34
|
+
new_input = input.to_i # make user input a number
|
35
|
+
# check if user input a number between 1-20
|
36
|
+
if new_input.between?(1,20)
|
37
|
+
# take user input and run .find method on Project class
|
38
|
+
project = NewestKickstarter::Project.find(new_input)
|
39
|
+
# check if user input a number between 1-20 and i so
|
40
|
+
#run more_info method with an argument of the project
|
41
|
+
more_info(project)
|
42
|
+
# Then prompt question again
|
43
|
+
else # if user input is not a number between 1-20
|
44
|
+
puts "Oops!"
|
45
|
+
# Then prompt question again
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def more_info(project)
|
52
|
+
puts "" #Skips Line
|
53
|
+
# Run .name method on searched project
|
54
|
+
puts "-------------- #{project.name} --------------"
|
55
|
+
puts "" #Skips Line
|
56
|
+
# Run .summary method on searched project
|
57
|
+
puts project.summary
|
58
|
+
puts "" #Skips Line
|
59
|
+
# Run .author method on searched project
|
60
|
+
puts "Author: #{project.author}"
|
61
|
+
puts "" #Skips Line
|
62
|
+
# Run .url method on searched project
|
63
|
+
puts "URL: #{project.url}"
|
64
|
+
puts "" #Skips Line
|
65
|
+
# Then prompt question again
|
66
|
+
end
|
67
|
+
|
68
|
+
def goodbye # Closing Method
|
69
|
+
# Signal to the user that CLI has ended
|
70
|
+
puts "Thanks for stopping by. See you later for more projects!"
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class NewestKickstarter::Project
|
2
|
+
attr_accessor :name, :url, :summary, :author
|
3
|
+
# reader and writer methods for my project properties
|
4
|
+
|
5
|
+
# Initialize new projects with a name and url
|
6
|
+
# Set to nil if not provided
|
7
|
+
def initialize(name = nil, url = nil)
|
8
|
+
# Set instance variables for project properties
|
9
|
+
@name = name
|
10
|
+
@url = url
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.all
|
14
|
+
# fetch all projects if available or scrape KS
|
15
|
+
@@all ||= scrape_newest_projects
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find(id)
|
19
|
+
# find method that searches all projects by index
|
20
|
+
# [id-1] for offset, id starts @ 1, index starts @ 0
|
21
|
+
self.all[id-1]
|
22
|
+
end
|
23
|
+
|
24
|
+
def summary
|
25
|
+
# fetch summary if available or search doc and retrieve
|
26
|
+
@summary ||= doc.search("p.h3").text.strip
|
27
|
+
end
|
28
|
+
|
29
|
+
def author
|
30
|
+
# fetch author if available or search doc and retrieve
|
31
|
+
@author ||= doc.search('h5.mobile-hide a[data-modal-class="modal_project_by"]').text.strip
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
# scrape method for kickstarter projects
|
36
|
+
def self.scrape_newest_projects
|
37
|
+
# Set doc variable for all html scraped from KS Page
|
38
|
+
doc = Nokogiri::HTML(open('https://www.kickstarter.com/discover/advanced?recommended=false&sort=newest'))
|
39
|
+
# Set names variable for all project names scraped from doc
|
40
|
+
names = doc.search('h6.project-title a[data-score="null"]')
|
41
|
+
# iterate through names variable, collect name text, and url
|
42
|
+
# instantiate new project with name text and url for each pair
|
43
|
+
names.collect{|e| new(e.text.strip, "https://www.kickstarter.com#{e.attr("href").split("?").first.strip}")}
|
44
|
+
# Split at "?", take first part and remove whitespace
|
45
|
+
end
|
46
|
+
|
47
|
+
# Set doc variable for all html scraped from an objects url
|
48
|
+
def doc
|
49
|
+
@doc ||= Nokogiri::HTML(open(self.url))
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
Binary file
|
data/newest_kickstarter.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Scrapes top 20 new projects from kickstarter.com, an gives more info on each.}
|
13
13
|
spec.description = %q{This ruby gem is a simple command line interface (CLI) to access the top 20 newest projects on Kickstarter.com.This gem also allows you to recieve basic information about those projects and a link to their project page.}
|
14
|
-
spec.homepage = "
|
14
|
+
spec.homepage = "https://github.com/IshmaelKhalid/newest_kickstarter"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
end
|
24
24
|
|
25
25
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
-
spec.bindir = "
|
26
|
+
spec.bindir = "bin"
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
Binary file
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newest_kickstarter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IshmaelKhalid
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -75,18 +75,25 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- ".gitignore"
|
79
78
|
- CODE_OF_CONDUCT.md
|
80
79
|
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
81
|
- LICENSE.txt
|
82
|
+
- NOTES.md
|
82
83
|
- README.md
|
83
84
|
- Rakefile
|
84
85
|
- bin/console
|
86
|
+
- bin/newest-kickstarter
|
85
87
|
- bin/setup
|
88
|
+
- config/environment.rb
|
86
89
|
- lib/newest_kickstarter.rb
|
90
|
+
- lib/newest_kickstarter/cli.rb
|
91
|
+
- lib/newest_kickstarter/project.rb
|
87
92
|
- lib/newest_kickstarter/version.rb
|
93
|
+
- newest_kickstarter-0.1.0.gem
|
88
94
|
- newest_kickstarter.gemspec
|
89
|
-
|
95
|
+
- pkg/newest_kickstarter-0.1.0.gem
|
96
|
+
homepage: https://github.com/IshmaelKhalid/newest_kickstarter
|
90
97
|
licenses:
|
91
98
|
- MIT
|
92
99
|
metadata:
|