moves 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 586d9629aea04bbbd947c97877999a2e689adcfb
4
- data.tar.gz: dee6b28c75496903e0613b660e9950a4d1fb389e
3
+ metadata.gz: 97db4f987d82860502e468a5abb2967faa27afe3
4
+ data.tar.gz: 705a61073bec4d403b2fac1e16ab56dc80a73e92
5
5
  SHA512:
6
- metadata.gz: 59eab146e896dfb9bde357b641df02b201083a083fdf0126bda42baafc701964142ab2e0de7d47e4a05a4d72ff16de78863c962234d07b89804fe93b2d3c6c3a
7
- data.tar.gz: b30869d993ff7423bd1ddfb5a4a23a72f17f6e7b2e467eaf22a5cc8f8ba79b9b93ff1e34eb4310cdba70382c1cafb3d371bbcc7964616b2ef5cb67fab95e2187
6
+ metadata.gz: 9f9e8f08f45526c648e340a91b43beb3d93bd1890b2cbbd54262d6a97a7b14ce951919118a7de8949e18dcda05385c7b7fb89625392275e2788c76b68da5e8c1
7
+ data.tar.gz: bea42b1ed4b81af9de051009fc146e33ad8fa7bcdfffbcf661c7e81d7e26dd235eaa8a8b513ece4db3cf27b937203aac3b98bd9420d2dec903ed71a215362228
data/README.md CHANGED
@@ -4,7 +4,7 @@ Ruby client for [Moves](https://dev.moves-app.com/docs/overview)
4
4
 
5
5
  ## Usage
6
6
 
7
- Create a client.
7
+ Create a client. To obtain an access token, we recommend the [omniauth-moves](https://github.com/nickelser/omniauth-moves) gem.
8
8
 
9
9
  ```ruby
10
10
  client = Moves::Client.new(access_token)
@@ -24,6 +24,12 @@ client.daily_summary("2013-06-20") # any day
24
24
  client.daily_summary("2013-W25") # week
25
25
  client.daily_summary("2013-06") # month
26
26
  client.daily_summary(:from => "2013-06-20", :to => "2013-06-23") # max 31 days
27
+
28
+ # also supports Time, Date, and DateTime objects
29
+ client.daily_summary(Time.now)
30
+ client.daily_summary(Date.today)
31
+ client.daily_summary(DateTime.now)
32
+ client.daily_summary((Date.today - 1)..Date.today)
27
33
  ```
28
34
 
29
35
  Get daily activities
data/lib/moves/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Moves
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/moves.rb CHANGED
@@ -40,17 +40,31 @@ module Moves
40
40
  end
41
41
 
42
42
  def get_range(path, *args)
43
+ format = "%Y-%m-%d"
44
+
43
45
  extra_path, params =
44
- if args[0].is_a?(String)
45
- ["/#{args[0]}", args[1]]
46
- else
46
+ if args[0].is_a?(Hash)
47
47
  ["", args[0]]
48
+ elsif args[0].respond_to?(:strftime)
49
+ ["/#{args[0].strftime(format)}", args[1]]
50
+ elsif args[0].is_a?(Range)
51
+ ["", {:from => args[0].first, to: args[0].last}]
52
+ else
53
+ ["/#{args[0]}", args[1]]
48
54
  end
49
55
  params ||= {}
50
56
 
51
57
  # default to current day
52
58
  if extra_path.empty? and !(params[:to] or params[:from])
53
- extra_path = "/#{Time.now.strftime("%Y%m%d")}"
59
+ extra_path = "/#{Time.now.strftime(format)}"
60
+ end
61
+
62
+ if params[:to].respond_to?(:strftime)
63
+ params[:to] = params[:to].strftime(format)
64
+ end
65
+
66
+ if params[:from].respond_to?(:strftime)
67
+ params[:from] = params[:from].strftime(format)
54
68
  end
55
69
 
56
70
  get "#{path}#{extra_path}", params
data/test/moves_test.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "test_helper"
2
+ require "date"
2
3
 
3
4
  class TestMoves < Minitest::Test
4
5
 
@@ -9,6 +10,11 @@ class TestMoves < Minitest::Test
9
10
  @week = "2013-W25"
10
11
  @month = "2013-06"
11
12
  @from_to = {:from => "2013-06-20", :to => "2013-06-23"}
13
+ @time = Time.now
14
+ @date_time = DateTime.now
15
+ @date = Date.today
16
+ @from_to_time = {:from => @time - 86400, :to => @time}
17
+ @time_range = (@time - 86400)..@time
12
18
  end
13
19
 
14
20
  def test_profile
@@ -24,6 +30,18 @@ class TestMoves < Minitest::Test
24
30
  assert_works @client.daily_summary(@day)
25
31
  end
26
32
 
33
+ def test_daily_summary_time
34
+ assert_works @client.daily_summary(@time)
35
+ end
36
+
37
+ def test_daily_summary_date_time
38
+ assert_works @client.daily_summary(@date_time)
39
+ end
40
+
41
+ def test_daily_summary_date
42
+ assert_works @client.daily_summary(@date)
43
+ end
44
+
27
45
  def test_daily_summary_week
28
46
  assert_works @client.daily_summary(@week)
29
47
  end
@@ -36,6 +54,14 @@ class TestMoves < Minitest::Test
36
54
  assert_works @client.daily_summary(@from_to)
37
55
  end
38
56
 
57
+ def test_daily_summary_from_to_time
58
+ assert_works @client.daily_summary(@from_to_time)
59
+ end
60
+
61
+ def test_daily_summary_time_range
62
+ assert_works @client.daily_summary(@time_range)
63
+ end
64
+
39
65
  def test_daily_activites
40
66
  assert_works @client.daily_activities
41
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moves
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
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-24 00:00:00.000000000 Z
11
+ date: 2013-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client