NewKS 0.2.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 397314819dc981911b4ba46b74b94bce5d281b2b
4
+ data.tar.gz: 9c7ef3ac6468f7fbee6eb345d25a68a36d49aff8
5
+ SHA512:
6
+ metadata.gz: 55be44f23d2234658a5b83d9da68e0ec88ff07ae348f2d79609a4eb9b35ed1aa58fa17a6530b1c1a93be3a32c1461fd93de5b40d9e155331697bf6afb629d6e0
7
+ data.tar.gz: 72b8e54335865d4a1d63211b0596b44d218a51b71d90639e7dd336888f4a4ff3bb68625efd24224e0fa4d940cac0cebfa3e2e71d29d564535cdf0b1b695f181b
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at ishmaelkhalid@icloud.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in NewKS.gemspec
4
+
5
+ gem 'NewKS'
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ NewKS (0.1.2)
5
+ nokogiri
6
+ mini_portile2 (2.1.0)
7
+ nokogiri (1.6.8)
8
+ mini_portile2 (~> 2.1.0)
9
+ pkg-config (~> 1.1.7)
10
+ pkg-config (1.1.7)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ NewKS
17
+
18
+ BUNDLED WITH
19
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 IshmaelKhalid
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/NewKS-0.1.0.gem ADDED
Binary file
data/NewKS-0.1.1.gem ADDED
Binary file
data/NewKS-0.1.2.gem ADDED
Binary file
data/NewKS.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'NewKS/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "NewKS"
8
+ spec.version = NewKS::VERSION
9
+ spec.authors = ["IshmaelKhalid"]
10
+ spec.email = ["ishmaelkhalid@icloud.com"]
11
+
12
+ spec.summary = %q{Scrapes top 20 new projects from kickstarter.com, an gives more info on each.}
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 = "https://github.com/IshmaelKhalid/NewKS"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "bin"
27
+ spec.executables = ["NewKS"]
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+
33
+
34
+ spec.add_dependency "nokogiri"
35
+ end
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # NewKS - A revision of newest_kickstarter gem
2
+
3
+ https://rubygems.org/gems/NewKS
4
+
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.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'NewKS'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install NewKS
22
+
23
+ ## Usage
24
+
25
+ Use this gem to study ruby techniques or just to keep up-to-date with your favorite KS Projects!
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/IshmaelKhalid/newest_kickstarter. 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.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/NewKS ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # link to files that include NewestKickstarter::CLI.new.start method
4
+ require_relative '../lib/NewKS'
5
+
6
+ # Put here to avoid logic in bin folder
7
+ NewKS::CLI.new.start
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "NewKS"
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
data/bin/setup ADDED
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,9 @@
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 'nokogiri' # for scraping kickstarter website
4
+ require 'open-uri' # for scraping kickstarter website
5
+
6
+ # require all files in lib directory
7
+ require_relative '../lib/NewKS/version'
8
+ require_relative '../lib/NewKS/project'
9
+ require_relative '../lib/NewKS/cli'
data/lib/NewKS/cli.rb ADDED
@@ -0,0 +1,73 @@
1
+ class NewKS::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
+ NewKS::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 = NewKS::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,51 @@
1
+ class NewKS::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
+ end
@@ -0,0 +1,3 @@
1
+ module NewKS
2
+ VERSION = "0.2.0"
3
+ end
data/lib/NewKS.rb ADDED
@@ -0,0 +1,2 @@
1
+ # require environment file where other requirements are stored
2
+ require_relative '../config/environment'
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: NewKS
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - IshmaelKhalid
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-16 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This ruby gem is a simple command line interface (CLI) to access the
56
+ top 20 newest projects on Kickstarter.com.This gem also allows you to recieve basic
57
+ information about those projects and a link to their project page.
58
+ email:
59
+ - ishmaelkhalid@icloud.com
60
+ executables:
61
+ - NewKS
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - NewKS-0.1.0.gem
70
+ - NewKS-0.1.1.gem
71
+ - NewKS-0.1.2.gem
72
+ - NewKS.gemspec
73
+ - README.md
74
+ - Rakefile
75
+ - bin/NewKS
76
+ - bin/console
77
+ - bin/setup
78
+ - config/environment.rb
79
+ - lib/NewKS.rb
80
+ - lib/NewKS/cli.rb
81
+ - lib/NewKS/project.rb
82
+ - lib/NewKS/version.rb
83
+ homepage: https://github.com/IshmaelKhalid/NewKS
84
+ licenses:
85
+ - MIT
86
+ metadata:
87
+ allowed_push_host: https://rubygems.org
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.4.6
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Scrapes top 20 new projects from kickstarter.com, an gives more info on each.
108
+ test_files: []