lifeapi 0.0.12 → 1.0.0
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 +4 -4
- data/lib/lifeapi/version.rb +1 -1
- data/lib/lifeapi.rb +37 -89
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1cee89c310cf66a37d76f6410fcb92595eb4729
|
|
4
|
+
data.tar.gz: a3ac641366e5e8ef9446412aeae04ae9c95b1e32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74956f307092a4fb9627d3b668549b067485b20fc8e8a9f5823ec27a12d01b4bb59959bd1992d8c00d629fa4bc4b1ea96fd0c723895c505ea5e950961675171c
|
|
7
|
+
data.tar.gz: 4531ad8ff673f5ee48e7d1b51263407270b0779f6b68cdc7e39d879e5efe5d68561b321eaed31bfd57bebcaeca8caa6ef0aab4224197d28aa22d7a5a52eaeb48
|
data/lib/lifeapi/version.rb
CHANGED
data/lib/lifeapi.rb
CHANGED
|
@@ -94,12 +94,9 @@ module Lifeapi
|
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
# returns a single day
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
# day: the day to be searched
|
|
101
|
-
def self.get_one_day(year, month, day)
|
|
102
|
-
@year = year
|
|
97
|
+
# returns a single day
|
|
98
|
+
def self.single_day(month, day)
|
|
99
|
+
@year = 2016
|
|
103
100
|
@month = month
|
|
104
101
|
@day = day
|
|
105
102
|
json_data = HTTParty.get("https://jack-lifeapi.herokuapp.com/v1/days/single?year=#{@year}&month=#{@month}&day=#{day}")
|
|
@@ -110,29 +107,24 @@ module Lifeapi
|
|
|
110
107
|
end
|
|
111
108
|
|
|
112
109
|
data = JSON.parse(json_data.to_json)
|
|
113
|
-
|
|
114
110
|
day = Day.new(data["record_date"],data["activities"])
|
|
115
111
|
|
|
116
112
|
return day
|
|
117
113
|
end
|
|
118
114
|
|
|
119
|
-
# returns a range
|
|
120
|
-
#
|
|
121
|
-
#
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
# month2: the month to be used for second the start date
|
|
125
|
-
# day2: the day to be used for the second start date
|
|
126
|
-
def self.get_range_of_days_condensed(year1, month1, day1, year2, month2, day2)
|
|
127
|
-
@year1 = year1
|
|
115
|
+
# returns a range of days
|
|
116
|
+
# if the condense param is true it will return a condensed object representing the range of days
|
|
117
|
+
# otherwise it will retun an array of the days
|
|
118
|
+
def self.range(month1, day1, month2, day2, condense)
|
|
119
|
+
@year1 = 2016
|
|
128
120
|
@month1 = month1
|
|
129
121
|
@day1 = day1
|
|
130
|
-
@year2 =
|
|
122
|
+
@year2 = 2016
|
|
131
123
|
@month2 = month2
|
|
132
124
|
@day2 = day2
|
|
133
|
-
@condense =
|
|
125
|
+
@condense = condense
|
|
134
126
|
|
|
135
|
-
json_data = HTTParty.get("https://jack-lifeapi.herokuapp.com/v1/days/range?year1=#{@year1}&month1=#{@month1}&day1=#{@day1}&year2=#{@year2}&month2=#{@month2}&day2=#{@day2}&condense
|
|
127
|
+
json_data = HTTParty.get("https://jack-lifeapi.herokuapp.com/v1/days/range?year1=#{@year1}&month1=#{@month1}&day1=#{@day1}&year2=#{@year2}&month2=#{@month2}&day2=#{@day2}&condense=#{@condense}")
|
|
136
128
|
|
|
137
129
|
#if the params are bad
|
|
138
130
|
if json_data.code == 400
|
|
@@ -141,66 +133,24 @@ module Lifeapi
|
|
|
141
133
|
|
|
142
134
|
data = JSON.parse(json_data.to_json)
|
|
143
135
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
# day2: the day to be used for the second start date
|
|
156
|
-
def self.get_range_of_days(year1, month1, day1, year2, month2, day2)
|
|
157
|
-
@year1 = year1
|
|
158
|
-
@month1 = month1
|
|
159
|
-
@day1 = day1
|
|
160
|
-
@year2 = year2
|
|
161
|
-
@month2 = month2
|
|
162
|
-
@day2 = day2
|
|
163
|
-
@condense = false
|
|
164
|
-
|
|
165
|
-
json_data = HTTParty.get("https://jack-lifeapi.herokuapp.com/v1/days/range?year1=#{@year1}&month1=#{@month1}&day1=#{@day1}&year2=#{@year2}&month2=#{@month2}&day2=#{@day2}&condense=false")
|
|
166
|
-
|
|
167
|
-
#if the params are bad
|
|
168
|
-
if json_data.code == 400
|
|
169
|
-
raise Errors::BadParamsError
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
data = JSON.parse(json_data.to_json)
|
|
173
|
-
|
|
174
|
-
#day = Range.new(data["start_date"], data["end_date"], data["activities"])
|
|
175
|
-
@day_array = []
|
|
176
|
-
data.each do |d|
|
|
177
|
-
@day = Day.new(d["record_date"], d["activities"])
|
|
178
|
-
@day_array += [@day]
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
return @day_array
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
# returns the whole summer, in condensed format
|
|
185
|
-
def self.get_whole_summer_condensed()
|
|
186
|
-
json_data = HTTParty.get("https://jack-lifeapi.herokuapp.com/v1/days/all_time?condense=true")
|
|
187
|
-
|
|
188
|
-
#if the params are bad
|
|
189
|
-
if json_data.code == 400
|
|
190
|
-
raise Errors::BadParamsError
|
|
136
|
+
#if the data is condensed it needs to be handled differently
|
|
137
|
+
if @condense == true
|
|
138
|
+
day = Range.new(data["start_date"], data["end_date"], data["activities"])
|
|
139
|
+
return day
|
|
140
|
+
else
|
|
141
|
+
@day_array = []
|
|
142
|
+
data.each do |d|
|
|
143
|
+
@day = Day.new(d["record_date"], d["activities"])
|
|
144
|
+
@day_array += [@day]
|
|
145
|
+
end
|
|
146
|
+
return @day_array
|
|
191
147
|
end
|
|
192
|
-
|
|
193
|
-
data = JSON.parse(json_data.to_json)
|
|
194
|
-
|
|
195
|
-
day = Range.new(data["start_date"], data["end_date"], data["activities"])
|
|
196
|
-
|
|
197
|
-
return day
|
|
198
|
-
|
|
199
148
|
end
|
|
200
149
|
|
|
201
|
-
#
|
|
202
|
-
def self.
|
|
203
|
-
|
|
150
|
+
# the same thing as self.range() except the server collects every recorded day.
|
|
151
|
+
def self.all_time(condense)
|
|
152
|
+
@condense = condense
|
|
153
|
+
json_data = HTTParty.get("https://jack-lifeapi.herokuapp.com/v1/days/all_time?condense=#{@condense}")
|
|
204
154
|
|
|
205
155
|
#if the params are bad
|
|
206
156
|
if json_data.code == 400
|
|
@@ -209,22 +159,20 @@ module Lifeapi
|
|
|
209
159
|
|
|
210
160
|
data = JSON.parse(json_data.to_json)
|
|
211
161
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
@day_array
|
|
162
|
+
if @condense == true
|
|
163
|
+
day = Range.new(data["start_date"], data["end_date"], data["activities"])
|
|
164
|
+
return day
|
|
165
|
+
else
|
|
166
|
+
@day_array = []
|
|
167
|
+
data.each do |d|
|
|
168
|
+
@day = Day.new(d["record_date"], d["activities"])
|
|
169
|
+
@day_array += [@day]
|
|
170
|
+
end
|
|
171
|
+
return @day_array
|
|
217
172
|
end
|
|
218
|
-
|
|
219
|
-
return @day_array
|
|
220
|
-
|
|
221
173
|
end
|
|
222
174
|
|
|
223
|
-
#
|
|
224
|
-
# month: the month to be searched
|
|
225
|
-
# day: the day to be searched
|
|
226
|
-
# hour: the hour to be searched
|
|
227
|
-
# minute: the minute to be searched
|
|
175
|
+
# returns the activity being performed at a certain time.
|
|
228
176
|
def self.query(month, day, hour, minute)
|
|
229
177
|
@year = 2016 # year is hardcoded right now because i dont track anything outside of 2016
|
|
230
178
|
@month = month
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lifeapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jack rometty
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-05-
|
|
11
|
+
date: 2016-05-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|