top_ten_islands_cli_gem 0.1.2 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aee43619489c51bc309f4ce511832eefa5bcba5c
4
- data.tar.gz: 50ed887df39698f5715a3b69b7bd41bae339cc67
2
+ SHA256:
3
+ metadata.gz: 425ddae9c75edfff886fdc33eb10f35a8e656fb574335b96a44a11847401d69e
4
+ data.tar.gz: ab43c5fa409455230e71bf59c057a168d57c52fa712ed021e40919834a5c4393
5
5
  SHA512:
6
- metadata.gz: c2006a544c9d992faee57f848d98ded0aa1b1919e5afa56626b6282247896baceca0f63750ec08aee4b33f160c0375138afed480cda8fe933190bb666b4caa9a
7
- data.tar.gz: c64543958b550d47270f3d1e033fd48dbfeb7aa76caf293a71dd52f33751bae42fb4ee63154c0097f0e1b7f4074cf04798b45d7a9a468e68e09b818a859e2d5b
6
+ metadata.gz: df52d9df7aaff3fa1dd64d546f6c3a7e5d35e9e192bc29071ff2e0b85455ba9a6452e06b9458350bc89c1d67fb87ae9e73ea42b0fc4c46a4e5aeb038b6b667eb
7
+ data.tar.gz: 6666f4bb9e96c5716b21067d7ab64f96e852056b649abec7fde7fc085c7e7e0875753b53053eabf74a3f68efcae66f64bee1d244eda8d53a8ac69d61042915f5
data/README.md CHANGED
@@ -1,9 +1,3 @@
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
1
  ## Installation
8
2
 
9
3
  You can install this gem via `gem install top_ten_islands_cli_gem`. The `top_ten_islands_cli_gem` CLI will be installed and you can run `top_ten_islands_cli_gem` to get a list of islands to travel to in your command line.
data/bin/console CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
3
+ #require "bundler/setup"
4
4
  require "top_ten_islands_cli_gem"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
@@ -7,5 +7,9 @@ require_relative "top_ten_islands_cli_gem/scraper.rb"
7
7
  require_relative "top_ten_islands_cli_gem/island.rb"
8
8
  require_relative "top_ten_islands_cli_gem/cli.rb"
9
9
 
10
- module TopTenIslandsCliGem
11
- end
10
+ # module TopTenIslandsCliGem
11
+ # end
12
+
13
+
14
+ #x = TopTenIslandsCliGem::Island
15
+ #x.create_islands
@@ -1,7 +1,7 @@
1
1
  class TopTenIslandsCliGem::Cli
2
2
 
3
3
  def start
4
- TopTenIslandsCliGem::Scraper.create_islands
4
+ TopTenIslandsCliGem::Island.create_islands_from_hash
5
5
  puts " "
6
6
  puts "Welcome to the Worlds Top Islands to visit!!"
7
7
  puts " "
@@ -14,26 +14,34 @@ class TopTenIslandsCliGem::Cli
14
14
  end
15
15
 
16
16
  def discription
17
+
17
18
  @input = 0
18
19
  #binding.pry
19
- until @input.between?(1,10)
20
+ until @input.to_i.between?(1,10) || @input == "list"
20
21
  puts " "
21
- puts "What number island would you like to read about?"
22
- @input = gets.chomp.to_i
22
+ puts "What number island would you like to read about? Or type list"
23
+ @input = gets.chomp.downcase
24
+ end
25
+
26
+ if @input.to_i.between?(1,10)
27
+ #binding.pry
28
+ @input = @input.to_i
29
+ puts ""
30
+ puts "--------#{TopTenIslandsCliGem::Island.all[@input-1].name}--------"
31
+ puts ""
32
+ puts TopTenIslandsCliGem::Island.all[@input-1].get_discription
33
+ puts ""
34
+ ending
35
+ elsif @input.downcase == "list"
36
+ list
37
+ discription
23
38
  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
39
  end
32
40
 
33
41
  def ending
34
42
  input = ""
35
- until input == "y" || input == "n"
36
- puts "Would you like to read about another island? Y or N"
43
+ until input == "y" || input == "n" || input == "list"
44
+ puts "Would you like to read about another island? Y,N or list"
37
45
  input = gets.chomp.downcase
38
46
  end
39
47
  case input
@@ -41,6 +49,9 @@ class TopTenIslandsCliGem::Cli
41
49
  discription
42
50
  when "n"
43
51
  puts "Hope to see you at #{TopTenIslandsCliGem::Island.all[@input-1].name} soon!!"
52
+ when "list"
53
+ list
54
+ discription
44
55
  end
45
56
 
46
57
  end
@@ -1,22 +1,32 @@
1
1
  class TopTenIslandsCliGem::Island
2
2
 
3
- attr_accessor :name, :url, :discription
3
+ attr_accessor :name, :index, :discription
4
4
 
5
5
  ALL = []
6
6
 
7
- def initialize(name=nil, url=nil, discription=nil)
7
+ def initialize(name=nil, index=nil, discription=nil)
8
8
  @name = name
9
- @url = url
9
+ @index = index
10
10
  ALL.push(self)
11
11
  end
12
12
 
13
13
  def get_discription
14
- @discription ||= TopTenIslandsCliGem::Scraper.get_island_discription(@url)
14
+ @discription ||= TopTenIslandsCliGem::Scraper.get_island_discription(@index)
15
15
  end
16
16
 
17
17
  def self.all
18
18
  ALL
19
19
  end
20
20
 
21
+ def self.create_islands_from_hash
22
+ islands_array = TopTenIslandsCliGem::Scraper.get_islands_array
23
+
24
+ islands_array.each do |island_hash|
25
+ islands = self.new(island_hash[:name], island_hash[:index])
26
+ end
27
+
28
+ end
29
+
30
+
21
31
 
22
32
  end
@@ -1,17 +1,30 @@
1
1
  class TopTenIslandsCliGem::Scraper
2
2
 
3
3
  def self.get_page
4
- Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Islands"))
4
+ # Nokogiri::HTML(open("https://www.tripadvisor.com/TravelersChoice-Islands"))
5
+ Nokogiri::HTML(open("https://www.lonelyplanet.com/campaign/island-guide-2018/top-10-islands-for-2018/"))
6
+
5
7
  end
6
8
 
7
- def self.create_islands
8
- island_array = get_page.css(" .mainName").map do |island|
9
- i = TopTenIslandsCliGem::Island.new(island.text.strip,"https://www.tripadvisor.com#{island.css("a").attribute("href").text}")
9
+ def self.get_islands_array
10
+ islands_array = []
11
+
12
+ @@top_islands_page = self.get_page.css('.article__content')
13
+
14
+ @@top_islands_page.css(' h3 > strong')
15
+ .each_with_index do |island, index|
16
+ island_hash = {}
17
+ island_hash[:name] = island.text
18
+ island_hash[:index] = index
19
+ islands_array.push(island_hash)
10
20
  end
21
+ islands_array
11
22
  end
12
23
 
13
- def self.get_island_discription(url=nil)
14
- Nokogiri::HTML(open(url)).css(" .ermb_text").css(" .content").text.strip
24
+ def self.get_island_discription(index)
25
+ # Nokogiri::HTML(open(url)).css(" .ermb_text").css(" .content").text.strip
26
+
27
+ @@top_islands_page.css('p')[index].text.strip
15
28
  end
16
29
 
17
30
  end
@@ -1,3 +1,3 @@
1
1
  module TopTenIslandsCliGem
2
- VERSION = "0.1.1"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'top_ten_islands/version'
4
+ require 'top_ten_islands_cli_gem/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "top_ten_islands_cli_gem"
8
- spec.version = TopTenIslands::VERSION
8
+ spec.version = TopTenIslandsCliGem::VERSION
9
9
  spec.authors = ["Sholom Steinmetz"]
10
10
  spec.email = ["sholomsteinmetz@gmail.com"]
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: top_ten_islands_cli_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sholom Steinmetz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-11 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.6.4
139
+ rubygems_version: 2.7.6
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Shows a list of the worlds top ten islands to visit