Skip to content

Commit

Permalink
Merge pull request #18 from danielberkompas/upgrade-exdoc
Browse files Browse the repository at this point in the history
Upgrade ExDoc
  • Loading branch information
danielberkompas committed Sep 20, 2015
2 parents c4adbec + b1fd3b4 commit ed9bcc5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 65 deletions.
64 changes: 1 addition & 63 deletions lib/ex_twilio/resource.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ defmodule ExTwilio.Resource do
The `import` option specifies which methods you want to be able to use.
"""

@doc """
Provide a `use` macro for use extending.
"""
@doc false
defmacro __using__(options) do
import_functions = options[:import] || []
quote bind_quoted: [import_functions: import_functions] do
Expand All @@ -28,20 +26,6 @@ defmodule ExTwilio.Resource do
alias ExTwilio.UrlGenerator, as: Url
alias ExTwilio.ResultStream

module = String.replace(to_string(__MODULE__), ~r/Elixir\./, "")
resource = String.replace(module, ~r/ExTwilio\./, "")
variable = String.downcase(resource) |> Inflex.pluralize
variable_singular = Inflex.singularize(variable)

@doc """
Creates a new #{module} struct. Optionally, you can pass in attributes to
set their initial value in the struct.
## Example
%#{module}{} = #{module}.new
%#{module}{sid: "sid"} = #{module}.new(sid: "sid")
"""
@spec new :: %__MODULE__{}
def new, do: %__MODULE__{}

Expand All @@ -57,76 +41,30 @@ defmodule ExTwilio.Resource do
end

if :stream in import_functions do
@doc """
Create an `ExTwilio.ResultStream` of all #{resource} records from the
Twilio API.
"""
def stream(options \\ []), do: ResultStream.new(__MODULE__, options)
end

if :all in import_functions do
@doc """
Retrieve _all_ of the #{resource} records from the Twilio API, paging
through all the API response pages.
Delegates to `ExTwilio.Api.all/2`.
## Examples
#{variable} = #{module}.all
"""
@spec all(list) :: [map]
def all(options \\ []), do: stream(options) |> Enum.into([])
end

if :find in import_functions do
@doc """
Find any #{resource} by its Twilio SID.
Delegates to `ExTwilio.Api.find/3`.
## Examples
{:ok, #{variable_singular}} = #{module}.find("...")
{:error, msg, http_status} = #{module}.find("...")
"""
@spec find(String.t | nil, list) :: Parser.parsed_list_response
def find(sid, options \\ []), do: Api.find(__MODULE__, sid, options)
end

if :create in import_functions do
@doc """
Create a new #{resource} in the Twilio API. Any field supported by
Twilio's #{resource} API can be passed in the 'data' keyword list.
Delegates to `ExTwilio.Api.create/3`.
"""
@spec create(list, list) :: Parser.parsed_response
def create(data, options \\ []), do: Api.create(__MODULE__, data, options)
end

if :update in import_functions do
@doc """
Update an #{resource} in the Twilio API. You can pass it a binary SID as
the identifier, or a whole %#{module}{} struct.
Delegates to `ExTwilio.Api.update/4`.
## Examples
{:ok, #{variable_singular}} = #{module}.update(%#{module}{...}, field: "new_value")
{:ok, #{variable_singular}} = #{module}.update("<SID HERE>", field: "new_value")
"""
@spec update(String.t, list, list) :: Parser.parsed_response
def update(sid, data, options \\ []), do: Api.update(__MODULE__, sid, data, options)
end

if :destroy in import_functions do
@doc """
Delete any #{resource} from your Twilio account, using its SID.
Delegates to `ExTwilio.Api.destroy/3`.
"""
@spec destroy(String.t, list) :: Parser.success_delete | Parser.error
def destroy(sid, options \\ []), do: Api.destroy(__MODULE__, sid, options)
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ defmodule ExTwilio.Mixfile do
{:poison, "~> 1.4"},
{:inflex, "~> 1.0.0"},
{:mock, "~> 0.1.0", only: :test},
{:ex_doc, "~> 0.7", only: :docs},
{:ex_doc, only: :docs},
{:inch_ex, only: :docs}
]
end
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%{"dotenv": {:hex, :dotenv, "0.0.4"},
"ex_doc": {:hex, :ex_doc, "0.7.2"},
"ex_doc": {:hex, :ex_doc, "0.9.0"},
"hackney": {:hex, :hackney, "1.0.6"},
"httpoison": {:hex, :httpoison, "0.6.2"},
"httpotion": {:hex, :httpotion, "2.1.0"},
Expand Down

0 comments on commit ed9bcc5

Please sign in to comment.