rnnr 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rnnr/version.rb +1 -1
  3. data/lib/send.rb +14 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 856f3f9a1ed27d01c8153523f379b1719f50d5e1
4
- data.tar.gz: 7d3fafa2c6fc80efb01f4369bf3009ca6a105e45
3
+ metadata.gz: 96284545a44db53cd4797b2dce9afca289a26fa8
4
+ data.tar.gz: 1abaeacb99c553b8a6e2a2e622bcc0975f5ad161
5
5
  SHA512:
6
- metadata.gz: dbe261523a4c8c100fb3c2a17dc829ddb38443121c13bb5ad9f877bb5c94789a975a9bfbd1b2b52442bb709b25b23c54cbc9515ea4ae127d387efff5fca39cb9
7
- data.tar.gz: c1552bbf735a96acd77383cbdb50bfbfb6f54f41c39fc29a3bee5cc4046b6a71d3162e26f75e0f236f143a7c98bb314f15f979a0d3f4e4c13a53e2917020317d
6
+ metadata.gz: 07930a270d1ed857ac90e1d4f4a50fa5ab6a65a0d41dfb55a6ee7b55e3ba4083cb045263ef5b7907ca394e30e3dd311e2129c34d5d00a6deb622c77577370ba1
7
+ data.tar.gz: 260f08182afdf50bbb51ea230844a917903f4f80fca68316b86df0c3f9370983891a37d7894413612a3ade96e2c4b228fb1a9031ec2320835c2885631ace083a
data/lib/rnnr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rnnr
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/send.rb CHANGED
@@ -14,6 +14,7 @@ module Rnnr
14
14
  today = DateTime.now
15
15
  today_start = DateTime.new(today.year, today.month, today.day)
16
16
  last_sunday = today_start - today_start.wday
17
+ month_ref = today_start - today_start.mday + 1
17
18
 
18
19
  conn = Faraday.new(:url => 'https://api.ua.com')
19
20
  resp = conn.get do |req|
@@ -29,6 +30,7 @@ module Rnnr
29
30
  body = JSON.parse(resp.body)
30
31
  yearly_distance = 0.0
31
32
  weekly_distance = 0.0
33
+ monthly_distance = 0.0
32
34
  body['_embedded']['workouts'].each do |workout|
33
35
  yearly_distance += workout['aggregates']['distance_total']
34
36
 
@@ -36,14 +38,24 @@ module Rnnr
36
38
  if date > last_sunday
37
39
  weekly_distance += workout['aggregates']['distance_total']
38
40
  end
41
+
42
+ if date > month_ref
43
+ monthly_distance += workout['aggregates']['distance_total']
44
+ end
39
45
  end
40
46
  yearly_distance = yearly_distance.to_miles.round(2)
41
47
  weekly_distance = weekly_distance.to_miles.round(2)
42
- milesperday = (yearly_distance / (Date.today.yday - options.offset)).round(2)
48
+ monthly_distance = monthly_distance.to_miles.round(2)
49
+ yearly_milesperday = (yearly_distance / (Date.today.yday - options.offset)).round(2)
50
+ weekly_milesperday = (weekly_distance / (Date.today.wday - options.offset)).round(2)
51
+ monthly_milesperday = (monthly_distance / (Date.today.mday - options.offset)).round(2)
43
52
 
44
53
  rslt_str = "Yearly: #{yearly_distance}"\
54
+ "\nMonthly: #{monthly_distance}"\
45
55
  "\nWeekly: #{weekly_distance}"\
46
- "\nMiles/Day: #{milesperday}"\
56
+ "\nYearly Avg Miles/Day: #{yearly_milesperday}"\
57
+ "\nMonthly Avg Miles/Day: #{monthly_milesperday}"\
58
+ "\nWeekly Avg Miles/Day: #{weekly_milesperday}"
47
59
 
48
60
  send_email rslt_str if options.email == 'true'
49
61
  puts rslt_str if options.disp == 'true'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnnr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Merritt