top_ten_islands 0.1.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bc23cd223df8554d2240fb5ee0b3da58a4971021
4
+ data.tar.gz: 1dcf00a06e1de83823f8f94197a35d01ffc566bb
5
+ SHA512:
6
+ metadata.gz: 9ba58976147ef8d7f78c2fc1db1ea919adc5e001ad4dca5dccccd62097e3e56c415a230877ad05f80b36c4e17343bba195bad698d380e802b539be9cfbfd64ba
7
+ data.tar.gz: 91f63848722221505c51d215353d678325cc0645f53ff7c847c36ee2147c276a242ee80372b0c053fbf64589b7a12ba833036a1f075a3eb7c71a14260ee5cac6
@@ -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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in top_ten_islands.gemspec
4
+ gemspec
@@ -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.
@@ -0,0 +1,42 @@
1
+ # TopTenIslands
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`. 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'
13
+
14
+ #deleete
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install top_ten_islands
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Development
30
+
31
+ 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.
32
+
33
+ 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).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/top_ten_islands.
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "top_ten_islands"
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,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,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/top_ten_islands.rb"
4
+
5
+
6
+ islands = TopTenIslands::Cli.new.start
@@ -0,0 +1,11 @@
1
+ require "open-uri"
2
+ require "pry"
3
+ require "nokogiri"
4
+
5
+ require_relative "top_ten_islands/version"
6
+ require_relative "top_ten_islands/scraper.rb"
7
+ require_relative "top_ten_islands/island.rb"
8
+ require_relative "top_ten_islands/cli.rb"
9
+
10
+ module TopTenIslands
11
+ end
@@ -0,0 +1,48 @@
1
+ class TopTenIslands::Cli
2
+
3
+ def start
4
+ TopTenIslands::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
+ TopTenIslands::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 "--------#{TopTenIslands::Island.all[@input-1].name}--------"
27
+ puts ""
28
+ puts TopTenIslands::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 "Hope to see you come visit #{TopTenIslands::Island.all[@input-1].name} real soon!!"
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,22 @@
1
+ class TopTenIslands::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 ||= TopTenIslands::Scraper.get_island_discription(@url)
15
+ end
16
+
17
+ def self.all
18
+ ALL
19
+ end
20
+
21
+
22
+ end
@@ -0,0 +1,19 @@
1
+ class TopTenIslands::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 = TopTenIslands::Island.new(island.text.strip,"https://www.tripadvisor.com#{island.css("a").attribute("href").text}")
12
+ end
13
+ end
14
+
15
+ def self.get_island_discription(url=nil)
16
+ Nokogiri::HTML(open(url)).css(" .ermb_text").css(" .content").text.strip
17
+ end
18
+
19
+ end
@@ -0,0 +1,3 @@
1
+ module TopTenIslands
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,29 @@
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/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "top_ten_islands"
8
+ spec.version = TopTenIslands::VERSION
9
+ spec.authors = ["Sholom Steinmetz"]
10
+ spec.email = ["sholomsteinmetz@gmail.com"]
11
+
12
+ spec.summary = "Shows a list of the worlds top ten islands to visit"
13
+ spec.description = "Shows a list of the worlds top ten islands to go to for a vacation after a day of coding"
14
+ spec.homepage = "https://github.com/peacestone/top_ten_islands"
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 = ["top_ten_islands"]
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "nokogiri", "~> 1.6", ">= 0"
26
+ spec.add_development_dependency "pry", "~> 0.10.3"
27
+ spec.add_development_dependency "rubysl-open-uri", "~> 2.0", ">= 2.0"
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: top_ten_islands
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Sholom Steinmetz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-11 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
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.6'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: pry
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.10.3
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.10.3
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubysl-open-uri
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.0'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '2.0'
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '2.0'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '2.0'
95
+ description: Shows a list of the worlds top ten islands to go to for a vacation after
96
+ a day of coding
97
+ email:
98
+ - sholomsteinmetz@gmail.com
99
+ executables:
100
+ - top_ten_islands
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - bin/console
110
+ - bin/setup
111
+ - bin/top_ten_islands
112
+ - lib/top_ten_islands.rb
113
+ - lib/top_ten_islands/cli.rb
114
+ - lib/top_ten_islands/island.rb
115
+ - lib/top_ten_islands/scraper.rb
116
+ - lib/top_ten_islands/version.rb
117
+ - top_ten_islands.gemspec
118
+ homepage: https://github.com/peacestone/top_ten_islands
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.6.4
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Shows a list of the worlds top ten islands to visit
142
+ test_files: []