knitting_yarn_deals 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9e43ab5090461e845c84dab88e81961d491459e3
4
+ data.tar.gz: a2b75b86a17a2d22cce7ae8eca26ef1e64c5ff0d
5
+ SHA512:
6
+ metadata.gz: e792bf41b4040987053c33adace6340fe0f20991a17bce27eecb1067526d9121a7f14911fd8afc2e54baa893d1e11c31a238678c678edfb9c6fa8f9717df400b
7
+ data.tar.gz: c66c6bf9dbc240c7df447d55829160eecdd2f0619cf00ed6ce7c35e78152fc33e8b15d3f3599b77d3b948adf32f6b7544f9a5ad88edbf5a42b494d8ec14459f0
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.15.2
@@ -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 <github email address>. 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
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org" do
2
+
3
+ #git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in knitting_yarn_deals.gemspec
6
+
7
+ gemspec
8
+
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 christy743
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,31 @@
1
+ # KnittingYarnDeals
2
+
3
+ This Ruby Gem provides a command line interface to view a list of yarn product for knitters as per the Knitpicks.com website.
4
+
5
+ ## Installation
6
+
7
+ $ gem install knitting_yarn_deals
8
+
9
+ ## Usage
10
+
11
+ Type the below and follow the on screen prompts.
12
+
13
+ $ knitting_yarn_deals
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/profiles/christy743).
20
+
21
+ ## Contributing
22
+
23
+ Bug reports and pull requests are welcome on GitHub at https://github.com/christy743/knitting_yarn_deals. 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](http://opensource.org/licenses/MIT).
28
+
29
+ ## Code of Conduct
30
+
31
+ Everyone interacting in the KnittingYarnDeals project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/christy743/knitting_yarn_deals/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
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 ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "knitting_yarn_deals"
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
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/knitting_yarn_deals'
4
+ #require '/home/chrissyos/code/labs/CLI Data Gem Project/knitting-yarn-deals-cli-app/lib/knitting_yarn_deals'
5
+
6
+ cli = KnittingYarnDeals::CLI.new
7
+ cli.call
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,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "nokogiri"
4
+ require "open-uri"
5
+
6
+ require_relative "../lib/knitting_yarn_deals/scraper"
7
+ require_relative "../lib/knitting_yarn_deals/yarn_deal"
8
+ require_relative "../lib/knitting_yarn_deals/cli"
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "knitting_yarn_deals/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "knitting_yarn_deals"
8
+ spec.version = KnittingYarnDeals::VERSION
9
+ spec.author = ["Christina Chronister"]
10
+ spec.email = ["cchronister743@gmail.com"]
11
+ spec.platform = Gem::Platform::RUBY
12
+ spec.rubygems_version = "2.4.8 ans 2.6.13"
13
+
14
+ spec.summary = %q{Gem that uses scraping in nokogiri a website to help knitters to find yarn deals.}
15
+ spec.description = %q{As a knitter I am always looking for yarn deals even though I have a basement full of yarn. I want to help other knitters.}
16
+ spec.homepage = "https://github.com/Christy743/knitting-yarn-deals-cli-app"
17
+ spec.license = "MIT"
18
+ spec.version = "0.2.1"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+
24
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+ spec.post_install_message = "Thanks for installing!"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.15"
29
+ spec.add_development_dependency "rake", "~> 10.4"
30
+ spec.add_development_dependency "rspec", "~> 3.6"
31
+ spec.add_development_dependency "pry", "~> 0.10.4"
32
+
33
+ spec.add_dependency "nokogiri"
34
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module KnittingYarnDeals
4
+ end
5
+
6
+ require_relative '../config/environment'
@@ -0,0 +1,63 @@
1
+ class KnittingYarnDeals::CLI
2
+
3
+ def call
4
+ system("clear")
5
+ sleep(1)
6
+ hello
7
+ sleep(1)
8
+ list_yarns
9
+ menu
10
+ end
11
+
12
+ def hello
13
+ puts ""
14
+ puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
15
+ puts ""
16
+ puts "Hello! Check out this yarn list for your next knitting project:"
17
+ puts ""
18
+ end
19
+
20
+ def list_yarns
21
+ @skein = KnittingYarnDeals::Scraper.this_day
22
+ @skein.each.with_index(1) do |yarn, i|
23
+ puts "#{i}. #{yarn.name}"
24
+ end
25
+ end
26
+
27
+ def menu
28
+ puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
29
+ puts ""
30
+ puts "Please type in the number from the list of yarn you would like to know more about
31
+ or type in 'list' to see the list of yarn again or type 'exit' to end this app:".gsub /^\s*/, ''
32
+ puts ""
33
+ puts ""
34
+ input = gets.strip
35
+ if input.to_i > 0 && input.to_i < KnittingYarnDeals::YarnDeal.all.count
36
+ yarn_deal = @skein[input.to_i-1]
37
+ KnittingYarnDeals::Scraper.scrape_details(yarn_deal, input.to_i-1)
38
+ puts "Description of #{yarn_deal.name}"
39
+ puts "Price of yarn: #{yarn_deal.price}"
40
+ puts "#{yarn_deal.description}"
41
+ puts "Web page address for #{yarn_deal.name}:"
42
+ puts "#{yarn_deal.url}"
43
+ if yarn_deal.description.strip.empty?
44
+ puts ""
45
+ puts "Sorry! There is no description for this yarn."
46
+ end
47
+ menu
48
+ elsif input == "exit"
49
+ goodbye
50
+ elsif input == "list"
51
+ list_yarns
52
+ menu
53
+ else
54
+ puts "I'm not sure what you want."
55
+ menu
56
+ end
57
+ end
58
+
59
+ def goodbye
60
+ puts "Good Bye and Happy Knitting!"
61
+ end
62
+
63
+ end
@@ -0,0 +1,35 @@
1
+ class KnittingYarnDeals::Scraper
2
+
3
+ def self.get_page
4
+ html = Nokogiri::HTML(open("http://www.knitpicks.com/yarns/knitting_yarns.html"))
5
+ end
6
+
7
+ def self.this_day
8
+ if KnittingYarnDeals::YarnDeal.all == []
9
+ self.yarn_index
10
+ KnittingYarnDeals::YarnDeal.all
11
+ else
12
+ KnittingYarnDeals::YarnDeal.all
13
+ end
14
+ end
15
+
16
+ def self.scrape_details(yarn_ball, index)
17
+ skein = @yarn_array[index]
18
+
19
+ yarn_ball.price = skein.css("span.costSmall").text.delete(" ").gsub /^\s*/, ''
20
+ yarn_ball.url = "http://www.knitpicks.com#{skein.css("a").attribute("href").value}"
21
+ yarn_ball.description = Nokogiri::HTML(open(yarn_ball.url)).css("div#prodDesc span.prodDesc").text.gsub /^\s*/, ' '
22
+ yarn_ball.availability = true
23
+ end
24
+
25
+ def self.yarn_index
26
+ html = self.get_page
27
+ @yarn_array = html.css("div.jcarousel li")
28
+ @yarn_array.each do |each_skein|
29
+ yarn_ball = KnittingYarnDeals::YarnDeal.new
30
+ yarn_ball.name = each_skein.css("a.titleSmall").text
31
+ yarn_ball.save
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,3 @@
1
+ module KnittingYarnDeals
2
+ VERSION = "0.2.1"
3
+ end
@@ -0,0 +1,37 @@
1
+ class KnittingYarnDeals::YarnDeal
2
+ attr_accessor :name, :price, :availability, :url, :description
3
+
4
+ @@all = []
5
+
6
+ def self.all
7
+ @@all
8
+ end
9
+
10
+ def self.find(id)
11
+ self.all[id-1]
12
+ end
13
+
14
+ def initialize
15
+ @name = name
16
+ @price = price
17
+ @url = url
18
+ @description = description
19
+ @availability = true
20
+ end
21
+
22
+ def save
23
+ if valid?
24
+ @@all << self
25
+ end
26
+ end
27
+
28
+ def valid?
29
+ validate_name
30
+ end
31
+
32
+ def validate_name
33
+ !@name.strip.empty?
34
+ end
35
+
36
+
37
+ end
data/spec.md ADDED
@@ -0,0 +1,39 @@
1
+
2
+ How to Build a CLI Gem
3
+
4
+ 1. Plan your gem, imagine your interface
5
+ 2. Start with the project structure – google
6
+ 3. Start with the entry point – the file run
7
+ 4. Force that to build the CLI interface
8
+ 5. Stub out the interface
9
+ 6. Start making things real
10
+ 7. Discover objects
11
+ 8. Program
12
+
13
+ - A command line interface for project (put title here later), starting with web sites
14
+ --choose a website
15
+ --brings up list of yarns
16
+ --choose yarn and it gives price and weight
17
+
18
+ User types in request -
19
+ List is generated
20
+
21
+ User is prompted to choose or select from the list
22
+
23
+ What is a yarn deal?
24
+
25
+ A yarn deal has a name
26
+ A yarn deal has a price
27
+ A yarn deal has a URL
28
+ A yarn deal has availability
29
+
30
+
31
+ List for knitting_yarn_deals gem/app lab requirements:
32
+
33
+ Git Repo Address [X] Started repository for my gem CLI project
34
+ Record Code for 20 minutes [X] Used vokoscreen to record
35
+ Blog Post [X] Wrote a journal
36
+ Publish Gem [] Not complete - have to figure out why I have too many gem names
37
+ README.md [X] Wrote a README file to show how to install the gem
38
+ Video Demo of the Gem
39
+ for User [X] Recorded and put on website
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knitting_yarn_deals
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Christina Chronister
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-26 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
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.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
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.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.6'
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.10.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: As a knitter I am always looking for yarn deals even though I have a
84
+ basement full of yarn. I want to help other knitters.
85
+ email:
86
+ - cchronister743@gmail.com
87
+ executables:
88
+ - console
89
+ - knitting_yarn_deals
90
+ - setup
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".gitignore"
95
+ - ".rspec"
96
+ - ".travis.yml"
97
+ - CODE_OF_CONDUCT.md
98
+ - Gemfile
99
+ - LICENSE.txt
100
+ - README.md
101
+ - Rakefile
102
+ - bin/console
103
+ - bin/knitting_yarn_deals
104
+ - bin/setup
105
+ - config/environment.rb
106
+ - knitting_yarn_deals.gemspec
107
+ - lib/knitting_yarn_deals.rb
108
+ - lib/knitting_yarn_deals/cli.rb
109
+ - lib/knitting_yarn_deals/scraper.rb
110
+ - lib/knitting_yarn_deals/version.rb
111
+ - lib/knitting_yarn_deals/yarn_deal.rb
112
+ - spec.md
113
+ homepage: https://github.com/Christy743/knitting-yarn-deals-cli-app
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message: Thanks for installing!
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.6.13
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Gem that uses scraping in nokogiri a website to help knitters to find yarn
137
+ deals.
138
+ test_files: []