github_api 0.11.2 → 0.11.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.
- data/README.md +139 -78
- data/Rakefile +13 -1
- data/features/cassettes/{auths/list.yml → repos/pages/get.yml} +14 -12
- data/features/cassettes/repos/pages/list_builds.yml +63 -0
- data/features/cassettes/repos/pages/list_latest_builds.yml +62 -0
- data/features/repos/pages.feature +24 -0
- data/features/settings.yml +7 -0
- data/lib/github_api.rb +0 -1
- data/lib/github_api/authorizations.rb +55 -41
- data/lib/github_api/authorizations/app.rb +77 -0
- data/lib/github_api/core_ext/array.rb +13 -5
- data/lib/github_api/core_ext/hash.rb +49 -30
- data/lib/github_api/repos.rb +6 -0
- data/lib/github_api/repos/deployments.rb +8 -0
- data/lib/github_api/repos/pages.rb +49 -0
- data/lib/github_api/validations/required.rb +1 -1
- data/lib/github_api/version.rb +1 -1
- data/spec/github/authorizations/app/create_spec.rb +44 -0
- data/spec/github/authorizations/app/delete_spec.rb +59 -0
- data/spec/github/authorizations/create_spec.rb +13 -13
- data/spec/github/authorizations/delete_spec.rb +5 -4
- data/spec/github/core_ext/hash_spec.rb +5 -5
- data/spec/github/normalizer_spec.rb +2 -2
- data/spec/github/parameter_filter_spec.rb +5 -5
- metadata +49 -43
- data/features/authorizations.feature +0 -12
- data/lib/github_api/core_ext/deep_merge.rb +0 -13
- data/lib/github_api/ssl_certs/cacert.pem +0 -41
    
        data/README.md
    CHANGED
    
    | @@ -16,7 +16,7 @@ | |
| 16 16 |  | 
| 17 17 | 
             
            A Ruby wrapper for the GitHub REST API v3.
         | 
| 18 18 |  | 
| 19 | 
            -
            Supports all the API methods | 
| 19 | 
            +
            Supports all the API methods. It's built in a modular way. You can either instantiate the whole API wrapper Github.new or use parts of it i.e. Github::Repos.new if working solely with repositories is your main concern.
         | 
| 20 20 |  | 
| 21 21 | 
             
            ## Features
         | 
| 22 22 |  | 
| @@ -31,7 +31,7 @@ Supports all the API methods (nearly 200). It's built in a modular way. You can | |
| 31 31 | 
             
            * Supports multithreaded environment.
         | 
| 32 32 | 
             
            * Custom media type specification through the 'media' parameter. [media](#media-types)
         | 
| 33 33 | 
             
            * Request results caching (Status: TODO)
         | 
| 34 | 
            -
            * Fully tested with test coverage above 90% with over 1, | 
| 34 | 
            +
            * Fully tested with test coverage above 90% with over 1,700 specs and 1000 features. [testing](#testing)
         | 
| 35 35 |  | 
| 36 36 | 
             
            ## Installation
         | 
| 37 37 |  | 
| @@ -47,7 +47,26 @@ or put it in your Gemfile and run `bundle install` | |
| 47 47 | 
             
            gem "github_api"
         | 
| 48 48 | 
             
            ```
         | 
| 49 49 |  | 
| 50 | 
            -
            ##  | 
| 50 | 
            +
            ## Contents
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            * [1. Usage](#1-usage)
         | 
| 53 | 
            +
            * [2. Arguments & Parameters](#2-arguments--parameters)
         | 
| 54 | 
            +
            * [3. Advanced Configuration](#3-advanced-configuration)
         | 
| 55 | 
            +
            * [4. Authentication](#4-authentication)
         | 
| 56 | 
            +
            * [5. SSL](#5-ssl)
         | 
| 57 | 
            +
            * [6. API](#6-api)
         | 
| 58 | 
            +
            * [7. Media Types](#7-media-types)
         | 
| 59 | 
            +
            * [8. Hypermeida](#8-hypermedia)
         | 
| 60 | 
            +
            * [9. Configuration](#9-configurations)
         | 
| 61 | 
            +
            * [10. Pagination](#10-pagination)
         | 
| 62 | 
            +
            * [11. Caching](#11-caching)
         | 
| 63 | 
            +
            * [12. Debugging](#12-debugging)
         | 
| 64 | 
            +
            * [13. Error Handling](#13-error-handling)
         | 
| 65 | 
            +
            * [14. Response Message](#14-response-message)
         | 
| 66 | 
            +
            * [15. Examples](#15-examples)
         | 
| 67 | 
            +
            * [16. Testing](#16-testing)
         | 
| 68 | 
            +
             | 
| 69 | 
            +
            ## 1 Usage
         | 
| 51 70 |  | 
| 52 71 | 
             
            To start using the gem, you can either perform direct calls on `Github`
         | 
| 53 72 |  | 
| @@ -61,6 +80,8 @@ or create a new client instance | |
| 61 80 | 
             
            github = Github.new
         | 
| 62 81 | 
             
            ```
         | 
| 63 82 |  | 
| 83 | 
            +
            ### 1.1 Options
         | 
| 84 | 
            +
             | 
| 64 85 | 
             
            At this stage, you can also supply various configuration parameters, such as
         | 
| 65 86 | 
             
            ```
         | 
| 66 87 | 
             
              adapter          # http client used for performing requests
         | 
| @@ -108,6 +129,8 @@ or using a convenience method: | |
| 108 129 | 
             
            github = Github.new basic_auth: 'login:password'
         | 
| 109 130 | 
             
            ```
         | 
| 110 131 |  | 
| 132 | 
            +
            ### 1.2 API navigation
         | 
| 133 | 
            +
             | 
| 111 134 | 
             
            This gem closely mirrors the GitHub API hierarchy i.e. if you want to create a download resource,
         | 
| 112 135 | 
             
            look up the GitHub API spec and issue the request as in `github.repos.downloads.create`
         | 
| 113 136 |  | 
| @@ -119,6 +142,8 @@ github.repos.hooks.create 'user-name', 'repo-name', name: "web", active: true | |
| 119 142 | 
             
            github.repos.keys.get     'user-name', 'repo-name'
         | 
| 120 143 | 
             
            ```
         | 
| 121 144 |  | 
| 145 | 
            +
            ### 1.3 Modularity
         | 
| 146 | 
            +
             | 
| 122 147 | 
             
            The code base is modular and allows for you to work specifically with a given part of GitHub API e.g. blobs
         | 
| 123 148 |  | 
| 124 149 | 
             
            ```ruby
         | 
| @@ -126,18 +151,19 @@ blobs = Github::GitData::Blobs.new | |
| 126 151 | 
             
            blobs.create 'peter-murach', 'github', content: 'Blob content'
         | 
| 127 152 | 
             
            ```
         | 
| 128 153 |  | 
| 154 | 
            +
            ### 1.4 Response querying
         | 
| 129 155 | 
             
            The response is of type [Github::ResponseWrapper] which allows traversing all the json response attributes like method calls i.e.
         | 
| 130 156 |  | 
| 131 157 | 
             
            ```ruby
         | 
| 132 | 
            -
            repos = Github::Repos.new : | 
| 158 | 
            +
            repos = Github::Repos.new user: 'peter-murach', repo: 'github'
         | 
| 133 159 | 
             
            repos.branches do |branch|
         | 
| 134 160 | 
             
              puts branch.name
         | 
| 135 161 | 
             
            end
         | 
| 136 162 | 
             
            ```
         | 
| 137 163 |  | 
| 138 | 
            -
            ## Arguments & Parameters
         | 
| 164 | 
            +
            ## 2 Arguments & Parameters
         | 
| 139 165 |  | 
| 140 | 
            -
            The library allows for flexible argument parsing. Therefore, arguments can be passed during instance creation:
         | 
| 166 | 
            +
            The **GithubAPI** library allows for flexible argument parsing. Therefore, arguments can be passed during instance creation:
         | 
| 141 167 |  | 
| 142 168 | 
             
            ```ruby
         | 
| 143 169 | 
             
              issues = Github::Issues.new user: 'peter-murach', repo: 'github'
         | 
| @@ -178,7 +204,7 @@ Finally, use the `with` scope to clearly denote your requests | |
| 178 204 |  | 
| 179 205 | 
             
            ```ruby
         | 
| 180 206 | 
             
              issues = Github::Issues.new
         | 
| 181 | 
            -
              issues.milestones.with(user:'peter-murach', repo: 'github').list
         | 
| 207 | 
            +
              issues.milestones.with(user: 'peter-murach', repo: 'github').list
         | 
| 182 208 | 
             
            ```
         | 
| 183 209 |  | 
| 184 210 | 
             
            Some API methods apart from required parameters such as username, repository name
         | 
| @@ -202,7 +228,7 @@ github.git_data.trees.get 'peter-murach', 'github', 'c18647b75d72f19c1e0cc8af031 | |
| 202 228 | 
             
            end
         | 
| 203 229 | 
             
            ```
         | 
| 204 230 |  | 
| 205 | 
            -
            ## Advanced Configuration
         | 
| 231 | 
            +
            ## 3 Advanced Configuration
         | 
| 206 232 |  | 
| 207 233 | 
             
            The `github_api` gem will use the default middleware stack which is exposed by calling `stack` on a client instance. However, this stack can be freely modified with methods such as `insert`, `insert_after`, `delete` and `swap`. For instance, to add your `CustomMiddleware` do
         | 
| 208 234 |  | 
| @@ -225,71 +251,32 @@ github = Github.new do |config| | |
| 225 251 | 
             
            end
         | 
| 226 252 | 
             
            ```
         | 
| 227 253 |  | 
| 254 | 
            +
            ## 4 Authentication
         | 
| 228 255 |  | 
| 229 | 
            -
             | 
| 256 | 
            +
            ### 4.1 Basic
         | 
| 230 257 |  | 
| 231 | 
            -
             | 
| 258 | 
            +
            To start making requests as authenticated user you can use your GitHub username and password like so
         | 
| 232 259 |  | 
| 233 260 | 
             
            ```ruby
         | 
| 234 | 
            -
            Github | 
| 235 | 
            -
             | 
| 236 | 
            -
            Github::Gists           Github::GitData    Github::Repos             Github::Search
         | 
| 237 | 
            -
            Github::Orgs            Github::Issues     Github::Authorizations
         | 
| 238 | 
            -
            Github::PullRequests    Github::Users      Github::Activity
         | 
| 261 | 
            +
            Github.new basic_auth: 'login:password'
         | 
| 239 262 | 
             
            ```
         | 
| 240 263 |  | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 243 | 
            -
            ```ruby
         | 
| 244 | 
            -
            Github::Users::Emails
         | 
| 245 | 
            -
            Github::Users::Keys
         | 
| 246 | 
            -
            ```
         | 
| 247 | 
            -
             | 
| 248 | 
            -
            All method calls form Ruby like sentences and allow for intuitive API navigation, for instance
         | 
| 249 | 
            -
             | 
| 250 | 
            -
            ```ruby
         | 
| 251 | 
            -
            github = Github.new :oauth_token => '...'
         | 
| 252 | 
            -
            github.users.followers.following 'wycats'  # => returns users that 'wycats' is following
         | 
| 253 | 
            -
            github.users.followers.following? 'wycats' # => returns true if following, otherwise false
         | 
| 254 | 
            -
            ```
         | 
| 255 | 
            -
             | 
| 256 | 
            -
            For specifications on all available methods, go to http://developer.github.com/v3/ or
         | 
| 257 | 
            -
            read the rdoc. All methods are documented there with examples of usage.
         | 
| 258 | 
            -
             | 
| 259 | 
            -
            Alternatively, you can find out which methods are supported by calling `actions` on a class instance in your `irb`:
         | 
| 264 | 
            +
            Though this method is convenient you should strongly consider using `OAuth` for improved security reasons.
         | 
| 260 265 |  | 
| 261 | 
            -
             | 
| 262 | 
            -
            >> Github::Repos.actions                    >> github.issues.actions
         | 
| 263 | 
            -
            ---                                         ---
         | 
| 264 | 
            -
            |--> all                                    |--> all
         | 
| 265 | 
            -
            |--> branches                               |--> comments
         | 
| 266 | 
            -
            |--> collaborators                          |--> create
         | 
| 267 | 
            -
            |--> commits                                |--> edit
         | 
| 268 | 
            -
            |--> contribs                               |--> events
         | 
| 269 | 
            -
            |--> contributors                           |--> find
         | 
| 270 | 
            -
            |--> create                                 |--> get
         | 
| 271 | 
            -
            |--> downloads                              |--> labels
         | 
| 272 | 
            -
            |--> edit                                   |--> list
         | 
| 273 | 
            -
            |--> find                                   |--> list_repo
         | 
| 274 | 
            -
            |--> forks                                  |--> list_repository
         | 
| 275 | 
            -
            |--> get                                    |--> milestones
         | 
| 276 | 
            -
            |--> hooks                                  ...
         | 
| 277 | 
            -
            ...
         | 
| 278 | 
            -
            ```
         | 
| 266 | 
            +
            ### 4.2 Application OAuth access
         | 
| 279 267 |  | 
| 280 | 
            -
             | 
| 268 | 
            +
            In order to authenticate your app through OAuth2 on GitHub you need to
         | 
| 281 269 |  | 
| 282 | 
            -
             | 
| 283 | 
            -
             | 
| 284 | 
            -
            * visit https://github.com/settings/applications/new and register your app
         | 
| 270 | 
            +
            * Visit https://github.com/settings/applications/new and register your app.
         | 
| 285 271 | 
             
              You will need to be logged in to initially register the application.
         | 
| 286 272 |  | 
| 287 | 
            -
            *  | 
| 288 | 
            -
             | 
| 273 | 
            +
            * Authorize your credentials https://github.com/login/oauth/authorize
         | 
| 274 | 
            +
             | 
| 275 | 
            +
            You can use convenience methods to help you achieve this using **GithubAPI** gem:
         | 
| 289 276 |  | 
| 290 277 | 
             
            ```ruby
         | 
| 291 | 
            -
            github = Github.new : | 
| 292 | 
            -
            github.authorize_url : | 
| 278 | 
            +
            github = Github.new client_id: '...', client_secret: '...'
         | 
| 279 | 
            +
            github.authorize_url redirect_uri: 'http://localhost', scope: 'repo'
         | 
| 293 280 | 
             
            # => "https://github.com/login/oauth/authorize?scope=repo&response_type=code&client_id='...'&redirect_uri=http%3A%2F%2Flocalhost"
         | 
| 294 281 | 
             
            ```
         | 
| 295 282 | 
             
            After you get your authorization code, call to receive your access_token
         | 
| @@ -302,18 +289,42 @@ Once you have your access token, configure your github instance following instru | |
| 302 289 |  | 
| 303 290 | 
             
            **Note**: If you are working locally (i.e. your app URL and callback URL are localhost), do not specify a ```:redirect_uri``` otherwise you will get a ```redirect_uri_mismatch``` error.
         | 
| 304 291 |  | 
| 305 | 
            -
            ### Authorizations API
         | 
| 292 | 
            +
            ### 4.3 Authorizations API
         | 
| 293 | 
            +
             | 
| 294 | 
            +
            #### 4.3.1 For an User
         | 
| 306 295 |  | 
| 307 | 
            -
             | 
| 296 | 
            +
            To create an access token through the GitHub Authrizations API, you are required to pass your basic credentials and scopes you wish to have for the authentication token.
         | 
| 308 297 |  | 
| 309 298 | 
             
            ```ruby
         | 
| 310 299 | 
             
            github = Github.new basic_auth: 'login:password'
         | 
| 311 | 
            -
            github.oauth.create  | 
| 300 | 
            +
            github.oauth.create scopes: ['repo']
         | 
| 312 301 | 
             
            ```
         | 
| 313 302 |  | 
| 314 303 | 
             
            You can add more than one scope from the `user`, `public_repo`, `repo`, `gist` or leave the scopes parameter out, in which case, the default read-only access will be assumed (includes public user profile info, public repo info, and gists).
         | 
| 315 304 |  | 
| 316 | 
            -
             | 
| 305 | 
            +
            #### 4.3.2 For an App
         | 
| 306 | 
            +
             | 
| 307 | 
            +
            Furthermore, to create auth token for an application you need to pass `:app` argument together with `:client_id` and `:client_secret` parameters.
         | 
| 308 | 
            +
             | 
| 309 | 
            +
            ```ruby
         | 
| 310 | 
            +
            github = Github.new basic_auth: 'login:password'
         | 
| 311 | 
            +
            github.oauth.app.create 'clinet-id', scopes: ['repo']
         | 
| 312 | 
            +
            ```
         | 
| 313 | 
            +
             | 
| 314 | 
            +
            In order to revoke auth token(s) for an application you must use basic authentication with `client_id` as login and `client_secret` as password.
         | 
| 315 | 
            +
             | 
| 316 | 
            +
            ```ruby
         | 
| 317 | 
            +
            github = Github.new basic_auth: "client_id:client_secret"
         | 
| 318 | 
            +
            github.oauth.app.delete 'client-id'
         | 
| 319 | 
            +
            ```
         | 
| 320 | 
            +
             | 
| 321 | 
            +
            Revoke a specific app token.
         | 
| 322 | 
            +
             | 
| 323 | 
            +
            ```ruby
         | 
| 324 | 
            +
            github.oauth.app.delete 'client-id', 'access-token'
         | 
| 325 | 
            +
            ```
         | 
| 326 | 
            +
             | 
| 327 | 
            +
            ### 4.4 Scopes
         | 
| 317 328 |  | 
| 318 329 | 
             
            You can check OAuth scopes you have by:
         | 
| 319 330 |  | 
| @@ -332,7 +343,7 @@ To list the scopes that the particular GitHub API action checks for do: | |
| 332 343 |  | 
| 333 344 | 
             
            To understand what each scope means refer to [documentation](http://developer.github.com/v3/oauth/#scopes)
         | 
| 334 345 |  | 
| 335 | 
            -
            ## SSL
         | 
| 346 | 
            +
            ## 5 SSL
         | 
| 336 347 |  | 
| 337 348 | 
             
            By default requests over SSL are set to OpenSSL::SSL::VERIFY_PEER. However, you can turn off peer verification by
         | 
| 338 349 |  | 
| @@ -354,7 +365,58 @@ If your client fails to find CA certs, you can pass other SSL options to specify | |
| 354 365 | 
             
            For instance, download CA root certificates from Mozilla [cacert](http://curl.haxx.se/ca/cacert.pem) and point ca_file at your certificate bundle location.
         | 
| 355 366 | 
             
            This will allow the client to verify the github.com ssl certificate as authentic.
         | 
| 356 367 |  | 
| 357 | 
            -
            ##  | 
| 368 | 
            +
            ## 6 API
         | 
| 369 | 
            +
             | 
| 370 | 
            +
            Main API methods are grouped into the following classes that can be instantiated on their own
         | 
| 371 | 
            +
             | 
| 372 | 
            +
            ```ruby
         | 
| 373 | 
            +
            Github         - full API access
         | 
| 374 | 
            +
             | 
| 375 | 
            +
            Github::Gists           Github::GitData    Github::Repos             Github::Search
         | 
| 376 | 
            +
            Github::Orgs            Github::Issues     Github::Authorizations
         | 
| 377 | 
            +
            Github::PullRequests    Github::Users      Github::Activity
         | 
| 378 | 
            +
            ```
         | 
| 379 | 
            +
             | 
| 380 | 
            +
            Some parts of GitHub API v3 require you to be authenticated, for instance the following are examples of APIs only for the authenticated user
         | 
| 381 | 
            +
             | 
| 382 | 
            +
            ```ruby
         | 
| 383 | 
            +
            Github::Users::Emails
         | 
| 384 | 
            +
            Github::Users::Keys
         | 
| 385 | 
            +
            ```
         | 
| 386 | 
            +
             | 
| 387 | 
            +
            All method calls form Ruby like sentences and allow for intuitive API navigation, for instance
         | 
| 388 | 
            +
             | 
| 389 | 
            +
            ```ruby
         | 
| 390 | 
            +
            github = Github.new :oauth_token => '...'
         | 
| 391 | 
            +
            github.users.followers.following 'wycats'  # => returns users that 'wycats' is following
         | 
| 392 | 
            +
            github.users.followers.following? 'wycats' # => returns true if following, otherwise false
         | 
| 393 | 
            +
            ```
         | 
| 394 | 
            +
             | 
| 395 | 
            +
            For specifications on all available methods, go to http://developer.github.com/v3/ or
         | 
| 396 | 
            +
            read the rdoc. All methods are documented there with examples of usage.
         | 
| 397 | 
            +
             | 
| 398 | 
            +
            Alternatively, you can find out which methods are supported by calling `actions` on a class instance in your `irb`:
         | 
| 399 | 
            +
             | 
| 400 | 
            +
            ```ruby
         | 
| 401 | 
            +
            >> Github::Repos.actions                    >> github.issues.actions
         | 
| 402 | 
            +
            ---                                         ---
         | 
| 403 | 
            +
            |--> all                                    |--> all
         | 
| 404 | 
            +
            |--> branches                               |--> comments
         | 
| 405 | 
            +
            |--> collaborators                          |--> create
         | 
| 406 | 
            +
            |--> commits                                |--> edit
         | 
| 407 | 
            +
            |--> contribs                               |--> events
         | 
| 408 | 
            +
            |--> contributors                           |--> find
         | 
| 409 | 
            +
            |--> create                                 |--> get
         | 
| 410 | 
            +
            |--> downloads                              |--> labels
         | 
| 411 | 
            +
            |--> edit                                   |--> list
         | 
| 412 | 
            +
            |--> find                                   |--> list_repo
         | 
| 413 | 
            +
            |--> forks                                  |--> list_repository
         | 
| 414 | 
            +
            |--> get                                    |--> milestones
         | 
| 415 | 
            +
            |--> hooks                                  ...
         | 
| 416 | 
            +
            ...
         | 
| 417 | 
            +
            ```
         | 
| 418 | 
            +
             | 
| 419 | 
            +
            ## 7 Media Types
         | 
| 358 420 |  | 
| 359 421 | 
             
            You can specify custom media types to choose the format of the data you wish to receive. To make things easier you can specify the following shortcuts
         | 
| 360 422 | 
             
            `json`, `blob`, `raw`, `text`, `html`, `full`. For instance:
         | 
| @@ -374,12 +436,11 @@ Finally, you can always pass the whole accept header like so | |
| 374 436 | 
             
            github.issues.get 'peter-murach', 'github', 108, accept: 'application/vnd.github.raw'
         | 
| 375 437 | 
             
            ```
         | 
| 376 438 |  | 
| 377 | 
            -
            ## Hypermedia
         | 
| 439 | 
            +
            ## 8 Hypermedia
         | 
| 378 440 |  | 
| 379 | 
            -
            TODO | 
| 380 | 
            -
            Github::Resource for each *_url key
         | 
| 441 | 
            +
            TODO
         | 
| 381 442 |  | 
| 382 | 
            -
            ## Configuration
         | 
| 443 | 
            +
            ## 9 Configuration
         | 
| 383 444 |  | 
| 384 445 | 
             
            Certain methods require authentication. To get your GitHub OAuth v2 credentials,
         | 
| 385 446 | 
             
            register an app at https://github.com/settings/applications/
         | 
| @@ -402,7 +463,7 @@ All parameters can be overwritten each method call by passing a parameters hash. | |
| 402 463 |  | 
| 403 464 | 
             
            By default, no caching will be performed. In order to set the cache do... If no cache type is provided, a default memoization is done.
         | 
| 404 465 |  | 
| 405 | 
            -
            ## Pagination
         | 
| 466 | 
            +
            ## 10 Pagination
         | 
| 406 467 |  | 
| 407 468 | 
             
            Any request that returns multiple items will be paginated to 30 items by default. You can specify custom `page` and `per_page` query parameters to alter default behavior. For instance:
         | 
| 408 469 |  | 
| @@ -464,15 +525,15 @@ res.prev_page    # Get previous page | |
| 464 525 | 
             
            res.last_page    # Get last page
         | 
| 465 526 | 
             
            ```
         | 
| 466 527 |  | 
| 467 | 
            -
             | 
| 528 | 
            +
            ## 11 Caching
         | 
| 468 529 |  | 
| 469 530 | 
             
            TODO: explaing how to add faraday-cache midlleware
         | 
| 470 531 |  | 
| 471 | 
            -
             | 
| 532 | 
            +
            ## 12 Debugging
         | 
| 472 533 |  | 
| 473 534 | 
             
            run with ENV['DEBUG'] flag  or include middleware by passing `debug` flag
         | 
| 474 535 |  | 
| 475 | 
            -
            ## Error Handling
         | 
| 536 | 
            +
            ## 13 Error Handling
         | 
| 476 537 |  | 
| 477 538 | 
             
            The generic error class `Github::Error::GithubError` will handle both the client (`Github::Error::ClientError`) and service (`Github::Error::ServiceError`) side errors. For instance in your code you can catch errors like
         | 
| 478 539 |  | 
| @@ -490,7 +551,7 @@ rescue Github::Error::GithubError => e | |
| 490 551 | 
             
            end
         | 
| 491 552 | 
             
            ```
         | 
| 492 553 |  | 
| 493 | 
            -
            ## Response Message
         | 
| 554 | 
            +
            ## 14 Response Message
         | 
| 494 555 |  | 
| 495 556 | 
             
            Each response comes packaged with methods allowing for inspection of HTTP start line and headers. For example, to check for rate limits and status codes, call
         | 
| 496 557 |  | 
| @@ -504,7 +565,7 @@ res.headers.etag                # "\"2c5dfc54b3fe498779ef3a9ada9a0af9\"" | |
| 504 565 | 
             
            res.headers.cache_control       # "public, max-age=60, s-maxage=60"
         | 
| 505 566 | 
             
            ```
         | 
| 506 567 |  | 
| 507 | 
            -
            ## Examples
         | 
| 568 | 
            +
            ## 15 Examples
         | 
| 508 569 |  | 
| 509 570 | 
             
            Some API methods require input parameters. These are simply added as a hash of properties, for instance
         | 
| 510 571 |  | 
| @@ -536,7 +597,7 @@ github = Github.new | |
| 536 597 | 
             
            github.orgs.members.member? 'github', 'technoweenie', public: true # => true
         | 
| 537 598 | 
             
            ```
         | 
| 538 599 |  | 
| 539 | 
            -
             | 
| 600 | 
            +
            ### 15.1 Rails Example
         | 
| 540 601 |  | 
| 541 602 | 
             
            A Rails controller that allows a user to authorize their GitHub account and then performs a request.
         | 
| 542 603 |  | 
| @@ -560,7 +621,7 @@ class GithubController < ApplicationController | |
| 560 621 | 
             
            end
         | 
| 561 622 | 
             
            ```
         | 
| 562 623 |  | 
| 563 | 
            -
            ## Testing
         | 
| 624 | 
            +
            ## 16 Testing
         | 
| 564 625 |  | 
| 565 626 | 
             
            The test suite is split into two groups, `live` and `mock`.
         | 
| 566 627 |  | 
    
        data/Rakefile
    CHANGED
    
    | @@ -12,4 +12,16 @@ Cucumber::Rake::Task.new(:features) | |
| 12 12 |  | 
| 13 13 | 
             
            FileList['tasks/**/*.rake'].each { |task| import task }
         | 
| 14 14 |  | 
| 15 | 
            -
            task : | 
| 15 | 
            +
            task default: [:spec, :features]
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            desc 'Run all specs'
         | 
| 18 | 
            +
            task ci: %w[ spec features ]
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            desc 'Load gem inside irb console'
         | 
| 21 | 
            +
            task :console do
         | 
| 22 | 
            +
              require 'irb'
         | 
| 23 | 
            +
              require 'irb/completion'
         | 
| 24 | 
            +
              require File.join(__FILE__, '../lib/github_api')
         | 
| 25 | 
            +
              ARGV.clear
         | 
| 26 | 
            +
              IRB.start
         | 
| 27 | 
            +
            end
         | 
| @@ -2,7 +2,7 @@ | |
| 2 2 | 
             
            http_interactions: 
         | 
| 3 3 | 
             
            - request: 
         | 
| 4 4 | 
             
                method: get
         | 
| 5 | 
            -
                uri: https://<BASIC_AUTH>@api.github.com/ | 
| 5 | 
            +
                uri: https://<BASIC_AUTH>@api.github.com/repos/<USER>/github_api_test/pages?access_token=<TOKEN>
         | 
| 6 6 | 
             
                body: 
         | 
| 7 7 | 
             
                  encoding: US-ASCII
         | 
| 8 8 | 
             
                  string: ""
         | 
| @@ -12,7 +12,7 @@ http_interactions: | |
| 12 12 | 
             
                  Accept-Charset: 
         | 
| 13 13 | 
             
                  - utf-8
         | 
| 14 14 | 
             
                  User-Agent: 
         | 
| 15 | 
            -
                  - Github Ruby Gem 0.11. | 
| 15 | 
            +
                  - Github Ruby Gem 0.11.2
         | 
| 16 16 | 
             
                  Accept-Encoding: 
         | 
| 17 17 | 
             
                  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
         | 
| 18 18 | 
             
              response: 
         | 
| @@ -23,7 +23,7 @@ http_interactions: | |
| 23 23 | 
             
                  Server: 
         | 
| 24 24 | 
             
                  - GitHub.com
         | 
| 25 25 | 
             
                  Date: 
         | 
| 26 | 
            -
                  - Sun,  | 
| 26 | 
            +
                  - Sun, 16 Feb 2014 19:19:10 GMT
         | 
| 27 27 | 
             
                  Content-Type: 
         | 
| 28 28 | 
             
                  - application/json; charset=utf-8
         | 
| 29 29 | 
             
                  Transfer-Encoding: 
         | 
| @@ -33,13 +33,15 @@ http_interactions: | |
| 33 33 | 
             
                  X-Ratelimit-Limit: 
         | 
| 34 34 | 
             
                  - "5000"
         | 
| 35 35 | 
             
                  X-Ratelimit-Remaining: 
         | 
| 36 | 
            -
                  - " | 
| 36 | 
            +
                  - "4985"
         | 
| 37 37 | 
             
                  X-Ratelimit-Reset: 
         | 
| 38 | 
            -
                  - " | 
| 38 | 
            +
                  - "1392579836"
         | 
| 39 39 | 
             
                  Cache-Control: 
         | 
| 40 40 | 
             
                  - private, max-age=60, s-maxage=60
         | 
| 41 | 
            +
                  Last-Modified: 
         | 
| 42 | 
            +
                  - Sun, 16 Feb 2014 19:08:04 GMT
         | 
| 41 43 | 
             
                  Etag: 
         | 
| 42 | 
            -
                  - "\" | 
| 44 | 
            +
                  - "\"db416c75241ecab92cbb45b1addc0279\""
         | 
| 43 45 | 
             
                  Vary: 
         | 
| 44 46 | 
             
                  - Accept, Authorization, Cookie, X-GitHub-OTP
         | 
| 45 47 | 
             
                  - Accept-Encoding
         | 
| @@ -54,16 +56,16 @@ http_interactions: | |
| 54 56 | 
             
                  Access-Control-Allow-Origin: 
         | 
| 55 57 | 
             
                  - "*"
         | 
| 56 58 | 
             
                  X-Github-Request-Id: 
         | 
| 57 | 
            -
                  - 4D649864: | 
| 59 | 
            +
                  - 4D649864:3BA3:2B05E2C:53010F2D
         | 
| 58 60 | 
             
                  Content-Encoding: 
         | 
| 59 61 | 
             
                  - gzip
         | 
| 60 62 | 
             
                body: 
         | 
| 61 63 | 
             
                  encoding: ASCII-8BIT
         | 
| 62 | 
            -
                  string: !binary  | 
| 63 | 
            -
                     | 
| 64 | 
            -
                     | 
| 65 | 
            -
                     | 
| 64 | 
            +
                  string: !binary |
         | 
| 65 | 
            +
                    H4sIAAAAAAAAAz3KMQqAMAxA0btkLsahUy9TYolVbG1pkkm8u4Lg+B//AhsF
         | 
| 66 | 
            +
                    AmyqXQIi9X3Ku262TKlVHNybYLXBB34c3yMqi2KnzAIORElNIJxWioN0UuU/
         | 
| 67 | 
            +
                    TLTV6GcPYaUifD+TnpLscAAAAA==
         | 
| 66 68 |  | 
| 67 69 | 
             
                http_version: 
         | 
| 68 | 
            -
              recorded_at: Sun,  | 
| 70 | 
            +
              recorded_at: Sun, 16 Feb 2014 19:19:10 GMT
         | 
| 69 71 | 
             
            recorded_with: VCR 2.6.0
         |