wakatime 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wakatime/client.rb +3 -8
- data/lib/wakatime/version.rb +1 -1
- data/spec/client_spec.rb +5 -5
- data/spec/fixtures/{summary.json → summaries.json} +0 -0
- data/spec/integration/core_spec.rb +1 -1
- data/spec/session_spec.rb +6 -6
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 501e021ea28516b7b838aef0e5ceca05c50f0446
|
4
|
+
data.tar.gz: c0a1675154cd4f095fff5f59a0bcef4ceb9efc12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 017bb1801871fd2bbb4415232b8435e80c776ca2b4db9b6534ff92b255890ba5bed3530c5e602b7bdfbc6b2aa61d65681f978b9484707c7676f103b84ede451f
|
7
|
+
data.tar.gz: 2b5b36159ae7985b3d46765620da1c470ab8173e9e198c511425809d21eb8074a1f8612c87048b9eb0b82e9b8f98db2cefa9e60f38fca94e22aee8f1351b213b
|
data/lib/wakatime/client.rb
CHANGED
@@ -13,12 +13,8 @@ module Wakatime
|
|
13
13
|
@session = session
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
request_builder('
|
18
|
-
end
|
19
|
-
|
20
|
-
def daily(start_at = Time.now - 86_400, end_at = Time.now)
|
21
|
-
request_builder('summary/daily', start: start_at, end: end_at)
|
16
|
+
def summaries(start_at = Time.now - 86_400, end_at = Time.now)
|
17
|
+
request_builder('summaries', start: start_at, end: end_at)
|
22
18
|
end
|
23
19
|
|
24
20
|
def durations(date = Date.today)
|
@@ -26,8 +22,7 @@ module Wakatime
|
|
26
22
|
end
|
27
23
|
|
28
24
|
def heartbeats(params = {})
|
29
|
-
params[:
|
30
|
-
params[:end] ||= Time.now
|
25
|
+
params[:date] ||= Date.today
|
31
26
|
params[:show] ||= 'file,branch,project,time'
|
32
27
|
|
33
28
|
request_builder('heartbeats', params)
|
data/lib/wakatime/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -10,14 +10,14 @@ describe Wakatime::Client do
|
|
10
10
|
@session = Wakatime::Session.new
|
11
11
|
end
|
12
12
|
|
13
|
-
describe '#
|
13
|
+
describe '#summaries' do
|
14
14
|
it 'should return json' do
|
15
|
-
stub_request(:get, "#{Wakatime::API_URL}/
|
15
|
+
stub_request(:get, "#{Wakatime::API_URL}/summaries")
|
16
16
|
.with(query: hash_including(:start, :end))
|
17
|
-
.to_return(body: File.read('./spec/fixtures/
|
17
|
+
.to_return(body: File.read('./spec/fixtures/summaries.json'), status: 200)
|
18
18
|
|
19
19
|
client = Wakatime::Client.new(@session)
|
20
|
-
expect(client.
|
20
|
+
expect(client.summaries.grand_total.total_seconds).to eq 49_740
|
21
21
|
|
22
22
|
end
|
23
23
|
end
|
@@ -25,7 +25,7 @@ describe Wakatime::Client do
|
|
25
25
|
describe '#heartbeats' do
|
26
26
|
it 'should return json' do
|
27
27
|
stub_request(:get, "#{Wakatime::API_URL}/heartbeats")
|
28
|
-
.with(query: hash_including(:
|
28
|
+
.with(query: hash_including(:date))
|
29
29
|
.to_return(body: File.read('./spec/fixtures/heartbeats.json'), status: 200)
|
30
30
|
|
31
31
|
client = Wakatime::Client.new(@session)
|
File without changes
|
@@ -29,7 +29,7 @@ describe Wakatime, skip: true do
|
|
29
29
|
|
30
30
|
it 'will return json scoped to specified times' do
|
31
31
|
summary = @client.summary
|
32
|
-
expect(summary).to be_a Wakatime::Models::
|
32
|
+
expect(summary).to be_a Wakatime::Models::Summaries
|
33
33
|
expect(summary).to respond_to :grand_total
|
34
34
|
expect(summary).to respond_to :projects
|
35
35
|
end
|
data/spec/session_spec.rb
CHANGED
@@ -17,13 +17,13 @@ describe Wakatime::Session do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'raises a RequestError if a badly formed request detected by the server' do
|
20
|
-
stub_request(:get, /.*\/
|
21
|
-
expect { @client.
|
20
|
+
stub_request(:get, /.*\/summaries.*/).to_return(status: 401, body: '{\n \"errors\": [\n \"UNAUTHORIZED\"\n ]\n}', headers: {})
|
21
|
+
expect { @client.summaries }.to raise_error(Wakatime::AuthError)
|
22
22
|
|
23
23
|
# make sure status and body is
|
24
24
|
# set on error object.
|
25
25
|
begin
|
26
|
-
@client.
|
26
|
+
@client.summaries
|
27
27
|
rescue StandardError => e
|
28
28
|
expect(e.body).to eq '{\n \"errors\": [\n \"UNAUTHORIZED\"\n ]\n}'
|
29
29
|
expect(e.status).to eq 401
|
@@ -31,14 +31,14 @@ describe Wakatime::Session do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'raises a ServerError if the server raises a 500 error' do
|
34
|
-
stub_request(:get, /.*\/
|
34
|
+
stub_request(:get, /.*\/summaries.*/)
|
35
35
|
.to_return(status: 503, body: '{"type": "error", "status": 503, "message": "We messed up!"}', headers: {})
|
36
|
-
expect { @client.
|
36
|
+
expect { @client.summaries }.to raise_error(Wakatime::ServerError)
|
37
37
|
|
38
38
|
# make sure status and body is
|
39
39
|
# set on error object.
|
40
40
|
begin
|
41
|
-
@client.
|
41
|
+
@client.summaries
|
42
42
|
rescue StandardError => e
|
43
43
|
expect(e.body).to eq '{"type": "error", "status": 503, "message": "We messed up!"}' # TODO establish what happens when wakatime returns a 500 or something else.
|
44
44
|
expect(e.status).to eq 503
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wakatime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Osborne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -161,7 +161,7 @@ files:
|
|
161
161
|
- spec/fixtures/daily.json
|
162
162
|
- spec/fixtures/heartbeats.json
|
163
163
|
- spec/fixtures/plugins.json
|
164
|
-
- spec/fixtures/
|
164
|
+
- spec/fixtures/summaries.json
|
165
165
|
- spec/integration/core_spec.rb
|
166
166
|
- spec/session_spec.rb
|
167
167
|
- spec/spec_helper.rb
|
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
190
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.4.5
|
191
|
+
rubygems_version: 2.4.5.1
|
192
192
|
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: An unofficial ruby gem for accessing Wakatime records
|
@@ -198,7 +198,7 @@ test_files:
|
|
198
198
|
- spec/fixtures/daily.json
|
199
199
|
- spec/fixtures/heartbeats.json
|
200
200
|
- spec/fixtures/plugins.json
|
201
|
-
- spec/fixtures/
|
201
|
+
- spec/fixtures/summaries.json
|
202
202
|
- spec/integration/core_spec.rb
|
203
203
|
- spec/session_spec.rb
|
204
204
|
- spec/spec_helper.rb
|