moves 0.0.1 → 0.0.2

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: e194eda796dc1f6f5750343434c2a6e7e1a7d24e
4
- data.tar.gz: 78882e1f3ec1402d11160d8c1828c5fa5ece0a9f
3
+ metadata.gz: 586d9629aea04bbbd947c97877999a2e689adcfb
4
+ data.tar.gz: dee6b28c75496903e0613b660e9950a4d1fb389e
5
5
  SHA512:
6
- metadata.gz: 5406d051d67f3e4954e3a5ecd6ca2a9974cf54030aed158c81cafcfce98577b98e98508b940c4b64b2f3c50515875c857fdde3c8e7db3d2ebb593b5ffaca68da
7
- data.tar.gz: d1e8d13e95d7b0e085d9676a3cb9de8ccfe7cd76d74201d6cc5d1dc3d7a884a86e2c34afb493f5230d56c578758a373e4eb4d4728d79373e2a18e40f8e273870
6
+ metadata.gz: 59eab146e896dfb9bde357b641df02b201083a083fdf0126bda42baafc701964142ab2e0de7d47e4a05a4d72ff16de78863c962234d07b89804fe93b2d3c6c3a
7
+ data.tar.gz: b30869d993ff7423bd1ddfb5a4a23a72f17f6e7b2e467eaf22a5cc8f8ba79b9b93ff1e34eb4310cdba70382c1cafb3d371bbcc7964616b2ef5cb67fab95e2187
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Moves
2
2
 
3
- Ruby client for [Moves](http://www.moves-app.com/)
3
+ Ruby client for [Moves](https://dev.moves-app.com/docs/overview)
4
4
 
5
5
  ## Usage
6
6
 
@@ -19,31 +19,47 @@ client.profile
19
19
  Get daily summary
20
20
 
21
21
  ```ruby
22
- client.daily_summary # default to current day
22
+ client.daily_summary # current day
23
+ client.daily_summary("2013-06-20") # any day
24
+ client.daily_summary("2013-W25") # week
25
+ client.daily_summary("2013-06") # month
23
26
  client.daily_summary(:from => "2013-06-20", :to => "2013-06-23") # max 31 days
24
27
  ```
25
28
 
26
29
  Get daily activities
27
30
 
28
31
  ```ruby
29
- client.daily_activities # default to current day
32
+ client.daily_activities # current day
33
+ client.daily_activities("2013-06-20") # any day
34
+ client.daily_activities("2013-W25") # week
30
35
  client.daily_activities(:from => "2013-06-20", :to => "2013-06-23") # max 7 days
31
36
  ```
32
37
 
33
38
  Get daily places
34
39
 
35
40
  ```ruby
36
- client.daily_places # default to current day
41
+ client.daily_places # current day
42
+ client.daily_places("2013-06-20") # any day
43
+ client.daily_places("2013-W25") # week
37
44
  client.daily_places(:from => "2013-06-20", :to => "2013-06-23") # max 7 days
38
45
  ```
39
46
 
40
47
  Get daily storyline
41
48
 
42
49
  ```ruby
43
- client.daily_storyline # default to current day
50
+ client.daily_storyline # current day
51
+ client.daily_storyline("2013-06-20") # any day
52
+ client.daily_storyline("2013-W25") # week
44
53
  client.daily_storyline(:from => "2013-06-20", :to => "2013-06-23") # max 7 days
45
54
  ```
46
55
 
56
+ Get daily storyline with track points
57
+
58
+ ```ruby
59
+ client.daily_storyline(:trackPoints => true) # current day
60
+ client.daily_storyline("2013-06-20", :trackPoints => true) # any day
61
+ ```
62
+
47
63
  ## Installation
48
64
 
49
65
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ task :default => :test
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.pattern = "test/**/*_test.rb"
8
+ end
9
+
data/lib/moves/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Moves
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/moves.rb CHANGED
@@ -16,20 +16,20 @@ module Moves
16
16
  get "user/profile"
17
17
  end
18
18
 
19
- def daily_summary(params = {})
20
- get_range "user/summary/daily", params
19
+ def daily_summary(*args)
20
+ get_range "user/summary/daily", *args
21
21
  end
22
22
 
23
- def daily_activities(params = {})
24
- get_range "user/activities/daily", params
23
+ def daily_activities(*args)
24
+ get_range "user/activities/daily", *args
25
25
  end
26
26
 
27
- def daily_places(params = {})
28
- get_range "user/places/daily", params
27
+ def daily_places(*args)
28
+ get_range "user/places/daily", *args
29
29
  end
30
30
 
31
- def daily_storyline(params = {})
32
- get_range "user/storyline/daily", params
31
+ def daily_storyline(*args)
32
+ get_range "user/storyline/daily", *args
33
33
  end
34
34
 
35
35
  protected
@@ -39,10 +39,21 @@ module Moves
39
39
  JSON.parse(response.body)
40
40
  end
41
41
 
42
- def get_range(path, params = {})
43
- today = Time.now.strftime("%Y-%m-%d")
44
- get path, {:to => today, :from => today}.merge(params)
45
- end
42
+ def get_range(path, *args)
43
+ extra_path, params =
44
+ if args[0].is_a?(String)
45
+ ["/#{args[0]}", args[1]]
46
+ else
47
+ ["", args[0]]
48
+ end
49
+ params ||= {}
50
+
51
+ # default to current day
52
+ if extra_path.empty? and !(params[:to] or params[:from])
53
+ extra_path = "/#{Time.now.strftime("%Y%m%d")}"
54
+ end
46
55
 
56
+ get "#{path}#{extra_path}", params
57
+ end
47
58
  end
48
59
  end
data/moves.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest"
25
26
  end
@@ -0,0 +1,103 @@
1
+ require "test_helper"
2
+
3
+ class TestMoves < Minitest::Test
4
+
5
+ def setup
6
+ @client = Moves::Client.new(ENV["ACCESS_TOKEN"])
7
+ @today = Time.now.strftime("%Y-%m-%d")
8
+ @day = "2013-06-20"
9
+ @week = "2013-W25"
10
+ @month = "2013-06"
11
+ @from_to = {:from => "2013-06-20", :to => "2013-06-23"}
12
+ end
13
+
14
+ def test_profile
15
+ profile = @client.profile
16
+ assert_kind_of Hash, profile
17
+ end
18
+
19
+ def test_daily_summary
20
+ assert_works @client.daily_summary
21
+ end
22
+
23
+ def test_daily_summary_day
24
+ assert_works @client.daily_summary(@day)
25
+ end
26
+
27
+ def test_daily_summary_week
28
+ assert_works @client.daily_summary(@week)
29
+ end
30
+
31
+ def test_daily_summary_month
32
+ assert_works @client.daily_summary(@month)
33
+ end
34
+
35
+ def test_daily_summary_from_to
36
+ assert_works @client.daily_summary(@from_to)
37
+ end
38
+
39
+ def test_daily_activites
40
+ assert_works @client.daily_activities
41
+ end
42
+
43
+ def test_daily_activites_day
44
+ assert_works @client.daily_activities(@day)
45
+ end
46
+
47
+ def test_daily_activites_week
48
+ assert_works @client.daily_activities(@week)
49
+ end
50
+
51
+ def test_daily_activities_from_to
52
+ assert_works @client.daily_activities(@from_to)
53
+ end
54
+
55
+ def test_daily_places
56
+ assert_works @client.daily_places
57
+ end
58
+
59
+ def test_daily_places_day
60
+ assert_works @client.daily_places(@day)
61
+ end
62
+
63
+ def test_daily_places_week
64
+ assert_works @client.daily_places(@week)
65
+ end
66
+
67
+ def test_daily_places_from_to
68
+ assert_works @client.daily_places(@from_to)
69
+ end
70
+
71
+ def test_daily_storyline
72
+ assert_works @client.daily_storyline
73
+ end
74
+
75
+ def test_daily_storyline_day
76
+ assert_works @client.daily_storyline(@day)
77
+ end
78
+
79
+ def test_daily_storyline_week
80
+ assert_works @client.daily_storyline(@week)
81
+ end
82
+
83
+ def test_daily_storyline_from_to
84
+ assert_works @client.daily_storyline(@from_to)
85
+ end
86
+
87
+ def test_daily_storyline_track_points
88
+ assert_works @client.daily_storyline(:trackPoints => true)
89
+ end
90
+
91
+ def test_daily_storyline_track_points_day
92
+ assert_works @client.daily_storyline(@day, :trackPoints => true)
93
+ end
94
+
95
+ protected
96
+
97
+ # TODO better tests
98
+
99
+ def assert_works(actual)
100
+ assert_operator actual.size, :>=, 1
101
+ end
102
+
103
+ end
@@ -0,0 +1,4 @@
1
+ require "bundler/setup"
2
+ Bundler.require(:default)
3
+ require "minitest/autorun"
4
+ require "minitest/pride"
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.1
4
+ version: 0.0.2
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-23 00:00:00.000000000 Z
11
+ date: 2013-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
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'
55
69
  description: Ruby client for Moves
56
70
  email:
57
71
  - acekane1@gmail.com
@@ -67,6 +81,8 @@ files:
67
81
  - lib/moves.rb
68
82
  - lib/moves/version.rb
69
83
  - moves.gemspec
84
+ - test/moves_test.rb
85
+ - test/test_helper.rb
70
86
  homepage: https://github.com/ankane/moves
71
87
  licenses:
72
88
  - MIT
@@ -91,4 +107,6 @@ rubygems_version: 2.0.0
91
107
  signing_key:
92
108
  specification_version: 4
93
109
  summary: Ruby client for Moves
94
- test_files: []
110
+ test_files:
111
+ - test/moves_test.rb
112
+ - test/test_helper.rb