circleci 0.2.2 → 0.2.3

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: 4a8c8dbe2997c816b48f601d71ca462261071db6
4
- data.tar.gz: 65826412f05aca0a009c5e6358c8016b1c54b050
3
+ metadata.gz: 2b593d6e0bcf64fc14fb6ad923be106b6909cbd3
4
+ data.tar.gz: 702ed7c6b41beef442a87c7d1f6ce0139a0fd51e
5
5
  SHA512:
6
- metadata.gz: d6eb8eaf6d13fd82f49274380457ad9f8ee3b653cd7bb1be2a66e2488f8287a08ff0269870e87f6329bc7121361958a3abf1c525f033c5ccd14ec68a0b28435e
7
- data.tar.gz: 2598e61e61c78cddb3bdc1ae834de500075fecf8a55e0d75dbcfb2d6253f20d0b6787b2ffb0766e89149edfbcc1a56b34c2c1546d5a455dfe86d81dac0f44267
6
+ metadata.gz: a13042709bc07021325712265b2060d7b9fa4551bfd78163b90f337d6008c52d77cfe201f11d1a3f3331c3aafe705337e49f6064ca8bb89af870c4c97447772a
7
+ data.tar.gz: b795a0a4b3bbff5acac6b7bd8441e82859ae4e9a696df45b1fc86c189c185de0991c5ccbbf4ce5a478ac788729f94d1c1460df6453dfd292b4bbce9daf7e06e0
data/README.md CHANGED
@@ -44,6 +44,17 @@ CircleCi.configure do |config|
44
44
  end
45
45
  ```
46
46
 
47
+ Overriding request settings such as not verifying SSL
48
+
49
+ ```ruby
50
+ CircleCi.configure do |config|
51
+ config.token = ENV['CIRCLECI_TOKEN']
52
+ config.request_overrides = {
53
+ verify_ssl: false
54
+ }
55
+ end
56
+ ```
57
+
47
58
  ## API Endpoints
48
59
 
49
60
  * [User](#user)
@@ -61,7 +72,7 @@ end
61
72
  * [Get Checkout Key](#get_checkout_key)
62
73
  * [List Checkout Keys](#list_checkout_keys)
63
74
  * [New Checkout Key](#new_checkout_key)
64
- * [Recent Builds](#recent_builds)
75
+ * [Recent Builds](#project_recent_builds)
65
76
  * [Recent Builds Branch](#recent_builds_branch)
66
77
  * [Settings](#settings)
67
78
  * [Set Envvar](#set_envvar)
@@ -73,7 +84,8 @@ end
73
84
  * [Get](#get)
74
85
  * [Retry](#retry)
75
86
  * [Tests](#tests)
76
- * [Organization](#organization)
87
+ * [Recent Builds](#recent_builds)
88
+ * [Get](#recent_builds_get)
77
89
 
78
90
  ### [User](#user)
79
91
 
@@ -516,7 +528,7 @@ Example response
516
528
  }
517
529
  ```
518
530
 
519
- #### [recent_builds](#recent_builds)
531
+ #### [recent_builds](#project_recent_builds)
520
532
 
521
533
  Endpoint: `/project/:username/:repository`
522
534
 
@@ -524,6 +536,13 @@ Build summary for each of the last 30 recent builds, ordered by build_num.
524
536
 
525
537
  ```ruby
526
538
  res = CircleCi::Project.recent_builds 'username', 'reponame'
539
+
540
+ # Use params to filter by status
541
+ # res = CircleCi::Project.recent_builds 'username', 'reponame', filter: 'failed'
542
+
543
+ # Use params to limit and give an offset
544
+ # res = CircleCi::Project.recent_builds 'username', 'reponame', limit: 10, offset: 50
545
+
527
546
  res.success?
528
547
  res.body
529
548
  ```
@@ -977,170 +996,59 @@ res.body
977
996
  ]
978
997
  ```
979
998
 
980
- ### [organization](#organization)
999
+ ### [Recent Builds](#recent_builds)
981
1000
 
982
- Endpoint: `/organization/:name`
1001
+ #### [get](#recent_builds_get)
983
1002
 
984
- Recent builds for an entire organization
1003
+ Endpoint: `/recent-builds`
1004
+
1005
+ Build summary for each of the last 30 recent builds, ordered by build_num.
985
1006
 
986
1007
  ```ruby
987
- res = CircleCi.organization 'my-org'
988
- res.succes?
1008
+ res = CircleCi::RecentBuilds.get
1009
+
1010
+ # Params of limit and offset can be passed in
1011
+ # res = CircleCi::RecentBuilds.get limit: 10, offset: 50
1012
+
1013
+ res.success?
989
1014
  res.body
990
1015
  ```
991
1016
 
992
1017
  ```javascript
993
- [
994
- {
995
- "dont_build":null,
996
- "committer_name":"Chavez",
997
- "usage_queued_at":"2014-04-12T10:29:59.352Z",
998
- "branch":"master",
999
- "body":"Update Missing ''e'' in CircleCi in README.md",
1000
- "author_date":"2014-03-12T23:14:53Z",
1001
- "node":[
1002
- {
1003
- "username":"ubuntu",
1004
- "ssh_enabled":null,
1005
- "port":64721,
1006
- "public_ip_addr":"54.82.224.94"
1007
- }
1008
- ],
1009
- "committer_date":"2014-03-12T23:14:53Z",
1010
- "compare":null,
1011
- "retries":null,
1012
- "parallel":1,
1013
- "committer_email":"mtchavez@users.noreply.github.com",
1014
- "build_time_millis":16308,
1015
- "why":"retry",
1016
- "author_email":"mtchavez@users.noreply.github.com",
1017
- "ssh_enabled":null,
1018
- "start_time":"2014-04-12T10:29:59.587Z",
1019
- "stop_time":"2014-04-12T10:30:15.895Z",
1020
- "lifecycle":"finished",
1021
- "user":{
1022
- "is_user":true,
1023
- "login":"hwartig",
1024
- "name":"Harald Wartig",
1025
- "email":"hwartig@users.noreply.github.com"
1026
- },
1027
- "subject":"Merge pull request #4 from Alex-Poon/master",
1028
- "messages":[
1029
-
1030
- ],
1031
- "job_name":null,
1032
- "retry_of":1,
1033
- "previous_successful_build":{
1034
- "build_time_millis":37685,
1035
- "status":"success",
1036
- "build_num":1
1037
- },
1038
- "outcome":"success",
1039
- "status":"success",
1040
- "vcs_revision":"f33617404dc392ddd676fdde87cd5c87369e1857",
1041
- "build_num":2,
1042
- "username":"hwartigcom",
1043
- "vcs_url":"https://github.com/hwartigcom/circleci",
1044
- "timedout":false,
1045
- "previous":{
1046
- "build_time_millis":37685,
1047
- "status":"success",
1048
- "build_num":1
1049
- },
1050
- "canceled":false,
1051
- "infrastructure_fail":false,
1052
- "failed":null,
1053
- "reponame":"circleci",
1054
- "build_url":"https://circleci.com/gh/hwartigcom/circleci/2",
1055
- "feature_flags":{
1056
-
1057
- },
1058
- "author_name":"Chavez",
1059
- "queued_at":"2014-04-12T10:29:59.517Z"
1060
- },
1061
- {
1062
- "dont_build":null,
1063
- "committer_name":"Chavez",
1064
- "usage_queued_at":"2014-04-08T06:58:09.522Z",
1065
- "branch":"master",
1066
- "body":"Update Missing ''e'' in CircleCi in README.md",
1067
- "author_date":"2014-03-12T23:14:53Z",
1068
- "node":[
1069
- {
1070
- "username":"ubuntu",
1071
- "ssh_enabled":null,
1072
- "port":64775,
1073
- "public_ip_addr":"54.198.9.232"
1074
- }
1075
- ],
1076
- "committer_date":"2014-03-12T23:14:53Z",
1077
- "compare":null,
1078
- "retries":[
1079
- 2
1080
- ],
1081
- "parallel":1,
1082
- "committer_email":"mtchavez@users.noreply.github.com",
1083
- "build_time_millis":37685,
1084
- "why":"first-build",
1085
- "author_email":"mtchavez@users.noreply.github.com",
1086
- "ssh_enabled":null,
1087
- "start_time":"2014-04-08T06:58:09.868Z",
1088
- "stop_time":"2014-04-08T06:58:47.553Z",
1089
- "lifecycle":"finished",
1090
- "user":{
1091
- "is_user":true,
1092
- "login":"hwartig",
1093
- "name":"Harald Wartig",
1094
- "email":"hwartig@users.noreply.github.com"
1095
- },
1096
- "subject":"Merge pull request #4 from Alex-Poon/master",
1097
- "messages":[
1098
-
1099
- ],
1100
- "job_name":null,
1101
- "retry_of":null,
1102
- "previous_successful_build":null,
1103
- "outcome":"success",
1104
- "status":"success",
1105
- "vcs_revision":"f33617404dc392ddd676fdde87cd5c87369e1857",
1106
- "build_num":1,
1107
- "username":"hwartigcom",
1108
- "vcs_url":"https://github.com/hwartigcom/circleci",
1109
- "timedout":false,
1110
- "previous":null,
1111
- "all_commit_details":[
1112
- {
1113
- "committer_name":"Chavez",
1114
- "body":"Update Missing ''e'' in CircleCi in README.md",
1115
- "author_date":"2014-03-12T23:14:53Z",
1116
- "committer_date":"2014-03-12T23:14:53Z",
1117
- "commit_url":"https://github.com/hwartigcom/circleci/commit/f33617404dc392ddd676fdde87cd5c87369e1857",
1118
- "committer_email":"mtchavez@users.noreply.github.com",
1119
- "author_email":"mtchavez@users.noreply.github.com",
1120
- "subject":"Merge pull request #4 from Alex-Poon/master",
1121
- "commit":"f33617404dc392ddd676fdde87cd5c87369e1857",
1122
- "author_name":"Chavez"
1123
- }
1124
- ],
1125
- "canceled":false,
1126
- "infrastructure_fail":false,
1127
- "failed":null,
1128
- "reponame":"circleci",
1129
- "build_url":"https://circleci.com/gh/hwartigcom/circleci/1",
1130
- "feature_flags":{
1131
-
1132
- },
1133
- "author_name":"Chavez",
1134
- "queued_at":"2014-04-08T06:58:09.739Z"
1135
- }
1136
- ]
1018
+ [ {
1019
+ "vcs_url" : "https://github.com/circleci/mongofinil",
1020
+ "build_url" : "https://circleci.com/gh/circleci/mongofinil/22",
1021
+ "build_num" : 22,
1022
+ "branch" : "master",
1023
+ "vcs_revision" : "1d231626ba1d2838e599c5c598d28e2306ad4e48",
1024
+ "committer_name" : "Allen Rohner",
1025
+ "committer_email" : "arohner@gmail.com",
1026
+ "subject" : "Don't explode when the system clock shifts backwards",
1027
+ "body" : "", // commit message body
1028
+ "why" : "github", // short string explaining the reason we built
1029
+ "dont_build" : null, // reason why we didn't build, if we didn't build
1030
+ "queued_at" : "2013-02-12T21:33:30Z" // time build was queued
1031
+ "start_time" : "2013-02-12T21:33:38Z", // time build started
1032
+ "stop_time" : "2013-02-12T21:34:01Z", // time build finished
1033
+ "build_time_millis" : 23505,
1034
+ "username" : "circleci",
1035
+ "reponame" : "mongofinil",
1036
+ "lifecycle" : "finished", // :queued, :scheduled, :not_run, :not_running, :running or :finished
1037
+ "outcome" : "failed", // :canceled, :infrastructure_fail, :timedout, :failed, :no_tests or :success
1038
+ "status" : "failed", // :retried, :canceled, :infrastructure_fail, :timedout, :not_run, :running, :failed, :queued, :scheduled, :not_running, :no_tests, :fixed, :success
1039
+ "retry_of" : null, // build_num of the build this is a retry of
1040
+ "previous" : { // previous build
1041
+ "status" : "failed",
1042
+ "build_num" : 21
1043
+ }, ... ]
1137
1044
  ```
1138
1045
 
1139
1046
  ### Tests
1140
1047
 
1141
1048
  Tests are ran using Rspec and VCR for API interaction recording.
1142
1049
  Run using `rake` or `rspec`. Please add tests for any new features or
1143
- endpoints added if you are contributing.
1050
+ endpoints added if you are contributing. Code styling is enforced with RuboCop
1051
+ and uses a checked in `.rubocop.yml` for this project.
1144
1052
 
1145
1053
  Tests are using a live CircleCi API token for this repository. Any tests
1146
1054
  should be using this key, which is in the `.env` file. You should not have
@@ -7,6 +7,7 @@ files = %w[
7
7
  config
8
8
  http
9
9
  project
10
+ recent_builds
10
11
  request_error
11
12
  response
12
13
  user
@@ -42,18 +43,4 @@ module CircleCi
42
43
  def http # @private
43
44
  Http.new(config)
44
45
  end
45
-
46
- ##
47
- #
48
- # Get recent builds for an organization
49
- #
50
- # @param name [String] Name of the organization. Currently CircleCi treats
51
- # the name case sensetive so make sure the spelling is the same
52
- # as the github organisation.
53
- # @param params [Hash] Additional query params.
54
- # @return [CircleCi::Response] - Response object.
55
-
56
- def organization(name, params = {})
57
- http.get "/organization/#{name}", params
58
- end
59
46
  end
@@ -9,7 +9,7 @@ module CircleCi
9
9
  DEFAULT_URI = "#{DEFAULT_HOST}/api/#{DEFAULT_VERSION}".freeze
10
10
  DEFAULT_PORT = 80
11
11
 
12
- attr_accessor :token, :host, :port, :version
12
+ attr_accessor :token, :host, :port, :request_overrides, :version
13
13
 
14
14
  ##
15
15
  #
@@ -19,6 +19,7 @@ module CircleCi
19
19
  @host = DEFAULT_HOST
20
20
  @port = DEFAULT_PORT
21
21
  @version = DEFAULT_VERSION
22
+ @request_overrides = {}
22
23
  end
23
24
 
24
25
  def uri
@@ -36,15 +36,20 @@ module CircleCi
36
36
  end
37
37
 
38
38
  def create_request_args(http_verb, url, body)
39
- return [http_verb, url, body, headers] if http_verb == 'post'
40
- [http_verb, url, headers]
39
+ args = {
40
+ method: http_verb.to_sym,
41
+ url: url,
42
+ headers: headers }
43
+ args[:payload] = body if http_verb == 'post'
44
+ args.merge!(@config.request_overrides)
45
+ args
41
46
  end
42
47
 
43
48
  def request(http_verb, path, body = {})
44
49
  url = "#{@config.uri}#{path}"
45
50
  args = create_request_args http_verb, url, body
46
51
 
47
- RestClient.send(*args) do |res, _, raw_res|
52
+ RestClient::Request.execute(args) do |res, _, raw_res|
48
53
  body = res.body.to_s
49
54
  body.force_encoding(Encoding::UTF_8)
50
55
  code = raw_res.code.to_i
@@ -177,10 +177,11 @@ module CircleCi
177
177
  #
178
178
  # @param username [String] - User or org name who owns project
179
179
  # @param project [String] - Name of project
180
+ # @param params [Hash] - Parameters for builds (limit, offset, filter)
180
181
  # @return [CircleCi::Response] - Response object
181
182
 
182
- def self.recent_builds(username, project)
183
- CircleCi.http.get "/project/#{username}/#{project}"
183
+ def self.recent_builds(username, project, params = {})
184
+ CircleCi.http.get "/project/#{username}/#{project}", params
184
185
  end
185
186
 
186
187
  ##
@@ -0,0 +1,17 @@
1
+ module CircleCi
2
+ ##
3
+ #
4
+ # Class for interacting with recent builds
5
+ class RecentBuilds
6
+ ##
7
+ #
8
+ # Get get recent builds for your account
9
+ #
10
+ # @param params [Hash] - Params to send for recent builds (limit, offset)
11
+ # @return [CircleCi::Response] - Response object
12
+
13
+ def self.get(params = {})
14
+ CircleCi.http.get '/recent-builds', params
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circleci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chavez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-26 00:00:00.000000000 Z
11
+ date: 2016-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -317,6 +317,7 @@ files:
317
317
  - lib/circleci/config.rb
318
318
  - lib/circleci/http.rb
319
319
  - lib/circleci/project.rb
320
+ - lib/circleci/recent_builds.rb
320
321
  - lib/circleci/request_error.rb
321
322
  - lib/circleci/response.rb
322
323
  - lib/circleci/user.rb