wakatime 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 +4 -4
- data/Rakefile +3 -3
- data/lib/wakatime.rb +1 -1
- data/lib/wakatime/client.rb +24 -23
- data/lib/wakatime/exceptions.rb +2 -2
- data/lib/wakatime/session.rb +17 -19
- data/lib/wakatime/version.rb +1 -1
- data/spec/client_spec.rb +17 -5
- data/spec/fixtures/actions.json +18353 -0
- data/spec/integration/core_spec.rb +30 -30
- data/spec/session_spec.rb +16 -16
- data/spec/spec_helper.rb +1 -2
- data/spec/support/account.rb +2 -2
- data/wakatime.gemspec +17 -17
- metadata +5 -3
@@ -1,67 +1,67 @@
|
|
1
|
-
#encoding: UTF-8
|
1
|
+
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'support/account'
|
5
5
|
require 'wakatime'
|
6
6
|
require 'webmock/rspec'
|
7
7
|
|
8
|
-
describe Wakatime, :
|
8
|
+
describe Wakatime, skip: true do
|
9
9
|
before do
|
10
10
|
WebMock.allow_net_connect!
|
11
|
-
@session = Wakatime::Session.new(
|
11
|
+
@session = Wakatime::Session.new(
|
12
12
|
api_key: ACCOUNT['api_key']
|
13
|
-
|
13
|
+
)
|
14
14
|
|
15
15
|
@client = Wakatime::Client.new(@session)
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
session = Wakatime::Session.new(
|
19
|
+
it 'raises an AuthError if not client auth fails' do
|
20
|
+
session = Wakatime::Session.new(
|
21
21
|
api_key: 'bad-key'
|
22
|
-
|
22
|
+
)
|
23
23
|
|
24
24
|
@bad_client = Wakatime::Client.new(session)
|
25
25
|
|
26
|
-
|
26
|
+
expect { @bad_client.summary }.to raise_error(Wakatime::AuthError)
|
27
27
|
end
|
28
28
|
describe Wakatime::Client do
|
29
29
|
|
30
|
-
it
|
30
|
+
it 'will return json scoped to specified times' do
|
31
31
|
summary = @client.summary
|
32
|
-
summary.
|
33
|
-
summary.
|
34
|
-
summary.
|
32
|
+
expect(summary).to be_a Wakatime::Models::Summary
|
33
|
+
expect(summary).to respond_to :grand_total
|
34
|
+
expect(summary).to respond_to :projects
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it 'will return json scoped to specified times' do
|
38
38
|
actions = @client.actions
|
39
|
-
actions.
|
40
|
-
actions.first.
|
41
|
-
actions.first.
|
42
|
-
actions.first.
|
39
|
+
expect(actions).to be_a Array
|
40
|
+
expect(actions.first).to be_a Wakatime::Models::Action
|
41
|
+
expect(actions.first).to respond_to :file
|
42
|
+
expect(actions.first).to respond_to :time
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'will return current user json' do
|
46
46
|
current_user = @client.current_user
|
47
|
-
current_user.
|
48
|
-
current_user.
|
49
|
-
current_user.
|
47
|
+
expect(current_user).to be_a Wakatime::Models::User
|
48
|
+
expect(current_user).to respond_to :email
|
49
|
+
expect(current_user).to respond_to :timezone
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
52
|
+
it 'will return plugin usage json scoped to specified times' do
|
53
53
|
plugins = @client.plugins
|
54
|
-
plugins.
|
55
|
-
plugins.first.
|
56
|
-
plugins.first.
|
54
|
+
expect(plugins).to be_a Array
|
55
|
+
expect(plugins.first).to be_a Wakatime::Models::Plugin
|
56
|
+
expect(plugins.first).to respond_to :name
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
59
|
+
it 'will return daily json scoped to specified times' do
|
60
60
|
daily = @client.daily
|
61
|
-
daily.
|
62
|
-
daily.first.
|
63
|
-
daily.first.
|
64
|
-
daily.first.
|
61
|
+
expect(daily).to be_a Array
|
62
|
+
expect(daily.first).to be_a Wakatime::Models::Summary
|
63
|
+
expect(daily.first).to respond_to :grand_total
|
64
|
+
expect(daily.first).to respond_to :projects
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/spec/session_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#encoding: UTF-8
|
1
|
+
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'support/account'
|
@@ -8,40 +8,40 @@ require 'webmock/rspec'
|
|
8
8
|
describe Wakatime::Session do
|
9
9
|
before do
|
10
10
|
|
11
|
-
@session = Wakatime::Session.new(
|
12
|
-
api_key:
|
13
|
-
|
11
|
+
@session = Wakatime::Session.new(
|
12
|
+
api_key: 'Lame Key'
|
13
|
+
)
|
14
14
|
|
15
15
|
@client = Wakatime::Client.new(@session)
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
stub_request(:get, /.*\/summary.*/).to_return(:
|
21
|
-
|
19
|
+
it 'raises a RequestError if a badly formed request detected by the server' do
|
20
|
+
stub_request(:get, /.*\/summary.*/).to_return(status: 401, body: '{\n \"errors\": [\n \"UNAUTHORIZED\"\n ]\n}', headers: {})
|
21
|
+
expect { @client.summary }.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
26
|
@client.summary
|
27
|
-
rescue
|
28
|
-
e.body.
|
29
|
-
e.status.
|
27
|
+
rescue StandardError => e
|
28
|
+
expect(e.body).to eq '{\n \"errors\": [\n \"UNAUTHORIZED\"\n ]\n}'
|
29
|
+
expect(e.status).to eq 401
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'raises a ServerError if the server raises a 500 error' do
|
34
34
|
stub_request(:get, /.*\/summary.*/)
|
35
|
-
.to_return(:
|
36
|
-
|
35
|
+
.to_return(status: 503, body: '{"type": "error", "status": 503, "message": "We messed up!"}', headers: {})
|
36
|
+
expect { @client.summary }.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
41
|
@client.summary
|
42
|
-
rescue
|
43
|
-
e.body.
|
44
|
-
e.status.
|
42
|
+
rescue StandardError => e
|
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
|
+
expect(e.status).to eq 503
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/account.rb
CHANGED
@@ -3,5 +3,5 @@ require 'yaml'
|
|
3
3
|
begin
|
4
4
|
ACCOUNT = YAML.load_file(File.dirname(__FILE__) + '/account.yml')
|
5
5
|
rescue
|
6
|
-
p
|
7
|
-
end
|
6
|
+
p 'create an account.yml file with your credentials to run integration tests.'
|
7
|
+
end
|
data/wakatime.gemspec
CHANGED
@@ -4,27 +4,27 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'wakatime/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'wakatime'
|
8
8
|
spec.version = Wakatime::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Russell Osborne']
|
10
|
+
spec.email = ['russell@burningpony.com']
|
11
|
+
spec.summary = 'An unofficial ruby gem for accessing Wakatime records'
|
12
|
+
spec.description = 'An unofficial ruby gem for accessing Wakatime records'
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_runtime_dependency(
|
22
|
-
spec.add_runtime_dependency(
|
23
|
-
spec.add_runtime_dependency(
|
24
|
-
spec.add_runtime_dependency(
|
25
|
-
spec.add_runtime_dependency(
|
26
|
-
spec.add_development_dependency(
|
27
|
-
spec.add_development_dependency(
|
28
|
-
spec.add_development_dependency(
|
29
|
-
spec.add_development_dependency(
|
21
|
+
spec.add_runtime_dependency('hashie', ['>= 0'])
|
22
|
+
spec.add_runtime_dependency('activesupport', ['>= 0'])
|
23
|
+
spec.add_runtime_dependency('multipart-post', ['>= 0'])
|
24
|
+
spec.add_runtime_dependency('json', ['>= 0'])
|
25
|
+
spec.add_runtime_dependency('addressable', ['>= 0'])
|
26
|
+
spec.add_development_dependency('rspec', ['>= 0'])
|
27
|
+
spec.add_development_dependency('bundler', ['>= 0'])
|
28
|
+
spec.add_development_dependency('jeweler', ['~> 1.6.4'])
|
29
|
+
spec.add_development_dependency('webmock', ['>= 0'])
|
30
30
|
end
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Osborne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- lib/wakatime/session.rb
|
158
158
|
- lib/wakatime/version.rb
|
159
159
|
- spec/client_spec.rb
|
160
|
+
- spec/fixtures/actions.json
|
160
161
|
- spec/fixtures/current_user.json
|
161
162
|
- spec/fixtures/daily.json
|
162
163
|
- spec/fixtures/plugins.json
|
@@ -187,12 +188,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
188
|
version: '0'
|
188
189
|
requirements: []
|
189
190
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
191
|
+
rubygems_version: 2.4.5
|
191
192
|
signing_key:
|
192
193
|
specification_version: 4
|
193
194
|
summary: An unofficial ruby gem for accessing Wakatime records
|
194
195
|
test_files:
|
195
196
|
- spec/client_spec.rb
|
197
|
+
- spec/fixtures/actions.json
|
196
198
|
- spec/fixtures/current_user.json
|
197
199
|
- spec/fixtures/daily.json
|
198
200
|
- spec/fixtures/plugins.json
|