Skip to content

Commit

Permalink
Prefix internal options with octo (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Minoru committed Dec 16, 2016
1 parent 3bb8dfc commit 70f2a5b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ GitHub API [paginates](https://en.wikipedia.org/wiki/Pagination) its responses
wherever possible. octo.erl can either fetch all the pages for you in one call
(effectively hiding pagination from you), or it can let you handle it yourself.

To make octo.erl fetch all the pages, read about `all_pages` option below.
To make octo.erl fetch all the pages, read about `octo_all_pages` option below.

If you decided to consume pages one by one, here's how you do it:

Expand Down Expand Up @@ -391,7 +391,7 @@ By default, GitHub returns 30 results per page. To change that to, say, 100
results per page, do the following:

```erlang
Options = [{per_page, 100}],
Options = [{octo_per_page, 100}],
{ok, PullRequests} = octo:read_pull_request(Owner, Repo, Number, Options).
```

Expand All @@ -401,7 +401,7 @@ If you don't want to do the pagination manually, you can provide an option that
resolves all pages automatically:

```erlang
Options = [all_pages],
Options = [octo_all_pages],
{ok, PullRequests} = octo:read_pull_request(Owner, Repo, Number, Options).
```

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/octo_http_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal_read_collection(Url, Options, ProcessingFun, Acc) ->

case Result of
{ok, PrevResult} ->
case proplists:get_value(all_pages, Options) of
case proplists:get_value(octo_all_pages, Options) of
true ->
case octo_pagination_helper:get_url({next, Result}) of
{ok, NextUrl} ->
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/octo_url_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ options_to_query_params(Options) ->

options_to_query_params([], Query) ->
Query;
options_to_query_params([{ per_page, PerPage }|Rest], Query) ->
options_to_query_params([{ octo_per_page, PerPage }|Rest], Query) ->
options_to_query_params(Rest, Query ++ ["per_page=" ++ integer_to_list(PerPage)]);
options_to_query_params([_|Rest], Query) ->
options_to_query_params(Rest, Query).
4 changes: 2 additions & 2 deletions test/octo_http_helper_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pagination_test_() ->

?assertEqual(
{ok, [1,2,3]},
octo_http_helper:read_collection(url, [all_pages], Id)),
octo_http_helper:read_collection(url, [octo_all_pages], Id)),
?assert(meck:validate(hackney))
end,
fun() ->
Expand All @@ -171,6 +171,6 @@ pagination_test_() ->

?assertEqual(
{ok, [1,2,3,4,5,6]},
octo_http_helper:read_collection(url, [all_pages], Id)),
octo_http_helper:read_collection(url, [octo_all_pages], Id)),
?assert(meck:validate(hackney))
end]).
4 changes: 2 additions & 2 deletions test/octo_url_helper_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ options_to_query_params_test_() ->
octo_url_helper:options_to_query_params([])),
?_assertEqual(
"per_page=100",
octo_url_helper:options_to_query_params([{per_page, 100}])),
octo_url_helper:options_to_query_params([{octo_per_page, 100}])),
?_assertEqual(
"per_page=100",
octo_url_helper:options_to_query_params([{per_page, 100}, hi, {haha, 2}]))
octo_url_helper:options_to_query_params([{octo_per_page, 100}, hi, {haha, 2}]))
]}.

pull_request_url_test_() ->
Expand Down

0 comments on commit 70f2a5b

Please sign in to comment.