NewKS 0.2.1 → 0.2.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 +4 -4
- data/NewKS-0.2.1.gem +0 -0
- data/lib/NewKS/cli.rb +8 -4
- data/lib/NewKS/project.rb +25 -21
- data/lib/NewKS/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ee36e6e53981b7257cd4cefdbda0c1bcb9c77c6
|
4
|
+
data.tar.gz: ae9aef3f40b90757c2653716bcf989e6b4cd28c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a0267db5368e50ee67e788d9d68f1c0e6e8ebc9b5e3cc548a8ddab1896a4c8792f29825b38e2fd858ce12aa3dc89b70d6268550e1f0aca0f0c6b9e374e2cff3
|
7
|
+
data.tar.gz: 12c7dfd8c0ade02be962e7d90d982840abcea9df8722450bc16bc00e9f4adc90142d3180c1b7f0e85ef5445a4b0fba2bb0bb39703ad5ad0cf61e51bf42325637
|
data/NewKS-0.2.1.gem
ADDED
Binary file
|
data/lib/NewKS/cli.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class NewKS::CLI
|
2
|
-
|
3
2
|
def start # Dictates the flow and order of my gem
|
4
3
|
list # Call Scraping Method
|
5
4
|
menu # Call Interactive Method
|
@@ -22,17 +21,18 @@ class NewKS::CLI
|
|
22
21
|
input = nil # Define input for while method on next line
|
23
22
|
while input != "exit" #run this code unless user inputs exit
|
24
23
|
# 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"
|
24
|
+
puts "Enter the number of the project you would like more info on, or type list to relist projects, type refresh to check for new projects, or type exit"
|
26
25
|
#recieve user input, remove whitespace, and make lowercase
|
27
26
|
input = gets.strip.downcase
|
28
27
|
# Start Case Method based on user input
|
29
28
|
case input
|
30
29
|
when "exit"
|
31
30
|
|
31
|
+
when "refresh"
|
32
|
+
refresh
|
32
33
|
when "list"
|
33
34
|
list # Run list method, then prompt question again
|
34
35
|
else #check if its a number, and add if statment
|
35
|
-
new_input = nil # Define new_input in case next line breaks
|
36
36
|
new_input = input.to_i # make user input a number
|
37
37
|
# check if user input a number between 1-20
|
38
38
|
if new_input.between?(1,20)
|
@@ -50,6 +50,11 @@ class NewKS::CLI
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
def refresh
|
54
|
+
NewKS::Project.refresh
|
55
|
+
list
|
56
|
+
end
|
57
|
+
|
53
58
|
def more_info(project)
|
54
59
|
puts "" #Skips Line
|
55
60
|
# Run .name method on searched project
|
@@ -71,5 +76,4 @@ class NewKS::CLI
|
|
71
76
|
# Signal to the user that CLI has ended
|
72
77
|
puts "Thanks for stopping by. See you later for more projects!"
|
73
78
|
end
|
74
|
-
|
75
79
|
end
|
data/lib/NewKS/project.rb
CHANGED
@@ -21,31 +21,35 @@ class NewKS::Project
|
|
21
21
|
self.all[id-1]
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.refresh
|
25
|
+
@@all.clear
|
26
|
+
@@all = scrape_newest_projects
|
27
|
+
end
|
28
|
+
|
24
29
|
def summary
|
25
30
|
# fetch summary if available or search doc and retrieve
|
26
|
-
@summary
|
31
|
+
@summary = doc.search("p.h3").text.strip
|
27
32
|
end
|
28
33
|
|
29
34
|
def author
|
30
35
|
# fetch author if available or search doc and retrieve
|
31
|
-
@author
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
36
|
+
@author = doc.search('h5.mobile-hide a[data-modal-class="modal_project_by"]').text.strip
|
37
|
+
end
|
38
|
+
|
39
|
+
# scrape method for kickstarter projects
|
40
|
+
def self.scrape_newest_projects
|
41
|
+
# Set doc variable for all html scraped from KS Page
|
42
|
+
doc = Nokogiri::HTML(open('https://www.kickstarter.com/discover/advanced?recommended=false&sort=newest'))
|
43
|
+
# Set names variable for all project names scraped from doc
|
44
|
+
names = doc.search('h6.project-title a[data-score="null"]')
|
45
|
+
# iterate through names variable, collect name text, and url
|
46
|
+
# instantiate new project with name text and url for each pair
|
47
|
+
names.collect{|e| new(e.text.strip, "https://www.kickstarter.com#{e.attr("href").split("?").first.strip}")}
|
48
|
+
# Split at "?", take first part and remove whitespace
|
49
|
+
end
|
50
|
+
|
51
|
+
# Set doc variable for all html scraped from an objects url
|
52
|
+
def doc
|
53
|
+
@doc = Nokogiri::HTML(open(self.url))
|
54
|
+
end
|
51
55
|
end
|
data/lib/NewKS/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: NewKS
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IshmaelKhalid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- NewKS-0.1.1.gem
|
72
72
|
- NewKS-0.1.2.gem
|
73
73
|
- NewKS-0.2.0.gem
|
74
|
+
- NewKS-0.2.1.gem
|
74
75
|
- NewKS.gemspec
|
75
76
|
- README.md
|
76
77
|
- Rakefile
|