CigarFreaks 0.1.0

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
+ SHA256:
3
+ metadata.gz: 6ec3f44cafa976065e4e61d2e2c1453fedc5aaf8e62feb5d73e1e007226b5f22
4
+ data.tar.gz: 91e6134878c93ed3bb04699d5a4f154b4d25175500e1b01637573be846707dd3
5
+ SHA512:
6
+ metadata.gz: 471bfd7bd040d63889c8300dc77f8a74347dab789b3f178ac5f9a42b5af6b0153e9306714cf41819d970b52cd23eb9d1b910e6e4bf041256ceb5fb8f7e532f21
7
+ data.tar.gz: 33e05a1d6fc79f3ad8ffe134a06ee5d65f4e9fdba969a675be4ae22fa131a634d24097371d8c0c213f740c6b41d5c930465b37994c89edf02cbd809f53c62827
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,11 @@
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 ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.0
@@ -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 catalano.work@gmail.com. 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/
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "CigarFreaks/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "CigarFreaks"
7
+ spec.version = CigarFreaks::VERSION
8
+ spec.authors = ["catalanowebdevelopment"]
9
+ spec.email = ["catalano.work@gmail.com"]
10
+
11
+ spec.summary = "Allows the user to view the most current and top rated cigars in the world."
12
+ spec.description = "Test"
13
+ spec.homepage = "https://github.com/CatalanoWebDevelopment/CigarFreaks"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.16"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ end
data/Gemfile ADDED
@@ -0,0 +1,13 @@
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 CigarFreaks.gemspec
6
+ gemspec
7
+
8
+ gem 'pry'
9
+ gem 'colorize'
10
+ gem 'open-uri'
11
+ gem 'nokogiri'
12
+ gem 'rakefile'
13
+ gem 'require_all'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 catalanowebdevelopment
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,57 @@
1
+ # CigarFreaks
2
+
3
+ Welcome to CigarFreaks! This is a dynamic gem that will keep you up-to-date on the top ten highest valued cigars. Information will include a description of the cigar's:
4
+
5
+ 1) Tasting note
6
+ 2) Ring gauge
7
+ 3) Body
8
+ 4) Size
9
+ 5) Length
10
+ 6) Filler
11
+ 7) Binder
12
+ 8) Wrapper
13
+ 9) Price
14
+
15
+ The data updates every time the program is ran. So keep in mind to check back regularly!! <3
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'CigarFreaks'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install CigarFreaks
32
+
33
+ ## Usage
34
+
35
+ Once you have this gem loaded, simply execute:
36
+
37
+ bin/cigar_freaks
38
+
39
+ to get everything up and running! Once the program loads, you will be given a list of ten current cigars ordered 1 to 10. In order to retrieve information regarding the cigar in question, simply enter in the number associated with its rank. Simple!
40
+
41
+ ## Development
42
+
43
+ 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.
44
+
45
+ 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).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/catalanowebdevelopment/CigarFreaks. 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.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
54
+
55
+ ## Code of Conduct
56
+
57
+ Everyone interacting in the CigarFreaks project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/catalanowebdevelopment/CigarFreaks/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "./lib/CigarFreaksEnvironment.rb"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ task :console do
10
+ require 'pry'
11
+ Pry.start
12
+ end
data/bin/cigar_freaks ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require './lib/CigarFreaksEnvironment'
3
+
4
+ CLI.new.call
data/bin/console ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require_relative "CigarFreaksEnvironment"
5
+
6
+
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
data/lib/CLI.rb ADDED
@@ -0,0 +1,122 @@
1
+ class CLI
2
+
3
+ def call
4
+ greeting
5
+ CigarScraper.new.run
6
+ options
7
+ end
8
+
9
+ def greeting
10
+ puts "Welcome to CigarFreaks! Here is a list of the top ten most highly valued cigars. If you would like a more in-depth look at one of these beauties, simply type in the number associated with their rank. If you'd like to quit the program, just type in 'exit'.".black
11
+ end
12
+
13
+ def powermove(input)
14
+ c = CigarScraper.new
15
+ h = c.hyperlink(input.to_i - 1)
16
+ ci = CigarScraper.new.scrape_details(h)
17
+
18
+ puts "TASTING NOTE:".blue
19
+ puts "#{ci.tasting_note}"
20
+
21
+ puts "- - - - - -".red
22
+
23
+ puts "BODY:".blue
24
+ puts "#{ci.body}"
25
+
26
+ puts "- - - - - -".red
27
+
28
+ puts "SIZE:".blue
29
+ puts "#{ci.size}"
30
+
31
+ puts "- - - - - -".red
32
+
33
+ puts "RING GAUGE:".blue
34
+ puts "#{ci.ring_gauge}"
35
+
36
+ puts "- - - - - -".red
37
+
38
+ puts "LENGTH:".blue
39
+ puts "#{ci.length}"
40
+
41
+ puts "- - - - - -".red
42
+
43
+ puts "FILLER:".blue
44
+ puts "#{ci.filler}"
45
+
46
+ puts "- - - - - -".red
47
+
48
+ puts "BINDER:".blue
49
+ puts "#{ci.binder}"
50
+
51
+ puts "- - - - - -".red
52
+
53
+ puts "WRAPPER:".blue
54
+ puts "#{ci.wrapper}"
55
+
56
+ puts "- - - - - -".red
57
+
58
+ puts "PRICE:".blue
59
+ puts "#{ci.price}"
60
+
61
+ puts "- - - - - -".red
62
+
63
+ end
64
+
65
+ def options
66
+ puts "- - - - - -".red
67
+ puts "Which cigar would you like to look at? To quit, type 'exit'"
68
+ input = gets.strip
69
+ input = input.downcase
70
+
71
+ if input == "1"
72
+ powermove(input)
73
+ options
74
+
75
+ elsif input == "2"
76
+ powermove(input)
77
+ options
78
+
79
+ elsif input == "3"
80
+ powermove(input)
81
+ options
82
+
83
+ elsif input == "4"
84
+ powermove(input)
85
+ options
86
+
87
+ elsif input == "5"
88
+ powermove(input)
89
+ options
90
+
91
+ elsif input == "6"
92
+ powermove(input)
93
+ options
94
+
95
+ elsif input == "7"
96
+ powermove(input)
97
+ options
98
+
99
+ elsif input == "8"
100
+ powermove(input)
101
+ options
102
+
103
+ elsif input == "9"
104
+ powermove(input)
105
+ options
106
+
107
+ elsif input == "10"
108
+ powermove(input)
109
+ options
110
+
111
+ elsif input == "exit"
112
+ goodbye
113
+ else
114
+ puts "I'm sorry; we do not understand what you want! Please try a valid input between 1 and 10, or type 'exit' to quit the program. Happy smoking!"
115
+ options
116
+ end
117
+ end
118
+
119
+ def goodbye
120
+ puts "Thank you for using CigarFreaks for your daily deals! We look forward to seeing you next time. Happy smoking <3"
121
+ end
122
+ end
@@ -0,0 +1,3 @@
1
+ module CigarFreaks
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,8 @@
1
+ require_relative "CigarFreaks/version"
2
+ require_relative "CigarScraper"
3
+ require_relative "Cigars"
4
+ require_relative "CLI"
5
+ require 'Nokogiri'
6
+ require 'colorize'
7
+ require 'open-uri'
8
+ require 'pry'
@@ -0,0 +1,67 @@
1
+ require_relative 'CigarFreaksEnvironment.rb'
2
+
3
+ class CigarScraper
4
+ attr_accessor :doc
5
+
6
+ def initialize
7
+ url = "https://www.cigaraficionado.com/ratingsandreviews"
8
+ @doc ||= Nokogiri::HTML(open(url))
9
+ end
10
+
11
+
12
+ def get_names
13
+ names = @doc.css("div.cigar-teaser_wrapper h3").map {|name| name.text}.compact
14
+ end
15
+
16
+ def get_points
17
+ counter = 10
18
+ while counter <= 10 do
19
+ counter += 1
20
+ points = @doc.css("div.cigar-teaser_wrapper div.cigar-teaser_info div.cigar-teaser_score").map {|points| points.text}.compact
21
+ end
22
+ points
23
+ end
24
+
25
+ def hyperlink(input)
26
+ prefix = "https://www.cigaraficionado.com"
27
+ suffix = @doc.search("div.cigar-teaser_wrapper a[href]").map do |link|
28
+ link.attribute("href").value
29
+ end
30
+
31
+ "#{prefix}#{suffix[input]}"
32
+ end
33
+
34
+ def run
35
+ scraper = CigarScraper.new
36
+ names = scraper.get_names
37
+ points = scraper.get_points
38
+
39
+ (0...names.size).each do |index|
40
+ puts "- - - - - -".red
41
+ puts "#{names[index]} | Points: #{points[index]}".blue
42
+ end
43
+ end
44
+
45
+ def scrape_details(url)
46
+ @d = Nokogiri::HTML(open(url))
47
+ params = {}
48
+
49
+ specs = @d.search("tbody td").map do |info|
50
+ info.text
51
+ end
52
+
53
+ params[:tasting_note] = specs[0].strip
54
+ params[:body] = specs[2].strip
55
+ params[:size] = specs[4].strip
56
+ params[:ring_gauge] = specs[6].strip
57
+ params[:length] = specs[8].strip
58
+ params[:filler] = specs[10].strip
59
+ params[:binder] = specs[12].strip
60
+ params[:wrapper] = specs[14].strip
61
+ params[:price] = specs[18].strip
62
+
63
+ Cigars.new(params)
64
+
65
+ end
66
+
67
+ end
data/lib/Cigars.rb ADDED
@@ -0,0 +1,21 @@
1
+ require_relative 'CigarFreaksEnvironment.rb'
2
+
3
+ class Cigars
4
+ attr_accessor :tasting_note, :ring_gauge, :body,
5
+ :size, :length, :filler, :binder, :wrapper, :price
6
+
7
+ def initialize(tasting_note: nil, ring_gauge: nil, body: nil, size: nil, length: nil, filler: nil, binder: nil, wrapper: nil, price: nil)
8
+ @tasting_note = tasting_note
9
+ @ring_gauge = ring_gauge
10
+ @body = body
11
+ @size = size
12
+ @length = length
13
+ @filler = filler
14
+ @binder = binder
15
+ @wrapper = wrapper
16
+ @price = price
17
+ end
18
+
19
+ end
20
+
21
+
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: CigarFreaks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - catalanowebdevelopment
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-15 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Test
56
+ email:
57
+ - catalano.work@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".DS_Store"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - CigarFreaks.gemspec
68
+ - Gemfile
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - bin/cigar_freaks
73
+ - bin/console
74
+ - bin/setup
75
+ - lib/CLI.rb
76
+ - lib/CigarFreaks/version.rb
77
+ - lib/CigarFreaksEnvironment.rb
78
+ - lib/CigarScraper.rb
79
+ - lib/Cigars.rb
80
+ homepage: https://github.com/CatalanoWebDevelopment/CigarFreaks
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.7.2
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Allows the user to view the most current and top rated cigars in the world.
104
+ test_files: []