tourist_guide 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbd229feb0748be82dfd2d50b6bbe45fab712db8
4
- data.tar.gz: 4838e5ad03164ccf131b98ce7ff87b8b6b6ee4e1
3
+ metadata.gz: a6e149a9fd7f97e24678c6a3c176d35e03b53969
4
+ data.tar.gz: 7e1dfd6e0d0264e0d003dd5b9fa6682f39212f9d
5
5
  SHA512:
6
- metadata.gz: fe4e08c802450c672faf7778c4b46c21d7628f120317ea0330d57b1918a3ae42ee416dd7b2f103b9ab0656bd8e26e9290eb16012a205a2c34058dde16ada5acf
7
- data.tar.gz: b0165aa55955bb018bf3cce7011480c8ec61f269847515ff78b22acb5ae2e6c7878418bfe1e57dd8df9209eac861f551a240825c61f17196afc6d241e315577c
6
+ metadata.gz: 5bb7514303993b15101423bd6c60bf809352f1c9bdbc81006e9fb62042f6eadc9030baa976ca304d0ea53f9346c76f558e7de822fa27abdee6e90b6a3c649895
7
+ data.tar.gz: 939675cc9eca775d8b29f5db442f6b80b9337ba4ceb240a592237786785a1f979fed111856ccabcff5abc8d6ce12831bfdae0c8492a0835963c559324031d201
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -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 muataz.aziz91@yahoo.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 tourist_guide.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Muataz Aziz
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,41 @@
1
+ # TouristGuide
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/tourist_guide`. 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 'tourist_guide'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tourist_guide
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/Muataz Aziz/tourist_guide. 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.
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
+
@@ -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 "tourist_guide"
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__)
@@ -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,3 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/tourist_guide'
3
+ TouristGuide::Cli.new.call
@@ -0,0 +1,14 @@
1
+ # require "tourist_guide/version"
2
+ require 'colorize'
3
+ require 'open-uri'
4
+ require 'pry'
5
+ require 'nokogiri'
6
+
7
+ require_relative "./tourist_guide/version"
8
+ require_relative "./tourist_guide/cli"
9
+ require_relative "./tourist_guide/tour"
10
+ require_relative "./tourist_guide/scraping"
11
+
12
+ module TouristGuide
13
+ # Your code goes here...
14
+ end
@@ -0,0 +1,153 @@
1
+ class TouristGuide::Cli
2
+
3
+ def call
4
+ puts " ✰✰✰✰✰".light_red
5
+ puts " ✰✰✰✰✰ ✰✰✰✰✰ ✰✰✰✰✰ ✰✰✰✰✰".light_red
6
+ puts " ✰✰✰✰✰ WELCOME TO THE TOURIST'S ERBIL GUIDE ✰✰✰✰✰".colorize(:color => :light_yellow).bold
7
+ puts " version#{TouristGuide::VERSION}".colorize(:color => :yellow)
8
+ puts " ✰✰✰✰✰ ✰✰✰✰✰ ✰✰✰✰✰".light_yellow
9
+ puts " ✰✰✰✰✰ ✰✰✰✰✰".green
10
+ puts " ✰✰✰✰✰".green
11
+ list
12
+ user_insert
13
+ end
14
+
15
+ def list
16
+ puts ""
17
+ puts "CHOOSE YOUR CATEGORY:".colorize(:color => :blue).bold
18
+ # puts "----------------------------------------------------------------------------------------------------------------------------------------------------".colorize(:background => :light_blue)
19
+ puts " ".colorize(:background => :blue)
20
+ puts ""
21
+ puts " 1. Hotels ♡ ♡ ♡ ♡ ♡ 2. Restaurants ♡ ♡ ♡ ♡ ♡ 3. Cafeterias ♡ ♡ ♡ ♡ ♡ 4. Parks ♡ ♡ ♡ ♡ ♡ 5. Malls".light_green
22
+ puts ""
23
+ puts " ♡ ♡ ♡ ♡ ♡ 6. Back to the main menu ♡ ♡ ♡ ♡ ♡ 7. Exit ♡ ♡ ♡ ♡ ♡ ".green
24
+ end
25
+
26
+ def user_insert
27
+ input = nil
28
+ input = gets.strip
29
+ directions(input)
30
+ end
31
+
32
+ #first_way
33
+ def directions(num)
34
+ if num == "1"
35
+ puts "ERBIL'S HOTELS LIST:"
36
+ puts ""
37
+ run("Hotels")
38
+ list
39
+ user_insert
40
+ elsif num == "2"
41
+ puts "ERBIL'S RESTAURANTS LIST:"
42
+ puts ""
43
+ run("Restaurants")
44
+ list
45
+ user_insert
46
+ elsif num == "3"
47
+ puts "ERBIL'S CAFETERIES LIST:"
48
+ puts ""
49
+ run("coffee%20shops")
50
+ list
51
+ user_insert
52
+ elsif num == "4"
53
+ puts "ERBIL'S PARKS LIST:"
54
+ puts ""
55
+ run("Parks")
56
+ list
57
+ user_insert
58
+ elsif num == "5"
59
+ puts "ERBIL'S MALLS LIST:"
60
+ puts ""
61
+ run("Malls")
62
+ list
63
+ user_insert
64
+ elsif num == "6"
65
+ call
66
+ elsif num == "7"
67
+ puts " THANK YOU! HAVE A NICE TIME!".magenta.bold
68
+ else
69
+ puts ""
70
+ puts ""
71
+ puts " NOT valid, please insert valid input ".colorize(:color => :white, :background => :red).bold
72
+ puts ""
73
+
74
+ list
75
+ user_insert
76
+ end
77
+ end
78
+
79
+ #second_way
80
+ # def directions(num)
81
+ # case num
82
+ # when "1"
83
+ # puts "ERBIL'S HOTELS LIST:"
84
+ # puts ""
85
+ # run("Hotels")
86
+ # list
87
+ # user_insert
88
+ # when "2"
89
+ # puts "ERBIL'S RESTAURANTS LIST:"
90
+ # puts ""
91
+ # run("Restaurants")
92
+ # list
93
+ # user_insert
94
+ # when "3"
95
+ # puts "ERBIL'S CAFETERIES LIST:"
96
+ # puts ""
97
+ # run("coffee%20shops")
98
+ # list
99
+ # user_insert
100
+ # when "4"
101
+ # puts "ERBIL'S PARKS LIST:"
102
+ # puts ""
103
+ # run("Parks")
104
+ # list
105
+ # user_insert
106
+ # when "5"
107
+ # puts "ERBIL'S MALLS LIST:"
108
+ # puts ""
109
+ # run("Malls")
110
+ # list
111
+ # user_insert
112
+ # when "6"
113
+ # call
114
+ # when "7"
115
+ # puts "THANK YOU! HAVE A NICE TIME!"
116
+ # else
117
+ # puts ""
118
+ # puts ""
119
+ # puts "NOT valid, please insert valid input"
120
+ # puts ""
121
+ # list
122
+ # user_insert
123
+ # end
124
+ # end
125
+
126
+
127
+
128
+ def run(direction)
129
+ create_directions(direction)
130
+ display_directions
131
+ TouristGuide::Tour.clear
132
+ end
133
+
134
+ def create_directions(name)
135
+ scraping = TouristGuide::Scraping.new
136
+ dir_attr = scraping.page_scraping(name)
137
+ TouristGuide::Tour.create_from_collection(dir_attr)
138
+ end
139
+
140
+ def display_directions
141
+ TouristGuide::Tour.all.each do |direction|
142
+ #first_way
143
+ # name= direction.name.ljust(38, ' ')
144
+ # address= direction.address.ljust(21, ' ')
145
+ # description= direction.description.ljust(0, ' ')
146
+ # puts "Name: #{name} Address: #{address} Description: #{description}"
147
+ #second_way
148
+ puts "Name: #{direction.name.ljust(38, ' ').blue} Address: #{direction.address.ljust(21, ' ').blue} Description: #{direction.description.ljust(0, ' ').blue}"
149
+ puts "_________________________________________________________________________________________________________________________".magenta
150
+ end
151
+ end
152
+
153
+ end
@@ -0,0 +1,34 @@
1
+ class TouristGuide::Scraping
2
+
3
+ def page_scraping(direction_name)
4
+ scraped_directions =[]
5
+ direction_name = direction_name.downcase
6
+ # direction_name= ["malls", "park", "restaurants", "hotels", "coffee%20shops"]
7
+ html = open("https://iq.brate.com/en/search?q=#{direction_name}&region=8&sort=2&page=1")
8
+
9
+ scraped_page = Nokogiri::HTML(html)
10
+
11
+ array = scraped_page.css("div.single-search-result")
12
+ array.each do |category|
13
+ place = {}
14
+ name = category.css(".search-result-title h3").text.strip
15
+ address = category.css(".source a.b-link").text.strip
16
+ description = category.css(".search-result-title div.search-result-business-category").text.strip
17
+
18
+ place[:name] = name
19
+ place[:address] = address
20
+ place[:description] = description
21
+
22
+ scraped_directions << place
23
+ end
24
+ return scraped_directions
25
+ end
26
+
27
+ end
28
+
29
+
30
+ # https://iq.brate.com/en/search?q=malls&region=8&sort=2&page=1 #malls
31
+ # https://iq.brate.com/en/search?q=park&region=8&sort=2&page=1 #parks
32
+ # https://iq.brate.com/en/search?q=restaurants&region=8&sort=2&page=1 #restaurants
33
+ # https://iq.brate.com/en/search?q=hotels&region=8&sort=2&page=1 #hotels
34
+ # https://iq.brate.com/en/search?q=coffee%20shops&region=8&sort=2&page=1 #coffee shops
@@ -0,0 +1,37 @@
1
+ class TouristGuide::Tour
2
+ attr_accessor :name, :address, :description
3
+ @@all =[]
4
+
5
+ def initialize(attr_hash)
6
+ # attr_hash.each do |attribute, v|
7
+ # self.name= attribute(:name)
8
+ # self.address= attribute(:address)
9
+ # self.description= attribute(:description)
10
+
11
+ # self.send "name=", "John Smith"
12
+ # equivalent to
13
+ # self.name = "John Smith"
14
+
15
+ attr_hash.each do |attribute, v|
16
+ self.send("#{attribute}=",v)
17
+
18
+ end
19
+ @@all << self
20
+ end
21
+
22
+ def self.all
23
+ @@all
24
+ end
25
+
26
+ def self.create_from_collection(array)
27
+ array.each do |hash|
28
+ self.new(hash)
29
+ end
30
+ end
31
+
32
+ #to delete duplicated & previous lists
33
+ def self.clear
34
+ @@all =[]
35
+ end
36
+
37
+ end
@@ -0,0 +1,3 @@
1
+ module TouristGuide
2
+ VERSION = "0.1.5"
3
+ end
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'tourist_guide/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "tourist_guide"
7
+ spec.version = TouristGuide::VERSION
8
+ spec.authors = ["Muataz Aziz"]
9
+ spec.email = ["muataz.aziz91@yahoo.com"]
10
+
11
+ spec.summary = 'gem for helping tourists find places'
12
+ spec.description = 'gem for tourists'
13
+ spec.homepage = 'https://github.com/MuatazAziz/TouristGuide'
14
+ spec.license = "MIT"
15
+ if spec.respond_to?(:metadata)
16
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
17
+ else
18
+ raise "RubyGems 2.0 or newer is required to protect against " \
19
+ "public gem pushes."
20
+ end
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{^(test|spec|features)/})
24
+ end
25
+ spec.bindir = "bin"
26
+ spec.executables = "tourist_guide"
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.14"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tourist_guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muataz Aziz
@@ -41,10 +41,26 @@ dependencies:
41
41
  description: gem for tourists
42
42
  email:
43
43
  - muataz.aziz91@yahoo.com
44
- executables: []
44
+ executables:
45
+ - tourist_guide
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
- files: []
48
+ files:
49
+ - ".gitignore"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - bin/tourist_guide
58
+ - lib/tourist_guide.rb
59
+ - lib/tourist_guide/cli.rb
60
+ - lib/tourist_guide/scraping.rb
61
+ - lib/tourist_guide/tour.rb
62
+ - lib/tourist_guide/version.rb
63
+ - tourist_guide.gemspec
48
64
  homepage: https://github.com/MuatazAziz/TouristGuide
49
65
  licenses:
50
66
  - MIT