codecov_api 0.0.0 → 0.0.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: 7b48651bc577638f6224494f15789aff728ecd0c
4
- data.tar.gz: e779ee1c67a6b315e9e2ed5c24367aa440a65b14
3
+ metadata.gz: a04529eef4ca42d7bb269450cdbeb43c481ec45c
4
+ data.tar.gz: ce304d411e169200fef12c0bc8099c9628488163
5
5
  SHA512:
6
- metadata.gz: 3932913c4d32cbd6e856a96b2e6ad9f251c2f2f6a9067a86ae63d46ef00bb6c8a71c82209350915eed08f265fbfbb9d958c1d22070f9ae948cef530d1f5ca495
7
- data.tar.gz: 445d173463e3336be2db93a86d8b1d71a06aa9228c0d89e430dbacb3041821481cddb50e2163e51b0b436a84dc3876a7068f6a5606cffba1da53293427f3e05f
6
+ metadata.gz: d9bffce5ba741e1f489720add28f607039f8c8de739415fc908fb43f965b66ca8d1d899bbc3962be927bb641eed88ae818bf5232d997bb726d612822ada3ead3
7
+ data.tar.gz: 13769b1683d52848000f64f4e42d5c11ae7f40386a6f0873bf8fbdf2a006453b9025a35a38a1b91edf1b1f16247b7bd8ba9139921b83291b898d14377319a9f2
@@ -0,0 +1,3 @@
1
+ # Change Log
2
+ ## 0.0.1 - 2017-02-14
3
+ - Support for CodeCov API v4.3.0 for commits and branches resources only, except delete
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # codecov_api
2
- Unofficial toolset to consume CodeCov's API
2
+ Unofficial toolset to consume CodeCov's API v4.3.0
3
+
4
+ [![Build Status](https://travis-ci.org/snepote/codecov_api.svg?branch=master)](https://travis-ci.org/snepote/codecov_api) [![Gem Version](https://badge.fury.io/rb/codecov_api.svg)](https://badge.fury.io/rb/codecov_api)
3
5
 
4
6
  ## Usage
5
7
  ```bash
@@ -4,18 +4,18 @@ require 'json'
4
4
  module CodecovApi
5
5
  module Api
6
6
  class Base
7
-
8
- protected
7
+ protected
9
8
 
10
9
  def get_request(path)
11
- get_response(base_url + base_path + path)
10
+ response(base_url + base_path + path)
12
11
  end
13
12
 
14
13
  def base_path
15
14
  raise 'base_path method not defined'
16
15
  end
17
16
 
18
- private
17
+ private
18
+
19
19
  def auth_token
20
20
  raise 'CODECOV_AUTH_TOKEN ENV VAR not defined' if ENV['CODECOV_AUTH_TOKEN'].nil?
21
21
  ENV['CODECOV_AUTH_TOKEN']
@@ -25,12 +25,12 @@ module CodecovApi
25
25
  'https://codecov.io/api/gh'
26
26
  end
27
27
 
28
- def get_response(url)
29
- puts "GET #{url}"
28
+ def response(url, method: :get)
29
+ puts "#{method.to_s.upcase} #{url}"
30
30
  RestClient::Request.new(
31
- method: :get,
31
+ method: method,
32
32
  url: url,
33
- headers: { :Authorization => 'token ' + auth_token }
33
+ headers: { Authorization: 'token ' + auth_token }
34
34
  ).execute
35
35
  end
36
36
  end
@@ -20,7 +20,7 @@ module CodecovApi
20
20
  raise 'delete method not implemented'
21
21
  end
22
22
 
23
- protected
23
+ protected
24
24
 
25
25
  def base_path
26
26
  "/#{@owner}/#{@repo}"
@@ -9,8 +9,16 @@ module CodecovApi
9
9
  end
10
10
 
11
11
  def list(from = nil, to = nil)
12
- # todo: add from and to parameters
13
- get_request('/commits')
12
+ uri = '/commits'
13
+ params = { from: from, to: to }.map do |key, value|
14
+ if value.instance_of?(Time)
15
+ "#{key}=#{value.utc.strftime('%F %T')}"
16
+ elsif !value.nil?
17
+ raise 'not a valid time'
18
+ end
19
+ end.compact
20
+ uri = "#{uri}/?#{params.join('&')}" unless params.empty?
21
+ get_request(uri)
14
22
  end
15
23
 
16
24
  def get(sha)
@@ -21,7 +29,7 @@ module CodecovApi
21
29
  get_request("/tree/#{branch}/#{path}")
22
30
  end
23
31
 
24
- protected
32
+ protected
25
33
 
26
34
  def base_path
27
35
  "/#{@owner}/#{@repo}"
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module CodecovApi
3
- VERSION = '0.0.0'
3
+ VERSION = '0.0.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codecov_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Nepote