best_cities 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: adc756a795c1be20b2a9ca13e2667e65251f872b
4
+ data.tar.gz: 0d4ba22c037fa3819fb4ae7e61827f89c621f866
5
+ SHA512:
6
+ metadata.gz: 5c0010425553a65be3f2511e23ee844725da69f33ef13cd829cd067f7ddf89087044e51540054b1cdd93ec45cece248f834edc16558557bf7918dc200a255202
7
+ data.tar.gz: 4a9f31f0d095ff93b488aed0f5ef79bea71b51e724c8349ce4b3ab77ef39d558e8e6f354d403cd7704bcc84640ebaf03fbd001409e6f56901866bf3f49faf537
data/bin/best_cities ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/best_cities.rb'
3
+ BestCity::CLI.new.call
@@ -0,0 +1,7 @@
1
+ require 'pry'
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+
5
+ require_relative '../lib/best_cities/scraper'
6
+ require_relative '../lib/best_cities/city'
7
+ require_relative '../lib/best_cities/cli'
@@ -0,0 +1,4 @@
1
+ module BestCity
2
+ # Your code goes here...
3
+ end
4
+ require_relative '../config/environment.rb'
@@ -0,0 +1,26 @@
1
+ class BestCity::City
2
+
3
+ attr_accessor :population, :median_annual_salary,:quality_of_life ,:overall_value,:rank_city, :description
4
+
5
+ @@all = []
6
+
7
+ def initialize(rank_city=nil, population=nil, median_annual_salary=nil, quality_of_life=nil, overall_value=nil,description=nil)
8
+ @description = description
9
+ @rank_city = rank_city
10
+ @population=population
11
+ @median_annual_salary=median_annual_salary
12
+ @quality_of_life=quality_of_life
13
+ @overall_value=overall_value
14
+ @@all.unshift(self)
15
+
16
+ end
17
+
18
+ def self.all
19
+ @@all
20
+ end
21
+
22
+ def self.find(id)
23
+ self.all[id-1]
24
+ end
25
+
26
+ end
@@ -0,0 +1,95 @@
1
+ class BestCity::CLI
2
+
3
+ def call
4
+ BestCity::Scraper.new.make_games
5
+ start
6
+ end
7
+
8
+ def start
9
+ print %x{clear}
10
+ puts "Welcome to the 50 Best cities to live in America 2016"
11
+ puts ""
12
+ puts "What number city would you like to see?"
13
+ puts "a) 1-10"
14
+ puts "b) 11-20 "
15
+ puts "c) 21-30"
16
+ puts "d) 31-40 "
17
+ puts "e) 41-50"
18
+ puts "Enter the alphabet"
19
+ input= ' '
20
+ while !['a','b','c','d','e'].include?(input) do
21
+ input = gets.strip
22
+ end
23
+ i=1
24
+ case input
25
+ when 'a'
26
+ i=1
27
+ when 'b'
28
+ i=11
29
+ when 'c'
30
+ i=21
31
+ when 'd'
32
+ i=31
33
+ when 'e'
34
+ i=41
35
+ end
36
+ print %x{clear}
37
+ show_cities(i)
38
+
39
+ puts ""
40
+ puts "Which city would you like more information about? Enter the number"
41
+
42
+ input1 = -1
43
+ while !(input1 >= i && input1 <= (i + 10)) do
44
+ input1 = gets.strip.to_i
45
+ end
46
+
47
+ city = BestCity::City.find(input1.to_i)
48
+
49
+ show_city(city)
50
+
51
+ puts ""
52
+ puts "Would you like to continue? Enter Y or N"
53
+
54
+ input = gets.strip.downcase
55
+ if input == "y"
56
+ start
57
+ else
58
+ puts ""
59
+ puts "Thank you! Have a great day! Bye !"
60
+ exit
61
+ end
62
+ end
63
+
64
+ def show_city(city)
65
+ print %x{clear}
66
+ 120.times do print "*" end
67
+ puts " #{city.rank_city.upcase} "
68
+ 120.times do print "*" end
69
+ puts ""
70
+ puts "Population #{city.population}"
71
+ puts "Median Annual Salary #{city.median_annual_salary}"
72
+ puts "Quality of life #{city.quality_of_life}"
73
+ puts "Overall value #{city.overall_value}"
74
+ puts ""
75
+ puts "#{city.description}"
76
+ 120.times do print "*" end
77
+ ##puts "Description: #{game.description}"
78
+ end
79
+
80
+ def show_cities(from_number)
81
+ 120.times do print "*" end
82
+ puts ""
83
+ puts " Cities #{from_number} - #{from_number+9} "
84
+ 120.times do print "*" end
85
+ puts ""
86
+ puts "No. city"
87
+ BestCity::City.all[from_number-1, 10].each.with_index(from_number) do |city, index|
88
+ str = format('%2d', index)
89
+ puts "#{str}. #{city.rank_city.split(".")[1]}"
90
+ end
91
+ 120.times do print "*" end
92
+ end
93
+
94
+
95
+ end
@@ -0,0 +1,26 @@
1
+ class BestCity::Scraper
2
+
3
+ def get_page
4
+ Nokogiri::HTML(open("http://www.businessinsider.com/us-news-best-places-to-live-in-america-2016-3"))
5
+ ##Nokogiri::HTML(open("http://www.metacritic.com/browse/games/score/metascore/year/xboxone/filtered"))
6
+ end
7
+
8
+ def scrape_game_index
9
+ self.get_page.css("div.slide-module")
10
+ end
11
+
12
+ def make_games
13
+ scrape_game_index.each do |c|
14
+ city= c.css("h3.slide-title").text
15
+ pop= c.css("p:first").text.split(":")[1]
16
+ sal= c.css("p:nth-of-type(2)").text.split("$")[1]
17
+ qual= c.css("p:nth-of-type(3)").text.split(":")[1]
18
+ value= c.css("p:nth-of-type(4)").text.split(":")[1]
19
+ desc= c.css("p:nth-of-type(5)").text
20
+ BestCity::City.new(
21
+ city,pop,sal,qual,value,desc
22
+ )
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module BestCity
2
+ VERSION = "0.1.2"
3
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: best_cities
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - bharti gurnaney
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: With this gem you can see 50 Best places to live in america 2016 and
84
+ see the detail of any city
85
+ email:
86
+ - bharti0717@yahoo.com
87
+ executables:
88
+ - best_cities
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - bin/best_cities
93
+ - config/environment.rb
94
+ - lib/best_cities.rb
95
+ - lib/best_cities/city.rb
96
+ - lib/best_cities/cli.rb
97
+ - lib/best_cities/scraper.rb
98
+ - lib/best_cities/version.rb
99
+ homepage: https://github.com/bhartiRA/best_cities_CLI_app
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.6.8
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Best places to live in America 2016
123
+ test_files: []