top_ten_islands_cli_gem 0.1.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: 715f554009aaaadf5ce81ec7ba63abf75c88f9c5
4
+ data.tar.gz: e27594f5aca2537d2d2e6fb82979081356f2ae99
5
+ SHA512:
6
+ metadata.gz: 2a8c9ee04c20e40810097942c94bce6fb926355d12567de3f83ee2c0c5f08120cf19dca9f4c6b895d20f1f19bdf9d4fad1c46f36451e11a0f5fbbd23c85f87a2
7
+ data.tar.gz: 843467016c492b877b64d947cc4d773269f360527a136b84e39ab75691a9dee03b3705ac682b1313c813259df770d74e7a2ecc53fb173357f0a93fd4407b2bdf
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'nokogiri'
4
+ gem 'pry'
5
+
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Baruch Steinmetz
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,41 @@
1
+ # TopTenIslandsCliGem
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/top_ten_islands_cli_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'top_ten_islands_cli_gem'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install top_ten_islands_cli_gem
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
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/[USERNAME]/top_ten_islands_cli_gem.
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).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #require "bundler/setup"
4
+ #require "top_ten_islands_cli_gem"
5
+ require_relative '../config/environment.rb'
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
+ TopTenIslandsCliGem::Cli.new.start
14
+
15
+ require "irb"
16
+ 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,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../config/environment.rb'
4
+
5
+ TopTenIslandsCliGem::Cli.new.start
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ require 'open-uri'
5
+
6
+
7
+ require_relative '../lib/top_ten_islands_cli_gem/island.rb'
8
+ require_relative '../lib/top_ten_islands_cli_gem/scraper.rb'
9
+ require_relative '../lib/top_ten_islands_cli_gem/cli.rb'
@@ -0,0 +1,4 @@
1
+ require "top_ten_islands_cli_gem/version"
2
+
3
+ module TopTenIslandsCliGem
4
+ end
@@ -0,0 +1,54 @@
1
+ class TopTenIslandsCliGem::Cli
2
+
3
+ def start
4
+ TopTenIslandsCliGem::Scraper.create_islands
5
+ puts " "
6
+ puts "Welcome to the Worlds Top Islands to visit!!"
7
+ puts " "
8
+ list
9
+ discription
10
+ end
11
+
12
+ def list
13
+ TopTenIslandsCliGem::Island.all.each.with_index(1) {|island, index| puts "#{index}. #{island.name}"}
14
+ end
15
+
16
+ def discription
17
+ input = 0
18
+ #binding.pry
19
+ until input.between?(1,10)
20
+ puts " "
21
+ puts "What number island would you like to read about?"
22
+ input = gets.chomp.to_i
23
+ end
24
+ #binding.pry
25
+ puts ""
26
+ puts "--------#{TopTenIslandsCliGem::Island.all[input-1].name}--------"
27
+ puts ""
28
+ puts TopTenIslandsCliGem::Island.all[input-1].get_discription
29
+ puts ""
30
+ ending
31
+ end
32
+
33
+ def ending
34
+ input = ""
35
+ until input == "y" || input == "n"
36
+ puts "Would you like to read about another island? Y or N"
37
+ input = gets.chomp.downcase
38
+ end
39
+ case input
40
+ when "y"
41
+ discription
42
+ when "n"
43
+ puts "Have an awesome day!!"
44
+ exit
45
+ end
46
+
47
+ end
48
+
49
+
50
+
51
+
52
+
53
+
54
+ end
@@ -0,0 +1,37 @@
1
+ class TopTenIslandsCliGem::Island
2
+
3
+ attr_accessor :name, :url, :discription
4
+
5
+ ALL = []
6
+
7
+ def initialize(name=nil, url=nil, discription=nil)
8
+ @name = name
9
+ @url = url
10
+ ALL.push(self)
11
+ end
12
+
13
+ def get_discription
14
+ @discription ||= Nokogiri::HTML(open(@url)).css(" .ermb_text").css(" .content").text.strip
15
+ end
16
+
17
+ def self.all
18
+ ALL
19
+ end
20
+
21
+ def discription
22
+ input = ""
23
+ until input > 0
24
+ puts "What island would you like more information about, by number?"
25
+ input = gets.chomp
26
+ end
27
+ TopTenIslandsCliGem::Island.all[input-1].get_discription
28
+ end
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+ end
@@ -0,0 +1,21 @@
1
+ class TopTenIslandsCliGem::Scraper
2
+
3
+ def self.get_page
4
+ Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Islands"))
5
+ #binding.pry
6
+ end
7
+
8
+ def self.create_islands
9
+ #binding.pry
10
+ island_array = get_page.css(" .mainName").map do |island|
11
+ i = TopTenIslandsCliGem::Island.new(island.text.strip,"https://www.tripadvisor.com#{island.css("a").attribute("href").text}")
12
+ end
13
+ end
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ end
@@ -0,0 +1,3 @@
1
+ module TopTenIslandsCliGem
2
+ VERSION = "0.1.0"
3
+ end
data/spec.md ADDED
@@ -0,0 +1,9 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ Users are greeted, shown a list of islands, input a island to get a discrption, and are asked if they want to select another island.
6
+ - [X] Pull data from an external source
7
+ Pulls data from travel adviser for list of top islands
8
+ - [X] Implement both list and detail views
9
+ shows a list of islands and details of a specific island.
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'top_ten_islands_cli_gem/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "top_ten_islands_cli_gem"
8
+ spec.version = TopTenIslandsCliGem::VERSION
9
+ spec.authors = ["Sholom Steinmetz"]
10
+ spec.email = ["sholomsteinmetz@gmail.com"]
11
+
12
+ spec.summary = "Provides a list of the best islands in the entire world"
13
+
14
+ spec.homepage = "https://github.com/peacestone/top-ten-islands-cli-gem"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "bin"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: top_ten_islands_cli_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sholom Steinmetz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-06 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
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
+ description:
42
+ email:
43
+ - sholomsteinmetz@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - bin/top_ten_islands_cli_gem
56
+ - config/environment.rb
57
+ - lib/top_ten_islands_cli_gem.rb
58
+ - lib/top_ten_islands_cli_gem/cli.rb
59
+ - lib/top_ten_islands_cli_gem/island.rb
60
+ - lib/top_ten_islands_cli_gem/scraper.rb
61
+ - lib/top_ten_islands_cli_gem/version.rb
62
+ - spec.md
63
+ - top_ten_islands_cli_gem.gemspec
64
+ homepage: https://github.com/peacestone/top-ten-islands-cli-gem
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.6.4
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Provides a list of the best islands in the entire world
88
+ test_files: []