horoscopes 0.1.1

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.
data/igns ADDED
@@ -0,0 +1,17 @@
1
+ => [#<Horoscopes::Zodiacs:0x00000002db90c8
2
+ @name="Aries",
3
+ @number=1,
4
+ @reading=
5
+ "Jul 18, 2017 - Today is a great day to move forward, Aries. Your emotions are stable, leaving your heart free to take off to the clouds. Daydream. Now might be a good time to make plans with a romantic partner. Solidify your relationship and confirm your commitment to one another. If you're single, this is a good time to set a plan in motion that will put you one step closer to your greatest fantasy.\nWhat's in your future? Ask a psychic nowWhat's in your future? Ask a psychic nowGet your daily horoscopes straight to your inbox!The Wheel of Fortune symbolizes the ever-changing cycle of life, wins and losses, ups and downs, unexpected luck, advancements and setbacks, success and failure \u2013 the duality of things. Representing...What specific type of Aquarius are you?How to clear through the clutter of your cosmetics...Cancers should invest in this for biggest payoffs...To manage your subscriptions, please type in your email below.">,
6
+ #<Horoscopes::Zodiacs:0x00000002db90a0 @name="Taurus", @number=2>,
7
+ #<Horoscopes::Zodiacs:0x00000002db9078 @name="Gemini", @number=3>,
8
+ #<Horoscopes::Zodiacs:0x00000002db9028 @name="Cancer", @number=4>,
9
+ #<Horoscopes::Zodiacs:0x00000002db9000 @name="Leo", @number=5>,
10
+ #<Horoscopes::Zodiacs:0x00000002db8fb0 @name="Virgo", @number=6>,
11
+ #<Horoscopes::Zodiacs:0x00000002db8f88 @name="Libra", @number=7>,
12
+ #<Horoscopes::Zodiacs:0x00000002db8f38 @name="Scorpio", @number=8>,
13
+ #<Horoscopes::Zodiacs:0x00000002db8f10 @name="Sagittarius", @number=9>,
14
+ #<Horoscopes::Zodiacs:0x00000002db8ee8 @name="Capricorn", @number=10>,
15
+ #<Horoscopes::Zodiacs:0x00000002db8ec0 @name="Aquarius", @number=11>,
16
+ #<Horoscopes::Zodiacs:0x00000002db8e98 @name="Pisces", @number=12>,
17
+ "Jul 18, 2017 - Today is a great day to move forward, Aries. Your emotions are stable, leaving your heart free to take off to the clouds. Daydream. Now might be a good time to make plans with a romantic partner. Solidify your relationship and confirm your commitment to one another. If you're single, this is a good time to set a plan in motion that will put you one step closer to your greatest fantasy.\nWhat's in your future? Ask a psychic nowWhat's in your future? Ask a psychic nowGet your daily horoscopes straight to your inbox!The Wheel of Fortune symbolizes the ever-changing cycle of life, wins and losses, ups and downs, unexpected luck, advancements and setbacks, success and failure \u2013 the duality of things. Representing...What specific type of Aquarius are you?How to clear through the clutter of your cosmetics...Cancers should invest in this for biggest payoffs...To manage your subscriptions, please type in your email below."]
@@ -0,0 +1,48 @@
1
+ #CLI Controller
2
+ class Horoscopes::CLI
3
+
4
+ def call
5
+ puts "Welcome to daily horoscopes!"
6
+ Horoscopes::Scraper.new.signs
7
+ list_zodiac
8
+ main_menu
9
+ end
10
+
11
+ def list_zodiac
12
+ Horoscopes::Zodiacs.all.each.with_index(1) do |sign, index|
13
+ puts "#{index}. #{sign.name}: #{sign.birthday}"
14
+ end
15
+ end
16
+
17
+ def main_menu
18
+ puts "Please enter the number of your zodiac sign from the list above:"
19
+ input = gets.strip.to_i
20
+ if input.between?(1, Horoscopes::Zodiacs.all.size)
21
+ puts "Today's Reading:"
22
+ puts Horoscopes::Scraper.new.reading[input - 1].reading
23
+ horoscope_reading
24
+ else
25
+ puts "Looks like that doesn't exist in the stars..."
26
+ main_menu
27
+ end
28
+ end
29
+
30
+ def horoscope_reading
31
+ puts "Please type menu for list of zodiac signs or exit to leave:"
32
+ answer = gets.strip.downcase
33
+ case answer
34
+ when "exit"
35
+ goodbye
36
+ when "menu"
37
+ list_zodiac
38
+ main_menu
39
+ else
40
+ horoscope_reading
41
+ end
42
+ end
43
+
44
+ def goodbye
45
+ puts "Come back later for tomorrow's horoscopes! <3"
46
+ end
47
+
48
+ end
@@ -0,0 +1,28 @@
1
+ class Horoscopes::Scraper
2
+
3
+ def signs
4
+ @doc = Nokogiri::HTML(open("https://www.horoscope.com/us/index.aspx"))
5
+ @doc.css("div.span-2.span-sm-3.span-xs-4.col").each do |signs|
6
+ sign = Horoscopes::Zodiacs.new
7
+
8
+ sign.name = signs.css("h3").text
9
+ sign.number = signs.css("a").attribute('href').value.split("=")[1]
10
+ sign.birthday = signs.css("p").text
11
+
12
+ sign.save
13
+ end
14
+ end
15
+
16
+ def reading
17
+ @list = []
18
+ Horoscopes::Zodiacs.all.each do |sign|
19
+ number = sign.number
20
+ doc = Nokogiri::HTML(open("https://www.horoscope.com/us/horoscopes/general/horoscope-general-daily-today.aspx?sign=#{number}"))
21
+ sign_reading = doc.css("div.horoscope-content p:first-child").text.strip
22
+ sign.reading = sign_reading
23
+ @list << sign
24
+ end
25
+ @list
26
+ end
27
+
28
+ end
@@ -0,0 +1,3 @@
1
+ module Horoscopes
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,16 @@
1
+ class Horoscopes::Zodiacs
2
+ attr_accessor :name, :number, :reading, :birthday
3
+ @@list = []
4
+
5
+ def self.all
6
+ @@list
7
+ end
8
+
9
+ def save
10
+ @@list << self
11
+ end
12
+
13
+ def self.sort_by_name
14
+ @@list.sort_by {|sign| sign.name}
15
+ end
16
+ end
data/lib/horoscopes.rb ADDED
@@ -0,0 +1,9 @@
1
+ #Acts as environment
2
+ require "open-uri"
3
+ require "nokogiri"
4
+ require "pry"
5
+
6
+ require_relative "./horoscopes/version"
7
+ require_relative "./horoscopes/scraper"
8
+ require_relative "./horoscopes/zodiacs"
9
+ require_relative "./horoscopes/cli"
data/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ - [X] Pull data from an external source
6
+ - [X] Implement both list and detail views
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: horoscopes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Sohee Cho
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: CLI Ruby gem that lets you check your daily horoscope readings.
70
+ email:
71
+ - soheecho94@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - NOTES.md
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/horoscopes
83
+ - bin/setup
84
+ - horoscopes.gemspec
85
+ - ign
86
+ - igns
87
+ - lib/horoscopes.rb
88
+ - lib/horoscopes/cli.rb
89
+ - lib/horoscopes/scraper.rb
90
+ - lib/horoscopes/version.rb
91
+ - lib/horoscopes/zodiacs.rb
92
+ - spec.md
93
+ homepage: https://github.com/soheecho94/horoscopes-cli-app
94
+ licenses: []
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.6.12
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Check your daily horoscopes here!
116
+ test_files: []