travel_leisure 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 684359f837999ffe03c6b3f62c5eba23f50a79830954a112ec4ad7378059092b
4
- data.tar.gz: ba34dfc40950e63287085674ca7164c1bf6c92d98e28bd1860ec53e038ce78a4
3
+ metadata.gz: b74a6f33473f5f2dfb2002dae2aa0d68eefee6ec414871a2499b7dba0eb30aea
4
+ data.tar.gz: 46fc3124fff1797e5aef3967c5467867fefcf7a901b579ba7f6faaddcb8dcd4c
5
5
  SHA512:
6
- metadata.gz: 4a95de7a1a3416615a789be38bbff92a5689abdcb1a93d78d45634280be38c69db358941bf1ee19eeb68ea5cddef6286a29faa871390976d17a5bce6d1fd3fe9
7
- data.tar.gz: 284fb88fc6a4c23abb74b7d45bc5c86f847995cd44343bfc936a7c80dcbdb4d2b0b6b1a6aeaf9a549bf2859116f7c01e262a2c23cfd08c3ca42099cc82364c82
6
+ metadata.gz: '058d6279353acb1382ae83073500300284dae7f8add82a816d76cbeb04a9bb722ad0deaa76fc94c7fa25adf97910a1654ce131288b6d9fa19962073760ab005d'
7
+ data.tar.gz: 784347895f12df6d9d3f07b4c99b131fa85ecf2015ea52048b50651837f49377dff38421f6a98c9b2a1ecfb576449fafd3deeb0847d25984f133db5abace8fad
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,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.1
7
+ before_install: gem install bundler -v 2.0.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 corbin.c.arnett@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/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in travel_leisure.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ travel_leisure (0.1.0)
5
+ colorize (~> 0.8.1)
6
+ nokogiri (~> 1.8)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.1.2)
12
+ colorize (0.8.1)
13
+ diff-lcs (1.3)
14
+ method_source (0.8.2)
15
+ mini_portile2 (2.4.0)
16
+ nokogiri (1.10.4)
17
+ mini_portile2 (~> 2.4.0)
18
+ pry (0.10.4)
19
+ coderay (~> 1.1.0)
20
+ method_source (~> 0.8.1)
21
+ slop (~> 3.4)
22
+ rake (10.5.0)
23
+ rspec (3.8.0)
24
+ rspec-core (~> 3.8.0)
25
+ rspec-expectations (~> 3.8.0)
26
+ rspec-mocks (~> 3.8.0)
27
+ rspec-core (3.8.2)
28
+ rspec-support (~> 3.8.0)
29
+ rspec-expectations (3.8.4)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-mocks (3.8.1)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-support (3.8.2)
36
+ slop (3.6.0)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bundler (~> 2.0)
43
+ pry (~> 0.10.4)
44
+ rake (~> 10.0)
45
+ rspec (~> 3.0)
46
+ travel_leisure!
47
+
48
+ BUNDLED WITH
49
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 corbinarnett
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
+ # TravelLeisure
2
+
3
+ This Ruby Gem provides a CLI to access travel guides sourced from [Travel & Leisure](https://www.travelandleisure.com/travel-guide).
4
+
5
+ ## Installation
6
+
7
+ $ gem install travel_leisure
8
+
9
+ ## Usage
10
+
11
+ Type the below and follow the on screen prompts.
12
+
13
+ $ travel_leisure
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).
20
+
21
+ ## Contributing
22
+
23
+ Bug reports and pull requests are welcome on GitHub at https://github.com/corbinarnett/travel_leisure. 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](https://opensource.org/licenses/MIT).
28
+
29
+ ## Code of Conduct
30
+
31
+ Everyone interacting in the TravelLeisure project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/corbinarnett/travel_leisure/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 "travel_leisure"
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(__FILE__)
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,103 @@
1
+ # code handling CLI display logic and user input
2
+ class TravelLeisure::CLI #:: name space
3
+ def call
4
+ TravelLeisure::Scraper.new.make_destinations
5
+ puts ""
6
+ puts ""
7
+ puts " ------------------------------------------------ ".blue
8
+ puts "| |".blue
9
+ puts "| Welcome to Command Line Travel Guides |".blue.bold
10
+ puts "| |".blue
11
+ puts " ------------------------------------------------ ".blue
12
+ puts ""
13
+ puts ""
14
+
15
+ menu
16
+ end
17
+
18
+ def menu
19
+
20
+ puts "To view the destinations that we have travel guides for, enter 'travel'.".yellow.bold
21
+ puts "or enter 'q' to exit".yellow.bold
22
+
23
+ input = gets.strip.downcase
24
+
25
+ if input == 'travel'
26
+ puts ""
27
+ puts "Here is a list of destinations that we have travel guides for:".yellow.bold
28
+ puts ""
29
+
30
+ list_destinations
31
+
32
+ elsif input == "q"
33
+ exit
34
+ else
35
+ puts ""
36
+ puts "I don't understand that answer, please try again:".red.bold
37
+ puts ""
38
+ menu
39
+ end
40
+
41
+ puts "\nPlease enter the number of the travel guide you would like to access\nor enter 'q' to exit:".yellow.bold
42
+ input = gets.strip
43
+ if input == 'q'
44
+ exit
45
+ elsif
46
+ destination = TravelLeisure::Destination.find(input.to_i)
47
+ print_destination(destination)
48
+
49
+ end
50
+
51
+ puts ""
52
+ puts "Would you like to see another travel guide? Enter Y or N".yellow.bold
53
+
54
+ input = gets.strip.downcase
55
+ if input == "y"
56
+ menu
57
+ elsif input == "n"
58
+ puts ""
59
+ puts "Thank you! Have a great day!".yellow.bold
60
+ exit
61
+ else
62
+ puts ""
63
+ puts "I don't understand that answer.".red.bold
64
+ menu
65
+ end
66
+ end
67
+
68
+ def print_destination(destination)
69
+ puts ""
70
+ puts "----------- #{destination.city}, #{destination.country} -----------".blue.bold
71
+ puts ""
72
+ puts "Best Time To Visit: #{destination.best_time_to_visit}".green.bold
73
+ puts "\nTransportation: #{destination.transportation}".green.bold
74
+ puts "\nWeather: #{destination.weather}".green.bold
75
+ puts "\nKnow Before Visiting: #{destination.know_before_visiting}".green.bold
76
+ puts "\nLanguage: #{destination.language}".green.bold
77
+ puts "\nCurrency: #{destination.currency}".green.bold
78
+ puts ""
79
+ puts "Would you like to read more on #{destination.city}? Enter Y or N".yellow.bold
80
+
81
+ input = gets.strip.downcase
82
+ if input == "y"
83
+ puts ""
84
+ puts "More info:"
85
+ puts ""
86
+ puts destination.description
87
+ elsif input == "n"
88
+ menu
89
+ elsif input == "q"
90
+ exit
91
+ else
92
+ puts ""
93
+ puts "I don't understand that answer."
94
+ menu
95
+ end
96
+ end
97
+
98
+ def list_destinations
99
+ TravelLeisure::Destination.all.each.with_index(1) do |destination, index|
100
+ puts "#{index}. #{destination.city}, #{destination.country}"
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,65 @@
1
+ class TravelLeisure::Destination
2
+ @@all = []
3
+ attr_accessor :city, :country, :url, :best_time_to_visit, :transportation, :weather, :know_before_visiting, :language, :currency, :description
4
+
5
+ def self.new_from_website(r)
6
+ self.new(
7
+ r.css("span.grid__item__title").text,
8
+ r.css("span.grid__item__cat").text,
9
+ r.css("a").attribute("href")
10
+ )
11
+ end
12
+
13
+ def initialize(city=nil,country=nil,url=nil)
14
+ @city = city
15
+ @country = country
16
+ @url = url
17
+ save
18
+ end
19
+
20
+ def self.all
21
+ @@all
22
+ end
23
+
24
+ def save
25
+ @@all << self
26
+ end
27
+
28
+ def self.find(index)
29
+ self.all[index-1]
30
+ end
31
+
32
+ def doc
33
+ @doc ||= Nokogiri::HTML(open(self.url))
34
+ end
35
+
36
+ def best_time_to_visit
37
+ @best_time_to_visit ||= doc.css("div.article-tips__item")[0].css("p.article-tips__content").text
38
+ end
39
+
40
+ def transportation
41
+ @transportation ||= doc.css("div.article-tips__item")[1].css("p.article-tips__content").text
42
+ end
43
+
44
+ def weather
45
+ @weather ||= doc.css("div.article-tips__item")[2].css("p.article-tips__content").text
46
+ end
47
+
48
+ def know_before_visiting
49
+ @know_before_visiting ||= doc.css("div.article-tips__item")[3].css("p.article-tips__content").text.strip
50
+ end
51
+
52
+ def language
53
+ @language ||= doc.css("div.article-tips__item")[4].css("p.article-tips__content").text.strip
54
+ end
55
+
56
+ def currency
57
+ @currency ||= doc.css("div.article-tips__item")[6].css("p.article-tips__content").text
58
+ end
59
+
60
+ def description
61
+ @description ||= doc.css("div.destination-page-header__copy--full p").text
62
+ end
63
+
64
+
65
+ end
@@ -0,0 +1,15 @@
1
+ class TravelLeisure::Scraper
2
+ def get_page
3
+ Nokogiri::HTML(open("https://www.travelandleisure.com/travel-guide"))
4
+ end
5
+
6
+ def scrape_destinations
7
+ self.get_page.css("ul.grid li")
8
+ end
9
+
10
+ def make_destinations
11
+ scrape_destinations.each do |r|
12
+ TravelLeisure::Destination.new_from_website(r)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module TravelLeisure
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,10 @@
1
+ #environment
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+ require 'pry'
5
+ require 'colorize'
6
+
7
+ require_relative "./travel_leisure/version"
8
+ require_relative "./travel_leisure/scraper"
9
+ require_relative "./travel_leisure/destination"
10
+ require_relative "./travel_leisure/cli"
data/notes.md ADDED
@@ -0,0 +1,12 @@
1
+ 1. flow
2
+ 2. classes
3
+ 2a. relationships
4
+
5
+ - user is welcomed to app with a list of travel destinations
6
+ - user is asked for the destination that they want more info on
7
+ - user selects destination
8
+ - user sees info of selected destination
9
+
10
+ Classes
11
+
12
+ - Destination
Binary file
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require_relative "./lib/travel_leisure/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "travel_leisure"
7
+ spec.version = TravelLeisure::VERSION
8
+ spec.authors = ["corbinarnett"]
9
+ spec.email = ["corbin.c.arnett@gmail.com"]
10
+
11
+ spec.summary = %q{"A ruby gem to display travel guides in your terminal!"}
12
+ spec.description = %q{"A ruby gem that accesses 'Travel & Leisure' magazine's travel guides"}
13
+ spec.homepage = "https://github.com/corbinarnett/travel-leisure-cli"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "bin"
22
+ spec.executables = ['travel_exec'] #spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 2.0"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "pry", "~> 0.10.4"
29
+ spec.add_dependency "nokogiri", "~> 1.8"
30
+ spec.add_dependency "colorize", "~> 0.8.1"
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travel_leisure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - corbinarnett
@@ -102,7 +102,26 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - CODE_OF_CONDUCT.md
109
+ - Gemfile
110
+ - Gemfile.lock
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/setup
105
116
  - bin/travel_exec
117
+ - lib/travel_leisure.rb
118
+ - lib/travel_leisure/cli.rb
119
+ - lib/travel_leisure/destination.rb
120
+ - lib/travel_leisure/scraper.rb
121
+ - lib/travel_leisure/version.rb
122
+ - notes.md
123
+ - travel_leisure-0.1.0.gem
124
+ - travel_leisure.gemspec
106
125
  homepage: https://github.com/corbinarnett/travel-leisure-cli
107
126
  licenses:
108
127
  - MIT