wakatime 0.2.0 → 0.2.1

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: 501e021ea28516b7b838aef0e5ceca05c50f0446
4
- data.tar.gz: c0a1675154cd4f095fff5f59a0bcef4ceb9efc12
3
+ metadata.gz: e029e38b9c34933d0e6c8aa8318c89d354617042
4
+ data.tar.gz: 7d2d7ea7b012dd97724ce757285b6b6e1b0680b3
5
5
  SHA512:
6
- metadata.gz: 017bb1801871fd2bbb4415232b8435e80c776ca2b4db9b6534ff92b255890ba5bed3530c5e602b7bdfbc6b2aa61d65681f978b9484707c7676f103b84ede451f
7
- data.tar.gz: 2b5b36159ae7985b3d46765620da1c470ab8173e9e198c511425809d21eb8074a1f8612c87048b9eb0b82e9b8f98db2cefa9e60f38fca94e22aee8f1351b213b
6
+ metadata.gz: 663a41a707a98a1f06c64263978e19c361cacae275dde22848c74c61a6d08d12d99dab66aa57b7ce4a4142783193a80fb49641443ea11804eaa08ee7149085ee
7
+ data.tar.gz: 2153191f498ee20414fe19934ad2eebec421dfcf07e2971997109a67851278c58387478821c55ef66fa8fe92fcebf3ce9a937cecd0661db61a479bbc7bac8b6b
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
3
- - 2.1.1
4
+ - 2.2.3
4
5
  before_install:
5
- - gem install bundler --pre
6
- script: bundle exec rake spec
6
+ - gem install bundler
7
+ script: bundle exec rake
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Wakatime Ruby
1
+ # Wakatime Ruby
2
2
  [![Code Climate](https://codeclimate.com/github/burningpony/wakatime.png)](https://codeclimate.com/github/burningpony/wakatime)
3
3
  [![Build Status](https://travis-ci.org/burningpony/wakatime.svg?branch=master)](https://travis-ci.org/burningpony/wakatime)
4
4
  An Unofficial Wakatime Ruby API Client
@@ -26,10 +26,7 @@ Or install it yourself as:
26
26
  @client = Wakatime::Client.new(@session)
27
27
 
28
28
  #### Summary
29
- @client.summary
30
-
31
- #### Daily Summary
32
- @client.daily
29
+ @client.summaries
33
30
 
34
31
  #### Durations
35
32
  @client.durations
@@ -39,10 +36,10 @@ Or install it yourself as:
39
36
 
40
37
  #### Current User
41
38
  @client.current_user
42
-
39
+
43
40
  #### Plugin Data
44
41
  @client.plugins
45
-
42
+
46
43
 
47
44
  ## Testing
48
45
 
@@ -59,4 +56,4 @@ Or install it yourself as:
59
56
 
60
57
  ## Credits
61
58
 
62
- Massive Credit to [Ruby Box][https://github.com/attachmentsme/ruby-box] as being a template API client.
59
+ Massive Credit to [Ruby Box][https://github.com/attachmentsme/ruby-box] as being a template API client.
@@ -4,6 +4,7 @@ require 'json'
4
4
  require 'net/http/post/multipart'
5
5
  require 'open-uri'
6
6
  require 'cgi'
7
+ require 'active_support'
7
8
  require 'active_support/inflector'
8
9
  require 'addressable/template'
9
10
  require 'base64'
@@ -14,27 +15,27 @@ module Wakatime
14
15
  end
15
16
 
16
17
  def summaries(start_at = Time.now - 86_400, end_at = Time.now)
17
- request_builder('summaries', start: start_at, end: end_at)
18
+ request_builder('users/current/summaries', start: start_at, end: end_at)
18
19
  end
19
20
 
20
21
  def durations(date = Date.today)
21
- request_builder('durations', date: date)
22
+ request_builder('users/current/durations', date: date)
22
23
  end
23
24
 
24
25
  def heartbeats(params = {})
25
- params[:date] ||= Date.today
26
- params[:show] ||= 'file,branch,project,time'
26
+ params[:date] ||= Date.today
27
+ params[:show] ||= 'file,branch,project,time'
27
28
 
28
- request_builder('heartbeats', params)
29
+ request_builder('users/current/heartbeats', params)
29
30
  end
30
31
 
31
32
  def plugins(params = {})
32
- params[:show] ||= 'name,version'
33
- request_builder('plugins', params)
33
+ params[:show] ||= 'name,version'
34
+ request_builder('users/current/plugins', params)
34
35
  end
35
36
 
36
37
  def current_user(params = {})
37
- params[:show] ||= 'email,timeout,last_plugin,timezone'
38
+ params[:show] ||= 'email,timeout,last_plugin,timezone'
38
39
  request_builder('users/current', params)
39
40
  end
40
41
 
@@ -54,7 +55,7 @@ module Wakatime
54
55
  end
55
56
 
56
57
  def request_builder(action, params = {}, raw = false)
57
- uri = Addressable::Template.new("#{Wakatime::API_URL}/#{action}{?query*}")
58
+ uri = Addressable::Template.new("#{Wakatime::API_URL}/#{action}{?query*}")
58
59
  uri = uri.expand(
59
60
  'query' => cast_params(params)
60
61
  )
@@ -74,7 +75,7 @@ module Wakatime
74
75
  if response['data'].is_a? Hash
75
76
  klass.new(response['data'])
76
77
  else
77
- response['data'].map do |attributes|
78
+ response['data'].map do |attributes|
78
79
  klass.new(attributes)
79
80
  end
80
81
  end
@@ -24,9 +24,7 @@ module Wakatime
24
24
 
25
25
  response = http.request(request)
26
26
 
27
- if response.is_a? Net::HTTPNotFound
28
- fail Wakatime::ObjectNotFound
29
- end
27
+ fail Wakatime::ObjectNotFound if response.is_a? Net::HTTPNotFound
30
28
 
31
29
  sleep(@backoff) # try not to excessively hammer API.
32
30
 
@@ -1,3 +1,3 @@
1
1
  module Wakatime
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -12,25 +12,23 @@ describe Wakatime::Client do
12
12
 
13
13
  describe '#summaries' do
14
14
  it 'should return json' do
15
- stub_request(:get, "#{Wakatime::API_URL}/summaries")
16
- .with(query: hash_including(:start, :end))
17
- .to_return(body: File.read('./spec/fixtures/summaries.json'), status: 200)
15
+ stub_request(:get, "#{Wakatime::API_URL}/users/current/summaries")
16
+ .with(query: hash_including(:start, :end))
17
+ .to_return(body: File.read('./spec/fixtures/summaries.json'), status: 200)
18
18
 
19
19
  client = Wakatime::Client.new(@session)
20
20
  expect(client.summaries.grand_total.total_seconds).to eq 49_740
21
-
22
21
  end
23
22
  end
24
23
 
25
24
  describe '#heartbeats' do
26
25
  it 'should return json' do
27
- stub_request(:get, "#{Wakatime::API_URL}/heartbeats")
28
- .with(query: hash_including(:date))
29
- .to_return(body: File.read('./spec/fixtures/heartbeats.json'), status: 200)
26
+ stub_request(:get, "#{Wakatime::API_URL}/users/current/heartbeats")
27
+ .with(query: hash_including(:date))
28
+ .to_return(body: File.read('./spec/fixtures/heartbeats.json'), status: 200)
30
29
 
31
30
  client = Wakatime::Client.new(@session)
32
31
  expect(client.heartbeats.last.time).to eq 1_422_631_940.699831
33
-
34
32
  end
35
33
  end
36
34
  end
@@ -9,16 +9,15 @@ describe Wakatime, skip: true do
9
9
  before do
10
10
  WebMock.allow_net_connect!
11
11
  @session = Wakatime::Session.new(
12
- api_key: ACCOUNT['api_key']
12
+ api_key: ACCOUNT['api_key']
13
13
  )
14
14
 
15
15
  @client = Wakatime::Client.new(@session)
16
-
17
16
  end
18
17
 
19
18
  it 'raises an AuthError if not client auth fails' do
20
19
  session = Wakatime::Session.new(
21
- api_key: 'bad-key'
20
+ api_key: 'bad-key'
22
21
  )
23
22
 
24
23
  @bad_client = Wakatime::Client.new(session)
@@ -26,7 +25,6 @@ describe Wakatime, skip: true do
26
25
  expect { @bad_client.summary }.to raise_error(Wakatime::AuthError)
27
26
  end
28
27
  describe Wakatime::Client do
29
-
30
28
  it 'will return json scoped to specified times' do
31
29
  summary = @client.summary
32
30
  expect(summary).to be_a Wakatime::Models::Summaries
@@ -7,13 +7,11 @@ require 'webmock/rspec'
7
7
 
8
8
  describe Wakatime::Session do
9
9
  before do
10
-
11
10
  @session = Wakatime::Session.new(
12
- api_key: 'Lame Key'
11
+ api_key: 'Lame Key'
13
12
  )
14
13
 
15
14
  @client = Wakatime::Client.new(@session)
16
-
17
15
  end
18
16
 
19
17
  it 'raises a RequestError if a badly formed request detected by the server' do
@@ -32,7 +30,7 @@ describe Wakatime::Session do
32
30
 
33
31
  it 'raises a ServerError if the server raises a 500 error' do
34
32
  stub_request(:get, /.*\/summaries.*/)
35
- .to_return(status: 503, body: '{"type": "error", "status": 503, "message": "We messed up!"}', headers: {})
33
+ .to_return(status: 503, body: '{"type": "error", "status": 503, "message": "We messed up!"}', headers: {})
36
34
  expect { @client.summaries }.to raise_error(Wakatime::ServerError)
37
35
 
38
36
  # make sure status and body is
@@ -40,9 +38,8 @@ describe Wakatime::Session do
40
38
  begin
41
39
  @client.summaries
42
40
  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.
41
+ 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
42
  expect(e.status).to eq 503
45
43
  end
46
-
47
44
  end
48
45
  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.2.0
4
+ version: 0.2.1
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-10-12 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie