night_sky 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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/night-sky +5 -0
- data/bin/setup +8 -0
- data/config/environment.rb +8 -0
- data/lib/night_sky/cli.rb +277 -0
- data/lib/night_sky/event.rb +67 -0
- data/lib/night_sky/scraper.rb +23 -0
- data/lib/night_sky/version.rb +3 -0
- data/lib/night_sky.rb +5 -0
- data/night_sky.gemspec +39 -0
- data/spec.md +6 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4658370f5301739fc9e46bb69451809f0730e943
|
4
|
+
data.tar.gz: 975b0a69441a10d2ad6ac50bd78f757b7aba2108
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b70cd4d6a702499700c00b07433fa82fe68506ed06c52e4e7502a6deb42a7e27b0aa8d48dcdb86e0e350090ff9dd6878210dbb9393bceb3e8223195c8f783a4
|
7
|
+
data.tar.gz: 59d7d141c3bfb19c99da89041798ae2e24a198b3180e2d9942d972cf0fc7c0d50af4fe6950339a0f2ba326b844e018674481d899303d4bd3cde06fc433033330
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 nikolaip@gmail.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
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 nikolaip33
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# NightSky
|
2
|
+
|
3
|
+
This Gem provides dates and times for the major astrological events starting from 2010 and ending in 2030. The data is presented in a CLI format with both a numbered list tree navigational system, as well as a free-form search function. While the information is pretty minimal, you can find information about:
|
4
|
+
- The Lunar Cycle
|
5
|
+
- Meteor Shower dates and times
|
6
|
+
- Solstice and Equinox dates
|
7
|
+
- Planetary viewing dates
|
8
|
+
- Dates of Solar and Lunar eclipses
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'night_sky'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install night_sky
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
This Gem can be used as-is as a astronomy quick reference guide, or extended with additional functionality if you see fit.
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
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).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/night_sky. 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.
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
43
|
+
|
44
|
+
## Code of Conduct
|
45
|
+
|
46
|
+
Everyone interacting in the NightSky project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/night_sky/blob/master/CODE_OF_CONDUCT.md).
|
47
|
+
=======
|
48
|
+
# night-sky
|
49
|
+
>>>>>>> 875999ffa2c1029246624f6be11f3082ea0ddeb6
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "night_sky"
|
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__)
|
data/bin/night-sky
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
class NightSky::CLI
|
2
|
+
|
3
|
+
attr_accessor :year, :previous_title, :previous_events
|
4
|
+
|
5
|
+
# class constants - these are used in lieu of having to do constant == comparisons
|
6
|
+
# with a bunch of ||'s. Plus it gives me the added benefit of only having to
|
7
|
+
# edit once to change the logic on every instance of the various navs, since
|
8
|
+
# making a nav method seemed nearly-impossible.
|
9
|
+
|
10
|
+
CHANGE = ["change", "change year"]
|
11
|
+
EXIT = ["exit", "quit"]
|
12
|
+
MAIN = ["main", "menu", "main menu"]
|
13
|
+
YES = ["yes", "y"]
|
14
|
+
NO = ["no", "n"]
|
15
|
+
NONE = ["none", "no", "n"]
|
16
|
+
SEARCH = ["search"]
|
17
|
+
PREVIOUS = ["back", "previous"]
|
18
|
+
|
19
|
+
# controls the width of #wrap and the width of #center to give the CLI a
|
20
|
+
# uniform width.
|
21
|
+
|
22
|
+
WIDTH = 70
|
23
|
+
|
24
|
+
def call
|
25
|
+
introduction
|
26
|
+
set_year
|
27
|
+
main_menu
|
28
|
+
end
|
29
|
+
|
30
|
+
# gets a year from the user and scrapes the correct page. the internal @year
|
31
|
+
# is set here just to make labeling easier.
|
32
|
+
|
33
|
+
def set_year
|
34
|
+
puts "\nPlease enter a year between 2010 and 2030"
|
35
|
+
|
36
|
+
input = nil
|
37
|
+
input= gets.chomp
|
38
|
+
if EXIT.include?(input.downcase)
|
39
|
+
quit
|
40
|
+
elsif input.to_i.between?(2010,2030)
|
41
|
+
self.year = input
|
42
|
+
NightSky::Scraper.new(input).make_events
|
43
|
+
else
|
44
|
+
set_year
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def change_year
|
49
|
+
puts ""
|
50
|
+
puts center("Change Year - Currently #{self.year}")
|
51
|
+
puts wrap("\nYou can only view one year worth of data at a time currently. If you change the year, the previous results will no longer appear in your searches unless you switch back again.")
|
52
|
+
puts center("")
|
53
|
+
NightSky::Event.reset!
|
54
|
+
set_year
|
55
|
+
main_menu
|
56
|
+
end
|
57
|
+
|
58
|
+
def introduction
|
59
|
+
puts ""
|
60
|
+
puts center("*", " ")
|
61
|
+
puts center("* nS *", " ")
|
62
|
+
puts center("* *", " ")
|
63
|
+
puts center("Welcome to The Night Sky")
|
64
|
+
puts wrap("\nThis program can provide you with dates and information on a variety of astronomical events. To get started, we would like to know what year you are interested in searching through.")
|
65
|
+
puts "\nOur records range from the year 2010 all the way through 2030."
|
66
|
+
puts center("")
|
67
|
+
end
|
68
|
+
|
69
|
+
def main_menu
|
70
|
+
puts center("The Night Sky for #{self.year}")
|
71
|
+
puts "\n1. Lunar Calendar - Moon Phase Dates & Times"
|
72
|
+
puts "2. Meteor Showers - Information, Dates & Times"
|
73
|
+
puts "3. Planetary Viewing - Best Gazing Dates & Times"
|
74
|
+
puts "4. Seasonal - Equinox and Solstice Dates & Times"
|
75
|
+
puts "5. Eclipses - Information, Dates & Times"
|
76
|
+
puts "6. Search - Search By Keyword or Month"
|
77
|
+
puts "7. Change Year - Select a new Year for Events"
|
78
|
+
puts " You can enter 'change year' at any time"
|
79
|
+
puts " You can enter 'search' at any time"
|
80
|
+
puts " You can enter 'quit' or 'exit' at any time"
|
81
|
+
puts center("")
|
82
|
+
puts "\nPlease make a selection:"
|
83
|
+
main_menu_nav
|
84
|
+
end
|
85
|
+
|
86
|
+
def main_menu_nav
|
87
|
+
input = 0
|
88
|
+
input = gets.chomp
|
89
|
+
if EXIT.include?(input.downcase)
|
90
|
+
quit
|
91
|
+
elsif SEARCH.include?(input.downcase)
|
92
|
+
search_events
|
93
|
+
elsif CHANGE.include?(input.downcase)
|
94
|
+
change_year
|
95
|
+
elsif input.to_i.between?(1,7)
|
96
|
+
case input.to_i
|
97
|
+
when 1
|
98
|
+
list_events(NightSky::Event.lunar, "Lunar Calendar - #{self.year}")
|
99
|
+
when 2
|
100
|
+
list_events(NightSky::Event.meteor, "Meteor Showers - #{self.year}")
|
101
|
+
when 3
|
102
|
+
list_events(NightSky::Event.planetary, "Planetary Viewing - #{self.year}")
|
103
|
+
when 4
|
104
|
+
list_events(NightSky::Event.seasonal, "Seasonal - #{self.year}")
|
105
|
+
when 5
|
106
|
+
list_events(NightSky::Event.eclipses, "Eclipses - #{self.year}")
|
107
|
+
when 6
|
108
|
+
search_events
|
109
|
+
when 7
|
110
|
+
change_year
|
111
|
+
end
|
112
|
+
else
|
113
|
+
puts "Please make a valid selection."
|
114
|
+
main_menu_nav
|
115
|
+
end
|
116
|
+
puts "\nWould you like to return to the Main Menu?"
|
117
|
+
main_menu_nav_again
|
118
|
+
end
|
119
|
+
|
120
|
+
def main_menu_nav_again
|
121
|
+
puts "Please enter 'yes', 'main menu', 'no', 'exit', or 'search'."
|
122
|
+
input = gets.chomp
|
123
|
+
if EXIT.include?(input.downcase) || NO.include?(input.downcase)
|
124
|
+
quit
|
125
|
+
elsif YES.include?(input.downcase) || MAIN.include?(input.downcase)
|
126
|
+
main_menu
|
127
|
+
elsif SEARCH.include?(input.downcase)
|
128
|
+
search_events
|
129
|
+
elsif CHANGE.include?(input.downcase)
|
130
|
+
change_year
|
131
|
+
elsif PREVIOUS.include?(input.downcase)
|
132
|
+
previous_results
|
133
|
+
puts "\nWould you like to return to the Main Menu?"
|
134
|
+
main_menu_nav_again
|
135
|
+
else
|
136
|
+
main_menu_nav_again
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def search_events
|
141
|
+
puts center("Search for an Astronomical Event in #{self.year}")
|
142
|
+
puts wrap"\nSearch Tips: For the best results, consider searching by month, or by a single term with a high amount of specificity. Multi-word searches may not return accurate results."
|
143
|
+
puts center("")
|
144
|
+
puts "\nWhat would you like to search for?"
|
145
|
+
|
146
|
+
input = gets.chomp
|
147
|
+
if EXIT.include?(input.downcase)
|
148
|
+
quit
|
149
|
+
elsif MAIN.include?(input.downcase)
|
150
|
+
main_menu
|
151
|
+
elsif CHANGE.include?(input.downcase)
|
152
|
+
change_year
|
153
|
+
else
|
154
|
+
results = NightSky::Event.search_by(input.downcase)
|
155
|
+
if results.length == 0
|
156
|
+
puts "\nSorry, 0 matches were found."
|
157
|
+
else
|
158
|
+
msg = results.length == 1 ? "We found 1 match for:" : "We found #{results.length} matches for:"
|
159
|
+
list_events(results, "#{msg} #{input}")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
puts "\nWould you like to search again?"
|
163
|
+
search_events_again
|
164
|
+
end
|
165
|
+
|
166
|
+
def search_events_again
|
167
|
+
puts "Please enter 'yes', 'no' or 'exit'."
|
168
|
+
|
169
|
+
input = gets.chomp
|
170
|
+
if EXIT.include?(input.downcase)
|
171
|
+
quit
|
172
|
+
elsif YES.include?(input.downcase)
|
173
|
+
search_events
|
174
|
+
elsif NO.include?(input.downcase)
|
175
|
+
main_menu
|
176
|
+
elsif MAIN.include?(input.downcase)
|
177
|
+
main_menu
|
178
|
+
elsif SEARCH.include?(input.downcase)
|
179
|
+
search_events
|
180
|
+
elsif CHANGE.include?(input.downcase)
|
181
|
+
change_year
|
182
|
+
elsif PREVIOUS.include?(input.downcase)
|
183
|
+
previous_results
|
184
|
+
puts "\nWould you like to search again?"
|
185
|
+
search_events_again
|
186
|
+
else
|
187
|
+
search_events_again
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# methods for populating and formatting list screens
|
192
|
+
|
193
|
+
def list_events(events, title)
|
194
|
+
self. previous_events = events
|
195
|
+
self.previous_title = title
|
196
|
+
|
197
|
+
puts center(title)
|
198
|
+
puts ""
|
199
|
+
events.each.with_index(1) do |e, i|
|
200
|
+
puts " #{i}. #{e.date} - #{e.name}" if i < 10
|
201
|
+
puts "#{i}. #{e.date} - #{e.name}" if i >= 10
|
202
|
+
end
|
203
|
+
puts center("")
|
204
|
+
|
205
|
+
puts "\nWhich event would you like more information for?"
|
206
|
+
select_event(events)
|
207
|
+
end
|
208
|
+
|
209
|
+
def select_event(events)
|
210
|
+
input = 0
|
211
|
+
input = gets.chomp
|
212
|
+
if EXIT.include?(input.downcase)
|
213
|
+
quit
|
214
|
+
elsif NONE.include?(input.downcase)
|
215
|
+
elsif MAIN.include?(input.downcase)
|
216
|
+
main_menu
|
217
|
+
elsif SEARCH.include?(input.downcase)
|
218
|
+
search_events
|
219
|
+
elsif CHANGE.include?(input.downcase)
|
220
|
+
change_year
|
221
|
+
elsif input.to_i.between?(1,events.length)
|
222
|
+
more_details(events[input.to_i-1])
|
223
|
+
else
|
224
|
+
puts "Please choose an event from the list."
|
225
|
+
select_event(events)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def previous_results
|
230
|
+
list_events(self.previous_events, self.previous_title)
|
231
|
+
end
|
232
|
+
|
233
|
+
# this seems a bit janky here, but there doesn't seem like a good place to
|
234
|
+
# rip it apart. Plus, I'm stylizing the title here as well so it seemed fine.
|
235
|
+
|
236
|
+
def more_details(event)
|
237
|
+
#formatter
|
238
|
+
parts = event.details.split(".")
|
239
|
+
title = parts.shift + " "
|
240
|
+
until title.length == WIDTH
|
241
|
+
title << "-"
|
242
|
+
end
|
243
|
+
details = parts.join(".").strip << "."
|
244
|
+
|
245
|
+
#writer
|
246
|
+
puts "\n#{title}"
|
247
|
+
puts wrap(details).prepend("\n")
|
248
|
+
puts center("")
|
249
|
+
end
|
250
|
+
|
251
|
+
# makes Title strings have their accent without having to code it into the actual string
|
252
|
+
# makes them a set width by filling the missing space on each side with a character
|
253
|
+
# default is -
|
254
|
+
|
255
|
+
def center(string, c = "-")
|
256
|
+
string = " #{string} " if string != ""
|
257
|
+
until string.length >= WIDTH
|
258
|
+
string.prepend(c)
|
259
|
+
string << (c)
|
260
|
+
end
|
261
|
+
string.prepend("\n")
|
262
|
+
end
|
263
|
+
|
264
|
+
|
265
|
+
def wrap(string)
|
266
|
+
string.gsub(/(.{1,#{WIDTH}})(\s+|\Z)/, "\\1\n ")
|
267
|
+
end
|
268
|
+
|
269
|
+
def quit
|
270
|
+
puts center("Thank You!", "-")
|
271
|
+
puts center("Get out and enjoy The Night Sky", " ")
|
272
|
+
puts center("* *", " ")
|
273
|
+
puts center("*", " ")
|
274
|
+
exit
|
275
|
+
end
|
276
|
+
|
277
|
+
end #class NightSky::CLI
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class NightSky::Event
|
2
|
+
|
3
|
+
attr_accessor :name, :date, :date_full, :year, :details
|
4
|
+
# @@all = Hash.new([])
|
5
|
+
@@all = []
|
6
|
+
|
7
|
+
def initialize(name, date, year, details)
|
8
|
+
@name = name
|
9
|
+
@date_full = date
|
10
|
+
@date = abreviate_date(date)
|
11
|
+
@year = year
|
12
|
+
@details = details
|
13
|
+
@@all << self
|
14
|
+
end
|
15
|
+
|
16
|
+
def abreviate_date(date)
|
17
|
+
parts = date.split(" ")
|
18
|
+
parts[0] = parts[0][0..2]
|
19
|
+
parts.join(" ")
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.new_from_item(item, year)
|
23
|
+
self.new(
|
24
|
+
item.search(".title-text").text.strip.gsub(".",""),
|
25
|
+
item.search(".date-text").text.strip,
|
26
|
+
year,
|
27
|
+
item.search("p").text.strip
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.lunar
|
32
|
+
select_by("moon")
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.meteor
|
36
|
+
select_by("meteor")
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.planetary
|
40
|
+
all.select { |e| /Mercury|Venus|Earth|Mars|Jupiter|Saturn|Uranus|Neptune/ === e.name }
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.seasonal
|
44
|
+
all.select { |e| e.name.downcase.include?("solstice") || e.name.downcase.include?("equinox") }
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.eclipses
|
48
|
+
select_by("eclipse")
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.select_by(term)
|
52
|
+
all.select { |e| e.name.downcase.include?(term.downcase) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.search_by(term)
|
56
|
+
all.select { |e| e.details.downcase.include?(term.downcase) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.all
|
60
|
+
@@all
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.reset!
|
64
|
+
@@all.clear
|
65
|
+
end
|
66
|
+
|
67
|
+
end #class NightSky::Event
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class NightSky::Scraper
|
2
|
+
|
3
|
+
attr_reader :year
|
4
|
+
|
5
|
+
def initialize(year="2017")
|
6
|
+
@year = year
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_page
|
10
|
+
Nokogiri::HTML(open("http://www.seasky.org/astronomy/astronomy-calendar-#{self.year}.html"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def scrape_events
|
14
|
+
get_page.search("#right-column-content li")
|
15
|
+
end
|
16
|
+
|
17
|
+
def make_events
|
18
|
+
scrape_events.each do |event|
|
19
|
+
NightSky::Event.new_from_item(event, self.year)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end #Class NightSky Scraper
|
data/lib/night_sky.rb
ADDED
data/night_sky.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "night_sky/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "night_sky"
|
8
|
+
spec.version = NightSky::VERSION
|
9
|
+
spec.authors = ["nikolaip33"]
|
10
|
+
spec.email = ["nikolaip@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Astronomy Calendar CLI"
|
13
|
+
spec.description = "Prvoides information on upcoming atronomical events."
|
14
|
+
spec.homepage = "https://github.com/nikolaip33/night-sky"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "nokogiri", ">= 0"
|
37
|
+
spec.add_development_dependency "pry", ">= 0"
|
38
|
+
spec.add_development_dependency "require_all", "~> 1.3", ">= 1.3.3"
|
39
|
+
end
|
data/spec.md
ADDED
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: night_sky
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nikolaip33
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-05 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.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.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: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: require_all
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 1.3.3
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '1.3'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.3.3
|
103
|
+
description: Prvoides information on upcoming atronomical events.
|
104
|
+
email:
|
105
|
+
- nikolaip@gmail.com
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- ".rspec"
|
112
|
+
- ".travis.yml"
|
113
|
+
- CODE_OF_CONDUCT.md
|
114
|
+
- Gemfile
|
115
|
+
- LICENSE.txt
|
116
|
+
- README.md
|
117
|
+
- Rakefile
|
118
|
+
- bin/console
|
119
|
+
- bin/night-sky
|
120
|
+
- bin/setup
|
121
|
+
- config/environment.rb
|
122
|
+
- lib/night_sky.rb
|
123
|
+
- lib/night_sky/cli.rb
|
124
|
+
- lib/night_sky/event.rb
|
125
|
+
- lib/night_sky/scraper.rb
|
126
|
+
- lib/night_sky/version.rb
|
127
|
+
- night_sky.gemspec
|
128
|
+
- spec.md
|
129
|
+
homepage: https://github.com/nikolaip33/night-sky
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata:
|
133
|
+
allowed_push_host: https://rubygems.org
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.6.14
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Astronomy Calendar CLI
|
154
|
+
test_files: []
|