simple_forecast 0.0.2 → 0.0.3.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.
@@ -1,20 +0,0 @@
1
- class Scraper
2
- attr_reader :forecast
3
-
4
- def initialize(scrape_target)
5
- @scraped_content = Nokogiri::HTML(open(scrape_target))
6
- end
7
-
8
- def get_temp_yesterday
9
- @scraped_content.css('p.wx-temp').text.strip[0..1].to_i
10
- end
11
-
12
- def get_temp_now
13
- @scraped_content.css('span.temperature-fahrenheit')
14
- end
15
-
16
- def get_temp_tomorrow
17
- @scraped_content.css('p.wx-temp').text.strip[0..1].to_i
18
- end
19
-
20
- end
@@ -1,33 +0,0 @@
1
- class WeatherData
2
-
3
- attr_accessor :yesterday_data, :today_data, :lat, :long
4
-
5
- NYC = [40.714623, -74.006605]
6
- NYC_LAT = NYC[0]
7
- NYC_LONG = NYC[1]
8
-
9
- def initialize(lat = NYC_LAT, long = NYC_LONG)
10
- @lat = lat
11
- @long = long
12
- puts "checking my instruments"
13
- @today_data = ForecastIO.forecast(self.lat, self.long, time: Time.now.to_i)
14
- end
15
-
16
- def temp_yesterday
17
- @yesterday_data = ForecastIO.forecast(self.lat, self.long, time: time_yesterday)
18
- self.yesterday_data["currently"]["temperature"]
19
- end
20
-
21
- def temp_today
22
- self.today_data["currently"]["temperature"]
23
- end
24
-
25
- def temp_tomorrow
26
- self.today_data["hourly"]["data"][23]["temperature"]
27
- end
28
-
29
- def time_yesterday
30
- Time.now.to_i - 86400
31
- end
32
-
33
- end
data/notes.md DELETED
@@ -1,168 +0,0 @@
1
- # # time
2
- # Time.now.utc
3
-
4
- # # cron job use whenever gem
5
- # # apple uses launchd instead - works while computer is sleeping
6
-
7
- # every 24.hours do
8
- # #get weather forecast and store
9
- # end
10
-
11
-
12
- get temperatures for yesterday, today and tomorrow
13
- just for new york, ny
14
- allowing for invoking from the command line
15
-
16
- # scraper = Scraper.new('http://students.flatironschool.com')
17
- # scraper.get_links_to_student_pages
18
-
19
- #TODO
20
- # next: create a bunch of dummy data I can use to create a good command line
21
-
22
-
23
- # class SimpleWeather
24
- # def initialize(woeid)
25
- # @weather = Weather.lookup(woeid, :fahrenheit)
26
- # end
27
-
28
- # def title
29
- # @weather.title
30
- # end
31
-
32
- # def condition
33
- # @weather.title
34
- # end
35
-
36
- # end
37
-
38
- # my_weather = SimpleWeather.new(2459115)
39
-
40
-
41
- # print <<-EOT
42
- # #{response.title}
43
- # #{response.condition.temp} degrees
44
- # #{response.condition.text}
45
- # EOT
46
-
47
-
48
- # -> forecast for tomorrow
49
- # -> slightly colder than yesterday
50
-
51
- # -> forecast for seattle wa
52
- # -> much colder than here, and rainier
53
-
54
- ### ARCHIVE
55
- # def crawl_student_pages(student_page)
56
- # url = Nokogiri::HTML(open(student_page))
57
- # end
58
-
59
- # def get_student_list
60
- # students_list = @scraped_content.css('.home-blog ul')
61
- # student_list_item = students_list.css('.blog-thumb a')
62
- # end
63
-
64
- # def get_student_images
65
- # image = url.css('.student_pic').first.attributes["src"].value || "image"
66
- # # student_images = @scraped_content.css('.home-blog .blog-thumb .prof-image')
67
- # end
68
-
69
- # def get_student_names
70
- # name = @url.css('.ib_main_header').children[0].text || "name"
71
- # # student_names = @scraped_content.css('.home-blog .blog-title .big-comment h3 a').text
72
- # end
73
-
74
- # def get_links_to_student_pages
75
- # student_page_links = @scraped_content.css('.blog-thumb a').collect do |link|
76
- # "http://students.flatironschool.com/" + link["href"]
77
- # end
78
- # end
79
-
80
- # def get_student_quotes
81
- # quote = url.css('.textwidget h3')[0].children.text.strip || "quote"
82
- # end
83
-
84
- # def get_student_cities
85
- # cities = url.css('h3')[-3].parent.parent.children[5].children.map { |city| city.text.strip || "cities" }.reject(&:empty?)
86
- # end
87
-
88
- # def get_student_bios
89
- # bio = url.css('h3')[1].parent.parent.children[5].text.strip || "bio"
90
- # end
91
-
92
- # def get_student_personal_projects
93
- # personal_projects = url.css('h3')[-4].parent.parent.children[5].text.strip || "projects"
94
- # end
95
-
96
- # def get_coder_cred
97
- # url.css(".coder-cred a").each do |instance|
98
- # social_media_array << instance.attributes["href"].value
99
- # end
100
- # end
101
-
102
- # def get_coder_cred
103
- # url.css(".social-icons a").each do |link|
104
- # social_media_array << link.attributes["href"].value
105
- # end
106
- # end
107
-
108
- # def get_social_media
109
- # social_media_array = social_media_array.uniq || "social media"
110
- # end
111
-
112
- # def add_to_db
113
- # db = SQLite3::Database.new( "test.db" )
114
- # db.execute(" create table if not exists student (
115
- # student_name varchar2(30),
116
- # image varchar2(30),
117
- # quote text,
118
- # biography text
119
- # )
120
- # ;")
121
-
122
- # db.execute( "insert into student values ( ?, ?,?,? )",
123
- # *student_name,*image,*quote, *biography )
124
- # end
125
-
126
- # # weather = Scraper.new('http://www.weather.com/weather/pastweather/hourly/USNY0996')
127
-
128
- # # puts weather.yesterday
129
-
130
- # forecast = Forecast.new(40.70536,74.013963)
131
-
132
- #binding.pry
133
-
134
-
135
- # forecast tomorrow
136
- # compare tomorrow
137
- # example: today = 64, tomorrow = 72 => a bit warmer than today
138
-
139
- # command == "tomorrow"
140
- # 1. if if tomorrow == today => "same as today"
141
- # 2. if tomorrow > today => "warmer than today"
142
- # 3. if tomorrow < today => "colder than today"
143
-
144
- # 4. get the difference size value.
145
- # 5. if the difference size value is < 3: "a smidge colder/warmer"
146
- # 6. if between 3 and 8: a bit colder
147
- # 7. if between 8 and 12 a lot colder
148
- # 8. if greater than 12: way colder than today
149
-
150
- # if not understand: "I have no idea what you just said, but I'm sure the forecast is excellent" or "Sorry, I didn't understand that."
151
-
152
- # def get_forecast
153
- # if @tomorrow == @today
154
- # "same as today"
155
- # elsif @tomorrow > @today
156
-
157
-
158
- # end
159
-
160
- # it "can return a mock reply to a weather forecast request" do
161
- # @cli.command("forecast for tomorrow")
162
- # @cli.command.should eq "a little warmer than today"
163
- # end
164
-
165
- # it "exits after providing a weather forecast" do
166
- # @cli.command("exit")
167
- # @cli.on.should eq false
168
- # end