hexsha
stringlengths
40
40
size
int64
2
991k
ext
stringclasses
2 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
208
max_stars_repo_name
stringlengths
6
106
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
sequence
max_stars_count
int64
1
33.5k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
208
max_issues_repo_name
stringlengths
6
106
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
sequence
max_issues_count
int64
1
16.3k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
208
max_forks_repo_name
stringlengths
6
106
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
sequence
max_forks_count
int64
1
6.91k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
2
991k
avg_line_length
float64
1
36k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
79b32d0a1a7ba31c8d342eae53bfe2f3d0776d6e
692
exs
Elixir
test/changelog/policies/default_test.exs
lawik/changelog.com
3f0b6ceb6ba723df9b21164114fbc208509e9c12
[ "MIT" ]
null
null
null
test/changelog/policies/default_test.exs
lawik/changelog.com
3f0b6ceb6ba723df9b21164114fbc208509e9c12
[ "MIT" ]
null
null
null
test/changelog/policies/default_test.exs
lawik/changelog.com
3f0b6ceb6ba723df9b21164114fbc208509e9c12
[ "MIT" ]
null
null
null
defmodule Changelog.Policies.DefaultTest do use Changelog.PolicyCase defmodule TestPolicy, do: use(Changelog.Policies.Default) test "nobody can new/create" do for actor <- @all do refute TestPolicy.create(actor) end end test "nobody can index" do for actor <- @all do refute TestPolicy.index(actor) end end test "nobody can show" do for actor <- @all do refute TestPolicy.show(actor, %{}) end end test "nobody can edit/update" do for actor <- @all do refute TestPolicy.edit(actor, %{}) end end test "nobody can delete" do for actor <- @all do refute TestPolicy.delete(actor, %{}) end end end
19.222222
59
0.644509
79b333fcdcde564c980dfc0c56819b692fb632ea
2,513
ex
Elixir
deps/plug/lib/plug/conn/adapter.ex
JoakimEskils/elixir-absinthe
d81e24ec7c7b1164e6d152101dd50422f192d7e9
[ "MIT" ]
null
null
null
deps/plug/lib/plug/conn/adapter.ex
JoakimEskils/elixir-absinthe
d81e24ec7c7b1164e6d152101dd50422f192d7e9
[ "MIT" ]
null
null
null
deps/plug/lib/plug/conn/adapter.ex
JoakimEskils/elixir-absinthe
d81e24ec7c7b1164e6d152101dd50422f192d7e9
[ "MIT" ]
null
null
null
defmodule Plug.Conn.Adapter do @moduledoc """ Specification of the connection adapter API implemented by webservers """ alias Plug.Conn @typep payload :: term @doc """ Sends the given status, headers and body as a response back to the client. If the request has method `"HEAD"`, the adapter should not send the response to the client. Webservers are advised to return `nil` as the sent_body, as the body can no longer be manipulated. However, the test implementation returns the actual body so it can be used during testing. """ @callback send_resp(payload, Conn.status, Conn.headers, Conn.body) :: {:ok, sent_body :: binary | nil, payload} @doc """ Sends the given status, headers and file as a response back to the client. If the request has method `"HEAD"`, the adapter should not send the response to the client. Webservers are advised to return `nil` as the sent_body, as the body can no longer be manipulated. However, the test implementation returns the actual body so it can be used during testing. """ @callback send_file(payload, Conn.status, Conn.headers, file :: binary, offset :: integer, length :: integer | :all) :: {:ok, sent_body :: binary | nil, payload} @doc """ Sends the given status, headers as the beginning of a chunked response to the client. Webservers are advised to return `nil` as the sent_body, as the body can no longer be manipulated. However, the test implementation returns the actual body so it can be used during testing. """ @callback send_chunked(payload, Conn.status, Conn.headers) :: {:ok, sent_body :: binary | nil, payload} @doc """ Sends a chunk in the chunked response. If the request has method `"HEAD"`, the adapter should not send the response to the client. Webservers are advised to return `:ok` and not modify any further state for each chunk. However, the test implementation returns the actual body and payload so it can be used during testing. """ @callback chunk(payload, Conn.status) :: :ok | {:ok, sent_body :: binary, payload} | {:error, term} @doc """ Reads the request body. Read the docs in `Plug.Conn.read_body/2` for the supported options and expected behaviour. """ @callback read_req_body(payload, options :: Keyword.t) :: {:ok, data :: binary, payload} | {:more, data :: binary, payload} | {:error, term} end
33.065789
73
0.674493
79b3833aa0a4b021527634ead6eeb7db34b8ecd1
1,820
ex
Elixir
lib/nsq/consumer/helpers.ex
amokan/elixir_nsq
26e9cdf8f6c99b6688e540181a501f53aa5e9e4b
[ "MIT" ]
89
2015-11-17T01:15:02.000Z
2022-01-31T20:17:17.000Z
lib/nsq/consumer/helpers.ex
amokan/elixir_nsq
26e9cdf8f6c99b6688e540181a501f53aa5e9e4b
[ "MIT" ]
20
2016-06-17T14:15:22.000Z
2019-09-23T13:31:18.000Z
lib/nsq/consumer/helpers.ex
amokan/elixir_nsq
26e9cdf8f6c99b6688e540181a501f53aa5e9e4b
[ "MIT" ]
33
2016-01-28T15:20:43.000Z
2021-12-18T14:36:19.000Z
defmodule NSQ.Consumer.Helpers do alias NSQ.Consumer, as: C alias NSQ.Consumer.Connections alias NSQ.ConnInfo @doc """ Each connection is responsible for maintaining its own rdy_count in ConnInfo. This function sums all the values of rdy_count for each connection, which lets us get an accurate picture of a consumer's total RDY count. Not for external use. """ @spec total_rdy_count(pid) :: integer def total_rdy_count(agent_pid) when is_pid(agent_pid) do ConnInfo.reduce agent_pid, 0, fn({_, conn_info}, acc) -> acc + conn_info.rdy_count end end @doc """ Convenience function; uses the consumer state to get the conn info pid. Not for external use. """ @spec total_rdy_count(C.state) :: integer def total_rdy_count(%{conn_info_pid: agent_pid} = _cons_state) do total_rdy_count(agent_pid) end @doc """ Returns how much `max_in_flight` should be distributed to each connection. If `max_in_flight` is less than the number of connections, then this always returns 1 and they are randomly distributed via `redistribute_rdy`. Not for external use. """ @spec per_conn_max_in_flight(C.state) :: integer def per_conn_max_in_flight(cons_state) do max_in_flight = cons_state.max_in_flight conn_count = Connections.count(cons_state) if conn_count == 0 do 0 else min(max(1, max_in_flight / conn_count), max_in_flight) |> round end end @spec now() :: integer def now do :calendar.datetime_to_gregorian_seconds(:calendar.universal_time) end @spec conn_from_nsqd(pid, C.host_with_port, C.state) :: C.connection def conn_from_nsqd(cons, nsqd, cons_state) do needle = ConnInfo.conn_id(cons, nsqd) Enum.find Connections.get(cons_state), fn({conn_id, _}) -> needle == conn_id end end end
28.888889
79
0.71978
79b3992ab20c05b3cd9643fce8778a7dd7ddc096
1,471
exs
Elixir
mix.exs
jbowtie/opentype-elixir
6ac33e2d3edc0ab4c69712bcd9683cceda70c4fc
[ "Apache-2.0" ]
null
null
null
mix.exs
jbowtie/opentype-elixir
6ac33e2d3edc0ab4c69712bcd9683cceda70c4fc
[ "Apache-2.0" ]
53
2017-09-29T11:33:42.000Z
2021-08-02T17:14:48.000Z
mix.exs
jbowtie/opentype-elixir
6ac33e2d3edc0ab4c69712bcd9683cceda70c4fc
[ "Apache-2.0" ]
null
null
null
defmodule Opentype.Mixfile do use Mix.Project @version "0.5.0" def project do [ app: :opentype, name: "OpenType", version: @version, elixir: "~> 1.5", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], preferred_cli_env: [ coveralls: :test, "coveralls.detail": :test, "coveralls.post": :test, "coveralls.html": :test ], description: "Provides facilities for working with OpenType fonts.", package: package(), deps: deps() ] end # Configuration for the OTP application # # Type "mix help compile.app" for more information def application do # Specify extra applications you'll use from Erlang/Elixir [extra_applications: [:logger]] end # Dependencies can be Hex packages: # # {:my_dep, "~> 0.3.0"} # # Or git/path repositories: # # {:my_dep, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} # # Type "mix help deps" for more examples and options defp deps do [ {:unicode_data, "~> 0.6.0"}, {:excoveralls, "~> 0.8.1", only: :test}, {:ex_doc, "~> 0.18.1", only: :dev} ] end defp package do [ licenses: ["Apache 2.0"], name: "opentype", maintainers: ["jbowtie/John C Barstow"], links: %{ "GitHub" => "https://github.com/jbowtie/opentype-elixir" } ] end end
23.349206
79
0.575119
79b3e62b73984a240672c552912847b8f20efdd1
2,601
ex
Elixir
apps/testchain/lib/testchain/deployment/base_api.ex
makerdao/qa_backend_gateway
38e9a3f3f4b66212f1ee9d38b3b698a2a1f9a809
[ "Apache-2.0" ]
1
2020-10-23T19:25:27.000Z
2020-10-23T19:25:27.000Z
apps/testchain/lib/testchain/deployment/base_api.ex
makerdao/qa_backend_gateway
38e9a3f3f4b66212f1ee9d38b3b698a2a1f9a809
[ "Apache-2.0" ]
5
2019-01-11T11:48:08.000Z
2019-01-16T17:29:23.000Z
apps/testchain/lib/testchain/deployment/base_api.ex
makerdao/qa_backend_gateway
38e9a3f3f4b66212f1ee9d38b3b698a2a1f9a809
[ "Apache-2.0" ]
7
2019-10-09T05:49:52.000Z
2022-03-23T16:48:45.000Z
defmodule Staxx.Testchain.Deployment.BaseApi do @moduledoc """ Module represents basic http layer for deployment service """ use HTTPoison.Base require Logger @random_max 9_999_999_999_999_999_999_999 @doc false def process_response_body(""), do: %{} def process_response_body(body) do case Jason.decode(body, keys: :strings) do {:ok, parsed} -> parsed {:error, err} -> Logger.error("Error parsing response #{inspect(body)} with error: #{inspect(err)}") body end end @doc """ Make request to deployment service """ @spec request(binary, binary, map()) :: {:ok, term()} | {:error, term()} def request(id, method, data \\ %{}) do req = %{ id: id, method: method, data: data } |> Jason.encode!() url() |> post(req, [{"Content-Type", "application/json"}]) |> fetch_body() end @doc """ Load list of steps from deployment service """ @spec load_steps() :: {:ok, term()} | {:error, term()} def load_steps() do random_id() |> request("GetInfo") end @doc """ Request service to reload sources for deployment scripts """ @spec update_source() :: {:ok, term()} | {:error, term()} def update_source() do random_id() |> request("UpdateSource") end @doc """ Run deployment step with list of env variables """ @spec run(binary, 1..9, map()) :: {:ok, term()} | {:error, term()} def run(id, step, env_vars \\ %{}) when step in 1..9 do data = %{ stepId: step, envVars: env_vars } request(id, "Run", data) end @doc """ Check out new commit for deployemnt scripts """ @spec checkout(binary, binary) :: {:ok, term} | {:error, term} def checkout(id, commit) when is_binary(commit) do data = %{ commit: commit } request(id, "Checkout", data) end @doc """ Will load list of available comits from deployment scripts repo """ @spec get_commit_list() :: {:ok, term} | {:error, term} def get_commit_list() do random_id() |> request("GetCommitList") end # generate random number for request def random_id(), do: @random_max |> :rand.uniform() |> to_string() # Get deployment service url defp url(), do: Application.get_env(:instance, :deployment_service_url) # Pick only needed information defp fetch_body({:ok, %HTTPoison.Response{body: %{"type" => "error", "result" => res}}}) do {:error, res} end defp fetch_body({:ok, %HTTPoison.Response{status_code: 200, body: body}}), do: {:ok, body} defp fetch_body(res), do: res end
23.432432
93
0.607074
79b3f9520ac794d759579020130b37597253a111
2,528
ex
Elixir
lib/lastfm/archive.ex
boonious/lastfm_archive
a3d0194f28cd67572c230a207583e5d0b88eb199
[ "Apache-2.0" ]
1
2019-04-25T18:28:24.000Z
2019-04-25T18:28:24.000Z
lib/lastfm/archive.ex
boonious/lastfm_archive
a3d0194f28cd67572c230a207583e5d0b88eb199
[ "Apache-2.0" ]
14
2020-12-24T16:54:08.000Z
2021-05-05T15:21:55.000Z
lib/lastfm/archive.ex
boonious/lastfm_archive
a3d0194f28cd67572c230a207583e5d0b88eb199
[ "Apache-2.0" ]
1
2019-10-20T23:02:06.000Z
2019-10-20T23:02:06.000Z
defmodule Lastfm.Archive do @moduledoc """ A behaviour module for implementing a Lastfm archive. The module also provides a struct that keeps metadata about the archive. An archive contains scrobbles data retrieved from Lastfm API. It can be based upon various storage implementation such as file systems and databases. """ @archive Application.get_env(:lastfm_archive, :type, LastFm.FileArchive) @derive Jason.Encoder @enforce_keys [:creator] defstruct [ :created, :creator, :date, :description, :extent, :format, :identifier, :modified, :source, :temporal, :title, :type ] @type options :: keyword() @type user :: binary() @type scrobbles :: map() @typedoc """ Metadata descriping a Lastfm archive based on [Dublin Core Metadata Initiative](https://www.dublincore.org/specifications/dublin-core/dcmi-terms/). """ @type t :: %__MODULE__{ created: DateTime.t(), creator: binary(), date: Date.t(), description: binary(), extent: integer(), format: binary(), identifier: binary(), modified: DateTime.t(), source: binary(), temporal: {integer, integer}, title: binary(), type: atom() } @doc """ Creates a new and empty archive and records metadata. """ @callback update_metadata(t(), options) :: {:ok, t()} | {:error, term()} @doc """ Describes the status of an existing archive. """ @callback describe(user, options) :: {:ok, t()} | {:error, term()} @doc """ Write scrobbles data to an existing archive. """ @callback write(t(), scrobbles, options) :: :ok | {:error, term()} @doc """ Data struct containing new and some default metadata of an archive. Other metadata fields such as temporal, modified can be populated based on the outcomes of archiving, i.e. the implementation of the callbacks of this behaviour. """ @spec new(user) :: t() def new(user) do %__MODULE__{ created: DateTime.utc_now(), creator: user, description: "Lastfm archive of #{user}, extracted from Lastfm API", format: "application/json", identifier: user, source: "http://ws.audioscrobbler.com/2.0", title: "Lastfm archive of #{user}", type: @archive } end end defimpl Jason.Encoder, for: Tuple do def encode(data, options) when is_tuple(data) do data |> Tuple.to_list() |> Jason.Encoder.List.encode(options) end end
26.333333
103
0.630142
79b3fa27ff3122ac73a6a1ae09985b383b7a2360
1,417
ex
Elixir
lib/brando/villain/tags/picture.ex
univers-agency/brando
69c3c52498a3f64518da3522cd9f27294a52cc68
[ "Apache-2.0" ]
1
2020-04-26T09:53:02.000Z
2020-04-26T09:53:02.000Z
lib/brando/villain/tags/picture.ex
univers-agency/brando
69c3c52498a3f64518da3522cd9f27294a52cc68
[ "Apache-2.0" ]
198
2019-08-20T16:16:07.000Z
2020-07-03T15:42:07.000Z
lib/brando/villain/tags/picture.ex
univers-agency/brando
69c3c52498a3f64518da3522cd9f27294a52cc68
[ "Apache-2.0" ]
null
null
null
defmodule Brando.Villain.Tags.Picture do @moduledoc """ {% picture entry.cover { size: 'auto', lazyload: true, srcset: 'MyApp.Projects.Project:cover.default', prefix: '/media' } %} """ @behaviour Liquex.Tag import NimbleParsec alias Liquex.Parser.Argument alias Liquex.Parser.Literal alias Liquex.Parser.Tag alias Liquex.Parser.Object import Phoenix.LiveView.Helpers @impl true def parse() do ignore(Tag.open_tag()) |> ignore(string("picture")) |> ignore(Literal.whitespace()) |> unwrap_and_tag(Argument.argument(), :source) |> ignore(Literal.whitespace()) |> optional(tag(braced_args(), :args)) |> ignore(Tag.close_tag()) end @impl true def render([source: source, args: args], context) do evaled_source = Liquex.Argument.eval(source, context) evaled_args = args |> Enum.map(fn arg -> {key, val} = Liquex.Argument.eval(arg, context) {String.to_existing_atom(key), val} end) assigns = %{src: evaled_source, opts: evaled_args} comp = ~H""" <Brando.HTML.Images.picture src={@src} opts={@opts} /> """ html = Phoenix.LiveViewTest.rendered_to_string(comp) {[html], context} end defp braced_args(combinator \\ empty()) do combinator |> ignore(string("{ ")) |> repeat( lookahead_not(string(" }")) |> Object.arguments() ) |> ignore(string(" }")) end end
24.859649
126
0.636556
79b40f5630c6a03bf724c7dcae53c68ba4d3ba7a
1,944
ex
Elixir
clients/health_care/lib/google_api/health_care/v1beta1/model/list_consent_stores_response.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/health_care/lib/google_api/health_care/v1beta1/model/list_consent_stores_response.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/health_care/lib/google_api/health_care/v1beta1/model/list_consent_stores_response.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.HealthCare.V1beta1.Model.ListConsentStoresResponse do @moduledoc """ ## Attributes * `consentStores` (*type:* `list(GoogleApi.HealthCare.V1beta1.Model.ConsentStore.t)`, *default:* `nil`) - The returned consent stores. The maximum number of stores returned is determined by the value of page_size in the ListConsentStoresRequest. * `nextPageToken` (*type:* `String.t`, *default:* `nil`) - Token to retrieve the next page of results, or empty if there are no more results in the list. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :consentStores => list(GoogleApi.HealthCare.V1beta1.Model.ConsentStore.t()) | nil, :nextPageToken => String.t() | nil } field(:consentStores, as: GoogleApi.HealthCare.V1beta1.Model.ConsentStore, type: :list) field(:nextPageToken) end defimpl Poison.Decoder, for: GoogleApi.HealthCare.V1beta1.Model.ListConsentStoresResponse do def decode(value, options) do GoogleApi.HealthCare.V1beta1.Model.ListConsentStoresResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.HealthCare.V1beta1.Model.ListConsentStoresResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
38.88
249
0.750514
79b41050b7927a09b9b502848b32a31d06a381d3
2,571
exs
Elixir
config/prod.exs
anndream/phoenix-commerce
5e4471fa8fd1ac402d4df68fe7ccbcb0f7a53296
[ "MIT" ]
229
2016-09-21T09:24:46.000Z
2020-05-16T22:41:31.000Z
config/prod.exs
sadiqmmm/ex-shop
5e4471fa8fd1ac402d4df68fe7ccbcb0f7a53296
[ "MIT" ]
3
2016-09-21T10:26:50.000Z
2016-10-19T07:25:12.000Z
config/prod.exs
sadiqmmm/ex-shop
5e4471fa8fd1ac402d4df68fe7ccbcb0f7a53296
[ "MIT" ]
32
2016-09-22T05:19:05.000Z
2019-11-01T04:07:13.000Z
use Mix.Config # For production, we configure the host to read the PORT # from the system environment. Therefore, you will need # to set PORT=80 before running your server. # # You should also configure the url host to something # meaningful, we use this information when generating URLs. # # Finally, we also include the path to a manifest # containing the digested version of static files. This # manifest is generated by the mix phoenix.digest task # which you typically run after static files are built. config :ap, Ap.Endpoint, http: [port: {:system, "PORT"}], url: [host: System.get_env("HOSTNAME"), port: 80], cache_static_manifest: "priv/static/manifest.json", secret_key_base: System.get_env("SECRET_KEY_BASE") # Do not print debug messages in production config :logger, level: :info # ## SSL Support # # To get SSL working, you will need to add the `https` key # to the previous section and set your `:url` port to 443: # # config :ap, Ap.Endpoint, # ... # url: [host: "example.com", port: 443], # https: [port: 443, # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), # certfile: System.get_env("SOME_APP_SSL_CERT_PATH")] # # Where those two env variables return an absolute path to # the key and cert in disk or a relative path inside priv, # for example "priv/ssl/server.key". # # We also recommend setting `force_ssl`, ensuring no data is # ever sent via http, always redirecting to https: # # config :ap, Ap.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. # ## Using releases # # If you are doing OTP releases, you need to instruct Phoenix # to start the server for all endpoints: # # config :phoenix, :serve_endpoints, true # # Alternatively, you can configure exactly which server to # start per endpoint: # # config :ap, Ap.Endpoint, server: true # config :ap, Ap.Repo, adapter: Ecto.Adapters.Postgres, url: System.get_env("DATABASE_URL"), pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), ssl: true # Mailer config :ap, Ap.Mailer, adapter: Bamboo.SendgridAdapter, api_key: System.get_env("SENDGRID_API_KEY") # Cloudinary config :cloudini, api_key: System.get_env("CLOUDINARY_API_KEY"), api_secret: System.get_env("CLOUDINARY_API_SECRET"), name: System.get_env("CLOUDINARY_NAME"), stub_requests: false, http_options: [timeout: 15000] config :sentry, use_error_logger: true, environment_name: :prod, dsn: System.get_env("SENTRY_DSN"), tags: %{ env: "production" }
29.215909
68
0.709841
79b4608b0ac93753dc631130ba8036a767301faf
2,390
ex
Elixir
clients/android_device_provisioning/lib/google_api/android_device_provisioning/v1/model/partner_claim.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/android_device_provisioning/lib/google_api/android_device_provisioning/v1/model/partner_claim.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/android_device_provisioning/lib/google_api/android_device_provisioning/v1/model/partner_claim.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.AndroidDeviceProvisioning.V1.Model.PartnerClaim do @moduledoc """ Identifies one claim request. ## Attributes * `customerId` (*type:* `String.t`, *default:* `nil`) - Required. The ID of the customer for whom the device is being claimed. * `deviceIdentifier` (*type:* `GoogleApi.AndroidDeviceProvisioning.V1.Model.DeviceIdentifier.t`, *default:* `nil`) - Required. Device identifier of the device. * `deviceMetadata` (*type:* `GoogleApi.AndroidDeviceProvisioning.V1.Model.DeviceMetadata.t`, *default:* `nil`) - Required. The metadata to attach to the device at claim. * `sectionType` (*type:* `String.t`, *default:* `nil`) - Required. The section type of the device's provisioning record. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :customerId => String.t(), :deviceIdentifier => GoogleApi.AndroidDeviceProvisioning.V1.Model.DeviceIdentifier.t(), :deviceMetadata => GoogleApi.AndroidDeviceProvisioning.V1.Model.DeviceMetadata.t(), :sectionType => String.t() } field(:customerId) field(:deviceIdentifier, as: GoogleApi.AndroidDeviceProvisioning.V1.Model.DeviceIdentifier) field(:deviceMetadata, as: GoogleApi.AndroidDeviceProvisioning.V1.Model.DeviceMetadata) field(:sectionType) end defimpl Poison.Decoder, for: GoogleApi.AndroidDeviceProvisioning.V1.Model.PartnerClaim do def decode(value, options) do GoogleApi.AndroidDeviceProvisioning.V1.Model.PartnerClaim.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.AndroidDeviceProvisioning.V1.Model.PartnerClaim do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
42.678571
173
0.746444
79b48172774ac10abc8cd26d3938c1a4fdf2139a
1,759
ex
Elixir
clients/analytics_reporting/lib/google_api/analytics_reporting/v4/model/date_range.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/analytics_reporting/lib/google_api/analytics_reporting/v4/model/date_range.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/analytics_reporting/lib/google_api/analytics_reporting/v4/model/date_range.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.AnalyticsReporting.V4.Model.DateRange do @moduledoc """ A contiguous set of days: startDate, startDate + 1 day, ..., endDate. The start and end dates are specified in [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) date format `YYYY-MM-DD`. ## Attributes * `endDate` (*type:* `String.t`, *default:* `nil`) - The end date for the query in the format `YYYY-MM-DD`. * `startDate` (*type:* `String.t`, *default:* `nil`) - The start date for the query in the format `YYYY-MM-DD`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :endDate => String.t(), :startDate => String.t() } field(:endDate) field(:startDate) end defimpl Poison.Decoder, for: GoogleApi.AnalyticsReporting.V4.Model.DateRange do def decode(value, options) do GoogleApi.AnalyticsReporting.V4.Model.DateRange.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.AnalyticsReporting.V4.Model.DateRange do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
33.826923
115
0.71859
79b4a0b19c0f798f386b6a569a8b4ecc512ebeec
1,121
exs
Elixir
config/config.exs
podlove/metalove
8b52c91eba6b39366ee35a06e6d9eedccbe8517d
[ "MIT" ]
6
2019-02-23T12:19:57.000Z
2020-12-19T16:28:17.000Z
config/config.exs
podlove/metalove
8b52c91eba6b39366ee35a06e6d9eedccbe8517d
[ "MIT" ]
11
2019-02-23T12:22:08.000Z
2021-04-10T21:49:48.000Z
config/config.exs
podlove/metalove
8b52c91eba6b39366ee35a06e6d9eedccbe8517d
[ "MIT" ]
1
2019-03-23T13:23:19.000Z
2019-03-23T13:23:19.000Z
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. use Mix.Config # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this # file won't be loaded nor affect the parent project. For this reason, # if you want to provide default values for your application for # 3rd-party users, it should be done in your "mix.exs" file. # You can configure your application as: # # config :metalove, key: :value # # and access this configuration in your application as: # # Application.get_env(:metalove, :key) # # You can also configure a 3rd-party app: # config :logger, level: :info # # It is also possible to import configuration files, relative to this # directory. For example, you can emulate configuration per environment # by uncommenting the line below and defining dev.exs, test.exs and such. # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # # import_config "#{Mix.env()}.exs"
36.16129
73
0.754683
79b4a4ad277b2f795ed511f1b957f424f0ea5286
2,083
ex
Elixir
lib/graphql_markdown/schema.ex
podium/graphql_markdown
8b2ece7239f83e8cf70795b22c7b54358345852d
[ "MIT" ]
1
2021-09-17T19:23:19.000Z
2021-09-17T19:23:19.000Z
lib/graphql_markdown/schema.ex
podium/graphql_markdown
8b2ece7239f83e8cf70795b22c7b54358345852d
[ "MIT" ]
null
null
null
lib/graphql_markdown/schema.ex
podium/graphql_markdown
8b2ece7239f83e8cf70795b22c7b54358345852d
[ "MIT" ]
null
null
null
defmodule GraphqlMarkdown.Schema do @moduledoc """ Internal Schema representation of Graphql section we care about """ defstruct [:mutations, :queries, :inputs, :objects, :enums, :scalars, :interfaces, :unions] @object_kind "OBJECT" @input_kind "INPUT_OBJECT" @enum_kind "ENUM" @scalar_kind "SCALAR" @interface_kind "INTERFACE" @union_kind "UNION" def full_field_type(type) do case type["kind"] do "NON_NULL" -> "#{full_field_type(type["ofType"])}!" "LIST" -> "\\[#{full_field_type(type["ofType"])}\\]" _ -> type["name"] end end def field_type(type) do case type["kind"] do "NON_NULL" -> field_type(type["ofType"]) "LIST" -> field_type(type["ofType"]) _ -> type["name"] end end def field_kind(type) do case type["kind"] do "NON_NULL" -> field_type(type["ofType"]) "LIST" -> field_type(type["ofType"]) _ -> type["kind"] end end def object_kind do @object_kind end def input_kind do @input_kind end def enum_kind do @enum_kind end def scalar_kind do @scalar_kind end def interface_kind do @interface_kind end def union_kind do @union_kind end def mutation_type(schema) do schema["mutationType"]["name"] end def query_type(schema) do schema["queryType"]["name"] end def types(schema) do Enum.filter(schema["types"], fn type -> !String.starts_with?(type["name"], "__") end) end def schema_from_json(%{"data" => %{"__schema" => schema_defintion}}) do {:ok, schema_defintion} end def schema_from_json(_) do {:error, :invalid_schema} end def find_and_sort_type(types, field, value, sort_by \\ "name") do types |> find_type(field, value) |> sort_type(sort_by) end defp sort_type(types, sort_by) do Enum.sort_by(types, fn type -> type[sort_by] end) end defp find_type(types, field, value) do Enum.filter(types, fn type -> type[field] == value end) end end
18.433628
93
0.612578
79b4d2895ab0da60c6a42e089f6d9c4533f79384
3,981
ex
Elixir
clients/drive/lib/google_api/drive/v3/model/revision.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/drive/lib/google_api/drive/v3/model/revision.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/drive/lib/google_api/drive/v3/model/revision.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.Drive.V3.Model.Revision do @moduledoc """ The metadata for a revision to a file. ## Attributes - exportLinks (%{optional(String.t) &#x3D;&gt; String.t}): Links for exporting Google Docs to specific formats. Defaults to: `null`. - id (String.t): The ID of the revision. Defaults to: `null`. - keepForever (boolean()): Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file. This field is only applicable to files with binary content in Drive. Defaults to: `null`. - kind (String.t): Identifies what kind of resource this is. Value: the fixed string \&quot;drive#revision\&quot;. Defaults to: `null`. - lastModifyingUser (User): The last user to modify this revision. Defaults to: `null`. - md5Checksum (String.t): The MD5 checksum of the revision&#39;s content. This is only applicable to files with binary content in Drive. Defaults to: `null`. - mimeType (String.t): The MIME type of the revision. Defaults to: `null`. - modifiedTime (DateTime.t): The last time the revision was modified (RFC 3339 date-time). Defaults to: `null`. - originalFilename (String.t): The original filename used to create this revision. This is only applicable to files with binary content in Drive. Defaults to: `null`. - publishAuto (boolean()): Whether subsequent revisions will be automatically republished. This is only applicable to Google Docs. Defaults to: `null`. - published (boolean()): Whether this revision is published. This is only applicable to Google Docs. Defaults to: `null`. - publishedOutsideDomain (boolean()): Whether this revision is published outside the domain. This is only applicable to Google Docs. Defaults to: `null`. - size (String.t): The size of the revision&#39;s content in bytes. This is only applicable to files with binary content in Drive. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :exportLinks => map(), :id => any(), :keepForever => any(), :kind => any(), :lastModifyingUser => GoogleApi.Drive.V3.Model.User.t(), :md5Checksum => any(), :mimeType => any(), :modifiedTime => DateTime.t(), :originalFilename => any(), :publishAuto => any(), :published => any(), :publishedOutsideDomain => any(), :size => any() } field(:exportLinks, type: :map) field(:id) field(:keepForever) field(:kind) field(:lastModifyingUser, as: GoogleApi.Drive.V3.Model.User) field(:md5Checksum) field(:mimeType) field(:modifiedTime, as: DateTime) field(:originalFilename) field(:publishAuto) field(:published) field(:publishedOutsideDomain) field(:size) end defimpl Poison.Decoder, for: GoogleApi.Drive.V3.Model.Revision do def decode(value, options) do GoogleApi.Drive.V3.Model.Revision.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Drive.V3.Model.Revision do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
47.392857
353
0.709621
79b5186153677fad5e056a2c09daaec51c14fe35
1,755
ex
Elixir
clients/testing/lib/google_api/testing/v1/model/device_file.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/testing/lib/google_api/testing/v1/model/device_file.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/testing/lib/google_api/testing/v1/model/device_file.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.Testing.V1.Model.DeviceFile do @moduledoc """ A single device file description. ## Attributes * `obbFile` (*type:* `GoogleApi.Testing.V1.Model.ObbFile.t`, *default:* `nil`) - A reference to an opaque binary blob file. * `regularFile` (*type:* `GoogleApi.Testing.V1.Model.RegularFile.t`, *default:* `nil`) - A reference to a regular file. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :obbFile => GoogleApi.Testing.V1.Model.ObbFile.t(), :regularFile => GoogleApi.Testing.V1.Model.RegularFile.t() } field(:obbFile, as: GoogleApi.Testing.V1.Model.ObbFile) field(:regularFile, as: GoogleApi.Testing.V1.Model.RegularFile) end defimpl Poison.Decoder, for: GoogleApi.Testing.V1.Model.DeviceFile do def decode(value, options) do GoogleApi.Testing.V1.Model.DeviceFile.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Testing.V1.Model.DeviceFile do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
35.1
127
0.732194
79b53128c0e4f9438e71465deb87b20befb1f6c0
1,095
exs
Elixir
kousa/mix.exs
ninetu/dogehouse
1f7b80400c9e1b19b3ec5403392aa0ab02f1d697
[ "MIT" ]
1
2021-04-19T19:02:21.000Z
2021-04-19T19:02:21.000Z
kousa/mix.exs
ninetu/dogehouse
1f7b80400c9e1b19b3ec5403392aa0ab02f1d697
[ "MIT" ]
null
null
null
kousa/mix.exs
ninetu/dogehouse
1f7b80400c9e1b19b3ec5403392aa0ab02f1d697
[ "MIT" ]
null
null
null
defmodule Kousa.MixProject do use Mix.Project def project do [ app: :kousa, version: "0.1.0", elixir: "~> 1.9", start_permanent: Mix.env() == :prod, deps: deps() ] end # Run "mix help compile.app" to learn about applications. def application do dev_only_apps = if Mix.env() == :dev, do: [:remix], else: [] [ mod: {Kousa, []}, extra_applications: [:logger, :amqp] ++ dev_only_apps ] end # Run "mix help deps" to learn about dependencies. defp deps do [ {:amqp, "~> 1.0"}, {:gen_registry, "~> 1.0"}, {:plug_cowboy, "~> 2.0"}, {:poison, "~> 3.1"}, {:ecto_sql, "~> 3.0"}, {:jason, "~> 1.2"}, {:joken, "~> 2.0"}, {:httpoison, "~> 1.8"}, {:decorator, "~> 1.2"}, {:sentry, "~> 8.0"}, {:postgrex, ">= 0.0.0"}, {:remix, "~> 0.0.1", only: :dev}, {:oauther, "~> 1.1"}, {:extwitter, "~> 0.12"} # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] end end
23.804348
87
0.481279
79b54d8caed2de2005a5698e3adebae821355ab0
380
ex
Elixir
lib/cotoami_web/views/session_view.ex
fmorita/cotoami
e3eb92ad15829f99cf3e8974077f135e789924cf
[ "Apache-2.0" ]
null
null
null
lib/cotoami_web/views/session_view.ex
fmorita/cotoami
e3eb92ad15829f99cf3e8974077f135e789924cf
[ "Apache-2.0" ]
null
null
null
lib/cotoami_web/views/session_view.ex
fmorita/cotoami
e3eb92ad15829f99cf3e8974077f135e789924cf
[ "Apache-2.0" ]
null
null
null
defmodule CotoamiWeb.SessionView do use CotoamiWeb, :view alias CotoamiWeb.AmishiView def render("session.json", %{ amishi: amishi, token: token, websocket_url: websocket_url, lang: lang }) do %{ amishi: render_relation(amishi, AmishiView, "amishi.json"), token: token, websocket_url: websocket_url, lang: lang } end end
20
65
0.655263
79b5618f86bd0c7d9ec0645634cce79ab1d1bdc2
700
exs
Elixir
test/ex_stone_openbank/api/model/statement_test.exs
duzzifelipe/ex-stone-openbank
5a0faa547c3aa3d7f3842739e50cca6b14337124
[ "Apache-2.0" ]
null
null
null
test/ex_stone_openbank/api/model/statement_test.exs
duzzifelipe/ex-stone-openbank
5a0faa547c3aa3d7f3842739e50cca6b14337124
[ "Apache-2.0" ]
null
null
null
test/ex_stone_openbank/api/model/statement_test.exs
duzzifelipe/ex-stone-openbank
5a0faa547c3aa3d7f3842739e50cca6b14337124
[ "Apache-2.0" ]
null
null
null
defmodule ExStoneOpenbank.API.Model.StatementTest do use ExUnit.Case, async: true alias ExStoneOpenbank.API.Model.StatementEntry test "can parse" do map = ~s({"amount":50,"balance_after":681776564,"balance_before":681776514,"counter_party":{"account":{"account_code":"125746237705","branch_code":"1","institution":"16501555","institution_name":"Stone Pagamentos S.A."},"entity":{"name":"Luiz Carlos Pires de Oliveira Junior"}},"created_at":"2020-01-10T15:51:48Z","description":"","id":"d4112274-d597-484b-a386-701ba86b92e3","operation":"credit","status":"FINISHED","type":"internal"}) |> Jason.decode!() assert StatementEntry.changeset(map) |> Map.get(:valid?) end end
50
435
0.718571
79b56205519bc6a41becf8b090adb8ae6790b1f6
803
ex
Elixir
lib/riverside/session/transmission_limitter.ex
LukasDoesDev/riverside
c2866be6c152e38cc142becf3e9c8c042c80ed57
[ "MIT" ]
63
2018-05-02T16:47:44.000Z
2022-03-07T09:48:58.000Z
lib/riverside/session/transmission_limitter.ex
LukasDoesDev/riverside
c2866be6c152e38cc142becf3e9c8c042c80ed57
[ "MIT" ]
20
2017-09-24T00:42:12.000Z
2021-12-11T12:00:13.000Z
lib/riverside/session/transmission_limitter.ex
LukasDoesDev/riverside
c2866be6c152e38cc142becf3e9c8c042c80ed57
[ "MIT" ]
9
2019-02-18T10:09:30.000Z
2021-12-09T21:11:02.000Z
defmodule Riverside.Session.TransmissionLimitter do @type t :: %__MODULE__{count: non_neg_integer, started_at: non_neg_integer} defstruct count: 0, started_at: 0 @spec new() :: t def new() do %__MODULE__{count: 0, started_at: Riverside.IO.Timestamp.milli_seconds()} end @spec countup(t, non_neg_integer, non_neg_integer) :: {:ok, t} | {:error, :too_many_messages} def countup(limitter, duration, capacity) do now = Riverside.IO.Timestamp.milli_seconds() if limitter.started_at + duration < now do {:ok, %{limitter | count: 1, started_at: now}} else count = limitter.count + 1 if count < capacity do {:ok, %{limitter | count: count}} else {:error, :too_many_messages} end end end end
25.09375
77
0.635118
79b59a6e3ec83c0a437a70c943d3498445f9ada3
1,647
ex
Elixir
web/web.ex
tmecklem/ex_diagcare
cb3236253a19254f3a278f2ffbfa78446bfb1675
[ "MIT" ]
null
null
null
web/web.ex
tmecklem/ex_diagcare
cb3236253a19254f3a278f2ffbfa78446bfb1675
[ "MIT" ]
null
null
null
web/web.ex
tmecklem/ex_diagcare
cb3236253a19254f3a278f2ffbfa78446bfb1675
[ "MIT" ]
null
null
null
defmodule ExDiagcare.Web do @moduledoc """ A module that keeps using definitions for controllers, views and so on. This can be used in your application as: use ExDiagcare.Web, :controller use ExDiagcare.Web, :view The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused on imports, uses and aliases. Do NOT define functions inside the quoted expressions below. """ def model do quote do use Ecto.Schema import Ecto import Ecto.Changeset import Ecto.Query end end def controller do quote do use Phoenix.Controller alias ExDiagcare.Repo import Ecto import Ecto.Query import ExDiagcare.Router.Helpers import ExDiagcare.Gettext end end def view do quote do use Phoenix.View, root: "web/templates" # Import convenience functions from controllers import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1] # Use all HTML functionality (forms, tags, etc) use Phoenix.HTML import ExDiagcare.Router.Helpers import ExDiagcare.ErrorHelpers import ExDiagcare.Gettext end end def router do quote do use Phoenix.Router end end def channel do quote do use Phoenix.Channel alias ExDiagcare.Repo import Ecto import Ecto.Query import ExDiagcare.Gettext end end @doc """ When used, dispatch to the appropriate controller/view/etc. """ defmacro __using__(which) when is_atom(which) do apply(__MODULE__, which, []) end end
20.085366
88
0.672738
79b5a8cbb9705b254fe5d339f04a778640b14a78
3,758
exs
Elixir
mix.exs
mbuhot/ecto_sql
10b34132b3bc3013f5f89266efcb79939cbf04fa
[ "Apache-2.0" ]
null
null
null
mix.exs
mbuhot/ecto_sql
10b34132b3bc3013f5f89266efcb79939cbf04fa
[ "Apache-2.0" ]
null
null
null
mix.exs
mbuhot/ecto_sql
10b34132b3bc3013f5f89266efcb79939cbf04fa
[ "Apache-2.0" ]
null
null
null
defmodule EctoSQL.MixProject do use Mix.Project @version "3.2.0-dev" @adapters ~w(pg myxql) def project do [ app: :ecto_sql, version: @version, elixir: "~> 1.6", deps: deps(), test_paths: test_paths(System.get_env("ECTO_ADAPTER")), xref: [ exclude: [ MyXQL, Ecto.Adapters.MyXQL.Connection, Postgrex, Ecto.Adapters.Postgres.Connection ] ], # Custom testing aliases: ["test.all": ["test", "test.adapters"], "test.adapters": &test_adapters/1], preferred_cli_env: ["test.all": :test, "test.adapters": :test], # Hex description: "SQL-based adapters for Ecto and database migrations", package: package(), # Docs name: "Ecto SQL", docs: docs() ] end def application do [ extra_applications: [:logger], env: [postgres_map_type: "jsonb"], mod: {Ecto.Adapters.SQL.Application, []} ] end defp deps do [ ecto_dep(), {:telemetry, "~> 0.4.0"}, # Drivers {:db_connection, "~> 2.1"}, postgrex_dep(), myxql_dep(), # Bring something in for JSON during tests {:jason, ">= 0.0.0", only: [:test, :docs]}, # Docs {:ex_doc, "~> 0.19", only: :docs}, # Benchmarks {:benchee, "~> 0.11.0", only: :bench}, {:benchee_json, "~> 0.4.0", only: :bench} ] end defp ecto_dep do if path = System.get_env("ECTO_PATH") do {:ecto, path: path} else {:ecto, "~> 3.2.0-dev", github: "elixir-ecto/ecto"} end end defp postgrex_dep do if path = System.get_env("POSTGREX_PATH") do {:postgrex, path: path} else {:postgrex, "~> 0.14.0 or ~> 0.15.0", optional: true} end end defp myxql_dep do if path = System.get_env("MYXQL_PATH") do {:myxql, path: path} else {:myxql, "~> 0.2.0", optional: true} end end defp test_paths(adapter) when adapter in @adapters, do: ["integration_test/#{adapter}"] defp test_paths(_), do: ["test"] defp package do [ maintainers: ["Eric Meadows-Jönsson", "José Valim", "James Fish", "Michał Muskała"], licenses: ["Apache 2.0"], links: %{"GitHub" => "https://github.com/elixir-ecto/ecto_sql"}, files: ~w(.formatter.exs mix.exs README.md CHANGELOG.md lib) ++ ~w(integration_test/sql integration_test/support) ] end defp test_adapters(args) do for adapter <- @adapters, do: env_run(adapter, args) end defp env_run(adapter, args) do args = if IO.ANSI.enabled?(), do: ["--color" | args], else: ["--no-color" | args] IO.puts("==> Running tests for ECTO_ADAPTER=#{adapter} mix test") {_, res} = System.cmd("mix", ["test" | args], into: IO.binstream(:stdio, :line), env: [{"ECTO_ADAPTER", adapter}] ) if res > 0 do System.at_exit(fn _ -> exit({:shutdown, 1}) end) end end defp docs do [ main: "Ecto.Adapters.SQL", source_ref: "v#{@version}", canonical: "http://hexdocs.pm/ecto_sql", source_url: "https://github.com/elixir-ecto/ecto_sql", groups_for_modules: [ # Ecto.Adapters.SQL, # Ecto.Adapters.SQL.Sandbox, # Ecto.Migration, # Ecto.Migrator, "Built-in adapters": [ Ecto.Adapters.MyXQL, Ecto.Adapters.Postgres ], "Adapter specification": [ Ecto.Adapter.Migration, Ecto.Adapter.Structure, Ecto.Adapters.SQL.Connection, Ecto.Migration.Command, Ecto.Migration.Constraint, Ecto.Migration.Index, Ecto.Migration.Reference, Ecto.Migration.Table ] ] ] end end
24.245161
90
0.560404
79b5b104f8fee16d4659ac12aebcaacdcf0c83dd
2,078
ex
Elixir
clients/dataproc/lib/google_api/dataproc/v1/model/gke_node_pool_accelerator_config.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
clients/dataproc/lib/google_api/dataproc/v1/model/gke_node_pool_accelerator_config.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
clients/dataproc/lib/google_api/dataproc/v1/model/gke_node_pool_accelerator_config.ex
yoshi-code-bot/elixir-google-api
cdb6032f01fac5ab704803113c39f2207e9e019d
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Dataproc.V1.Model.GkeNodePoolAcceleratorConfig do @moduledoc """ A GkeNodeConfigAcceleratorConfig represents a Hardware Accelerator request for a node pool. ## Attributes * `acceleratorCount` (*type:* `String.t`, *default:* `nil`) - The number of accelerator cards exposed to an instance. * `acceleratorType` (*type:* `String.t`, *default:* `nil`) - The accelerator type resource namename (see GPUs on Compute Engine). * `gpuPartitionSize` (*type:* `String.t`, *default:* `nil`) - Size of partitions to create on the GPU. Valid values are described in the NVIDIA mig user guide (https://docs.nvidia.com/datacenter/tesla/mig-user-guide/#partitioning). """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :acceleratorCount => String.t() | nil, :acceleratorType => String.t() | nil, :gpuPartitionSize => String.t() | nil } field(:acceleratorCount) field(:acceleratorType) field(:gpuPartitionSize) end defimpl Poison.Decoder, for: GoogleApi.Dataproc.V1.Model.GkeNodePoolAcceleratorConfig do def decode(value, options) do GoogleApi.Dataproc.V1.Model.GkeNodePoolAcceleratorConfig.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Dataproc.V1.Model.GkeNodePoolAcceleratorConfig do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
39.207547
235
0.737247
79b60c0ca8ac33dd8211c6665110c669be4526bd
370
ex
Elixir
lib/rocketpay.ex
mCodex/nlw4-elixir
e1e281d1790c4638cec5b6a4380d9bc6b7ef9472
[ "MIT" ]
null
null
null
lib/rocketpay.ex
mCodex/nlw4-elixir
e1e281d1790c4638cec5b6a4380d9bc6b7ef9472
[ "MIT" ]
null
null
null
lib/rocketpay.ex
mCodex/nlw4-elixir
e1e281d1790c4638cec5b6a4380d9bc6b7ef9472
[ "MIT" ]
null
null
null
defmodule Rocketpay do alias Rocketpay.Users.Create, as: UserCreate alias Rocketpay.Accounts.{Deposit, Withdraw, Transaction} defdelegate create_user(params), to: UserCreate, as: :call defdelegate deposit(params), to: Deposit, as: :call defdelegate withdraw(params), to: Withdraw, as: :call defdelegate transaction(params), to: Transaction, as: :call end
30.833333
61
0.759459
79b659b1fc39c16738ec19fc3696c9a842dec043
1,211
exs
Elixir
clients/accelerated_mobile_page_url/mix.exs
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/accelerated_mobile_page_url/mix.exs
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/accelerated_mobile_page_url/mix.exs
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
1
2018-07-28T20:50:50.000Z
2018-07-28T20:50:50.000Z
defmodule GoogleApi.AcceleratedMobilePageUrl.V1.Mixfile do use Mix.Project def project do [app: :google_api_accelerated_mobile_page_url, version: "0.0.1", elixir: "~> 1.4", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, description: description(), package: package(), deps: deps(), source_url: "https://github.com/GoogleCloudPlatform/elixir-google-api/tree/master/clients/accelerated_mobile_page_url" ] end def application() do [extra_applications: [:logger]] end defp deps() do [ {:tesla, "~> 0.8"}, {:poison, ">= 1.0.0"}, {:ex_doc, "~> 0.16", only: :dev} ] end defp description() do """ Retrieves the list of AMP URLs (and equivalent AMP Cache URLs) for a given list of public URL(s). """ end defp package() do [ files: ["lib", "mix.exs", "README*", "LICENSE"], maintainers: ["Jeff Ching"], licenses: ["Apache 2.0"], links: %{ "GitHub" => "https://github.com/GoogleCloudPlatform/elixir-google-api/tree/master/clients/accelerated_mobile_page_url", "Homepage" => "https://developers.google.com/amp/cache/" } ] end end
25.765957
127
0.613543
79b660c7478e346dcc03c861e4b4f862bacc5085
3,572
ex
Elixir
clients/apigee/lib/google_api/apigee/v1/model/google_cloud_apigee_v1_deployment_change_report.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/apigee/lib/google_api/apigee/v1/model/google_cloud_apigee_v1_deployment_change_report.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/apigee/lib/google_api/apigee/v1/model/google_cloud_apigee_v1_deployment_change_report.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport do @moduledoc """ Response for GenerateDeployChangeReport and GenerateUndeployChangeReport. This report contains any validation failures that would cause the deployment to be rejected, as well changes and conflicts in routing that may occur due to the new deployment. The existence of a routing warning does not necessarily imply that the deployment request is bad, if the desired state of the deployment request is to effect a routing change. The primary purposes of the routing messages are: 1) To inform users of routing changes that may have an effect on traffic currently being routed to other existing deployments. 2) To warn users if some base path in the proxy will not receive traffic due to an existing deployment having already claimed that base path. The presence of routing conflicts/changes will not cause non-dry-run DeployApiProxy/UndeployApiProxy requests to be rejected. ## Attributes * `routingChanges` (*type:* `list(GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReportRoutingChange.t)`, *default:* `nil`) - All routing changes that may result from a deployment request. * `routingConflicts` (*type:* `list(GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReportRoutingConflict.t)`, *default:* `nil`) - All base path conflicts detected for a deployment request. * `validationErrors` (*type:* `GoogleApi.Apigee.V1.Model.GoogleRpcPreconditionFailure.t`, *default:* `nil`) - Validation errors that would cause the deployment change request to be rejected. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :routingChanges => list( GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReportRoutingChange.t() ), :routingConflicts => list( GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReportRoutingConflict.t() ), :validationErrors => GoogleApi.Apigee.V1.Model.GoogleRpcPreconditionFailure.t() } field(:routingChanges, as: GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReportRoutingChange, type: :list ) field(:routingConflicts, as: GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReportRoutingConflict, type: :list ) field(:validationErrors, as: GoogleApi.Apigee.V1.Model.GoogleRpcPreconditionFailure) end defimpl Poison.Decoder, for: GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport do def decode(value, options) do GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Apigee.V1.Model.GoogleCloudApigeeV1DeploymentChangeReport do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
53.313433
872
0.770717
79b675c4a3b65defbc89011b0e57b30c87fdf1f5
1,606
exs
Elixir
mix.exs
mattbaker/elixir-thrift
3d42d9a57fdca14281d0afa8993bf1c8a0e4c984
[ "Apache-2.0" ]
null
null
null
mix.exs
mattbaker/elixir-thrift
3d42d9a57fdca14281d0afa8993bf1c8a0e4c984
[ "Apache-2.0" ]
null
null
null
mix.exs
mattbaker/elixir-thrift
3d42d9a57fdca14281d0afa8993bf1c8a0e4c984
[ "Apache-2.0" ]
1
2018-06-18T20:12:02.000Z
2018-06-18T20:12:02.000Z
defmodule Thrift.Mixfile do use Mix.Project @version "1.2.1" @project_url "https://github.com/pinterest/elixir-thrift" def project do [app: :thrift, version: @version, elixir: "~> 1.0", deps: deps, # Build Environment erlc_paths: ["src", "ext/thrift/lib/erl/src"], erlc_include_path: "ext/thrift/lib/erl/include", compilers: [:leex, :erlang, :elixir, :app], # Testing test_coverage: [tool: ExCoveralls], preferred_cli_env: ["coveralls": :test, "coveralls.detail": :test, "coveralls.post": :test], # URLs source_url: @project_url, homepage_url: @project_url, # Hex description: description, package: package, # Docs name: "Thrift", docs: [source_ref: "v#{@version}", main: "Thrift", source_url: @project_url]] end def application do [applications: [:inets]] end defp deps do [{:ex_doc, "~> 0.11.4", only: :dev}, {:earmark, "~> 0.2.1", only: :dev}, {:excoveralls, "~> 0.5.4", only: :test}] end defp description do """ A collection of utilities for working with Thrift in Elixir. Provides a copy of the Apache Thrift Erlang runtime. """ end defp package do [maintainers: ["Jon Parise", "Steve Cohen"], licenses: ["Apache 2.0"], links: %{"GitHub" => @project_url}, files: ~w(README.md LICENSE mix.exs lib) ++ ~w(ext/thrift/CHANGES ext/thrift/LICENSE ext/thrift/NOTICE) ++ ~w(ext/thrift/README.md ext/thrift/doc ext/thrift/lib/erl) ++ ~w(src/thrift_lexer.xrl)] end end
25.09375
97
0.599626
79b69c13ebeb93834bc2df1053b83188f4b8f04d
3,622
exs
Elixir
talks-articles/languages-n-runtimes/elixir/book--programming-elixir-ge-1.6/chapter-07.exs
abhishekkr/tutorials_as_code
f355dc62a5025b710ac6d4a6ac2f9610265fad54
[ "MIT" ]
37
2015-02-01T23:16:39.000Z
2021-12-22T16:50:48.000Z
talks-articles/languages-n-runtimes/elixir/book--programming-elixir-ge-1.6/chapter-07.exs
abhishekkr/tutorials_as_code
f355dc62a5025b710ac6d4a6ac2f9610265fad54
[ "MIT" ]
1
2017-03-02T04:55:48.000Z
2018-01-14T10:51:11.000Z
talks-articles/languages-n-runtimes/elixir/book--programming-elixir-ge-1.6/chapter-07.exs
abhishekkr/tutorials_as_code
f355dc62a5025b710ac6d4a6ac2f9610265fad54
[ "MIT" ]
15
2015-03-02T08:09:01.000Z
2021-06-10T03:25:41.000Z
## complex list patterns defmodule MultiMatch do def swap_pairs([]), do: [] def swap_pairs([a, b | tail]), do: [b, a | swap_pairs(tail)] def swap_pairs([_|_]), do: raise "Odd element lists are not supported." end IO.inspect MultiMatch.swap_pairs([1, 3, 5, 7]) #IO.inspect MultiMatch.swap_pairs([1, 3, 5, 7, 9]) defmodule UserFilter do def for_user_7([]), do: [] def for_user_7([[time, 7, host, axn] | tail]), do: [[time, 7, host, axn] | for_user_7(tail)] def for_user_7([_ | tail]), do: for_user_7(tail) def for_user([], _), do: [] def for_user([[time, userid, host, axn] | tail], userid), do: [[time, userid, host, axn] | for_user(tail, userid)] def for_user([_ | tail], userid), do: for_user(tail, userid) def for([], _), do: [] def for([ head = [_, userid, _, _] | tail], userid), do: [head | for_user(tail, userid)] def for([_ | tail], userid), do: for_user(tail, userid) end defmodule TestData do def datax do [ [1378214512, 7, "svr1", "login"], [1378214512, 4, "svr7", "login"], [1378214513, 2, "svr3", "login"], [1378214513, 7, "svr1", "uptime"], [1378214513, 1, "svr1", "logout"], [1378214515, 7, "svr1", "logout"], [1378214517, 2, "svr1", "logout"], ] end end IO.inspect UserFilter.for_user_7(TestData.datax) IO.inspect UserFilter.for_user(TestData.datax, 1) IO.inspect UserFilter.for(TestData.datax, 2) ## list module in action defmodule ListModule do def partx do [1, 3] ++ [5, 7, 9] |> IO.inspect UserFilter.for(TestData.datax, 2) |> List.flatten |> IO.inspect List.foldl([1, 3, 5], "", &("#{&1}_#{&2}")) |> IO.inspect List.foldr([1, 3, 5], "", &("#{&1}_#{&2}")) |> IO.inspect List.replace_at([1, 3, 5], 1, "wazou") |> IO.inspect end def party do kw = [{:fname, "James"}, {:lname, "Bond"}, {:license, "to-kill", "or-not"}] kw |> List.keyfind("to-kill", 1) |> IO.inspect kw |> List.keyfind("to-kill", 2) |> IO.inspect kw |> List.keyfind("to-kill", 2, "don't kill") |> IO.inspect kw |> List.keyfind("or-not", 2) |> IO.inspect kw |> List.keydelete("or-not", 2) |> IO.inspect kw |> List.keyreplace(:fname, 0, {:first_name, "Jane"}) |> IO.inspect end end ListModule.partx ListModule.party ## exercise ListRecursion1to4 defmodule ListRecursion1to4 do defp do_mapsum(result, [], _foo), do: result defp do_mapsum(result, [h|tail], foo), do: do_mapsum(result+h, tail, foo) def mapsum(lst, foo), do: do_mapsum(0, lst, foo) def do_max([], m), do: m def do_max([h|tail], m) do cond do h > m -> do_max(tail, h) true -> do_max(tail, m) end end def max([]), do: nil def max([h|tail]), do: do_max(tail, h) def caeser([], _n), do: [] def caeser([h|tail], n) when (h+n) > 'z', do: ['?' | caeser(tail, n)] def caeser([h|tail], n), do: [h+n | caeser(tail, n)] def do_span(start, fin, lst) when start > fin, do: lst def do_span(start, fin, lst), do: do_span(start+1, fin, lst ++ [start]) def span(start, fin), do: do_span(start, fin, []) end ListRecursion1to4.mapsum([1,3,4], &(&1+1)) |> IO.inspect() ListRecursion1to4.max([10,3,4]) |> IO.inspect() ListRecursion1to4.max([1,3,4]) |> IO.inspect() ListRecursion1to4.caeser('hell-o', 10) |> IO.inspect() ListRecursion1to4.caeser('hell-o', 18) |> IO.inspect() ListRecursion1to4.span(15, 18) |> IO.inspect() ListRecursion1to4.span(15, 15) |> IO.inspect() ListRecursion1to4.span(18, 15) |> IO.inspect()
34.169811
116
0.580342
79b6a09c6742965cbd9208a13d25f4d0e1673090
1,747
ex
Elixir
clients/managed_identities/lib/google_api/managed_identities/v1/model/daily_cycle.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/managed_identities/lib/google_api/managed_identities/v1/model/daily_cycle.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/managed_identities/lib/google_api/managed_identities/v1/model/daily_cycle.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.ManagedIdentities.V1.Model.DailyCycle do @moduledoc """ Time window specified for daily operations. ## Attributes * `duration` (*type:* `String.t`, *default:* `nil`) - Output only. Duration of the time window, set by service producer. * `startTime` (*type:* `GoogleApi.ManagedIdentities.V1.Model.TimeOfDay.t`, *default:* `nil`) - Time within the day to start the operations. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :duration => String.t(), :startTime => GoogleApi.ManagedIdentities.V1.Model.TimeOfDay.t() } field(:duration) field(:startTime, as: GoogleApi.ManagedIdentities.V1.Model.TimeOfDay) end defimpl Poison.Decoder, for: GoogleApi.ManagedIdentities.V1.Model.DailyCycle do def decode(value, options) do GoogleApi.ManagedIdentities.V1.Model.DailyCycle.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.ManagedIdentities.V1.Model.DailyCycle do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
34.94
143
0.737836
79b6b061f33aaa77e240648a5e3db6aa632284ba
2,130
ex
Elixir
clients/people/lib/google_api/people/v1/model/url.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/people/lib/google_api/people/v1/model/url.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/people/lib/google_api/people/v1/model/url.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.People.V1.Model.Url do @moduledoc """ A person's associated URLs. ## Attributes * `formattedType` (*type:* `String.t`, *default:* `nil`) - Output only. The type of the URL translated and formatted in the viewer's account locale or the `Accept-Language` HTTP header locale. * `metadata` (*type:* `GoogleApi.People.V1.Model.FieldMetadata.t`, *default:* `nil`) - Metadata about the URL. * `type` (*type:* `String.t`, *default:* `nil`) - The type of the URL. The type can be custom or one of these predefined values: * `home` * `work` * `blog` * `profile` * `homePage` * `ftp` * `reservations` * `appInstallPage`: website for a Currents application. * `other` * `value` (*type:* `String.t`, *default:* `nil`) - The URL. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :formattedType => String.t(), :metadata => GoogleApi.People.V1.Model.FieldMetadata.t(), :type => String.t(), :value => String.t() } field(:formattedType) field(:metadata, as: GoogleApi.People.V1.Model.FieldMetadata) field(:type) field(:value) end defimpl Poison.Decoder, for: GoogleApi.People.V1.Model.Url do def decode(value, options) do GoogleApi.People.V1.Model.Url.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.People.V1.Model.Url do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
38.035714
275
0.695305
79b6b107ca77107f405cb35e0ad67fdb909db064
521
ex
Elixir
lib/stixex/types/windows_registry_value.ex
FloatingGhost/stixex
c3b012d0e8596fde6bd512f856f05b0187bb5273
[ "MIT" ]
1
2019-05-07T22:44:45.000Z
2019-05-07T22:44:45.000Z
lib/stixex/types/windows_registry_value.ex
FloatingGhost/stixex
c3b012d0e8596fde6bd512f856f05b0187bb5273
[ "MIT" ]
null
null
null
lib/stixex/types/windows_registry_value.ex
FloatingGhost/stixex
c3b012d0e8596fde6bd512f856f05b0187bb5273
[ "MIT" ]
null
null
null
defmodule StixEx.Types.WindowsRegistryValue do use Ecto.Schema import Ecto.Changeset import StixEx.Validation @derive Jason.Encoder @required_fields [:name] embedded_schema do field(:name, :string) field(:data, :string) field(:data_type, :string) end def changeset(struct, params) do struct |> cast(params, [:name, :data, :data_type]) |> validate_required(@required_fields) |> validate_change(:data_type, validate_values_in_enum("windows-registry-datatype-enum")) end end
23.681818
93
0.71785
79b6ce0e152af56d02c7b758120be978f500c113
2,282
ex
Elixir
lib/drab/live/cache.ex
bdfinlayson/drab
ce11a643ec8fe7e7f622489af5792ef12e69a8c7
[ "MIT" ]
null
null
null
lib/drab/live/cache.ex
bdfinlayson/drab
ce11a643ec8fe7e7f622489af5792ef12e69a8c7
[ "MIT" ]
null
null
null
lib/drab/live/cache.ex
bdfinlayson/drab
ce11a643ec8fe7e7f622489af5792ef12e69a8c7
[ "MIT" ]
null
null
null
defmodule Drab.Live.Cache do @moduledoc """ This is the `Drab.Live` internal cache module. It doesn't expose any API. ### Cache File Drab.Live stores internal information in the file `priv/drab.live.cache`. To clean up the cache just delete it, but allways followed with the `mix clean` command, to ensure all Drab.Live templates will recompile. """ @cache_file "drab.live.cache" require Logger # TODO: clean the table on mix clean # This module is the DETS cache for Drab Live expressions, amperes, partials, and shadow buffers. # DETS table is created and filled up during the compile-time. # Internal representation: # "expr_hash" => {:expr, expression, [:assigns], [:parent_assigns]} # {"partial_hash", "ampere_id"} => [amperes] # amperes - {:html | :prop | :attr, "tag", "prop_or_attr", expression, [:assigns], [:children]} # one ampere_id may contain more amperes, for different properties or attributes # {"partial_hash", :assign} => ["ampere_ids"] # "partial_hash" => {"partial_path", [:assigns]} @doc false @spec start :: :ok def start() do # if :dets.info(cache_file()) == :undefined do {:ok, _} = :dets.open_file(cache_file(), type: :set, ram_file: true) # end :ok end @doc false @spec stop :: :ok def stop() do :dets.close(cache_file()) end # Runtime function. Lookup in the already opened ETS cache @doc false @spec get(atom | String.t() | tuple) :: term def get(k) do val = case :dets.lookup(cache_file(), k) do [{_, v}] -> v [] -> nil _ -> raise "Can't find the expression or hash #{inspect(k)} in the Drab.Live.Cache" end val end @doc false @spec set(atom | String.t() | tuple, term) :: :ok def set(k, v) do :dets.insert(cache_file(), {k, v}) :dets.sync(cache_file()) end @doc false @spec add(atom | String.t() | tuple, term) :: :ok def add(k, v) do list = get(k) || [] :dets.insert(cache_file(), {k, list ++ [v]}) :dets.sync(cache_file()) end @doc false @spec cache_file :: String.t() def cache_file() do # "#{Path.join(Drab.Config.app_name() |> :code.priv_dir() |> to_string(), @cache_file)}" "#{Path.join(:drab |> :code.priv_dir() |> to_string(), @cache_file)}" end end
30.026316
118
0.628396
79b7087ba2aee6ac695d5a2a18d0aa998cbb6618
36,368
ex
Elixir
lib/exirc/client.ex
jeffweiss/exirc
d56e1d93ef83d350606e489021a276f8a49e9480
[ "MIT" ]
null
null
null
lib/exirc/client.ex
jeffweiss/exirc
d56e1d93ef83d350606e489021a276f8a49e9480
[ "MIT" ]
null
null
null
lib/exirc/client.ex
jeffweiss/exirc
d56e1d93ef83d350606e489021a276f8a49e9480
[ "MIT" ]
null
null
null
defmodule ExIRC.Client do @moduledoc """ Maintains the state and behaviour for individual IRC client connections """ use ExIRC.Commands use GenServer import ExIRC.Logger alias ExIRC.Channels alias ExIRC.Utils alias ExIRC.SenderInfo alias ExIRC.Client.Transport # Client internal state defmodule ClientState do defstruct event_handlers: [], server: "localhost", port: 6667, socket: nil, nick: "", pass: "", user: "", name: "", ssl?: false, connected?: false, logged_on?: false, autoping: true, channel_prefixes: "", network: "", user_prefixes: "", login_time: "", channels: [], debug?: false, retries: 0, inet: :inet, owner: nil, whois_buffers: %{}, who_buffers: %{} end ################# # External API ################# @doc """ Start a new IRC client process Returns either {:ok, pid} or {:error, reason} """ @spec start!(options :: list() | nil) :: {:ok, pid} | {:error, term} def start!(options \\ []) do start_link(options) end @doc """ Start a new IRC client process. Returns either {:ok, pid} or {:error, reason} """ @spec start_link(options :: list() | nil, process_opts :: list() | nil) :: {:ok, pid} | {:error, term} def start_link(options \\ [], process_opts \\ []) do options = Keyword.put_new(options, :owner, self()) GenServer.start_link(__MODULE__, options, process_opts) end @doc """ Stop the IRC client process """ @spec stop!(client :: pid) :: {:stop, :normal, :ok, ClientState.t} def stop!(client) do GenServer.call(client, :stop) end @doc """ Connect to a server with the provided server and port Example: Client.connect! pid, "localhost", 6667 """ @spec connect!(client :: pid, server :: binary, port :: non_neg_integer, options :: list() | nil) :: :ok def connect!(client, server, port, options \\ []) do GenServer.call(client, {:connect, server, port, options, false}, :infinity) end @doc """ Connect to a server with the provided server and port via SSL Example: Client.connect! pid, "localhost", 6697 """ @spec connect_ssl!(client :: pid, server :: binary, port :: non_neg_integer, options :: list() | nil) :: :ok def connect_ssl!(client, server, port, options \\ []) do GenServer.call(client, {:connect, server, port, options, true}, :infinity) end @doc """ Determine if the provided client process has an open connection to a server """ @spec is_connected?(client :: pid) :: true | false def is_connected?(client) do GenServer.call(client, :is_connected?) end @doc """ Logon to a server Example: Client.logon pid, "password", "mynick", "user", "My Name" """ @spec logon(client :: pid, pass :: binary, nick :: binary, user :: binary, name :: binary) :: :ok | {:error, :not_connected} def logon(client, pass, nick, user, name) do GenServer.call(client, {:logon, pass, nick, user, name}, :infinity) end @doc """ Determine if the provided client is logged on to a server """ @spec is_logged_on?(client :: pid) :: true | false def is_logged_on?(client) do GenServer.call(client, :is_logged_on?) end @doc """ Send a message to a nick or channel Message types are: :privmsg :notice :ctcp """ @spec msg(client :: pid, type :: atom, nick :: binary, msg :: binary) :: :ok | {:error, atom} def msg(client, type, nick, msg) do GenServer.call(client, {:msg, type, nick, msg}, :infinity) end @doc """ Send an action message, i.e. (/me slaps someone with a big trout) """ @spec me(client :: pid, channel :: binary, msg :: binary) :: :ok | {:error, atom} def me(client, channel, msg) do GenServer.call(client, {:me, channel, msg}, :infinity) end @doc """ Change the client's nick """ @spec nick(client :: pid, new_nick :: binary) :: :ok | {:error, atom} def nick(client, new_nick) do GenServer.call(client, {:nick, new_nick}, :infinity) end @doc """ Send a raw IRC command """ @spec cmd(client :: pid, raw_cmd :: binary) :: :ok | {:error, atom} def cmd(client, raw_cmd) do GenServer.call(client, {:cmd, raw_cmd}) end @doc """ Join a channel, with an optional password """ @spec join(client :: pid, channel :: binary, key :: binary | nil) :: :ok | {:error, atom} def join(client, channel, key \\ "") do GenServer.call(client, {:join, channel, key}, :infinity) end @doc """ Leave a channel """ @spec part(client :: pid, channel :: binary) :: :ok | {:error, atom} def part(client, channel) do GenServer.call(client, {:part, channel}, :infinity) end @doc """ Kick a user from a channel """ @spec kick(client :: pid, channel :: binary, nick :: binary, message :: binary | nil) :: :ok | {:error, atom} def kick(client, channel, nick, message \\ "") do GenServer.call(client, {:kick, channel, nick, message}, :infinity) end @spec names(client :: pid, channel :: binary) :: :ok | {:error, atom} def names(client, channel) do GenServer.call(client, {:names, channel}, :infinity) end @doc """ Ask the server for the user's informations. """ @spec whois(client :: pid, user :: binary) :: :ok | {:error, atom()} def whois(client, user) do GenServer.call(client, {:whois, user}, :infinity) end @doc """ Ask the server for the channel's users """ @spec who(client :: pid, channel :: binary) :: :ok | {:error, atom()} def who(client, channel) do GenServer.call(client, {:who, channel}, :infinity) end @doc """ Change mode for a user or channel """ @spec mode(client :: pid, channel_or_nick :: binary, flags :: binary, args :: binary | nil) :: :ok | {:error, atom} def mode(client, channel_or_nick, flags, args \\ "") do GenServer.call(client, {:mode, channel_or_nick, flags, args}, :infinity) end @doc """ Invite a user to a channel """ @spec invite(client :: pid, nick :: binary, channel :: binary) :: :ok | {:error, atom} def invite(client, nick, channel) do GenServer.call(client, {:invite, nick, channel}, :infinity) end @doc """ Quit the server, with an optional part message """ @spec quit(client :: pid, msg :: binary | nil) :: :ok | {:error, atom} def quit(client, msg \\ "Leaving..") do GenServer.call(client, {:quit, msg}, :infinity) end @doc """ Get details about each of the client's currently joined channels """ @spec channels(client :: pid) :: list(binary) | [] | {:error, atom} def channels(client) do GenServer.call(client, :channels) end @doc """ Get a list of users in the provided channel """ @spec channel_users(client :: pid, channel :: binary) :: list(binary) | [] | {:error, atom} def channel_users(client, channel) do GenServer.call(client, {:channel_users, channel}) end @doc """ Get the topic of the provided channel """ @spec channel_topic(client :: pid, channel :: binary) :: binary | {:error, atom} def channel_topic(client, channel) do GenServer.call(client, {:channel_topic, channel}) end @doc """ Get the channel type of the provided channel """ @spec channel_type(client :: pid, channel :: binary) :: atom | {:error, atom} def channel_type(client, channel) do GenServer.call(client, {:channel_type, channel}) end @doc """ Determine if a nick is present in the provided channel """ @spec channel_has_user?(client :: pid, channel :: binary, nick :: binary) :: true | false | {:error, atom} def channel_has_user?(client, channel, nick) do GenServer.call(client, {:channel_has_user?, channel, nick}) end @doc """ Add a new event handler process """ @spec add_handler(client :: pid, pid) :: :ok def add_handler(client, pid) do GenServer.call(client, {:add_handler, pid}) end @doc """ Add a new event handler process, asynchronously """ @spec add_handler_async(client :: pid, pid) :: :ok def add_handler_async(client, pid) do GenServer.cast(client, {:add_handler, pid}) end @doc """ Remove an event handler process """ @spec remove_handler(client :: pid, pid) :: :ok def remove_handler(client, pid) do GenServer.call(client, {:remove_handler, pid}) end @doc """ Remove an event handler process, asynchronously """ @spec remove_handler_async(client :: pid, pid) :: :ok def remove_handler_async(client, pid) do GenServer.cast(client, {:remove_handler, pid}) end @doc """ Get the current state of the provided client """ @spec state(client :: pid) :: [{atom, any}] def state(client) do state = GenServer.call(client, :state) [server: state.server, port: state.port, nick: state.nick, pass: state.pass, user: state.user, name: state.name, autoping: state.autoping, ssl?: state.ssl?, connected?: state.connected?, logged_on?: state.logged_on?, channel_prefixes: state.channel_prefixes, user_prefixes: state.user_prefixes, channels: Channels.to_proplist(state.channels), network: state.network, login_time: state.login_time, debug?: state.debug?, event_handlers: state.event_handlers] end ############### # GenServer API ############### @doc """ Called when GenServer initializes the client """ @spec init(list(any) | []) :: {:ok, ClientState.t} def init(options \\ []) do autoping = Keyword.get(options, :autoping, true) debug = Keyword.get(options, :debug, false) owner = Keyword.fetch!(options, :owner) # Add event handlers handlers = Keyword.get(options, :event_handlers, []) |> List.foldl([], &do_add_handler/2) ref = Process.monitor(owner) # Return initial state {:ok, %ClientState{ event_handlers: handlers, autoping: autoping, logged_on?: false, debug?: debug, channels: ExIRC.Channels.init(), owner: {owner, ref}}} end @doc """ Handle calls from the external API. It is not recommended to call these directly. """ # Handle call to get the current state of the client process def handle_call(:state, _from, state), do: {:reply, state, state} # Handle call to stop the current client process def handle_call(:stop, _from, state) do # Ensure the socket connection is closed if stop is called while still connected to the server if state.connected?, do: Transport.close(state) {:stop, :normal, :ok, %{state | connected?: false, logged_on?: false, socket: nil}} end # Handles call to add a new event handler process def handle_call({:add_handler, pid}, _from, state) do handlers = do_add_handler(pid, state.event_handlers) {:reply, :ok, %{state | event_handlers: handlers}} end # Handles call to remove an event handler process def handle_call({:remove_handler, pid}, _from, state) do handlers = do_remove_handler(pid, state.event_handlers) {:reply, :ok, %{state | event_handlers: handlers}} end # Handle call to connect to an IRC server def handle_call({:connect, server, port, options, ssl}, _from, state) do # If there is an open connection already, close it. if state.socket != nil, do: Transport.close(state) # Set SSL mode state = %{state | ssl?: ssl} # Open a new connection case Transport.connect(state, String.to_charlist(server), port, [:list, {:packet, :line}, {:keepalive, true}] ++ options) do {:ok, socket} -> send_event {:connected, server, port}, state {:reply, :ok, %{state | connected?: true, server: server, port: port, socket: socket}} error -> {:reply, error, state} end end # Handle call to determine if the client is connected def handle_call(:is_connected?, _from, state), do: {:reply, state.connected?, state} # Prevents any of the following messages from being handled if the client is not connected to a server. # Instead, it returns {:error, :not_connected}. def handle_call(_, _from, %ClientState{connected?: false} = state), do: {:reply, {:error, :not_connected}, state} # Handle call to login to the connected IRC server def handle_call({:logon, pass, nick, user, name}, _from, %ClientState{logged_on?: false} = state) do Transport.send state, pass!(pass) Transport.send state, nick!(nick) Transport.send state, user!(user, name) {:reply, :ok, %{state | pass: pass, nick: nick, user: user, name: name} } end # Handles call to change the client's nick. def handle_call({:nick, new_nick}, _from, %ClientState{logged_on?: false} = state) do Transport.send state, nick!(new_nick) # Since we've not yet logged on, we won't get a nick change message, so we have to remember the nick here. {:reply, :ok, %{state | nick: new_nick}} end # Handle call to determine if client is logged on to a server def handle_call(:is_logged_on?, _from, state), do: {:reply, state.logged_on?, state} # Prevents any of the following messages from being handled if the client is not logged on to a server. # Instead, it returns {:error, :not_logged_in}. def handle_call(_, _from, %ClientState{logged_on?: false} = state), do: {:reply, {:error, :not_logged_in}, state} # Handles call to send a message def handle_call({:msg, type, nick, msg}, _from, state) do data = case type do :privmsg -> privmsg!(nick, msg) :notice -> notice!(nick, msg) :ctcp -> notice!(nick, ctcp!(msg)) end Transport.send state, data {:reply, :ok, state} end # Handle /me messages def handle_call({:me, channel, msg}, _from, state) do data = me!(channel, msg) Transport.send state, data {:reply, :ok, state} end # Handles call to join a channel def handle_call({:join, channel, key}, _from, state) do Transport.send(state, join!(channel, key)) {:reply, :ok, state} end # Handles a call to leave a channel def handle_call({:part, channel}, _from, state) do Transport.send(state, part!(channel)) {:reply, :ok, state} end # Handles a call to kick a client def handle_call({:kick, channel, nick, message}, _from, state) do Transport.send(state, kick!(channel, nick, message)) {:reply, :ok, state} end # Handles a call to send the NAMES command to the server def handle_call({:names, channel}, _from, state) do Transport.send(state, names!(channel)) {:reply, :ok, state} end def handle_call({:whois, user}, _from, state) do Transport.send(state, whois!(user)) {:reply, :ok, state} end def handle_call({:who, channel}, _from, state) do Transport.send(state, who!(channel)) {:reply, :ok, state} end # Handles a call to change mode for a user or channel def handle_call({:mode, channel_or_nick, flags, args}, _from, state) do Transport.send(state, mode!(channel_or_nick, flags, args)) {:reply, :ok, state} end # Handle call to invite a user to a channel def handle_call({:invite, nick, channel}, _from, state) do Transport.send(state, invite!(nick, channel)) {:reply, :ok, state} end # Handle call to quit the server and close the socket connection def handle_call({:quit, msg}, _from, state) do if state.connected? do Transport.send state, quit!(msg) send_event(:disconnected, state) Transport.close state end {:reply, :ok, %{state | connected?: false, logged_on?: false, socket: nil}} end # Handles call to change the client's nick def handle_call({:nick, new_nick}, _from, state) do Transport.send(state, nick!(new_nick)); {:reply, :ok, state} end # Handles call to send a raw command to the IRC server def handle_call({:cmd, raw_cmd}, _from, state) do Transport.send(state, command!(raw_cmd)); {:reply, :ok, state} end # Handles call to return the client's channel data def handle_call(:channels, _from, state), do: {:reply, Channels.channels(state.channels), state} # Handles call to return a list of users for a given channel def handle_call({:channel_users, channel}, _from, state), do: {:reply, Channels.channel_users(state.channels, channel), state} # Handles call to return the given channel's topic def handle_call({:channel_topic, channel}, _from, state), do: {:reply, Channels.channel_topic(state.channels, channel), state} # Handles call to return the type of the given channel def handle_call({:channel_type, channel}, _from, state), do: {:reply, Channels.channel_type(state.channels, channel), state} # Handles call to determine if a nick is present in the given channel def handle_call({:channel_has_user?, channel, nick}, _from, state) do {:reply, Channels.channel_has_user?(state.channels, channel, nick), state} end # Handles message to add a new event handler process asynchronously def handle_cast({:add_handler, pid}, state) do handlers = do_add_handler(pid, state.event_handlers) {:noreply, %{state | event_handlers: handlers}} end @doc """ Handles asynchronous messages from the external API. Not recommended to call these directly. """ # Handles message to remove an event handler process asynchronously def handle_cast({:remove_handler, pid}, state) do handlers = do_remove_handler(pid, state.event_handlers) {:noreply, %{state | event_handlers: handlers}} end @doc """ Handle messages from the TCP socket connection. """ # Handles the client's socket connection 'closed' event def handle_info({:tcp_closed, _socket}, %ClientState{server: server, port: port} = state) do info "Connection to #{server}:#{port} closed!" send_event :disconnected, state new_state = %{state | socket: nil, connected?: false, logged_on?: false, channels: Channels.init() } {:noreply, new_state} end @doc """ Handle messages from the SSL socket connection. """ # Handles the client's socket connection 'closed' event def handle_info({:ssl_closed, socket}, state) do handle_info({:tcp_closed, socket}, state) end # Handles any TCP errors in the client's socket connection def handle_info({:tcp_error, socket, reason}, %ClientState{server: server, port: port} = state) do error "TCP error in connection to #{server}:#{port}:\r\n#{reason}\r\nClient connection closed." new_state = %{state | socket: nil, connected?: false, logged_on?: false, channels: Channels.init() } {:stop, {:tcp_error, socket}, new_state} end # Handles any SSL errors in the client's socket connection def handle_info({:ssl_error, socket, reason}, state) do handle_info({:tcp_error, socket, reason}, state) end # General handler for messages from the IRC server def handle_info({:tcp, _, data}, state) do debug? = state.debug? case Utils.parse(data) do %ExIRC.Message{ctcp: true} = msg -> handle_data msg, state {:noreply, state} %ExIRC.Message{ctcp: false} = msg -> handle_data msg, state %ExIRC.Message{ctcp: :invalid} = msg when debug? -> send_event msg, state {:noreply, state} _ -> {:noreply, state} end end # Wrapper for SSL socket messages def handle_info({:ssl, socket, data}, state) do handle_info({:tcp, socket, data}, state) end # If the owner process dies, we should die as well def handle_info({:DOWN, ref, _, pid, reason}, %{owner: {pid, ref}} = state) do {:stop, reason, state} end # If an event handler process dies, remove it from the list of event handlers def handle_info({:DOWN, _, _, pid, _}, state) do handlers = do_remove_handler(pid, state.event_handlers) {:noreply, %{state | event_handlers: handlers}} end # Catch-all for unrecognized messages (do nothing) def handle_info(_, state) do {:noreply, state} end @doc """ Handle termination """ def terminate(_reason, state) do if state.socket != nil do Transport.close state %{state | socket: nil} end :ok end @doc """ Transform state for hot upgrades/downgrades """ def code_change(_old, state, _extra), do: {:ok, state} ################ # Data handling ################ @doc """ Handle ExIRC.Messages received from the server. """ # Called upon successful login def handle_data(%ExIRC.Message{cmd: @rpl_welcome}, %ClientState{logged_on?: false} = state) do if state.debug?, do: debug "SUCCESFULLY LOGGED ON" new_state = %{state | logged_on?: true, login_time: :erlang.timestamp()} send_event :logged_in, new_state {:noreply, new_state} end # Called when the server sends it's current capabilities def handle_data(%ExIRC.Message{cmd: @rpl_isupport} = msg, state) do if state.debug?, do: debug "RECEIVING SERVER CAPABILITIES" {:noreply, Utils.isup(msg.args, state)} end # Called when the client enters a channel def handle_data(%ExIRC.Message{nick: nick, cmd: "JOIN"} = msg, %ClientState{nick: nick} = state) do channel = msg.args |> List.first |> String.trim if state.debug?, do: debug "JOINED A CHANNEL #{channel}" channels = Channels.join(state.channels, channel) new_state = %{state | channels: channels} send_event {:joined, channel}, new_state {:noreply, new_state} end # Called when another user joins a channel the client is in def handle_data(%ExIRC.Message{nick: user_nick, cmd: "JOIN", host: host, user: user} = msg, state) do sender = %SenderInfo{nick: user_nick, host: host, user: user} channel = msg.args |> List.first |> String.trim if state.debug?, do: debug "ANOTHER USER JOINED A CHANNEL: #{channel} - #{user_nick}" channels = Channels.user_join(state.channels, channel, user_nick) new_state = %{state | channels: channels} send_event {:joined, channel, sender}, new_state {:noreply, new_state} end # Called on joining a channel, to tell us the channel topic # Message with three arguments is not RFC compliant but very common # Message with two arguments is RFC compliant # Message with a single argument is not RFC compliant, but is present # to handle poorly written IRC servers which send RPL_TOPIC with an empty # topic (such as Slack's IRC bridge), when they should be sending RPL_NOTOPIC def handle_data(%ExIRC.Message{cmd: @rpl_topic} = msg, state) do {channel, topic} = case msg.args do [_nick, channel, topic] -> {channel, topic} [channel, topic] -> {channel, topic} [channel] -> {channel, "No topic is set"} end if state.debug? do debug "INITIAL TOPIC MSG" debug "1. TOPIC SET FOR #{channel} TO #{topic}" end channels = Channels.set_topic(state.channels, channel, topic) new_state = %{state | channels: channels} send_event {:topic_changed, channel, topic}, new_state {:noreply, new_state} end ## WHOIS def handle_data(%ExIRC.Message{cmd: @rpl_whoisuser, args: [_sender, nick, user, hostname, _, name]}, state) do user = %{nick: nick, user: user, hostname: hostname, name: name} {:noreply, %ClientState{state|whois_buffers: Map.put(state.whois_buffers, nick, user)}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoiscertfp, args: [_sender, nick, "has client certificate fingerprint "<> fingerprint]}, state) do {:noreply, %ClientState{state|whois_buffers: put_in(state.whois_buffers, [nick, :certfp], fingerprint)}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoisregnick, args: [_sender, nick, _message]}, state) do {:noreply, %ClientState{state|whois_buffers: put_in(state.whois_buffers, [nick, :registered_nick?], true)}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoishelpop, args: [_sender, nick, _message]}, state) do {:noreply, %ClientState{state|whois_buffers: put_in(state.whois_buffers, [nick, :helpop?], true)}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoischannels, args: [_sender, nick, channels]}, state) do chans = String.split(channels, " ") {:noreply, %ClientState{state|whois_buffers: put_in(state.whois_buffers, [nick, :channels], chans)}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoisserver, args: [_sender, nick, server_addr, server_name]}, state) do new_buffer = state.whois_buffers |> put_in([nick, :server_name], server_name) |> put_in([nick, :server_address], server_addr) {:noreply, %ClientState{state|whois_buffers: new_buffer}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoisoperator, args: [_sender, nick, _message]}, state) do {:noreply, %ClientState{state|whois_buffers: put_in(state.whois_buffers, [nick, :ircop?], true)}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoisaccount, args: [_sender, nick, account_name, _message]}, state) do {:noreply, %ClientState{state|whois_buffers: put_in(state.whois_buffers, [nick, :account_name], account_name)}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoissecure, args: [_sender, nick, _message]}, state) do {:noreply, %ClientState{state|whois_buffers: put_in(state.whois_buffers, [nick, :ssl?], true)}} end def handle_data(%ExIRC.Message{cmd: @rpl_whoisidle, args: [_sender, nick, idling_time, signon_time, _message]}, state) do new_buffer = state.whois_buffers |> put_in([nick, :idling_time], idling_time) |> put_in([nick, :signon_time], signon_time) {:noreply, %ClientState{state|whois_buffers: new_buffer}} end def handle_data(%ExIRC.Message{cmd: @rpl_endofwhois, args: [_sender, nick, _message]}, state) do buffer = struct(ExIRC.Whois, state.whois_buffers[nick]) send_event {:whois, buffer}, state {:noreply, %ClientState{state|whois_buffers: Map.delete(state.whois_buffers, nick)}} end ## WHO def handle_data(%ExIRC.Message{:cmd => "352", :args => [_, channel, user, host, server, nick, mode, hop_and_realn]}, state) do [hop, name] = String.split(hop_and_realn, " ", parts: 2) :binary.compile_pattern(["@", "&", "+"]) admin? = String.contains?(mode, "&") away? = String.contains?(mode, "G") founder? = String.contains?(mode, "~") half_operator? = String.contains?(mode, "%") operator? = founder? || admin? || String.contains?(mode, "@") server_operator? = String.contains?(mode, "*") voiced? = String.contains?(mode, "+") nick = %{nick: nick, user: user, name: name, server: server, hops: hop, admin?: admin?, away?: away?, founder?: founder?, half_operator?: half_operator?, host: host, operator?: operator?, server_operator?: server_operator?, voiced?: voiced? } buffer = Map.get(state.who_buffers, channel, []) {:noreply, %ClientState{state | who_buffers: Map.put(state.who_buffers, channel, [nick|buffer])}} end def handle_data(%ExIRC.Message{:cmd => "315", :args => [_, channel, _]}, state) do buffer = state |> Map.get(:who_buffers) |> Map.get(channel) |> Enum.map(fn user -> struct(ExIRC.Who, user) end) send_event {:who, channel, buffer}, state {:noreply, %ClientState{state | who_buffers: Map.delete(state.who_buffers, channel)}} end def handle_data(%ExIRC.Message{cmd: @rpl_notopic, args: [channel]}, state) do if state.debug? do debug "INITIAL TOPIC MSG" debug "1. NO TOPIC SET FOR #{channel}}" end channels = Channels.set_topic(state.channels, channel, "No topic is set") new_state = %{state | channels: channels} {:noreply, new_state} end # Called when the topic changes while we're in the channel def handle_data(%ExIRC.Message{cmd: "TOPIC", args: [channel, topic]}, state) do if state.debug?, do: debug "TOPIC CHANGED FOR #{channel} TO #{topic}" channels = Channels.set_topic(state.channels, channel, topic) new_state = %{state | channels: channels} send_event {:topic_changed, channel, topic}, new_state {:noreply, new_state} end # Called when joining a channel with the list of current users in that channel, or when the NAMES command is sent def handle_data(%ExIRC.Message{cmd: @rpl_namereply} = msg, state) do if state.debug?, do: debug "NAMES LIST RECEIVED" {_nick, channel_type, channel, names} = case msg.args do [nick, channel_type, channel, names] -> {nick, channel_type, channel, names} [channel_type, channel, names] -> {nil, channel_type, channel, names} end channels = Channels.set_type( Channels.users_join(state.channels, channel, String.split(names, " ", trim: true)), channel, channel_type) send_event({:names_list, channel, names}, state) {:noreply, %{state | channels: channels}} end # Called when our nick has succesfully changed def handle_data(%ExIRC.Message{cmd: "NICK", nick: nick, args: [new_nick]}, %ClientState{nick: nick} = state) do if state.debug?, do: debug "NICK CHANGED FROM #{nick} TO #{new_nick}" new_state = %{state | nick: new_nick} send_event {:nick_changed, new_nick}, new_state {:noreply, new_state} end # Called when someone visible to us changes their nick def handle_data(%ExIRC.Message{cmd: "NICK", nick: nick, args: [new_nick]}, state) do if state.debug?, do: debug "#{nick} CHANGED THEIR NICK TO #{new_nick}" channels = Channels.user_rename(state.channels, nick, new_nick) new_state = %{state | channels: channels} send_event {:nick_changed, nick, new_nick}, new_state {:noreply, new_state} end # Called upon mode change def handle_data(%ExIRC.Message{cmd: "MODE", args: [channel, op, user]}, state) do if state.debug?, do: debug "MODE #{channel} #{op} #{user}" send_event {:mode, [channel, op, user]}, state {:noreply, state} end # Called when we leave a channel def handle_data(%ExIRC.Message{cmd: "PART", nick: nick} = msg, %ClientState{nick: nick} = state) do channel = msg.args |> List.first |> String.trim if state.debug?, do: debug "WE LEFT A CHANNEL: #{channel}" channels = Channels.part(state.channels, channel) new_state = %{state | channels: channels} send_event {:parted, channel}, new_state {:noreply, new_state} end # Called when someone else in our channel leaves def handle_data(%ExIRC.Message{cmd: "PART", nick: from, host: host, user: user} = msg, state) do sender = %SenderInfo{nick: from, host: host, user: user} channel = msg.args |> List.first |> String.trim if state.debug?, do: debug "#{from} LEFT A CHANNEL: #{channel}" channels = Channels.user_part(state.channels, channel, from) new_state = %{state | channels: channels} send_event {:parted, channel, sender}, new_state {:noreply, new_state} end def handle_data(%ExIRC.Message{cmd: "QUIT", nick: from, host: host, user: user} = msg, state) do sender = %SenderInfo{nick: from, host: host, user: user} reason = msg.args |> List.first if state.debug?, do: debug "#{from} QUIT" channels = Channels.user_quit(state.channels, from) new_state = %{state | channels: channels} send_event {:quit, reason, sender}, new_state {:noreply, new_state} end # Called when we receive a PING def handle_data(%ExIRC.Message{cmd: "PING"} = msg, %ClientState{autoping: true} = state) do if state.debug?, do: debug "RECEIVED A PING!" case msg do %ExIRC.Message{args: [from]} -> if state.debug?, do: debug("SENT PONG2") Transport.send(state, pong2!(from, msg.server)) _ -> if state.debug?, do: debug("SENT PONG1") Transport.send(state, pong1!(state.nick)) end {:noreply, state}; end # Called when we are invited to a channel def handle_data(%ExIRC.Message{cmd: "INVITE", args: [nick, channel], nick: by, host: host, user: user} = msg, %ClientState{nick: nick} = state) do sender = %SenderInfo{nick: by, host: host, user: user} if state.debug?, do: debug "RECEIVED AN INVITE: #{msg.args |> Enum.join(" ")}" send_event {:invited, sender, channel}, state {:noreply, state} end # Called when we are kicked from a channel def handle_data(%ExIRC.Message{cmd: "KICK", args: [channel, nick, reason], nick: by, host: host, user: user} = _msg, %ClientState{nick: nick} = state) do sender = %SenderInfo{nick: by, host: host, user: user} if state.debug?, do: debug "WE WERE KICKED FROM #{channel} BY #{by}" send_event {:kicked, sender, channel, reason}, state {:noreply, state} end # Called when someone else was kicked from a channel def handle_data(%ExIRC.Message{cmd: "KICK", args: [channel, nick, reason], nick: by, host: host, user: user} = _msg, state) do sender = %SenderInfo{nick: by, host: host, user: user} if state.debug?, do: debug "#{nick} WAS KICKED FROM #{channel} BY #{by}" send_event {:kicked, nick, sender, channel, reason}, state {:noreply, state} end # Called when someone sends us a message def handle_data(%ExIRC.Message{nick: from, cmd: "PRIVMSG", args: [nick, message], host: host, user: user} = _msg, %ClientState{nick: nick} = state) do sender = %SenderInfo{nick: from, host: host, user: user} if state.debug?, do: debug "#{from} SENT US #{message}" send_event {:received, message, sender}, state {:noreply, state} end # Called when someone sends a message to a channel we're in, or a list of users def handle_data(%ExIRC.Message{nick: from, cmd: "PRIVMSG", args: [to, message], host: host, user: user} = _msg, %ClientState{nick: nick} = state) do sender = %SenderInfo{nick: from, host: host, user: user} if state.debug?, do: debug "#{from} SENT #{message} TO #{to}" send_event {:received, message, sender, to}, state # If we were mentioned, fire that event as well if String.contains?(message, nick), do: send_event({:mentioned, message, sender, to}, state) {:noreply, state} end # Called when someone uses ACTION, i.e. `/me dies` def handle_data(%ExIRC.Message{nick: from, cmd: "ACTION", args: [channel, message], host: host, user: user} = _msg, state) do sender = %SenderInfo{nick: from, host: host, user: user} if state.debug?, do: debug "* #{from} #{message} in #{channel}" send_event {:me, message, sender, channel}, state {:noreply, state} end # Called when a NOTICE is received by the client. def handle_data(%ExIRC.Message{nick: from, cmd: "NOTICE", args: [_target, message], host: host, user: user} = _msg, state) do sender = %SenderInfo{nick: from, host: host, user: user} if String.contains?(message, "identify") do if state.debug?, do: debug("* Told to identify by #{from}: #{message}") send_event({:identify, message, sender}, state) else if state.debug?, do: debug("* #{message} from #{sender}") send_event({:notice, message, sender}, state) end {:noreply, state} end # Called any time we receive an unrecognized message def handle_data(msg, state) do if state.debug? do debug "UNRECOGNIZED MSG: #{msg.cmd}"; IO.inspect(msg) end send_event {:unrecognized, msg.cmd, msg}, state {:noreply, state} end ############### # Internal API ############### defp send_event(msg, %ClientState{event_handlers: handlers}) when is_list(handlers) do Enum.each(handlers, fn({pid, _}) -> Kernel.send(pid, msg) end) end defp do_add_handler(pid, handlers) do case Enum.member?(handlers, pid) do false -> ref = Process.monitor(pid) [{pid, ref} | handlers] true -> handlers end end defp do_remove_handler(pid, handlers) do case List.keyfind(handlers, pid, 0) do {pid, ref} -> Process.demonitor(ref) List.keydelete(handlers, pid, 0) nil -> handlers end end defp debug(msg) do IO.puts(IO.ANSI.green() <> msg <> IO.ANSI.reset()) end end
39.616558
155
0.64488
79b751504d9fe2d426d6350717450b2816fc73a6
1,891
ex
Elixir
clients/civic_info/lib/google_api/civic_info/v2/model/election.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/civic_info/lib/google_api/civic_info/v2/model/election.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/civic_info/lib/google_api/civic_info/v2/model/election.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
1
2018-07-28T20:50:50.000Z
2018-07-28T20:50:50.000Z
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.CivicInfo.V2.Model.Election do @moduledoc """ Information about the election that was queried. ## Attributes - electionDay (String): Day of the election in YYYY-MM-DD format. Defaults to: `null`. - id (String): The unique ID of this election. Defaults to: `null`. - name (String): A displayable name for the election. Defaults to: `null`. - ocdDivisionId (String): The political division of the election. Represented as an OCD Division ID. Voters within these political jurisdictions are covered by this election. This is typically a state such as ocd-division/country:us/state:ca or for the midterms or general election the entire US (i.e. ocd-division/country:us). Defaults to: `null`. """ defstruct [ :"electionDay", :"id", :"name", :"ocdDivisionId" ] end defimpl Poison.Decoder, for: GoogleApi.CivicInfo.V2.Model.Election do def decode(value, _options) do value end end defimpl Poison.Encoder, for: GoogleApi.CivicInfo.V2.Model.Election do def encode(value, options) do GoogleApi.CivicInfo.V2.Deserializer.serialize_non_nil(value, options) end end
36.365385
350
0.74458
79b7570c6b0ed53fa0b22b132f4a454816d08af1
1,343
exs
Elixir
mix.exs
dcarneiro/exsolr
412d4c780fb45bc4f244bfaad4c864c1419b594d
[ "MIT" ]
25
2016-05-10T00:02:27.000Z
2020-11-08T16:51:43.000Z
mix.exs
dcarneiro/exsolr
412d4c780fb45bc4f244bfaad4c864c1419b594d
[ "MIT" ]
2
2016-11-01T10:23:20.000Z
2016-11-14T23:29:28.000Z
mix.exs
dcarneiro/exsolr
412d4c780fb45bc4f244bfaad4c864c1419b594d
[ "MIT" ]
16
2016-05-22T02:12:15.000Z
2021-02-10T20:56:54.000Z
defmodule Exsolr.Mixfile do use Mix.Project def project do [ app: :exsolr, version: "0.0.1", elixir: "~> 1.2", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, description: description, package: package, deps: deps, ] end defp description do """ Thin Wrapper around Solr api. """ end defp package do [ files: ["lib", "mix.exs", "README.md"], maintainers: ["Daniel Carneiro"], licenses: ["MIT License (MIT)"], links: %{"GitHub" => "https://github.com/dcarneiro/exsolr", "Docs" => "http://hexdocs.pm/exsolr/"} ] end # Configuration for the OTP application # # Type "mix help compile.app" for more information def application do [applications: [:httpoison, :logger]] end # Dependencies can be Hex packages: # # {:mydep, "~> 0.3.0"} # # Or git/path repositories: # # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"} # # Type "mix help deps" for more examples and options defp deps do [ {:httpoison, "~> 0.8.0"}, {:poison, "~> 2.0"}, {:credo, "~> 0.3", only: [:dev, :test]}, {:earmark, "~> 0.1", only: :dev}, {:ex_doc, "~> 0.11", only: :dev}, {:dialyxir, "~> 0.3", only: :dev}, ] end end
22.383333
77
0.541325
79b79c4afcce3a0dbbad4165583a4f331f2d4455
853
ex
Elixir
lib/ext/time.ex
FarmBot/farmbot_os
5ebdca3afd672eb6b0af5c71cfca02488b32569a
[ "MIT" ]
843
2016-10-05T23:46:05.000Z
2022-03-14T04:31:55.000Z
lib/ext/time.ex
FarmBot/farmbot_os
5ebdca3afd672eb6b0af5c71cfca02488b32569a
[ "MIT" ]
455
2016-10-15T08:49:16.000Z
2022-03-15T12:23:04.000Z
lib/ext/time.ex
FarmBot/farmbot_os
5ebdca3afd672eb6b0af5c71cfca02488b32569a
[ "MIT" ]
261
2016-10-10T04:37:06.000Z
2022-03-13T21:07:38.000Z
# FarmbotExt.Time.no_reply() defmodule FarmbotExt.Time do @conf Application.get_env(:farmbot, __MODULE__) || [] @disabled Keyword.get(@conf, :disable_timeouts, false) @doc """ A wrapper around `Process.send_after` for simplified dep. injection. If this function is called in `test` ENV, it will send the message immediately without a timeout. All other ENVs delegate to `Process.send_after/3) """ def send_after(pid, message, timeout) do Process.send_after(pid, message, ms(timeout)) end def no_reply(state, timeout) do {:noreply, state, ms(timeout)} end def sleep(num) do Process.sleep(ms(num)) end def cancel_timer(nil), do: nil def cancel_timer(ref), do: Process.cancel_timer(ref) def ms(num) do if @disabled, do: 0, else: num end def system_time_ms, do: :os.system_time(:millisecond) end
25.088235
70
0.705744
79b7d933d5b24e95296b0694e8a7cad5be178c61
3,994
ex
Elixir
lib/arena.ex
iensu/elixir-race
f3d65d987e8f663b68e1936b0b3b977a8081b085
[ "MIT" ]
1
2020-11-08T17:45:41.000Z
2020-11-08T17:45:41.000Z
lib/arena.ex
iensu/elixir-race
f3d65d987e8f663b68e1936b0b3b977a8081b085
[ "MIT" ]
null
null
null
lib/arena.ex
iensu/elixir-race
f3d65d987e8f663b68e1936b0b3b977a8081b085
[ "MIT" ]
null
null
null
defmodule Race.Arena do @moduledoc ~S""" This module represents the racing `arena`. It keeps track of all `racer`s and their current progress. """ use GenServer alias Race.Racer # # # # # # # # # Client API # # # # # # # # # @doc ~S""" Opens the arena by starting a new `arena` process ## Examples iex> {:ok, arena} = Race.Arena.open iex> is_pid arena true """ def open(opts \\ []) do GenServer.start_link(__MODULE__, :ok, opts) end @doc ~S""" Adds `racer`s to the `arena` equal to `num_racers`. ## Examples iex> {:ok, arena} = Race.Arena.open iex> Race.Arena.add_racers(arena, 10) iex> positions = Race.Arena.get_positions(arena) iex> length(positions) == 10 true """ def add_racers(arena, num_racers) when is_pid(arena) and is_integer(num_racers) do for _racer <- 1..num_racers do GenServer.cast(arena, :add) end end @doc ~S""" Returns a `list` of the `racer`s' current positions in the `arena`. ## Examples iex> {:ok, arena} = Race.Arena.open iex> Race.Arena.add_racers(arena, 1) iex> hd Race.Arena.get_positions(arena) 0 iex> Race.Arena.update(arena) iex> new_pos = hd Race.Arena.get_positions(arena) iex> new_pos > 0 true """ def get_positions(arena) when is_pid(arena) do GenServer.call(arena, :positions) end @doc ~S""" Updates the arena by moving all its `racer`s. ## Examples iex> {:ok, arena} = Race.Arena.open iex> Race.Arena.add_racers(arena, 1) iex> init_pos = hd Race.Arena.get_positions(arena) iex> Race.Arena.update(arena) iex> new_pos = hd Race.Arena.get_positions(arena) iex> new_pos > init_pos true """ def update(arena) when is_pid(arena) do GenServer.call(arena, :race) end @doc ~S""" Returns a `list` of first place winners represented by their respective index in the `list` of `racer`s. ## Examples iex> {:ok, arena} = Race.Arena.open iex> Race.Arena.add_racers(arena, 2) iex> # update arena three times iex> # to be sure to cross goal line iex> for _ <- 1..3, do: Race.Arena.update(arena) iex> Race.Arena.check_winners(arena, 3) [0, 1] Returns an empty `list` if there are no winners yet. iex> {:ok, arena} = Race.Arena.open iex> Race.Arena.add_racers(arena, 2) iex> init_pos = Race.Arena.get_positions(arena) iex> Enum.max init_pos 0 iex> Race.Arena.check_winners(arena, 80) [] """ def check_winners(arena, goal_line) when is_pid(arena) and is_integer(goal_line) do GenServer.call(arena, :positions) |> Enum.with_index |> Enum.filter(fn {pos, _idx} -> pos > goal_line end) |> Enum.map(fn {_pos, idx} -> idx end) end @doc ~S""" Stops the `arena` GenServer. """ def stop(arena) when is_pid(arena) do GenServer.call(arena, :stop) end # # # # # # # # # # # # Server Callbacks # # # # # # # # # # # # def init(:ok) do {:ok, []} end def handle_cast(:add, racers) do {:ok, racer} = Racer.create {:noreply, [racer|racers]} end def handle_call(:race, _from, racers) do progress = for racer <- racers do Racer.move(racer) Racer.get_progress(racer) end {:reply, progress, racers} end def handle_call(:positions, _from, racers) do positions = for racer <- racers do Racer.get_progress racer end {:reply, positions, racers} end def handle_call(:stop, _from, racers) do {:stop, :normal, :ok, racers} end end
26.805369
75
0.550576
79b7f7740286520c1cbfd95e3cdf71ee084faeaa
6,189
ex
Elixir
lib/lifelog/accounts/user_token.ex
jahio/lifelog
a3660e65acb3abdaac388b494736a645d825df1f
[ "MIT" ]
null
null
null
lib/lifelog/accounts/user_token.ex
jahio/lifelog
a3660e65acb3abdaac388b494736a645d825df1f
[ "MIT" ]
null
null
null
lib/lifelog/accounts/user_token.ex
jahio/lifelog
a3660e65acb3abdaac388b494736a645d825df1f
[ "MIT" ]
null
null
null
defmodule Lifelog.Accounts.UserToken do use Ecto.Schema import Ecto.Query @hash_algorithm :sha256 @rand_size 32 # It is very important to keep the reset password token expiry short, # since someone with access to the email may take over the account. @reset_password_validity_in_days 1 @confirm_validity_in_days 7 @change_email_validity_in_days 7 @session_validity_in_days 60 schema "users_tokens" do field :token, :binary field :context, :string field :sent_to, :string belongs_to :user, Lifelog.Accounts.User timestamps(updated_at: false) end @doc """ Generates a token that will be stored in a signed place, such as session or cookie. As they are signed, those tokens do not need to be hashed. The reason why we store session tokens in the database, even though Phoenix already provides a session cookie, is because Phoenix' default session cookies are not persisted, they are simply signed and potentially encrypted. This means they are valid indefinitely, unless you change the signing/encryption salt. Therefore, storing them allows individual user sessions to be expired. The token system can also be extended to store additional data, such as the device used for logging in. You could then use this information to display all valid sessions and devices in the UI and allow users to explicitly expire any session they deem invalid. """ def build_session_token(user) do token = :crypto.strong_rand_bytes(@rand_size) {token, %Lifelog.Accounts.UserToken{token: token, context: "session", user_id: user.id}} end @doc """ Checks if the token is valid and returns its underlying lookup query. The query returns the user found by the token, if any. The token is valid if it matches the value in the database and it has not expired (after @session_validity_in_days). """ def verify_session_token_query(token) do query = from token in token_and_context_query(token, "session"), join: user in assoc(token, :user), where: token.inserted_at > ago(@session_validity_in_days, "day"), select: user {:ok, query} end @doc """ Builds a token and its hash to be delivered to the user's email. The non-hashed token is sent to the user email while the hashed part is stored in the database. The original token cannot be reconstructed, which means anyone with read-only access to the database cannot directly use the token in the application to gain access. Furthermore, if the user changes their email in the system, the tokens sent to the previous email are no longer valid. Users can easily adapt the existing code to provide other types of delivery methods, for example, by phone numbers. """ def build_email_token(user, context) do build_hashed_token(user, context, user.email) end defp build_hashed_token(user, context, sent_to) do token = :crypto.strong_rand_bytes(@rand_size) hashed_token = :crypto.hash(@hash_algorithm, token) {Base.url_encode64(token, padding: false), %Lifelog.Accounts.UserToken{ token: hashed_token, context: context, sent_to: sent_to, user_id: user.id }} end @doc """ Checks if the token is valid and returns its underlying lookup query. The query returns the user found by the token, if any. The given token is valid if it matches its hashed counterpart in the database and the user email has not changed. This function also checks if the token is being used within a certain period, depending on the context. The default contexts supported by this function are either "confirm", for account confirmation emails, and "reset_password", for resetting the password. For verifying requests to change the email, see `verify_change_email_token_query/2`. """ def verify_email_token_query(token, context) do case Base.url_decode64(token, padding: false) do {:ok, decoded_token} -> hashed_token = :crypto.hash(@hash_algorithm, decoded_token) days = days_for_context(context) query = from token in token_and_context_query(hashed_token, context), join: user in assoc(token, :user), where: token.inserted_at > ago(^days, "day") and token.sent_to == user.email, select: user {:ok, query} :error -> :error end end defp days_for_context("confirm"), do: @confirm_validity_in_days defp days_for_context("reset_password"), do: @reset_password_validity_in_days @doc """ Checks if the token is valid and returns its underlying lookup query. The query returns the user found by the token, if any. This is used to validate requests to change the user email. It is different from `verify_email_token_query/2` precisely because `verify_email_token_query/2` validates the email has not changed, which is the starting point by this function. The given token is valid if it matches its hashed counterpart in the database and if it has not expired (after @change_email_validity_in_days). The context must always start with "change:". """ def verify_change_email_token_query(token, "change:" <> _ = context) do case Base.url_decode64(token, padding: false) do {:ok, decoded_token} -> hashed_token = :crypto.hash(@hash_algorithm, decoded_token) query = from token in token_and_context_query(hashed_token, context), where: token.inserted_at > ago(@change_email_validity_in_days, "day") {:ok, query} :error -> :error end end @doc """ Returns the token struct for the given token value and context. """ def token_and_context_query(token, context) do from Lifelog.Accounts.UserToken, where: [token: ^token, context: ^context] end @doc """ Gets all tokens for the given user for the given contexts. """ def user_and_contexts_query(user, :all) do from t in Lifelog.Accounts.UserToken, where: t.user_id == ^user.id end def user_and_contexts_query(user, [_ | _] = contexts) do from t in Lifelog.Accounts.UserToken, where: t.user_id == ^user.id and t.context in ^contexts end end
34.575419
97
0.721118
79b8408bda10a1241dca12b06b69177a31f5c51b
3,247
ex
Elixir
clients/cloud_asset/lib/google_api/cloud_asset/v1/model/iam_policy_analysis_query.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/cloud_asset/lib/google_api/cloud_asset/v1/model/iam_policy_analysis_query.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/cloud_asset/lib/google_api/cloud_asset/v1/model/iam_policy_analysis_query.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.CloudAsset.V1.Model.IamPolicyAnalysisQuery do @moduledoc """ ## IAM policy analysis query message. ## Attributes * `accessSelector` (*type:* `GoogleApi.CloudAsset.V1.Model.AccessSelector.t`, *default:* `nil`) - Optional. Specifies roles or permissions for analysis. This is optional. * `identitySelector` (*type:* `GoogleApi.CloudAsset.V1.Model.IdentitySelector.t`, *default:* `nil`) - Optional. Specifies an identity for analysis. * `options` (*type:* `GoogleApi.CloudAsset.V1.Model.Options.t`, *default:* `nil`) - Optional. The query options. * `resourceSelector` (*type:* `GoogleApi.CloudAsset.V1.Model.ResourceSelector.t`, *default:* `nil`) - Optional. Specifies a resource for analysis. * `scope` (*type:* `String.t`, *default:* `nil`) - Required. The relative name of the root asset. Only resources and IAM policies within the scope will be analyzed. This can only be an organization number (such as "organizations/123"), a folder number (such as "folders/123"), a project ID (such as "projects/my-project-id"), or a project number (such as "projects/12345"). To know how to get organization id, visit [here ](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). To know how to get folder or project id, visit [here ](https://cloud.google.com/resource-manager/docs/creating-managing-folders#viewing_or_listing_folders_and_projects). """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :accessSelector => GoogleApi.CloudAsset.V1.Model.AccessSelector.t(), :identitySelector => GoogleApi.CloudAsset.V1.Model.IdentitySelector.t(), :options => GoogleApi.CloudAsset.V1.Model.Options.t(), :resourceSelector => GoogleApi.CloudAsset.V1.Model.ResourceSelector.t(), :scope => String.t() } field(:accessSelector, as: GoogleApi.CloudAsset.V1.Model.AccessSelector) field(:identitySelector, as: GoogleApi.CloudAsset.V1.Model.IdentitySelector) field(:options, as: GoogleApi.CloudAsset.V1.Model.Options) field(:resourceSelector, as: GoogleApi.CloudAsset.V1.Model.ResourceSelector) field(:scope) end defimpl Poison.Decoder, for: GoogleApi.CloudAsset.V1.Model.IamPolicyAnalysisQuery do def decode(value, options) do GoogleApi.CloudAsset.V1.Model.IamPolicyAnalysisQuery.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.CloudAsset.V1.Model.IamPolicyAnalysisQuery do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
55.033898
709
0.747459
79b84572f628a2f19c938d4a19a28875d17a4ff4
56
ex
Elixir
lib/sealax/types/item_hashid.ex
sealas/sealax
3f11b7f649972a43f4812ea959bd2be2e0151baa
[ "MIT" ]
null
null
null
lib/sealax/types/item_hashid.ex
sealas/sealax
3f11b7f649972a43f4812ea959bd2be2e0151baa
[ "MIT" ]
9
2021-08-19T01:09:55.000Z
2022-03-08T01:18:45.000Z
lib/sealax/types/item_hashid.ex
sealas/sealax
3f11b7f649972a43f4812ea959bd2be2e0151baa
[ "MIT" ]
null
null
null
defmodule ItemHashId do use HashId, salt: "_item" end
14
27
0.75
79b84bce278f70a3bdfc254048bbb50bbc9d90c2
155
ex
Elixir
web/views/admin/user_view.ex
ramkrishna70/opencov
7a3415f8eebb797ad1f7b6c832daa4f04d70af8d
[ "MIT" ]
189
2018-09-25T09:02:41.000Z
2022-03-09T13:52:06.000Z
web/views/admin/user_view.ex
ramkrishna70/opencov
7a3415f8eebb797ad1f7b6c832daa4f04d70af8d
[ "MIT" ]
29
2018-09-26T05:51:18.000Z
2021-11-05T08:55:03.000Z
web/views/admin/user_view.ex
ramkrishna70/opencov
7a3415f8eebb797ad1f7b6c832daa4f04d70af8d
[ "MIT" ]
32
2018-10-21T12:28:11.000Z
2022-03-28T02:20:19.000Z
defmodule Opencov.Admin.UserView do use Opencov.Web, :view import Scrivener.HTML alias Opencov.Helpers.Display alias Opencov.Helpers.Datetime end
19.375
35
0.793548
79b85553cf469e0bcabd96fdfe844e0b11c42156
2,837
ex
Elixir
lib/jeopardixir_web/controllers/category_controller.ex
arielj/jeopardixir
d596dd4c0af7398f8b533518b5d8dc30c5bac94b
[ "MIT" ]
1
2021-06-16T15:27:04.000Z
2021-06-16T15:27:04.000Z
lib/jeopardixir_web/controllers/category_controller.ex
arielj/jeopardixir
d596dd4c0af7398f8b533518b5d8dc30c5bac94b
[ "MIT" ]
25
2021-06-18T13:08:18.000Z
2021-12-15T19:04:57.000Z
lib/jeopardixir_web/controllers/category_controller.ex
arielj/jeopardixir
d596dd4c0af7398f8b533518b5d8dc30c5bac94b
[ "MIT" ]
null
null
null
defmodule JeopardixirWeb.CategoryController do use JeopardixirWeb, :controller alias Jeopardixir.Categories alias Jeopardixir.Answers alias Jeopardixir.Board.Category alias Jeopardixir.Board.Answer plug :require_user when action in [:new, :create, :add_answer, :edit, :update, :delete] def index(conn, _params) do categories = Categories.list_categories() render(conn, "index.html", categories: categories) end def new(conn, _params) do changeset = Categories.change_category(%Category{}) render(conn, "new.html", changeset: changeset) end def create(conn, %{"category" => category_params}) do case Categories.create_category(category_params) do {:ok, category} -> conn |> put_flash(:info, "Category created successfully.") |> redirect(to: Routes.category_path(conn, :show, category)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", changeset: changeset) end end def add_answer(conn, %{"answer" => %{"body" => body }, "category_id" => category_id}) do user_id = Plug.Conn.get_session(conn, :current_user_id) case Answers.create_answer(%{body: body, category_id: category_id, user_id: user_id}) do {:ok, _} -> conn |> put_flash(:info, "Answer created successfully.") |> redirect(to: Routes.category_path(conn, :show, category_id)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", changeset: changeset) end end def show(conn, %{"id" => id}) do category = Categories.get_category!(id) user_id = Plug.Conn.get_session(conn, :current_user_id) answers = Answers.get_answer_for_category(category.id, user_id) changeset = Answers.change_answer(%Answer{}) render(conn, "show.html", category: category, changeset: changeset, answers: answers) end def edit(conn, %{"id" => id}) do category = Categories.get_category!(id) changeset = Categories.change_category(category) render(conn, "edit.html", category: category, changeset: changeset) end def update(conn, %{"id" => id, "category" => category_params}) do category = Categories.get_category!(id) case Categories.update_category(category, category_params) do {:ok, category} -> conn |> put_flash(:info, "Category updated successfully.") |> redirect(to: Routes.category_path(conn, :show, category)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "edit.html", category: category, changeset: changeset) end end def delete(conn, %{"id" => id}) do category = Categories.get_category!(id) {:ok, _category} = Categories.delete_category(category) conn |> put_flash(:info, "Category deleted successfully.") |> redirect(to: Routes.category_path(conn, :index)) end end
34.180723
92
0.673246
79b86b187bb28c8008cf757f9535ad8e97b28f50
714
ex
Elixir
lib/queerlink_web/gettext.ex
Queertoo/Queerlink
0a7726460cda63fc4ab342a2fe1d1155caa3d6d4
[ "MIT" ]
38
2015-11-07T23:54:26.000Z
2021-04-09T04:14:25.000Z
lib/queerlink_web/gettext.ex
Queertoo/Queerlink
0a7726460cda63fc4ab342a2fe1d1155caa3d6d4
[ "MIT" ]
2
2015-11-23T15:00:34.000Z
2015-11-26T09:59:26.000Z
lib/queerlink_web/gettext.ex
Queertoo/Queerlink
0a7726460cda63fc4ab342a2fe1d1155caa3d6d4
[ "MIT" ]
6
2015-11-26T00:25:22.000Z
2020-03-04T22:13:59.000Z
defmodule QueerlinkWeb.Gettext do @moduledoc """ A module providing Internationalization with a gettext-based API. By using [Gettext](https://hexdocs.pm/gettext), your module gains a set of macros for translations, for example: import QueerlinkWeb.Gettext # Simple translation gettext "Here is the string to translate" # Plural translation ngettext "Here is the string to translate", "Here are the strings to translate", 3 # Domain-based translation dgettext "errors", "Here is the error message to translate" See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. """ use Gettext, otp_app: :queerlink end
28.56
72
0.683473
79b878e9348c32eaea32776cd599435fa3ab4f3f
679
exs
Elixir
config/test.exs
DaniruKun/watchfaces-ex
699e345596000ec3e50141e44217b155400261d6
[ "MIT" ]
null
null
null
config/test.exs
DaniruKun/watchfaces-ex
699e345596000ec3e50141e44217b155400261d6
[ "MIT" ]
null
null
null
config/test.exs
DaniruKun/watchfaces-ex
699e345596000ec3e50141e44217b155400261d6
[ "MIT" ]
null
null
null
use Mix.Config # Configure your database # # The MIX_TEST_PARTITION environment variable can be used # to provide built-in test partitioning in CI environment. # Run `mix help test` for more information. config :watch_faces, WatchFaces.Repo, username: "postgres", password: "postgres", database: "watch_faces_test#{System.get_env("MIX_TEST_PARTITION")}", hostname: "localhost", pool: Ecto.Adapters.SQL.Sandbox # We don't run a server during test. If one is required, # you can enable the server option below. config :watch_faces, WatchFacesWeb.Endpoint, http: [port: 4002], server: false # Print only warnings and errors during test config :logger, level: :warn
29.521739
70
0.755523
79b88b6c94d0571697f762988a4d37f83fb1c84f
1,452
ex
Elixir
Microsoft.Azure.Management.Preview.Advisor/lib/microsoft/azure/management/preview/advisor/api/operations.ex
chgeuer/ex_microsoft_azure_management
99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603
[ "Apache-2.0" ]
4
2018-09-29T03:43:15.000Z
2021-04-01T18:30:46.000Z
Microsoft.Azure.Management.Preview.Advisor/lib/microsoft/azure/management/preview/advisor/api/operations.ex
chgeuer/ex_microsoft_azure_management
99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603
[ "Apache-2.0" ]
null
null
null
Microsoft.Azure.Management.Preview.Advisor/lib/microsoft/azure/management/preview/advisor/api/operations.ex
chgeuer/ex_microsoft_azure_management
99cd9f7f2ff1fdbe69ca5bac55b6e2af91ba3603
[ "Apache-2.0" ]
null
null
null
# NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule Microsoft.Azure.Management.Preview.Advisor.Api.Operations do @moduledoc """ API calls for all endpoints tagged `Operations`. """ alias Microsoft.Azure.Management.Preview.Advisor.Connection import Microsoft.Azure.Management.Preview.Advisor.RequestBuilder @doc """ Lists all the available Advisor REST API operations. ## Parameters - connection (Microsoft.Azure.Management.Preview.Advisor.Connection): Connection to server - api_version (String.t): The version of the API to be used with the client request. - opts (KeywordList): [optional] Optional parameters ## Returns {:ok, %Microsoft.Azure.Management.Preview.Advisor.Model.OperationEntityListResult{}} on success {:error, info} on failure """ @spec operations_list(Tesla.Env.client, String.t, keyword()) :: {:ok, Microsoft.Azure.Management.Preview.Advisor.Model.OperationEntityListResult.t} | {:error, Tesla.Env.t} def operations_list(connection, api_version, _opts \\ []) do %{} |> method(:get) |> url("/providers/Microsoft.Advisor/operations") |> add_param(:query, :"api-version", api_version) |> Enum.into([]) |> (&Connection.request(connection, &1)).() |> decode(%Microsoft.Azure.Management.Preview.Advisor.Model.OperationEntityListResult{}) end end
37.230769
173
0.733471
79b8b830e16f79b69bfd708276a386cac4fb6c85
272
ex
Elixir
lib/boilerplate/repo.ex
lorenzosinisi/react-phoenix-users-boilerplate
f39022a41c2b08947c9b4451248febce5005c1a3
[ "MIT" ]
152
2017-05-29T06:04:01.000Z
2021-12-11T19:24:02.000Z
lib/boilerplate/repo.ex
lorenzosinisi/react-phoenix-users-boilerplate
f39022a41c2b08947c9b4451248febce5005c1a3
[ "MIT" ]
13
2017-07-29T18:26:37.000Z
2018-10-26T08:33:16.000Z
lib/boilerplate/repo.ex
lorenzosinisi/react-phoenix-users-boilerplate
f39022a41c2b08947c9b4451248febce5005c1a3
[ "MIT" ]
12
2017-11-18T19:13:44.000Z
2019-10-10T01:29:28.000Z
defmodule Boilerplate.Repo do use Ecto.Repo, otp_app: :boilerplate @doc """ Dynamically loads the repository url from the DATABASE_URL environment variable. """ def init(_, opts) do {:ok, Keyword.put(opts, :url, System.get_env("DATABASE_URL"))} end end
22.666667
66
0.705882
79b8c1818977d1e45f9b05693378971567bc9023
1,642
ex
Elixir
lib/songmate_web.ex
jimytc/music-dating-app
ec46ef2ffa4fb263a8b283a96495b0643467697c
[ "MIT" ]
8
2020-06-06T02:12:36.000Z
2021-10-12T16:47:20.000Z
lib/songmate_web.ex
jimytc/music-dating-app
ec46ef2ffa4fb263a8b283a96495b0643467697c
[ "MIT" ]
2
2021-03-10T18:43:20.000Z
2021-07-16T04:37:20.000Z
lib/songmate_web.ex
jimytc/music-dating-app
ec46ef2ffa4fb263a8b283a96495b0643467697c
[ "MIT" ]
1
2020-06-24T08:41:09.000Z
2020-06-24T08:41:09.000Z
defmodule SongmateWeb do @moduledoc """ The entrypoint for defining your web interface, such as controllers, views, channels and so on. This can be used in your application as: use SongmateWeb, :controller use SongmateWeb, :view The definitions below will be executed for every view, controller, etc, so keep them short and clean, focused on imports, uses and aliases. Do NOT define functions inside the quoted expressions below. Instead, define any helper function in modules and import those modules here. """ def controller do quote do use Phoenix.Controller, namespace: SongmateWeb import Plug.Conn import SongmateWeb.Gettext alias SongmateWeb.Router.Helpers, as: Routes end end def view do quote do use Phoenix.View, root: "lib/songmate_web/templates", namespace: SongmateWeb # Import convenience functions from controllers import Phoenix.Controller, only: [get_flash: 1, get_flash: 2, view_module: 1] # Use all HTML functionality (forms, tags, etc) use Phoenix.HTML import SongmateWeb.ErrorHelpers import SongmateWeb.Gettext alias SongmateWeb.Router.Helpers, as: Routes end end def router do quote do use Phoenix.Router import Plug.Conn import Phoenix.Controller end end def channel do quote do use Phoenix.Channel import SongmateWeb.Gettext end end @doc """ When used, dispatch to the appropriate controller/view/etc. """ defmacro __using__(which) when is_atom(which) do apply(__MODULE__, which, []) end end
23.457143
83
0.69123
79b8f931935374db11030db76c3e3e3c1a806333
27
ex
Elixir
lib/cod_assist.ex
lau/cod_assist
6a1b380b42a74386c7a3a72b80e92404278623f7
[ "Apache-2.0" ]
2
2016-09-16T06:39:30.000Z
2018-01-02T10:59:05.000Z
lib/cod_assist.ex
lau/cod_assist
6a1b380b42a74386c7a3a72b80e92404278623f7
[ "Apache-2.0" ]
null
null
null
lib/cod_assist.ex
lau/cod_assist
6a1b380b42a74386c7a3a72b80e92404278623f7
[ "Apache-2.0" ]
null
null
null
defmodule CodAssist do end
9
22
0.851852
79b90aacd1e9cd338c8ccdbb47eceee32f8bcb63
1,083
exs
Elixir
issues/deps/earmark/mix.exs
vronic/programming-elixir
4465a81cc07b31a4c03bd277520e1127dda773b2
[ "MIT" ]
null
null
null
issues/deps/earmark/mix.exs
vronic/programming-elixir
4465a81cc07b31a4c03bd277520e1127dda773b2
[ "MIT" ]
null
null
null
issues/deps/earmark/mix.exs
vronic/programming-elixir
4465a81cc07b31a4c03bd277520e1127dda773b2
[ "MIT" ]
null
null
null
Code.eval_file "tasks/readme.exs" defmodule Earmark.Mixfile do use Mix.Project def project do [ app: :earmark, version: "0.1.19", elixir: ">= 1.0.0", escript: escript_config, deps: deps, description: description, package: package, ] end def application do [applications: []] end defp deps do [] end defp description do """ Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.to_html), but can also be used as a command-line tool (just run mix escript.build first). Output generation is pluggable. """ end defp package do [ files: [ "lib", "tasks", "mix.exs", "README.md" ], maintainers: [ "Dave Thomas <[email protected]>"], licenses: [ "Same as Elixir" ], links: %{ "GitHub" => "https://github.com/pragdave/earmark", } ] end defp escript_config do [ main_module: Earmark.CLI ] end end
20.433962
75
0.555863
79b9627f6687e1a4aed981f006875c11791e29db
388
ex
Elixir
apps/bankingAPI/lib/bankingAPI/accounts/schemas/account.ex
danielkv7/bankingAPI
d84b9a12c72d6bbd7d3077346501fde6db25ef19
[ "Apache-2.0" ]
null
null
null
apps/bankingAPI/lib/bankingAPI/accounts/schemas/account.ex
danielkv7/bankingAPI
d84b9a12c72d6bbd7d3077346501fde6db25ef19
[ "Apache-2.0" ]
null
null
null
apps/bankingAPI/lib/bankingAPI/accounts/schemas/account.ex
danielkv7/bankingAPI
d84b9a12c72d6bbd7d3077346501fde6db25ef19
[ "Apache-2.0" ]
null
null
null
defmodule BankingAPI.Accounts.Schemas.Account do @moduledoc """ The entity of Account. 1 user (id) - N accounts (FK user_id) """ use Ecto.Schema alias BankingAPI.Users.Schemas.User @primary_key {:id, :binary_id, autogenerate: true} @foreign_key_type :binary_id schema "accounts" do belongs_to(:user, User) field(:amount, :integer) timestamps() end end
19.4
52
0.695876
79b9aed1f915e742344047965e3a1eddfaa47e75
2,255
exs
Elixir
config/dev.exs
snyk-omar/changelog.com
66a8cff17ed8a237e439976aa7fb96b58ef276a3
[ "MIT" ]
2,599
2016-10-25T15:02:53.000Z
2022-03-26T02:34:42.000Z
config/dev.exs
snyk-omar/changelog.com
66a8cff17ed8a237e439976aa7fb96b58ef276a3
[ "MIT" ]
253
2016-10-25T20:29:24.000Z
2022-03-29T21:52:36.000Z
config/dev.exs
snyk-omar/changelog.com
66a8cff17ed8a237e439976aa7fb96b58ef276a3
[ "MIT" ]
298
2016-10-25T15:18:31.000Z
2022-01-18T21:25:52.000Z
use Mix.Config config :changelog, ChangelogWeb.Endpoint, url: [host: System.get_env("HOST", "localhost")], http: [ port: 4000 ], debug_errors: true, code_reloader: true, cache_static_lookup: false, check_origin: false, watchers: [ yarn: ["start", cd: Path.expand("../assets", __DIR__)] ] # Sometimes we need HTTPS, like when futzing with captchas if System.get_env("HTTPS") do config :changelog, ChangelogWeb.Endpoint, https: [ port: 4001, cipher_suite: :strong, certfile: "priv/cert/selfsigned.pem", keyfile: "priv/cert/selfsigned_key.pem" ] end # Watch static and templates for browser reloading. config :changelog, ChangelogWeb.Endpoint, live_reload: [ patterns: [ ~r{priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$}, ~r{lib/changelog_web/(live|views)/.*(ex)$}, ~r{lib/changelog_web/templates/.*(eex)$} ] ] # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n" # Set a higher stacktrace during development. # Do not configure such in production as keeping # and calculating stacktraces is usually expensive. config :phoenix, :stacktrace_depth, 20 config :phoenix, :plug_init_mode, :runtime config :changelog, Changelog.Repo, adapter: Ecto.Adapters.Postgres, database: System.get_env("DB_NAME", "changelog_dev"), hostname: System.get_env("DB_HOST", "localhost"), username: System.get_env("DB_USER", "postgres"), password: System.get_env("DB_PASS", "postgres"), show_sensitive_data_on_connection_error: true, pool_size: 10 config :changelog, Changelog.PromEx, manual_metrics_start_delay: :no_delay, drop_metrics_groups: [], grafana: [ host: System.get_env("GRAFANA_URL", "http://localhost:3000"), # This API Key will need to be created manually, most probably via http://localhost:3000/org/apikeys auth_token: SecretOrEnv.get("GRAFANA_API_KEY"), # This can default to Prometheus, PromEx uses this lowercase value for the built-in dashboards datasource_id: System.get_env("GRAFANA_DATASOURCE_ID", "prometheus"), annotate_app_lifecycle: true ], metrics_server: :disabled, prometheus_bearer_token: SecretOrEnv.get("PROMETHEUS_BEARER_TOKEN_PROM_EX")
32.681159
104
0.721064
79b9c3fffa7ea44460d134ad844e544803f8e411
605
ex
Elixir
lib/mongo/query.ex
MillionIntegrals/elixir-mongodb-driver
96c4cc3f21c4043323b8a9b33ad3a374760864c6
[ "Apache-2.0" ]
null
null
null
lib/mongo/query.ex
MillionIntegrals/elixir-mongodb-driver
96c4cc3f21c4043323b8a9b33ad3a374760864c6
[ "Apache-2.0" ]
null
null
null
lib/mongo/query.ex
MillionIntegrals/elixir-mongodb-driver
96c4cc3f21c4043323b8a9b33ad3a374760864c6
[ "Apache-2.0" ]
null
null
null
defmodule Mongo.Query do @moduledoc """ This is the query implementation for the Query Protocol   Encoding and decoding does not take place at this point, but is directly performed into the functions of Mongo.MongoDBConnection.Utils. """ defstruct action: nil end defimpl DBConnection.Query, for: Mongo.Query do # coveralls-ignore-start def parse(query, _opts), do: query # gets never called def describe(query, _opts), do: query # gets never called # coveralls-ignore-stop def encode(_query, params, _opts), do: params def decode(_query, reply, _opts), do: reply end
31.842105
86
0.728926
79b9f9724cb166865c5d5070322a0417ef4b091c
453
ex
Elixir
apps/dead_letter/lib/dead_letter/application.ex
calebcarroll1/smartcitiesdata
b0f03496f6c592c82ba14aebf6c5996311cf3cd0
[ "Apache-2.0" ]
26
2019-09-20T23:54:45.000Z
2020-08-20T14:23:32.000Z
apps/dead_letter/lib/dead_letter/application.ex
calebcarroll1/smartcitiesdata
b0f03496f6c592c82ba14aebf6c5996311cf3cd0
[ "Apache-2.0" ]
757
2019-08-15T18:15:07.000Z
2020-09-18T20:55:31.000Z
apps/dead_letter/lib/dead_letter/application.ex
calebcarroll1/smartcitiesdata
b0f03496f6c592c82ba14aebf6c5996311cf3cd0
[ "Apache-2.0" ]
9
2019-11-12T16:43:46.000Z
2020-03-25T16:23:16.000Z
defmodule DeadLetter.Application do @moduledoc false use Application def start(_something, _else) do opts = Application.get_all_env(:dead_letter) config = Keyword.fetch!(opts, :driver) |> Enum.into(%{}) children = [ {config.module, config.init_args}, {DeadLetter.Server, config} ] |> List.flatten() Supervisor.start_link(children, strategy: :one_for_one, name: DeadLetter.Supervisor) end end
23.842105
88
0.668874
79ba071b0e1fd9e3b92b235e9e831f99fa7510ea
2,023
ex
Elixir
clients/slides/lib/google_api/slides/v1/model/table_border_properties.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/slides/lib/google_api/slides/v1/model/table_border_properties.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/slides/lib/google_api/slides/v1/model/table_border_properties.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.Slides.V1.Model.TableBorderProperties do @moduledoc """ The border styling properties of the TableBorderCell. ## Attributes - dashStyle (String.t): The dash style of the border. Defaults to: `null`. - Enum - one of [DASH_STYLE_UNSPECIFIED, SOLID, DOT, DASH, DASH_DOT, LONG_DASH, LONG_DASH_DOT] - tableBorderFill (TableBorderFill): The fill of the table border. Defaults to: `null`. - weight (Dimension): The thickness of the border. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :dashStyle => any(), :tableBorderFill => GoogleApi.Slides.V1.Model.TableBorderFill.t(), :weight => GoogleApi.Slides.V1.Model.Dimension.t() } field(:dashStyle) field(:tableBorderFill, as: GoogleApi.Slides.V1.Model.TableBorderFill) field(:weight, as: GoogleApi.Slides.V1.Model.Dimension) end defimpl Poison.Decoder, for: GoogleApi.Slides.V1.Model.TableBorderProperties do def decode(value, options) do GoogleApi.Slides.V1.Model.TableBorderProperties.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Slides.V1.Model.TableBorderProperties do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.781818
98
0.741473
79ba095cd41d46014d24ce50ee6de3d1fe19eab9
1,678
exs
Elixir
projects/standup/mix.exs
erik/sketches
0a454ada58dee6db576e93cb2216dd750290329e
[ "MIT" ]
1
2020-02-11T06:00:11.000Z
2020-02-11T06:00:11.000Z
projects/standup/mix.exs
erik/sketches
0a454ada58dee6db576e93cb2216dd750290329e
[ "MIT" ]
1
2017-09-23T19:41:29.000Z
2017-09-25T05:12:38.000Z
projects/standup/mix.exs
erik/sketches
0a454ada58dee6db576e93cb2216dd750290329e
[ "MIT" ]
null
null
null
defmodule Standup.MixProject do use Mix.Project def project do [ app: :standup, version: "0.1.0", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps() ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [ mod: {Standup.Application, []}, extra_applications: [:logger, :runtime_tools] ] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. # # Type `mix help deps` for examples and options. defp deps do [ {:phoenix, "~> 1.4.0"}, {:phoenix_pubsub, "~> 1.1"}, {:phoenix_ecto, "~> 4.0"}, {:ecto_sql, "~> 3.0"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 2.11"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, {:gettext, "~> 0.11"}, {:jason, "~> 1.0"}, {:plug_cowboy, "~> 2.0"}, {:guardian, "~> 1.0"} ] end # Aliases are shortcuts or tasks specific to the current project. # For example, to create, migrate and run the seeds file at once: # # $ mix ecto.setup # # See the documentation for `Mix` for more info on aliases. defp aliases do [ "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], test: ["ecto.create --quiet", "ecto.migrate", "test"] ] end end
26.21875
79
0.572706
79ba09651145595d77993f4e3c7aebe8f7cc1b3a
1,451
ex
Elixir
lib/interfaces/i_steam_news.ex
kouwasi/steam_ex
b06469ad5bce8da60b4436f842b57287cb1db18f
[ "MIT" ]
2
2018-08-25T10:50:04.000Z
2018-10-02T02:05:01.000Z
lib/interfaces/i_steam_news.ex
kouwasi/steam_ex
b06469ad5bce8da60b4436f842b57287cb1db18f
[ "MIT" ]
null
null
null
lib/interfaces/i_steam_news.ex
kouwasi/steam_ex
b06469ad5bce8da60b4436f842b57287cb1db18f
[ "MIT" ]
1
2018-10-02T02:05:04.000Z
2018-10-02T02:05:04.000Z
defmodule SteamEx.ISteamNews do @moduledoc """ Provides access to the Steam News functionality. For more info on how to use the Steamworks Web API please see the [Web API Overview](https://partner.steamgames.com/doc/webapi_overview). """ import SteamEx.API.Base @interface "ISteamNews" @doc """ Get the news for the specified app. This method has previous versions which are no longer officially supported. They will continue to be usable but it's highly recommended that you use the latest version. Change history: - **Version 2** - Removes element names from arrays | Name | Type | Required | Description | | appid | uint32 | ✔ | AppID to retrieve news for| | maxlength | uint32 | | Maximum length for the content to return, if this is 0 the full content is returned, if it's less then a blurb is generated to fit.| | enddate | uint32 | | Retrieve posts earlier than this date (unix epoch timestamp)| | count | uint32 | | # of posts to retrieve (default 20)| | feeds | string | | Comma-seperated list of feed names to return news for| See other: [https://partner.steamgames.com/doc/webapi/ISteamNews#GetNewsForApp](https://partner.steamgames.com/doc/webapi/ISteamNews#GetNewsForApp) """ def get_news_for_app(access_key, params \\ %{}, headers \\ %{}) do get(@interface <> "/GetNewsForApp/v2/", access_key, params, headers) end end
46.806452
170
0.68918
79ba0fee4b38d58d34f7bf50605cc82060b80bf1
4,424
ex
Elixir
lib/machinery/transition.ex
bgentry/machinery
f4835da5977394b819cde785d52b0b93bf3beae1
[ "Apache-2.0" ]
null
null
null
lib/machinery/transition.ex
bgentry/machinery
f4835da5977394b819cde785d52b0b93bf3beae1
[ "Apache-2.0" ]
null
null
null
lib/machinery/transition.ex
bgentry/machinery
f4835da5977394b819cde785d52b0b93bf3beae1
[ "Apache-2.0" ]
null
null
null
defmodule Machinery.Transition do @moduledoc """ Machinery module responsible for control transitions, guard functions and callbacks (before and after). This is meant to be for internal use only. """ @doc """ Function responsible for checking if the transition from a state to another was specifically declared. This is meant to be for internal use only. """ @spec declared_transition?(list, atom, atom) :: boolean def declared_transition?(transitions, current_state, next_state) do if matches_wildcard?(transitions, next_state) do true else matches_transition?(transitions, current_state, next_state) end end @doc """ Default guard transition fallback to make sure all transitions are permitted unless another existing guard condition exists. This is meant to be for internal use only. """ @spec guarded_transition?(module, struct, atom) :: boolean def guarded_transition?(module, struct, state) do case run_or_fallback(&module.guard_transition/2, &guard_transition_fallback/3, struct, state) do {:error, cause} -> {:error, cause} _ -> false end end @doc """ Function responsible to run all before_transitions callbacks or fallback to a boilerplate behaviour. This is meant to be for internal use only. """ @spec before_callbacks(struct, atom, module) :: struct def before_callbacks(struct, state, module) do run_or_fallback(&module.before_transition/2, &callbacks_fallback/3, struct, state) end @doc """ Function responsible to run all after_transitions callbacks or fallback to a boilerplate behaviour. This is meant to be for internal use only. """ @spec after_callbacks(struct, atom, module) :: struct def after_callbacks(struct, state, module) do run_or_fallback(&module.after_transition/2, &callbacks_fallback/3, struct, state) end @doc """ This function will try to trigger persistence, if declared, to the struct changing state. This is meant to be for internal use only. """ @spec persist_struct(struct, atom, module) :: struct def persist_struct(struct, state, module) do run_or_fallback(&module.persist/2, &persist_fallback/3, struct, state) end @doc """ Function resposible for triggering transitions persistence. This is meant to be for internal use only. """ @spec log_transition(struct, atom, module) :: struct def log_transition(struct, state, module) do run_or_fallback(&module.log_transition/2, &log_transition_fallback/3, struct, state) end defp matches_wildcard?(transitions, next_state) do matches_transition?(transitions, "*", next_state) end defp matches_transition?(transitions, current_state, next_state) do case Map.fetch(transitions, current_state) do {:ok, [_|_] = declared_states} -> Enum.member?(declared_states, next_state) {:ok, declared_state} -> declared_state == next_state :error -> false end end # Private function that receives a function, a callback, # a struct and the related state. It tries to execute the function, # rescue for a couple of specific Exceptions and passes it forward # to the callback, that will re-raise it if not related to # guard_transition nor before | after call backs defp run_or_fallback(func, callback, struct, state) do func.(struct, state) rescue error in UndefinedFunctionError -> callback.(struct, state, error) error in FunctionClauseError -> callback.(struct, state, error) end defp persist_fallback(struct, state, error) do if error.function == :persist && error.arity == 2 do Map.put(struct, :state, state) else raise error end end defp log_transition_fallback(struct, _state, error) do if error.function == :log_transition && error.arity == 2 do struct else raise error end end defp callbacks_fallback(struct, _state, error) do if error.function in [:after_transition, :before_transition] && error.arity == 2 do struct else raise error end end # If the exception passed id related to a specific signature of # guard_transition/2 it will fallback returning true and # allwoing the transition, otherwise it will raise the exception. defp guard_transition_fallback(_struct, _state, error) do if error.function == :guard_transition && error.arity == 2 do true else raise error end end end
33.263158
100
0.720163
79ba417836d96af7f31cb167fb7c7ea739fa0db5
3,397
exs
Elixir
mix.exs
christhekeele/nerves_livebook
ec105d4cfb0fa13c137312447474fab9ed47487a
[ "Apache-2.0" ]
null
null
null
mix.exs
christhekeele/nerves_livebook
ec105d4cfb0fa13c137312447474fab9ed47487a
[ "Apache-2.0" ]
null
null
null
mix.exs
christhekeele/nerves_livebook
ec105d4cfb0fa13c137312447474fab9ed47487a
[ "Apache-2.0" ]
null
null
null
defmodule NervesLivebook.MixProject do use Mix.Project @app :nerves_livebook @version "0.4.1" @rpi_targets [:rpi, :rpi0, :rpi2, :rpi3, :rpi3a, :rpi4] @all_targets @rpi_targets ++ [:bbb, :osd32mp1, :x86_64, :npi_imx6ull] # See the BlueHeron repository for the boards that it supports. @ble_targets [:rpi0, :rpi3, :rpi3a] def project do [ app: @app, description: "Develop on embedded devices with Livebook and Nerves", author: "https://github.com/livebook-dev/nerves_livebook/graphs/contributors", version: @version, elixir: "~> 1.12", archives: [nerves_bootstrap: "~> 1.10"], start_permanent: Mix.env() == :prod, build_embedded: true, deps: deps(), releases: [{@app, release()}], preferred_cli_target: [run: :host, test: :host, "phx.server": :host] ] end def application do [ mod: {NervesLivebook.Application, []}, extra_applications: [:logger, :runtime_tools, :inets, :ex_unit] ] end defp deps do [ # Dependencies for host and target {:nerves, "~> 1.7.13", runtime: false}, {:shoehorn, "~> 0.8.0"}, {:ring_logger, "~> 0.8.1"}, {:toolshed, "~> 0.2.13"}, {:jason, "~> 1.2"}, {:nerves_runtime, "~> 0.11.3"}, {:nerves_pack, "~> 0.6.0"}, {:livebook, "~> 0.4.0", only: [:dev, :prod]}, {:plug, "~> 1.12"}, # Pull in commonly used libraries as a convenience to users. {:vega_lite, "~> 0.1"}, {:kino, "~> 0.3"}, {:phoenix_pubsub, "~> 2.0"}, {:circuits_uart, "~> 1.3", targets: @all_targets}, {:circuits_gpio, "~> 1.0", override: true, targets: @all_targets}, {:circuits_i2c, "~> 1.0", override: true, targets: @all_targets}, {:circuits_spi, "~> 1.0 or ~> 0.1", targets: @all_targets}, {:nerves_key, "~> 1.0", targets: @all_targets}, {:pigpiox, "~>0.1", targets: @rpi_targets}, {:ramoops_logger, "~> 0.1", targets: @all_targets}, {:bmp280, "~> 0.2", targets: @all_targets}, {:scroll_hat, "~> 0.1", targets: @rpi_targets}, {:input_event, "~> 1.0 or ~> 0.4", targets: @all_targets}, {:nx, "~> 0.1.0-dev", github: "elixir-nx/nx", sparse: "nx"}, {:blue_heron, "~> 0.3", override: true, targets: @ble_targets}, {:blue_heron_transport_uart, "~> 0.1.2", targets: @ble_targets}, {:nerves_time_zones, "~> 0.1.0", targets: @all_targets}, # Nerves system dependencies {:nerves_system_rpi, "~> 1.18", runtime: false, targets: :rpi}, {:nerves_system_rpi0, "~> 1.18", runtime: false, targets: :rpi0}, {:nerves_system_rpi2, "~> 1.18", runtime: false, targets: :rpi2}, {:nerves_system_rpi3, "~> 1.18", runtime: false, targets: :rpi3}, {:nerves_system_rpi3a, "~> 1.18", runtime: false, targets: :rpi3a}, {:nerves_system_rpi4, "~> 1.18", runtime: false, targets: :rpi4}, {:nerves_system_bbb, "~> 2.13", runtime: false, targets: :bbb}, {:nerves_system_osd32mp1, "~> 0.9", runtime: false, targets: :osd32mp1}, {:nerves_system_x86_64, "~> 1.18", runtime: false, targets: :x86_64}, {:nerves_system_npi_imx6ull, "~> 0.5", runtime: false, targets: :npi_imx6ull} ] end def release do [ overwrite: true, include_erts: &Nerves.Release.erts/0, steps: [&Nerves.Release.init/1, :assemble], strip_beams: [keep: ["Docs"]] ] end end
37.32967
84
0.584045
79ba58ae4a0dc3bbd131defbe77590e7a7291943
289
ex
Elixir
lib/mix/tasks/yatapp/download_translations.ex
antonioparisi/yatapp-elixir
5d426dda3ec8b9222a7197951da32d6f90d75d83
[ "MIT" ]
2
2019-08-23T09:42:30.000Z
2019-10-29T14:38:36.000Z
lib/mix/tasks/yatapp/download_translations.ex
antonioparisi/yatapp-elixir
5d426dda3ec8b9222a7197951da32d6f90d75d83
[ "MIT" ]
6
2019-03-27T13:30:05.000Z
2022-01-14T21:12:29.000Z
lib/mix/tasks/yatapp/download_translations.ex
antonioparisi/yatapp-elixir
5d426dda3ec8b9222a7197951da32d6f90d75d83
[ "MIT" ]
2
2019-11-14T13:51:42.000Z
2022-01-14T09:18:03.000Z
defmodule Mix.Tasks.Yatapp.DownloadTranslations do @moduledoc """ Downloads translations for all locales defined in config and saves as files. """ use Mix.Task @shortdoc "Downloads and saves translations." def run(_) do Yatapp.TranslationsDownloader.download() end end
22.230769
78
0.747405
79baab860e135c95cec58a73f08238330a8bacc5
2,269
ex
Elixir
lib/atom_tweaks_web/controllers/admin/release_note_controller.ex
amymariparker/atom-style-tweaks
9f17b626e4a527d17d2da85ac575029b52fb6a25
[ "MIT" ]
null
null
null
lib/atom_tweaks_web/controllers/admin/release_note_controller.ex
amymariparker/atom-style-tweaks
9f17b626e4a527d17d2da85ac575029b52fb6a25
[ "MIT" ]
null
null
null
lib/atom_tweaks_web/controllers/admin/release_note_controller.ex
amymariparker/atom-style-tweaks
9f17b626e4a527d17d2da85ac575029b52fb6a25
[ "MIT" ]
null
null
null
defmodule AtomTweaksWeb.Admin.ReleaseNoteController do @moduledoc """ Handles all admin release notes resource routes. """ use AtomTweaksWeb, :controller alias AtomTweaks.Releases alias AtomTweaks.Releases.Note @doc """ Creates a new release note. """ @spec create(Plug.Conn.t(), Map.t()) :: Plug.Conn.t() def create(conn, params) def create(conn, %{"note" => note_params}) do %Note{} |> Note.changeset(note_params) |> Repo.insert() |> case do {:ok, note} -> redirect(conn, to: Routes.admin_release_note_path(conn, :show, note)) {:error, changeset} -> render(conn, :new, changeset: changeset) end end @doc """ Displays the edit form for a release note. """ @spec edit(Plug.Conn.t(), Map.t()) :: Plug.Conn.t() def edit(conn, params) def edit(conn, %{"id" => id}) do note = Releases.get_note!(id) changeset = Releases.change_note(note) render(conn, "edit.html", changeset: changeset, note: note) end @doc """ Renders the list of release notes. """ @spec index(Plug.Conn.t(), Map.t()) :: Plug.Conn.t() def index(conn, _params) do notes = Releases.list_notes() render(conn, "index.html", notes: notes) end @doc """ Renders the new form for a release note. """ @spec new(Plug.Conn.t(), Map.t()) :: Plug.Conn.t() def new(conn, _params) do changeset = Releases.change_note(%Note{}) render(conn, "new.html", changeset: changeset) end @doc """ Renders the release note with the given `id`. """ @spec show(Plug.Conn.t(), Map.t()) :: Plug.Conn.t() def show(conn, params) def show(conn, %{"id" => id}) do note = Releases.get_note!(id) render(conn, "show.html", note: note) end @doc """ Updates a release note. """ @spec update(Plug.Conn.t(), Map.t()) :: Plug.Conn.t() def update(conn, params) def update(conn, %{"id" => id, "note" => note_params}) do note = Releases.get_note!(id) note |> Note.changeset(note_params) |> Repo.update() |> case do {:ok, note} -> redirect(conn, to: Routes.admin_release_note_path(conn, :show, note)) {:error, changeset} -> render(conn, "edit.html", changeset: changeset, note: note, errors: changeset.errors) end end end
24.397849
93
0.619656
79babf73a3be512ad15d50bb17c2ea447acb9154
611
ex
Elixir
lib/breadcrumbs/application.ex
azohra/breadcrumbs
6466e66d5a2a8fb103db5d1d8ddf43b92d1e13a0
[ "MIT" ]
3
2018-11-09T18:18:40.000Z
2018-12-10T21:10:21.000Z
lib/breadcrumbs/application.ex
azohra/Breadcrumbs
6466e66d5a2a8fb103db5d1d8ddf43b92d1e13a0
[ "MIT" ]
null
null
null
lib/breadcrumbs/application.ex
azohra/Breadcrumbs
6466e66d5a2a8fb103db5d1d8ddf43b92d1e13a0
[ "MIT" ]
null
null
null
defmodule Breadcrumbs.Application do @moduledoc false use Application @doc false def start(_type, _args) do import Supervisor.Spec pool_size = get_config() children = [ worker(Breadcrumbs.Pool, [pool_size]), worker(Breadcrumbs.PoolIndex, [pool_size]) ] Supervisor.start_link(children, [strategy: :one_for_one, name: __MODULE__]) end defp get_config do specified = Application.get_env(:breadcrumbs, :pool_size) case specified do nil -> 4 0 -> raise Breadcrumbs.ConfigError, message: "Pool size cannot be 0" val -> val end end end
21.068966
79
0.677578
79bac69c7885a14d831995768713aed8c69fbc89
3,350
ex
Elixir
apps/train_loc/lib/train_loc/vehicles/vehicle.ex
mbta/commuter_rail_boarding
213eb4ac72e5c678b06f3298e98c36b9a9dbd1ff
[ "MIT" ]
1
2022-01-30T20:53:07.000Z
2022-01-30T20:53:07.000Z
apps/train_loc/lib/train_loc/vehicles/vehicle.ex
mbta/commuter_rail_boarding
213eb4ac72e5c678b06f3298e98c36b9a9dbd1ff
[ "MIT" ]
47
2021-05-05T10:31:05.000Z
2022-03-30T22:18:14.000Z
apps/train_loc/lib/train_loc/vehicles/vehicle.ex
mbta/commuter_rail_boarding
213eb4ac72e5c678b06f3298e98c36b9a9dbd1ff
[ "MIT" ]
1
2021-05-14T00:35:08.000Z
2021-05-14T00:35:08.000Z
defmodule TrainLoc.Vehicles.Vehicle do @moduledoc """ Functions for working with individual vehicles. """ alias TrainLoc.Utilities.Time, as: TrainLocTime alias TrainLoc.Vehicles.Vehicle require Logger @enforce_keys [:vehicle_id] defstruct [ :vehicle_id, timestamp: DateTime.from_naive!(~N[1970-01-01T00:00:00], "Etc/UTC"), block: "", trip: "", latitude: 0.0, longitude: 0.0, heading: 0, speed: 0 ] @typedoc """ Vehicle data throughout the app is represented by vehicle structs. A vehicle struct includes: * `vehicle_id`: unique vehicle identifier * `timestamp`: datetime when data was received * `block`: represents a series of trips made by a single vehicle in a day * `trip`: represents a scheduled commuter rail trip * `latitude`: geographic coordinate that specifies the north–south position of the vehicle * `longitude`: geographic coordinate that specifies the east–west position of the vehicle * `heading`: compass direction to which the "nose" of the vehicle is pointing, its orientation * `speed`: the vehicle's speed (miles per hour) """ @type t :: %__MODULE__{ vehicle_id: non_neg_integer, timestamp: DateTime.t(), block: String.t(), trip: String.t(), latitude: float | nil, longitude: float | nil, heading: 0..359, speed: non_neg_integer } def from_json_object(obj) do from_json_elem({nil, obj}) end @spec from_json_map(map) :: [t] def from_json_map(map) do Enum.flat_map(map, &from_json_elem/1) end @spec from_json_elem({any, map}) :: [%Vehicle{}] defp from_json_elem({_, veh_data = %{"VehicleID" => _vehicle_id}}) do [from_json(veh_data)] end defp from_json_elem({_, _}), do: [] def from_json(veh_data) when is_map(veh_data) do %__MODULE__{ vehicle_id: veh_data["VehicleID"], timestamp: TrainLocTime.parse_improper_iso(veh_data["Update Time"]), block: process_trip_block(veh_data["WorkID"]), trip: process_trip_block(veh_data["TripID"]), latitude: process_lat_long(veh_data["Latitude"]), longitude: process_lat_long(veh_data["Longitude"]), heading: veh_data["Heading"], speed: veh_data["Speed"] } end defp process_lat_long(0), do: nil defp process_lat_long(lat_long), do: lat_long defp process_trip_block(trip_or_block) when is_integer(trip_or_block) do trip_or_block |> Integer.to_string() |> String.pad_leading(3, ["0"]) end defp process_trip_block(_), do: nil def active_vehicle?(%__MODULE__{block: "000"}), do: false def active_vehicle?(%__MODULE__{trip: "000"}), do: false def active_vehicle?(%__MODULE__{}), do: true @doc """ Logs all available vehicle data for a single vehicle and returns it without modifying it. """ @spec log_vehicle(Vehicle.t()) :: Vehicle.t() def log_vehicle(vehicle) do _ = Logger.debug(fn -> Enum.reduce(Map.from_struct(vehicle), "Vehicle - ", fn {key, value}, acc -> acc <> format_key_value_pair(key, value) end) end) vehicle end defp format_key_value_pair(key, %DateTime{} = value) do format_key_value_pair(key, DateTime.to_iso8601(value)) end defp format_key_value_pair(key, value) do "#{key}=#{value} " end end
27.916667
83
0.66597
79baf55e44bc00c4d06e32c41c98ebab60e0a8f7
1,187
exs
Elixir
clients/storage_transfer/mix.exs
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/storage_transfer/mix.exs
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/storage_transfer/mix.exs
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
1
2020-11-10T16:58:27.000Z
2020-11-10T16:58:27.000Z
defmodule GoogleApi.StorageTransfer.V1.Mixfile do use Mix.Project @version "0.1.0" def project do [app: :google_api_storage_transfer, version: @version, elixir: "~> 1.4", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, description: description(), package: package(), deps: deps(), source_url: "https://github.com/GoogleCloudPlatform/elixir-google-api/tree/master/clients/storage_transfer" ] end def application() do [extra_applications: [:logger]] end defp deps() do [ {:google_gax, "~> 0.1.0"}, {:ex_doc, "~> 0.16", only: :dev} ] end defp description() do """ Transfers data from external data sources to a Google Cloud Storage bucket or between Google Cloud Storage buckets. """ end defp package() do [ files: ["lib", "mix.exs", "README*", "LICENSE"], maintainers: ["Jeff Ching"], licenses: ["Apache 2.0"], links: %{ "GitHub" => "https://github.com/GoogleCloudPlatform/elixir-google-api/tree/master/clients/storage_transfer", "Homepage" => "https://cloud.google.com/storage/transfer" } ] end end
24.729167
119
0.620051
79bb0ebd71af7d38c9eb9708d0d5a844755c7f77
5,043
ex
Elixir
lib/exif_parser.ex
bruceme/exif_parser
38f8ccb9db82924229da3df89ce91a03e4c5decb
[ "Apache-2.0" ]
2
2019-03-09T21:35:43.000Z
2020-02-27T08:09:39.000Z
lib/exif_parser.ex
bruceme/exif_parser
38f8ccb9db82924229da3df89ce91a03e4c5decb
[ "Apache-2.0" ]
4
2018-09-05T14:55:25.000Z
2022-02-04T02:24:11.000Z
lib/exif_parser.ex
bruceme/exif_parser
38f8ccb9db82924229da3df89ce91a03e4c5decb
[ "Apache-2.0" ]
3
2020-02-26T22:52:05.000Z
2022-02-16T08:12:40.000Z
defmodule ExifParser do @moduledoc """ Parse EXIF/TIFF metadata from JPEG and TIFF files. Exif/TIFF referes to the metadata added to jpeg images. It is encoded as part of the jpeg file. There are multiple so-called "Image File Directories" or IFD that store information about the image. + IFD0 generally stores the image, EXIF and GPS metadata + IFD1 when available stores the information about a thumbnail image. ## Usage ### Read from jpeg file Read data from a binary jpeg file. ``` iex(1)> {:ok, tags} = ExifParser.parse_jpeg_file("/path/to/file.jpg") {:ok, %{ ifd0: %{ date_time: "2008:07:31 10:05:49", exif: %{color_space: 1, pixel_x_dimension: 100, pixel_y_dimension: 77}, orientation: 1, resolution_unit: 2, software: "GIMP 2.4.5", x_resolution: 300.0, y_resolution: 300.0 }, ifd1: %{ compression: 6, jpeg_interchange_format: 282, jpeg_interchange_format_length: 2022, resolution_unit: 2, x_resolution: 72.0, y_resolution: 72.0 } }} ``` A specific tag data can be retrived by ``` iex(2)> tags.ifd0.date_time "2008:07:31 10:05:49" iex(3)> tags.ifd0.exif.color_space 1 ``` ### Read from tiff file Data can also be read from binary tiff files. ``` iex(2)> {:ok, tags} = ExifParser.parse_tiff_file("/home/sri/exif_tests/test1.tiff") {:ok, %{ ifd0: %{ bits_per_sample: '\b\b\b\b', compression: 5, extra_samples: 1, image_length: 38, image_width: 174, orientation: 1, photometric_interpretation: 2, planar_configuration: 1, predictor: 2, rows_per_strip: 38, sample_format: [1, 1, 1, 1], samples_per_pixel: 4, strip_byte_counts: 6391, strip_offsets: 8 }} ``` """ @max_length 2 * (65536 + 2) # jpeg constants @jpeg_start_of_image 0xFFD8 @jpeg_app1 0xFFE1 alias ExifParser.Header alias ExifParser.ImageFileDirectory, as: IFD alias ExifParser.CustomLocationTag, as: CLT defmodule Options do @moduledoc """ Options that are passed to the API. Currently only two options are used. ### prettify This enables makes the tag output pretty. The values can be set to false to get data used to parse. **Default: true** ### tag_offsets_and_names This lets the user parse custom tags at custom memory locations. ``` %ExifParser.Options { tag_offsets_and_names: [{MEMORY_LOCATION, :custom_tag_name}] } ``` """ defstruct prettify: true, tag_offsets_and_names: nil @type t :: %__MODULE__{ prettify: Boolean, tag_offsets_and_names: map } end @doc """ EXIF/TIFF data can be loaded from tiff binary files ``` ExifParser.parse_tiff_file("/path/to/file.tiff") ``` returns ``` {:ok, tags} ``` """ def parse_tiff_file(filepath, options \\ %ExifParser.Options{}) do with {:ok, buffer} <- File.open(filepath, [:read], &IO.binread(&1, @max_length)), {:ok, tiff} <- parse_tiff_binary(buffer, options) do {:ok, tiff} else err -> err end end @doc """ EXIF/TIFF data can be loaded from tiff binary buffers """ def parse_tiff_binary( <<header::binary-size(8), _rest::binary>> = start_of_tiff, options \\ %ExifParser.Options{} ) do with {:ok, header} <- Header.parse(header), tags <- IFD.parse_tiff_body( header.identifier, start_of_tiff, header.ifd_offset, options.prettify ), custom_tags <- CLT.parse_custom_tags( options.tag_offsets_and_names, header.identifier, start_of_tiff, options.prettify ) do case custom_tags do nil -> {:ok, tags} custom_tags -> {:ok, tags, custom_tags} end else err -> err end end @doc """ EXIF/TIFF data can be loaded from jpeg binary files ``` ExifParser.parse_jpeg_file("/path/to/file.jpeg") ``` returns ``` {:ok, tags} ``` """ def parse_jpeg_file(filepath, options \\ %ExifParser.Options{}) do with {:ok, buffer} <- File.open(filepath, [:read], &IO.binread(&1, @max_length)), {:ok, buffer} <- find_app1(buffer), {:ok, tiff} <- parse_tiff_binary(buffer, options) do {:ok, tiff} else err -> err end end defp find_app1(<<@jpeg_app1::16, _length::16, "Exif"::binary, 0::16, rest::binary>>), do: {:ok, rest} defp find_app1(<<@jpeg_start_of_image::16, rest::binary>>), do: find_app1(rest) defp find_app1(<<0xFF::8, _num::8, len::16, rest::binary>>) do # Not app1, skip it # the len desciption is part of the length len = len - 2 <<_skip::size(len)-unit(8), rest::binary>> = rest find_app1(rest) end defp find_app1(_), do: {:error, "Can't find app1 in jpeg image"} end
25.089552
102
0.598652
79bb2f4d325595a98300eca1a76a55dc9195bdf0
5,408
ex
Elixir
lib/text_based_fps/player_commands/fire.ex
guisehn/elixir-text-based-fps
59a815da337309297f8b42ef3481277dd4d9b371
[ "MIT" ]
1
2022-03-02T12:18:07.000Z
2022-03-02T12:18:07.000Z
lib/text_based_fps/player_commands/fire.ex
guisehn/elixir-text-based-fps
59a815da337309297f8b42ef3481277dd4d9b371
[ "MIT" ]
12
2021-05-31T21:41:09.000Z
2021-07-30T03:18:09.000Z
lib/text_based_fps/player_commands/fire.ex
guisehn/elixir-text-based-fps
59a815da337309297f8b42ef3481277dd4d9b371
[ "MIT" ]
null
null
null
defmodule TextBasedFPS.PlayerCommand.Fire do import TextBasedFPS.CommandHelper import TextBasedFPS.Text, only: [danger: 1, highlight: 1] alias TextBasedFPS.{ GameMap, Notification, PlayerCommand, Room, RoomPlayer, ServerState } @behaviour PlayerCommand @impl true def execute(state, player, _) do with {:ok, room} <- require_alive_player(state, player) do room_player = Room.get_player(room, player.key) fire(state, player, room_player, room) end end defp fire(state, _, %{ammo: {0, 0}}, _) do {:error, state, "You're out of ammo"} end defp fire(state, _, %{ammo: {0, _}}, _) do {:error, state, "Reload your gun by typing #{highlight("reload")}"} end defp fire(state, player, room_player, room) do shot_players = players_on_path(room.game_map.matrix, room_player.coordinates, room_player.direction) |> Enum.with_index() |> Enum.map(fn {{shot_player_key, distance}, index} -> apply_damage(room, {shot_player_key, distance, index}) end) updated_state = ServerState.update_room(state, room.name, fn room -> shot_players |> Enum.reduce(room, fn shot_player, room -> apply_update(room, room_player, shot_player) end) |> Room.update_player(room_player.player_key, fn player -> RoomPlayer.decrement(player, :ammo) end) end) updated_state = push_notifications(updated_state, player, shot_players) {:ok, updated_state, generate_message(state, shot_players)} end defp players_on_path(matrix, {x, y}, direction) do %{players: players} = GameMap.Matrix.iterate_towards( matrix, {x, y}, direction, %{distance: 1, players: []}, fn coordinate, acc -> cond do GameMap.Matrix.wall_at?(matrix, coordinate) -> {:stop, acc} GameMap.Matrix.player_at?(matrix, coordinate) -> player = GameMap.Matrix.at(matrix, coordinate) updated_acc = acc |> Map.put(:players, acc.players ++ [{player.player_key, acc.distance}]) |> Map.put(:distance, acc.distance + 1) {:continue, updated_acc} true -> {:continue, Map.put(acc, :distance, acc.distance + 1)} end end ) players end defp apply_damage(room, {shot_player_key, distance_to_shooter, shot_player_order}) do shot_player = Room.get_player(room, shot_player_key) shoot_power = shoot_power(distance_to_shooter, shot_player_order) subtract_health(shot_player, shoot_power) end defp shoot_power(distance_to_shooter, enemy_index) do power = 30 - (distance_to_shooter - 1) - enemy_index * 10 max(0, power) end defp subtract_health(shot_player, shoot_power) do new_health = max(0, shot_player.health - shoot_power) Map.put(shot_player, :health, new_health) end defp apply_update(room, shooter, shot_player) do coordinates = shot_player.coordinates put_in(room.players[shot_player.player_key], shot_player) |> maybe_remove_player_from_map(shot_player) |> maybe_add_item(shot_player, coordinates) |> maybe_update_score(shooter, shot_player) end defp maybe_remove_player_from_map(room, shot_player = %{health: 0}) do Room.remove_player_from_map(room, shot_player.player_key) end defp maybe_remove_player_from_map(room, _shot_player), do: room defp maybe_add_item(room, _shot_player = %{health: 0}, coordinates) do Room.add_random_object(room, coordinates) end defp maybe_add_item(room, _shot_player, _coordinates), do: room defp maybe_update_score(room, shooter, shot_player = %{health: 0}) do room |> Room.update_player(shooter.player_key, &RoomPlayer.increment(&1, :kills)) |> Room.update_player(shot_player.player_key, &RoomPlayer.increment(&1, :killed)) end defp maybe_update_score(room, _shooter, _shot_player), do: room defp generate_message(_state, []) do "You've shot the wall." end defp generate_message(state, shot_players) do killed = Enum.filter(shot_players, &RoomPlayer.dead?/1) hit = shot_players -- killed phrase_parts = [action_message("hit", state, hit), action_message("killed", state, killed)] |> Stream.filter(fn part -> part != nil end) |> Enum.join(" and ") "You've #{phrase_parts}" end defp action_message(verb, state, shot_players) do names = shot_players |> Stream.map(fn shot -> ServerState.get_player(state, shot.player_key) end) |> Enum.map(& &1.name) case length(names) do 0 -> nil _ -> "#{verb} #{Enum.join(names, ", ")}" end end defp push_notifications(state, shooter_player, shot_players) do notifications = Enum.map(shot_players, &build_shot_notification(shooter_player, &1)) ServerState.add_notifications(state, notifications) end defp build_shot_notification(shooter_player, shot_player = %{health: 0}) do Notification.new( shot_player.player_key, danger( "#{shooter_player.name} killed you! Type #{highlight("respawn")} to return to the game" ) ) end defp build_shot_notification(shooter_player, shot_player) do Notification.new( shot_player.player_key, danger("uh oh! #{shooter_player.name} shot you!") ) end end
29.878453
95
0.664201
79bb96c2905e375128f2df63b5f9a17cfb56504e
107
ex
Elixir
lib/inch_test/invisible.ex
reergymerej/Hello-World-Elixir
dcdc1437821042225ebb2987dc015e356b0f87f5
[ "MIT" ]
3
2015-09-20T15:43:09.000Z
2016-12-30T19:20:05.000Z
lib/inch_test/invisible.ex
reergymerej/Hello-World-Elixir
dcdc1437821042225ebb2987dc015e356b0f87f5
[ "MIT" ]
null
null
null
lib/inch_test/invisible.ex
reergymerej/Hello-World-Elixir
dcdc1437821042225ebb2987dc015e356b0f87f5
[ "MIT" ]
1
2019-12-07T00:17:49.000Z
2019-12-07T00:17:49.000Z
defmodule InchTest.Invisible do @moduledoc false @doc """ Something """ def foo do end end
9.727273
31
0.635514
79bbbec39abe71358cfb98a574e840ff19e862db
2,288
ex
Elixir
clients/dialogflow/lib/google_api/dialogflow/v2/model/google_cloud_dialogflow_v2_batch_create_entities_request.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
1
2019-01-03T22:30:36.000Z
2019-01-03T22:30:36.000Z
clients/dialogflow/lib/google_api/dialogflow/v2/model/google_cloud_dialogflow_v2_batch_create_entities_request.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
clients/dialogflow/lib/google_api/dialogflow/v2/model/google_cloud_dialogflow_v2_batch_create_entities_request.ex
leandrocp/elixir-google-api
a86e46907f396d40aeff8668c3bd81662f44c71e
[ "Apache-2.0" ]
null
null
null
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the swagger code generator program. # https://github.com/swagger-api/swagger-codegen.git # Do not edit the class manually. defmodule GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2BatchCreateEntitiesRequest do @moduledoc """ The request message for EntityTypes.BatchCreateEntities. ## Attributes - entities ([GoogleCloudDialogflowV2EntityTypeEntity]): Required. The collection of entities to create. Defaults to: `null`. - languageCode (String.t): Optional. The language of entity synonyms defined in &#x60;entities&#x60;. If not specified, the agent&#39;s default language is used. [More than a dozen languages](https://dialogflow.com/docs/reference/language) are supported. Note: languages must be enabled in the agent, before they can be used. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :entities => list(GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2EntityTypeEntity.t()), :languageCode => any() } field( :entities, as: GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2EntityTypeEntity, type: :list ) field(:languageCode) end defimpl Poison.Decoder, for: GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2BatchCreateEntitiesRequest do def decode(value, options) do GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2BatchCreateEntitiesRequest.decode( value, options ) end end defimpl Poison.Encoder, for: GoogleApi.Dialogflow.V2.Model.GoogleCloudDialogflowV2BatchCreateEntitiesRequest do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.903226
348
0.756556
79bbbef61031b96eb216ae05304150de4c70e8df
265
ex
Elixir
dh11_live_view_ui/lib/dh11_live_view_ui.ex
ayarhlaine/dh11_live_view
e52aebc14d7667772bd314f0a147347be0afb599
[ "MIT" ]
null
null
null
dh11_live_view_ui/lib/dh11_live_view_ui.ex
ayarhlaine/dh11_live_view
e52aebc14d7667772bd314f0a147347be0afb599
[ "MIT" ]
null
null
null
dh11_live_view_ui/lib/dh11_live_view_ui.ex
ayarhlaine/dh11_live_view
e52aebc14d7667772bd314f0a147347be0afb599
[ "MIT" ]
null
null
null
defmodule Dh11LiveViewUi do @moduledoc """ Dh11LiveViewUi keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless if it comes from the database, an external API or others. """ end
26.5
66
0.766038
79bbd1e47c526a1dcdf606ff43cd6a9ebbbc7311
1,381
ex
Elixir
apps/artemis/lib/artemis/contexts/event_answer/create_event_answer.ex
artemis-platform/artemis_teams
9930c3d9528e37b76f0525390e32b66eed7eadde
[ "MIT" ]
2
2020-04-23T02:29:18.000Z
2020-07-07T13:13:17.000Z
apps/artemis/lib/artemis/contexts/event_answer/create_event_answer.ex
chrislaskey/artemis_teams
9930c3d9528e37b76f0525390e32b66eed7eadde
[ "MIT" ]
4
2020-04-26T20:35:36.000Z
2020-11-10T22:13:19.000Z
apps/artemis/lib/artemis/contexts/event_answer/create_event_answer.ex
chrislaskey/artemis_teams
9930c3d9528e37b76f0525390e32b66eed7eadde
[ "MIT" ]
null
null
null
defmodule Artemis.CreateEventAnswer do use Artemis.Context alias Artemis.EventAnswer alias Artemis.Helpers.Markdown alias Artemis.Repo def call!(params, user) do case call(params, user) do {:error, _} -> raise(Artemis.Context.Error, "Error creating event answer") {:ok, result} -> result end end def call(params, user) do with_transaction(fn -> params |> insert_record |> Event.broadcast("event-answer:created", params, user) end) end defp insert_record(params) do params = create_params(params) %EventAnswer{} |> EventAnswer.changeset(params) |> Repo.insert() end defp create_params(params) do params |> Artemis.Helpers.keys_to_strings() |> maybe_update_value_html() |> maybe_update_value_number() end defp maybe_update_value_html(%{"value" => value} = params) when is_bitstring(value) do value_html = Markdown.to_html!(value) Map.put(params, "value_html", value_html) rescue _ -> params end defp maybe_update_value_html(params), do: params defp maybe_update_value_number(%{"type" => type, "value" => value} = params) do numeric_types = ["number"] case Enum.member?(numeric_types, type) do true -> Map.put(params, "value_number", value) false -> params end end defp maybe_update_value_number(params), do: params end
23.40678
88
0.676322
79bbddfd43109d320c1ff1b03454818e22c97ec3
1,877
ex
Elixir
clients/content/lib/google_api/content/v21/model/accounttax_custom_batch_response.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/content/lib/google_api/content/v21/model/accounttax_custom_batch_response.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/content/lib/google_api/content/v21/model/accounttax_custom_batch_response.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2020-10-04T10:12:44.000Z
2020-10-04T10:12:44.000Z
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Content.V21.Model.AccounttaxCustomBatchResponse do @moduledoc """ ## Attributes * `entries` (*type:* `list(GoogleApi.Content.V21.Model.AccounttaxCustomBatchResponseEntry.t)`, *default:* `nil`) - The result of the execution of the batch requests. * `kind` (*type:* `String.t`, *default:* `content#accounttaxCustomBatchResponse`) - Identifies what kind of resource this is. Value: the fixed string "content#accounttaxCustomBatchResponse". """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :entries => list(GoogleApi.Content.V21.Model.AccounttaxCustomBatchResponseEntry.t()), :kind => String.t() } field(:entries, as: GoogleApi.Content.V21.Model.AccounttaxCustomBatchResponseEntry, type: :list) field(:kind) end defimpl Poison.Decoder, for: GoogleApi.Content.V21.Model.AccounttaxCustomBatchResponse do def decode(value, options) do GoogleApi.Content.V21.Model.AccounttaxCustomBatchResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Content.V21.Model.AccounttaxCustomBatchResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
37.54
194
0.752264
79bbe64cc366d0d004b1a8da75a762196d68cf45
1,800
exs
Elixir
mix.exs
ciroque/messaging_status_service
0d32873ac6e0a78c92a5cf08da373ba4aaf22da4
[ "MIT" ]
null
null
null
mix.exs
ciroque/messaging_status_service
0d32873ac6e0a78c92a5cf08da373ba4aaf22da4
[ "MIT" ]
null
null
null
mix.exs
ciroque/messaging_status_service
0d32873ac6e0a78c92a5cf08da373ba4aaf22da4
[ "MIT" ]
null
null
null
defmodule MessagingStatusService.Mixfile do use Mix.Project def project do [ app: :messaging_status_service, version: "0.0.1", elixir: "~> 1.4", elixirc_paths: elixirc_paths(Mix.env), compilers: [:phoenix, :gettext] ++ Mix.compilers, start_permanent: Mix.env == :prod, aliases: aliases(), deps: deps() ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [ mod: {MessagingStatusService.Application, []}, extra_applications: [:logger, :runtime_tools] ] end # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] # Specifies your project dependencies. # # Type `mix help deps` for examples and options. defp deps do [ {:phoenix, "~> 1.3.2"}, {:phoenix_pubsub, "~> 1.0"}, {:phoenix_ecto, "~> 3.2"}, {:plug, "~> 1.5"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 2.10"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.11"}, {:cowboy, "~> 1.0"}, {:distillery, "~> 1.5"}, {:honeydew, "~> 1.1"}, {:httpoison, "~> 1.1"}, {:mox, "~> 0.3.2"}, {:timex, "~> 3.3"} ] end # Aliases are shortcuts or tasks specific to the current project. # For example, to create, migrate and run the seeds file at once: # # $ mix ecto.setup # # See the documentation for `Mix` for more info on aliases. defp aliases do [ "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], "test": ["ecto.create --quiet", "ecto.migrate", "test"] ] end end
26.865672
79
0.569444
79bbebc8c5f65c8d92456166e7ce3609212d06ac
4,219
exs
Elixir
test/aws_ex_ray_test.exs
lyokato/aws_ex_ray
f2413e9ac0d248da8960eef548418b1a2a906aff
[ "MIT" ]
10
2018-06-17T03:20:59.000Z
2022-03-01T18:34:55.000Z
test/aws_ex_ray_test.exs
lyokato/aws_ex_ray
f2413e9ac0d248da8960eef548418b1a2a906aff
[ "MIT" ]
9
2018-05-29T05:26:24.000Z
2021-12-11T15:29:38.000Z
test/aws_ex_ray_test.exs
lyokato/aws_ex_ray
f2413e9ac0d248da8960eef548418b1a2a906aff
[ "MIT" ]
9
2018-06-11T06:15:58.000Z
2022-01-20T10:07:36.000Z
defmodule AwsExRayTest do use ExUnit.Case, async: true use StructAssert alias AwsExRay.Test.MockedSink alias AwsExRay.Trace alias AwsExRay.Util setup do AwsExRay.Test.Mox.setup_default() :ok end test "segment" do agent = MockedSink.start_agent() {:ok, trace} = Trace.parse("Root=root1;Parent=parent1;Sampled=1") t1 = Util.now() Process.sleep(5) seg = AwsExRay.start_tracing(trace, "MySegmentName") Process.sleep(5) t2 = Util.now() Process.sleep(5) AwsExRay.finish_tracing(seg) Process.sleep(5) t3 = Util.now() [got] = MockedSink.get(agent) s1 = Poison.decode!(got) assert s1["start_time"] > t1 assert s1["start_time"] < t2 assert s1["end_time"] > t2 assert s1["end_time"] < t3 assert_subset(s1, %{ "name" => "MySegmentName", "metadata" => %{ "tracing_sdk" => %{ "name" => "aws-ex-ray", "version" => "0.0.1" } }, }) end test "simple tracing" do agent = MockedSink.start_agent() {:ok, trace} = Trace.parse("Root=root1;Parent=parent1;Sampled=1") AwsExRay.trace(trace, "SimpleWay", fn -> Process.sleep(10) end) [got] = MockedSink.get(agent) s1 = Poison.decode!(got) assert_subset(s1, %{ "name" => "SimpleWay", "metadata" => %{ "tracing_sdk" => %{ "name" => "aws-ex-ray", "version" => "0.0.1" } }, }) end test "simple tracing with annotations" do agent = MockedSink.start_agent() {:ok, trace} = Trace.parse("Root=root1;Parent=parent1;Sampled=1") AwsExRay.trace(trace, "SimpleWay", %{"MyLogicType1" => "Foobar", "MyLogicType2" => "Barbuz"}, fn -> Process.sleep(10) end) [got] = MockedSink.get(agent) s1 = Poison.decode!(got) assert_subset(s1, %{ "name" => "SimpleWay", "annotations" => %{ "MyLogicType1" => "Foobar", "MyLogicType2" => "Barbuz", }, "metadata" => %{ "tracing_sdk" => %{ "name" => "aws-ex-ray", "version" => "0.0.1" } }, }) end test "simple subsegment" do agent = MockedSink.start_agent() {:ok, trace} = Trace.parse("Root=root1;Parent=parent1;Sampled=1") result = AwsExRay.trace(trace, "SimpleWay", fn -> Process.sleep(10) sub_result = AwsExRay.subsegment("SimpleSub", fn _trace_value -> Process.sleep(10) 1 end) Process.sleep(10) sub_result + 2 end) assert result == 3 [s1, s2] = agent |> MockedSink.get() |> Enum.map(&Poison.decode!/1) assert_subset(s1, %{ "name" => "SimpleWay", "metadata" => %{ "tracing_sdk" => %{ "name" => "aws-ex-ray", "version" => "0.0.1" } }, }) assert_subset(s2, %{ "name" => "SimpleSub", "metadata" => %{ "tracing_sdk" => %{ "name" => "aws-ex-ray", "version" => "0.0.1" } }, }) assert s2["parent_id"] == s1["id"] end test "simple subsegment with annotations" do agent = MockedSink.start_agent() {:ok, trace} = Trace.parse("Root=root1;Parent=parent1;Sampled=1") AwsExRay.trace(trace, "SimpleWay", fn -> Process.sleep(10) annotations = %{"MyLogic" => "Job1"} AwsExRay.subsegment("SimpleSub", annotations, [namespace: :none], fn _trace_value -> Process.sleep(10) end) Process.sleep(10) end) [s1, s2] = agent |> MockedSink.get() |> Enum.map(&Poison.decode!/1) assert_subset(s1, %{ "name" => "SimpleWay", "metadata" => %{ "tracing_sdk" => %{ "name" => "aws-ex-ray", "version" => "0.0.1" } }, }) assert_subset(s2, %{ "name" => "SimpleSub", "annotations" => %{ "MyLogic" => "Job1", }, "metadata" => %{ "tracing_sdk" => %{ "name" => "aws-ex-ray", "version" => "0.0.1" } }, }) assert s2["parent_id"] == s1["id"] end end
19.177273
103
0.506992
79bbee7853867081fcbd312f612c2a507406fad4
5,980
ex
Elixir
lib/ecto/parameterized_type.ex
yordis/ecto
6e7bc3f4d757b7c09ced10135e0c5c4ce1f4ea2f
[ "Apache-2.0" ]
null
null
null
lib/ecto/parameterized_type.ex
yordis/ecto
6e7bc3f4d757b7c09ced10135e0c5c4ce1f4ea2f
[ "Apache-2.0" ]
null
null
null
lib/ecto/parameterized_type.ex
yordis/ecto
6e7bc3f4d757b7c09ced10135e0c5c4ce1f4ea2f
[ "Apache-2.0" ]
null
null
null
defmodule Ecto.ParameterizedType do @moduledoc """ Parameterized types are Ecto types that can be customized per field. Parameterized types allow a set of options to be specified in the schema which are initialized on compilation and passed to the callback functions as the last argument. For example, `field :foo, :string` behaves the same for every field. On the other hand, `field :foo, Ecto.Enum, values: [:foo, :bar, :baz]` will likely have a different set of values per field. Note that options are specified as a keyword, but it is idiomatic to convert them to maps inside `c:init/1` for easier pattern matching in other callbacks. Parameterized types are a superset of regular types. In other words, with parameterized types you can do everything a regular type does, and more. For example, parameterized types can handle `nil` values in both `load` and `dump` callbacks, they can customize `cast` behavior per query and per changeset, and also control how values are embedded. However, parameterized types are also more complex. Therefore, if everything you need to achieve can be done with basic types, they should be preferred to parameterized ones. ## Examples To create a parameterized type, create a module as shown below: defmodule MyApp.MyType do use Ecto.ParameterizedType def type(_params), do: :string def init(opts) do validate_opts(opts) Enum.into(opts, %{}) end def cast(data, params) do ... cast_data end def load(data, _loader, params) do ... {:ok, loaded_data} end def dump(data, dumper, params) do ... {:ok, dumped_data} end def equal?(a, b, _params) do a == b end end To use this type in a schema field, specify the type and parameters like this: schema "foo" do field :bar, MyApp.MyType, opt1: :baz, opt2: :boo end To use this type in places where you need it to be initialized (for example, schemaless changesets), you can use `init/2`. """ @typedoc """ The keyword options passed from the Schema's field macro into `c:init/1` """ @type opts :: keyword() @typedoc """ The parameters for the ParameterizedType This is the value passed back from `c:init/1` and subsequently passed as the last argument to all callbacks. Idiomatically it is a map. """ @type params :: term() @doc """ Callback to convert the options specified in the field macro into parameters to be used in other callbacks. This function is called at compile time, and should raise if invalid values are specified. It is idiomatic that the parameters returned from this are a map. `field` and `schema` will be injected into the options automatically. For example, this schema specification schema "my_table" do field :my_field, MyParameterizedType, opt1: :foo, opt2: nil end will result in the call: MyParameterizedType.init([schema: "my_table", field: :my_field, opt1: :foo, opt2: nil]) """ @callback init(opts :: opts()) :: params() @doc """ Casts the given input to the ParameterizedType with the given parameters. If the parameterized type is also a composite type, the inner type can be cast by calling `Ecto.Type.cast/2` directly. For more information on casting, see `c:Ecto.Type.cast/1`. """ @callback cast(data :: term, params()) :: {:ok, term} | :error | {:error, keyword()} @doc """ Loads the given term into a ParameterizedType. It receives a `loader` function in case the parameterized type is also a composite type. In order to load the inner type, the `loader` must be called with the inner type and the inner value as argument. For more information on loading, see `c:Ecto.Type.load/1`. Note that this callback *will* be called when loading a `nil` value, unlike `c:Ecto.Type.load/1`. """ @callback load(value :: any(), loader :: function(), params()) :: {:ok, value :: any()} | :error @doc """ Dumps the given term into an Ecto native type. It receives a `dumper` function in case the parameterized type is also a composite type. In order to dump the inner type, the `dumper` must be called with the inner type and the inner value as argument. For more information on dumping, see `c:Ecto.Type.dump/1`. Note that this callback *will* be called when dumping a `nil` value, unlike `c:Ecto.Type.dump/1`. """ @callback dump(value :: any(), dumper :: function(), params()) :: {:ok, value :: any()} | :error @doc """ Returns the underlying schema type for the ParameterizedType. For more information on schema types, see `c:Ecto.Type.type/0` """ @callback type(params()) :: Ecto.Type.t() @doc """ Checks if two terms are semantically equal. """ @callback equal?(value1 :: any(), value2 :: any(), params()) :: boolean() @doc """ Dictates how the type should be treated inside embeds. For more information on embedding, see `c:Ecto.Type.embed_as/1` """ @callback embed_as(format :: atom(), params()) :: :self | :dump @doc """ Generates a loaded version of the data. This is callback is invoked when a parameterized type is given to `field` with the `:autogenerate` flag. """ @callback autogenerate(params()) :: term() @optional_callbacks autogenerate: 1 @doc """ Inits a parameterized type given by `type` with `opts`. Useful when manually initializing a type for schemaless changesets. """ def init(type, opts) do {:parameterized, type, type.init(opts)} end @doc false defmacro __using__(_) do quote location: :keep do @behaviour Ecto.ParameterizedType @doc false def embed_as(_, _), do: :self @doc false def equal?(term1, term2, _params), do: term1 == term2 defoverridable embed_as: 2, equal?: 3 end end end
30.20202
98
0.672575
79bbf261762f96a31ad5ad3bb006ab9d8e50cab0
1,535
exs
Elixir
data/config.exs
argrath/pleroma-vagrant
edeb6777dd1d775fbf4f1ac40e5d485905cf0066
[ "CC0-1.0" ]
2
2018-04-20T13:16:26.000Z
2019-02-16T21:53:23.000Z
data/config.exs
argrath/pleroma-vagrant
edeb6777dd1d775fbf4f1ac40e5d485905cf0066
[ "CC0-1.0" ]
null
null
null
data/config.exs
argrath/pleroma-vagrant
edeb6777dd1d775fbf4f1ac40e5d485905cf0066
[ "CC0-1.0" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. # # This configuration file is loaded before any dependency and # is restricted to this project. use Mix.Config # General application configuration config :pleroma, ecto_repos: [Pleroma.Repo] config :pleroma, Pleroma.Upload, uploads: "uploads" # Configures the endpoint config :pleroma, Pleroma.Web.Endpoint, url: [host: "192.168.1.202"], protocol: "http", secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl", render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)], pubsub: [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2] # Configures Elixir's Logger config :logger, :console, format: "$time $metadata[$level] $message\n", metadata: [:request_id] config :mime, :types, %{ "application/xrd+xml" => ["xrd+xml"] } config :pleroma, :websub, Pleroma.Web.Websub config :pleroma, :ostatus, Pleroma.Web.OStatus config :pleroma, :httpoison, HTTPoison version = with {version, 0} <- System.cmd("git", ["rev-parse", "HEAD"]) do "Pleroma #{String.trim(version)}" else _ -> "Pleroma dev" end config :pleroma, :instance, version: version, name: "Pleroma", email: "[email protected]", limit: 5000, registrations_open: true # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env}.exs"
28.962264
86
0.710098
79bc187729ba11e10b29dd526050805990e473b2
1,941
ex
Elixir
clients/dialogflow/lib/google_api/dialogflow/v3/model/google_cloud_dialogflow_cx_v3beta1_webhook_request_intent_info_intent_parameter_value.ex
renovate-bot/elixir-google-api
1da34cd39b670c99f067011e05ab90af93fef1f6
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/dialogflow/lib/google_api/dialogflow/v3/model/google_cloud_dialogflow_cx_v3beta1_webhook_request_intent_info_intent_parameter_value.ex
swansoffiee/elixir-google-api
9ea6d39f273fb430634788c258b3189d3613dde0
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/dialogflow/lib/google_api/dialogflow/v3/model/google_cloud_dialogflow_cx_v3beta1_webhook_request_intent_info_intent_parameter_value.ex
dazuma/elixir-google-api
6a9897168008efe07a6081d2326735fe332e522c
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowCxV3beta1WebhookRequestIntentInfoIntentParameterValue do @moduledoc """ Represents a value for an intent parameter. ## Attributes * `originalValue` (*type:* `String.t`, *default:* `nil`) - Always present. Original text value extracted from user utterance. * `resolvedValue` (*type:* `any()`, *default:* `nil`) - Always present. Structured value for the parameter extracted from user utterance. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :originalValue => String.t() | nil, :resolvedValue => any() | nil } field(:originalValue) field(:resolvedValue) end defimpl Poison.Decoder, for: GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowCxV3beta1WebhookRequestIntentInfoIntentParameterValue do def decode(value, options) do GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowCxV3beta1WebhookRequestIntentInfoIntentParameterValue.decode( value, options ) end end defimpl Poison.Encoder, for: GoogleApi.Dialogflow.V3.Model.GoogleCloudDialogflowCxV3beta1WebhookRequestIntentInfoIntentParameterValue do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
34.052632
141
0.752705
79bc426cf3782def11af472775804a3e3610987d
28,251
exs
Elixir
lib/mix/test/mix/tasks/xref_test.exs
mertonium/elixir
74e666156906974082f6b4d34dfbe6988d6465c0
[ "Apache-2.0" ]
1
2018-10-02T13:55:29.000Z
2018-10-02T13:55:29.000Z
lib/mix/test/mix/tasks/xref_test.exs
mertonium/elixir
74e666156906974082f6b4d34dfbe6988d6465c0
[ "Apache-2.0" ]
null
null
null
lib/mix/test/mix/tasks/xref_test.exs
mertonium/elixir
74e666156906974082f6b4d34dfbe6988d6465c0
[ "Apache-2.0" ]
null
null
null
Code.require_file("../../test_helper.exs", __DIR__) defmodule Mix.Tasks.XrefTest do use MixTest.Case import ExUnit.CaptureIO setup_all do previous = Application.get_env(:elixir, :ansi_enabled, false) Application.put_env(:elixir, :ansi_enabled, false) on_exit(fn -> Application.put_env(:elixir, :ansi_enabled, previous) end) end setup do Mix.Project.push(MixTest.Case.Sample) :ok end test "calls: returns all function calls" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: A.a() def a(arg), do: A.a(arg) def c, do: B.a() end """, "lib/b.ex" => """ defmodule B do def a, do: nil end """ } output = [ %{callee: {A, :a, 0}, caller_module: A, file: "lib/a.ex", line: 2}, %{callee: {A, :a, 1}, caller_module: A, file: "lib/a.ex", line: 3}, %{callee: {B, :a, 0}, caller_module: A, file: "lib/a.ex", line: 4}, %{callee: {Kernel, :def, 2}, caller_module: A, file: "lib/a.ex", line: 4}, %{callee: {Kernel, :def, 2}, caller_module: A, file: "lib/a.ex", line: 3}, %{callee: {Kernel, :def, 2}, caller_module: A, file: "lib/a.ex", line: 2}, %{callee: {Kernel, :defmodule, 2}, caller_module: A, file: "lib/a.ex", line: 1}, %{ callee: {Kernel.LexicalTracker, :read_cache, 2}, caller_module: A, file: "lib/a.ex", line: 1 }, %{callee: {Kernel, :def, 2}, caller_module: B, file: "lib/b.ex", line: 2}, %{callee: {Kernel, :defmodule, 2}, caller_module: B, file: "lib/b.ex", line: 1}, %{ callee: {Kernel.LexicalTracker, :read_cache, 2}, caller_module: B, file: "lib/b.ex", line: 1 } ] assert_all_calls(files, output) end test "calls: returns macro call" do files = %{ "lib/a.ex" => """ defmodule A do defmacro a_macro, do: :ok end """, "lib/b.ex" => """ defmodule B do require A def a, do: A.a_macro() end """ } output = [ %{callee: {A, :a_macro, 0}, caller_module: B, file: "lib/b.ex", line: 3}, %{callee: {Kernel, :def, 2}, caller_module: B, file: "lib/b.ex", line: 3}, %{callee: {Kernel, :defmodule, 2}, caller_module: B, file: "lib/b.ex", line: 1}, %{ callee: {Kernel.LexicalTracker, :read_cache, 2}, line: 1, caller_module: B, file: "lib/b.ex" }, %{callee: {Kernel, :defmacro, 2}, caller_module: A, file: "lib/a.ex", line: 2}, %{callee: {Kernel, :defmodule, 2}, caller_module: A, file: "lib/a.ex", line: 1}, %{ callee: {Kernel.LexicalTracker, :read_cache, 2}, line: 1, caller_module: A, file: "lib/a.ex" } ] assert_all_calls(files, output) end test "calls: returns function call inside macro" do files = %{ "lib/a.ex" => """ defmodule A do defmacro a_macro(x) do quote do A.b(unquote(x)) end end def b(x), do: x end """, "lib/b.ex" => """ defmodule B do require A def a, do: A.a_macro(1) end """ } output = [ %{callee: {A, :b, 1}, caller_module: B, file: "lib/b.ex", line: 3}, %{callee: {A, :a_macro, 1}, caller_module: B, file: "lib/b.ex", line: 3}, %{callee: {Kernel, :def, 2}, caller_module: B, file: "lib/b.ex", line: 3}, %{callee: {Kernel, :defmodule, 2}, caller_module: B, file: "lib/b.ex", line: 1}, %{ callee: {Kernel.LexicalTracker, :read_cache, 2}, caller_module: B, file: "lib/b.ex", line: 1 }, %{callee: {Kernel, :def, 2}, caller_module: A, file: "lib/a.ex", line: 8}, %{callee: {Kernel, :defmacro, 2}, caller_module: A, file: "lib/a.ex", line: 2}, %{callee: {Kernel, :defmodule, 2}, caller_module: A, file: "lib/a.ex", line: 1}, %{ callee: {Kernel.LexicalTracker, :read_cache, 2}, caller_module: A, file: "lib/a.ex", line: 1 } ] assert_all_calls(files, output) end defp assert_all_calls(files, expected) do in_fixture("no_mixfile", fn -> generate_files(files) Mix.Task.run("compile") assert Enum.sort(Mix.Tasks.Xref.calls()) == Enum.sort(expected) end) end ## Warnings test "warnings: reports nothing with no references" do files = %{"lib/a.ex" => "defmodule A do end"} assert_no_warnings(files) end test "warnings: reports missing functions" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: A.no_func def b, do: A.a() @file "lib/external_source.ex" def c, do: &A.no_func/1 end """ } warning = """ warning: function A.no_func/0 is undefined or private lib/a.ex:2 warning: function A.no_func/1 is undefined or private lib/external_source.ex:6 """ assert_warnings(files, warning) end test "warnings: reports missing functions respecting arity" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: :ok def b, do: A.a(1) @file "lib/external_source.ex" def c, do: A.b(1) end """ } warning = """ warning: function A.a/1 is undefined or private. Did you mean one of: * a/0 lib/a.ex:3 warning: function A.b/1 is undefined or private. Did you mean one of: * b/0 lib/external_source.ex:6 """ assert_warnings(files, warning) end test "warnings: reports missing modules" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: D.no_module @file "lib/external_source.ex" def c, do: E.no_module end """ } warning = """ warning: function D.no_module/0 is undefined (module D is not available) lib/a.ex:2 warning: function E.no_module/0 is undefined (module E is not available) lib/external_source.ex:5 """ assert_warnings(files, warning) end test "warnings: reports missing captures" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: &A.no_func/0 @file "lib/external_source.ex" def c, do: &A.no_func/1 end """ } warning = """ warning: function A.no_func/0 is undefined or private lib/a.ex:2 warning: function A.no_func/1 is undefined or private lib/external_source.ex:5 """ assert_warnings(files, warning) end test "warnings: doesn't report missing funcs at compile time" do files = %{ "lib/a.ex" => """ Enum.map([], fn _ -> BadReferencer.no_func4() end) if function_exported?(List, :flatten, 1) do List.flatten([1, 2, 3]) else List.old_flatten([1, 2, 3]) end """ } assert_no_warnings(files) end test "warnings: reports deprecated calls" do files = %{ "lib/a.ex" => """ defmodule A do @deprecated "Use A.c/0 instead" def a, do: c() def b, do: a() def c, do: :c end """, "lib/b.ex" => """ defmodule B do def a, do: A.a() end """ } warning = """ warning: A.a/0 is deprecated. Use A.c/0 instead. lib/b.ex:2 """ assert_warnings(files, warning) end test "warnings: protocols are checked, ignoring missing built-in impls" do files = %{ "lib/a.ex" => """ defprotocol AProtocol do def func(arg) end defmodule AImplementation do defimpl AProtocol do def func(_), do: B.no_func end end """ } warning = """ warning: function B.no_func/0 is undefined or private lib/a.ex:7 """ assert_warnings(files, warning) end test "warnings: handles Erlang ops" do files = %{ "lib/a.ex" => """ defmodule A do def a(a, b), do: a and b def b(a, b), do: a or b end """ } assert_no_warnings(files) end test "warnings: handles Erlang modules" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: :not_a_module.no_module def b, do: :lists.no_func end """ } warning = """ warning: function :lists.no_func/0 is undefined or private lib/a.ex:3 warning: function :not_a_module.no_module/0 is undefined (module :not_a_module is not available) lib/a.ex:2 """ assert_warnings(files, warning) end test "warnings: handles multiple modules in one file" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: B.no_func def b, do: B.a end """, "lib/b.ex" => """ defmodule B do def a, do: A.no_func def b, do: A.b end """ } warning = """ warning: function A.no_func/0 is undefined or private lib/b.ex:2 warning: function B.no_func/0 is undefined or private lib/a.ex:2 """ assert_warnings(files, warning) end test "warnings: doesn't load unloaded modules" do files = %{ "lib/a.ex" => """ defmodule A do @compile {:autoload, false} @on_load :init def init do raise "oops" end end """, "lib/b.ex" => """ defmodule B do def a, do: A.no_func def b, do: A.init end """ } warning = """ warning: function A.no_func/0 is undefined or private lib/b.ex:2 """ assert_warnings(files, warning) end test "warnings: groups multiple warnings in one file" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: A.no_func @file "lib/external_source.ex" def b, do: A2.no_func def c, do: A.no_func def d, do: A2.no_func end """ } warning = """ warning: function A.no_func/0 is undefined or private Found at 2 locations: lib/a.ex:2 lib/a.ex:7 warning: function A2.no_func/0 is undefined (module A2 is not available) Found at 2 locations: lib/a.ex:8 lib/external_source.ex:5 """ assert_warnings(files, warning) end test "warnings: handles module body conditionals" do files = %{ "lib/a.ex" => """ defmodule A do if function_exported?(List, :flatten, 1) do List.flatten([1, 2, 3]) else List.old_flatten([1, 2, 3]) end if function_exported?(List, :flatten, 1) do def flatten(arg), do: List.flatten(arg) else def flatten(arg), do: List.old_flatten(arg) end if function_exported?(List, :flatten, 1) do def flatten2(arg), do: List.old_flatten(arg) else def flatten2(arg), do: List.flatten(arg) end end """ } warning = """ warning: function List.old_flatten/1 is undefined or private. Did you mean one of: * flatten/1 * flatten/2 lib/a.ex:15 """ assert_warnings(files, warning) end test "warnings: imports" do files = %{ "lib/a.ex" => """ defmodule A do import Record def a(a, b), do: extract(a, b) def b(arg), do: is_record(arg) end """ } assert_no_warnings(files) end test "warnings: aliases" do files = %{ "lib/a.ex" => """ defmodule A do alias Enum, as: E def a(a, b), do: E.map2(a, b) def b, do: &E.map2/2 @file "lib/external_source.ex" def c do alias Enum, as: EE &EE.map2/2 end end """ } warning = """ warning: function Enum.map2/2 is undefined or private. Did you mean one of: * map/2 Found at 3 locations: lib/a.ex:4 lib/a.ex:5 lib/external_source.ex:10 """ assert_warnings(files, warning) end test "warnings: requires" do files = %{ "lib/a.ex" => """ defmodule A do require Integer def a(a), do: Integer.is_even(a) end """ } assert_no_warnings(files) end defp assert_warnings(files, expected) do in_fixture("no_mixfile", fn -> generate_files(files) output = capture_io(:stderr, fn -> Mix.Task.run("compile.xref") end) assert output == expected end) end defp assert_no_warnings(files) do in_fixture("no_mixfile", fn -> generate_files(files) output = capture_io(:stderr, fn -> Mix.Task.run("compile.xref") end) assert output == "" end) end ## Unreachable test "unreachable: reports nothing with no references" do in_fixture("no_mixfile", fn -> File.write!("lib/a.ex", "defmodule A do end") assert Mix.Task.run("xref", ["unreachable"]) == :ok end) end test "unreachable: reports missing functions" do code = """ defmodule A do def a, do: A.no_func def b, do: A.a() @file "lib/external_source.ex" def c, do: A.no_func end """ warning = """ Compiling 2 files (.ex) Generated sample app lib/a.ex:2: A.no_func/0 lib/external_source.ex:6: A.no_func/0 """ assert_unreachable(code, warning) end test "unreachable: aborts if any" do code = """ defmodule A do def a, do: A.no_func end """ assert_raise Mix.Error, "mix xref unreachable failed: unreachable calls were found", fn -> assert_unreachable(code, "NOT USED", ~w(--abort-if-any)) end end defp assert_unreachable(contents, expected, args \\ []) do in_fixture("no_mixfile", fn -> File.write!("lib/a.ex", contents) capture_io(:stderr, fn -> assert Mix.Task.run("xref", ["unreachable" | args]) == :error end) assert ^expected = receive_until_no_messages([]) end) end ## Deprecated test "deprecated: reports nothing with no references" do in_fixture("no_mixfile", fn -> File.write!("lib/a.ex", "defmodule A do end") assert Mix.Task.run("xref", ["deprecated"]) == :ok end) end test "deprecated: reports deprecated functions" do code = """ defmodule A do @deprecated "oops" def a, do: A.a end """ warning = """ Compiling 2 files (.ex) Generated sample app lib/a.ex:3: A.a/0 """ assert_deprecated(code, warning) end test "deprecated: aborts if any" do code = """ defmodule A do @deprecated "oops" def a, do: A.a end """ assert_raise Mix.Error, "mix xref deprecated failed: deprecated calls were found", fn -> assert_deprecated(code, "NOT USED", ~w(--abort-if-any)) end end defp assert_deprecated(contents, expected, args \\ []) do in_fixture("no_mixfile", fn -> File.write!("lib/a.ex", contents) capture_io(:stderr, fn -> assert Mix.Task.run("xref", ["deprecated" | args]) == :error end) assert ^expected = receive_until_no_messages([]) end) end ## Exclude test "exclude: excludes specified modules and MFAs" do defmodule ExcludeSample do def project do [ app: :sample, version: "0.1.0", xref: [exclude: [MissingModule, {MissingModule2, :no_func, 2}]] ] end end Mix.Project.push(ExcludeSample) files = %{ "lib/a.ex" => """ defmodule A do def a, do: MissingModule.no_func(1) def b, do: MissingModule2.no_func(1, 2) def c, do: MissingModule2.no_func(1) def d, do: MissingModule3.no_func(1, 2) end """ } warning = """ warning: function MissingModule2.no_func/1 is undefined (module MissingModule2 is not available) lib/a.ex:4 warning: function MissingModule3.no_func/2 is undefined (module MissingModule3 is not available) lib/a.ex:5 """ assert_warnings(files, warning) end ## Callers test "callers: prints callers of specified Module" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: A.a() def a(arg), do: A.a(arg) def b, do: A.b() def c, do: B.a() @file "lib/external_source.ex" def d, do: A.a() end """ } output = """ Compiling 2 files (.ex) Generated sample app lib/a.ex:2: A.a/0 lib/external_source.ex:8: A.a/0 lib/a.ex:3: A.a/1 lib/a.ex:4: A.b/0 """ assert_callers("A", files, output) end test "callers: prints callers of specified Module.func" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: A.a() def a(arg), do: A.a(arg) def b, do: A.b() def c, do: B.a() @file "lib/external_source.ex" def d, do: A.a() end """ } output = """ Compiling 2 files (.ex) Generated sample app lib/a.ex:2: A.a/0 lib/external_source.ex:8: A.a/0 lib/a.ex:3: A.a/1 """ assert_callers("A.a", files, output) end test "callers: prints callers of specified Module.func/arity" do files = %{ "lib/a.ex" => """ defmodule A do def a, do: A.a() def a(arg), do: A.a(arg) def b, do: A.b() def c, do: B.a() @file "lib/external_source.ex" def d, do: A.a() end """ } output = """ Compiling 2 files (.ex) Generated sample app lib/a.ex:2: A.a/0 lib/external_source.ex:8: A.a/0 """ assert_callers("A.a/0", files, output) end test "callers: lists compile calls and macros" do files = %{ "lib/a.ex" => """ defmodule A do defmacro a_macro, do: :ok def a, do: :ok end """, "lib/b.ex" => """ defmodule B do require A A.a_macro() A.a() @file "lib/external_source.ex" def b do A.a_macro() A.a() end end """ } output = """ Compiling 2 files (.ex) Generated sample app lib/b.ex:5: A.a/0 lib/external_source.ex:10: A.a/0 lib/b.ex:4: A.a_macro/0 lib/external_source.ex:9: A.a_macro/0 """ assert_callers("A", files, output) end test "callers: handles aliases" do files = %{ "lib/a.ex" => """ defmodule A do alias Enum, as: E E.map([], &E.flatten/1) def a(a, b), do: E.map(a, b) @file "lib/external_source.ex" def b() do alias Enum, as: EE EE.map([], &EE.flatten/1) end end """ } output = """ Compiling 2 files (.ex) Generated sample app lib/a.ex:4: Enum.flatten/1 lib/external_source.ex:11: Enum.flatten/1 lib/a.ex:4: Enum.map/2 lib/a.ex:6: Enum.map/2 lib/external_source.ex:11: Enum.map/2 """ assert_callers("Enum", files, output) end test "callers: handles imports" do files = %{ "lib/a.ex" => ~S""" defmodule A do import Integer &is_even/1 &parse/1 _ = is_even(Enum.random([1])) _ = parse("2") def a(a), do: is_even(a) def b(a), do: parse(a) _ = is_even(Enum.random([1])); def c(a), do: is_even(a) end """, "lib/b.ex" => ~S""" defmodule B do &Integer.parse/1 @file "lib/external_source.ex" def a(a) do import Integer parse(1) is_even(a) end end """ } output = """ Compiling 2 files (.ex) Generated sample app lib/a.ex:4: Integer.is_even/1 lib/a.ex:7: Integer.is_even/1 lib/a.ex:10: Integer.is_even/1 lib/a.ex:12: Integer.is_even/1 lib/external_source.ex:8: Integer.is_even/1 lib/a.ex:5: Integer.parse/1 lib/a.ex:8: Integer.parse/1 lib/a.ex:11: Integer.parse/1 lib/b.ex:2: Integer.parse/1 lib/external_source.ex:7: Integer.parse/1 """ assert_callers("Integer", files, output) end test "callers: no argument gives error" do in_fixture("no_mixfile", fn -> message = "xref doesn't support this command. For more information run \"mix help xref\"" assert_raise Mix.Error, message, fn -> assert Mix.Task.run("xref", ["callers"]) == :error end end) end test "callers: gives nice error for quotable but invalid callers spec" do in_fixture("no_mixfile", fn -> message = "xref callers CALLEE expects Module, Module.function, or Module.function/arity, got: Module.func(arg)" assert_raise Mix.Error, message, fn -> Mix.Task.run("xref", ["callers", "Module.func(arg)"]) end end) end test "callers: gives nice error for unquotable callers spec" do in_fixture("no_mixfile", fn -> message = "xref callers CALLEE expects Module, Module.function, or Module.function/arity, got: %" assert_raise Mix.Error, message, fn -> Mix.Task.run("xref", ["callers", "%"]) end end) end defp assert_callers(callee, files, expected) do in_fixture("no_mixfile", fn -> for {file, contents} <- files do File.write!(file, contents) end capture_io(:stderr, fn -> assert Mix.Task.run("xref", ["callers", callee]) == :ok end) assert ^expected = receive_until_no_messages([]) end) end ## Graph test "graph: basic usage" do assert_graph(""" lib/a.ex └── lib/b.ex └── lib/a.ex lib/b.ex lib/c.ex lib/d.ex └── lib/a.ex (compile) """) end test "graph: stats" do assert_graph(["--format", "stats"], """ Tracked files: 4 (nodes) Compile dependencies: 1 (edges) Structs dependencies: 0 (edges) Runtime dependencies: 2 (edges) Top 4 files with most outgoing dependencies: * lib/d.ex (1) * lib/b.ex (1) * lib/a.ex (1) * lib/c.ex (0) Top 2 files with most incoming dependencies: * lib/a.ex (2) * lib/b.ex (1) """) end test "graph: exclude many" do assert_graph(~w[--exclude lib/c.ex --exclude lib/b.ex], """ lib/a.ex lib/d.ex └── lib/a.ex (compile) """) end test "graph: exclude one" do assert_graph(~w[--exclude lib/d.ex], """ lib/a.ex └── lib/b.ex └── lib/a.ex lib/b.ex lib/c.ex """) end test "graph: source" do assert_graph(~w[--source lib/a.ex], """ lib/b.ex └── lib/a.ex └── lib/b.ex """) end test "graph: only nodes" do assert_graph(~w[--only-nodes], """ lib/a.ex lib/b.ex lib/c.ex lib/d.ex """) end test "graph: filter by compile label" do assert_graph(~w[--label compile], """ lib/a.ex lib/b.ex lib/c.ex lib/d.ex └── lib/a.ex (compile) """) end test "graph: filter by runtime label" do assert_graph(~w[--label runtime], """ lib/a.ex └── lib/b.ex └── lib/a.ex lib/b.ex lib/c.ex lib/d.ex """) end test "graph: invalid source" do assert_raise Mix.Error, "Source could not be found: lib/a2.ex", fn -> assert_graph(~w[--source lib/a2.ex], "") end end test "graph: sink" do assert_graph(~w[--sink lib/b.ex], """ lib/a.ex └── lib/b.ex └── lib/a.ex lib/d.ex └── lib/a.ex (compile) """) end test "graph: invalid sink" do assert_raise Mix.Error, "Sink could not be found: lib/b2.ex", fn -> assert_graph(~w[--sink lib/b2.ex], "") end end test "graph: sink and source is error" do assert_raise Mix.Error, "mix xref graph expects only one of --source and --sink", fn -> assert_graph(~w[--source lib/a.ex --sink lib/b.ex], "") end end test "graph: with dynamic module" do in_fixture("no_mixfile", fn -> File.write!("lib/a.ex", """ B.define() """) File.write!("lib/b.ex", """ defmodule B do def define do defmodule A do end end end """) assert Mix.Task.run("xref", ["graph", "--format", "dot"]) == :ok assert File.read!("xref_graph.dot") === """ digraph "xref graph" { "lib/a.ex" "lib/b.ex" } """ end) end test "graph: with struct" do in_fixture("no_mixfile", fn -> File.write!("lib/a.ex", """ defmodule A do def fun do %B{} end end """) File.write!("lib/b.ex", """ defmodule B do defstruct [] end """) assert Mix.Task.run("xref", ["graph", "--format", "dot"]) == :ok assert File.read!("xref_graph.dot") === """ digraph "xref graph" { "lib/a.ex" "lib/a.ex" -> "lib/b.ex" [label="(struct)"] "lib/b.ex" } """ end) end test "graph: with mixed cyclic dependencies" do in_fixture("no_mixfile", fn -> File.write!("lib/a.ex", """ defmodule A.Behaviour do @callback foo :: :foo end defmodule A do B def foo do :foo end end """) File.write!("lib/b.ex", """ defmodule B do # Let's also test that we track literal atom behaviours @behaviour :"Elixir.A.Behaviour" def foo do A.foo end end """) assert Mix.Task.run("xref", ["graph", "--format", "dot"]) == :ok assert File.read!("xref_graph.dot") === """ digraph "xref graph" { "lib/a.ex" "lib/a.ex" -> "lib/b.ex" [label="(compile)"] "lib/b.ex" -> "lib/a.ex" [label="(compile)"] "lib/b.ex" } """ end) end defp assert_graph(opts \\ [], expected) do in_fixture("no_mixfile", fn -> File.write!("lib/a.ex", """ defmodule A do def a do B.a end def b, do: :ok end """) File.write!("lib/b.ex", """ defmodule B do def a do A.a B.a end end """) File.write!("lib/c.ex", """ defmodule C do end """) File.write!("lib/d.ex", """ defmodule :d do A.b end """) assert Mix.Task.run("xref", opts ++ ["graph"]) == :ok assert "Compiling 4 files (.ex)\nGenerated sample app\n" <> result = receive_until_no_messages([]) assert normalize_graph_output(result) == normalize_graph_output(expected) end) end defp normalize_graph_output(graph) do String.replace(graph, "└──", "`--") end describe "inside umbrellas" do test "generates reports considering siblings" do in_fixture("umbrella_dep/deps/umbrella", fn -> Mix.Project.in_project(:bar, "apps/bar", fn _ -> File.write!("lib/bar.ex", """ defmodule Bar do def bar do Foo.foo end end """) Mix.Task.run("compile") Mix.shell().flush() Mix.Tasks.Xref.run(["graph", "--format", "stats", "--include-siblings"]) assert receive_until_no_messages([]) == """ Tracked files: 2 (nodes) Compile dependencies: 0 (edges) Structs dependencies: 0 (edges) Runtime dependencies: 1 (edges) Top 2 files with most outgoing dependencies: * lib/bar.ex (1) * lib/foo.ex (0) Top 1 files with most incoming dependencies: * lib/foo.ex (1) """ Mix.Tasks.Xref.run(["callers", "Foo.foo"]) assert receive_until_no_messages([]) == """ lib/bar.ex:3: Foo.foo/0 """ end) end) end end ## Helpers defp receive_until_no_messages(acc) do receive do {:mix_shell, :info, [line]} -> receive_until_no_messages([acc, line | "\n"]) after 0 -> IO.iodata_to_binary(acc) end end defp generate_files(files) do for {file, contents} <- files do File.write!(file, contents) end end end
22.192459
110
0.531167
79bc82721edba240ac562cb2e99b0673cdf8d41f
820
ex
Elixir
lib/projection/inbox.ex
jonasrichard/iris
eb4547ced7f7ff9305a4edfa1c32e8d45fa2aa00
[ "Apache-2.0" ]
1
2017-03-31T09:26:21.000Z
2017-03-31T09:26:21.000Z
lib/projection/inbox.ex
jonasrichard/iris
eb4547ced7f7ff9305a4edfa1c32e8d45fa2aa00
[ "Apache-2.0" ]
1
2017-05-03T06:30:09.000Z
2017-05-03T06:30:09.000Z
lib/projection/inbox.ex
jonasrichard/iris
eb4547ced7f7ff9305a4edfa1c32e8d45fa2aa00
[ "Apache-2.0" ]
null
null
null
defmodule Iris.Projection.Inbox do require Logger # TODO implement unread message number def apply(%Iris.Event.MessageSent{} = event) do Logger.info("Projecting #{inspect(event)}") for user <- event.members do save_message_to_inbox(user, event.channel, event.sender, event.body, event.ts) end end def apply(%Iris.Event.ChannelCreated{} = event) do for user <- event.members do create_inbox(user, event.channel) end end def apply(_) do :ok end def get_user_inbox(user_id) do Iris.Database.Inbox.find_by_user_id(user_id) end defp create_inbox(user, channel) do Iris.Database.Inbox.write!(user, channel) end defp save_message_to_inbox(user, channel, sender, body, ts) do Iris.Database.Inbox.write!(user, channel, sender, body, ts) end end
22.777778
84
0.702439
79bc927cdb647d7c4a4d153f3c035ef9140d5909
1,729
ex
Elixir
clients/data_catalog/lib/google_api/data_catalog/v1/model/set_iam_policy_request.ex
renovate-bot/elixir-google-api
1da34cd39b670c99f067011e05ab90af93fef1f6
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/data_catalog/lib/google_api/data_catalog/v1/model/set_iam_policy_request.ex
swansoffiee/elixir-google-api
9ea6d39f273fb430634788c258b3189d3613dde0
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/data_catalog/lib/google_api/data_catalog/v1/model/set_iam_policy_request.ex
dazuma/elixir-google-api
6a9897168008efe07a6081d2326735fe332e522c
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.DataCatalog.V1.Model.SetIamPolicyRequest do @moduledoc """ Request message for `SetIamPolicy` method. ## Attributes * `policy` (*type:* `GoogleApi.DataCatalog.V1.Model.Policy.t`, *default:* `nil`) - REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :policy => GoogleApi.DataCatalog.V1.Model.Policy.t() | nil } field(:policy, as: GoogleApi.DataCatalog.V1.Model.Policy) end defimpl Poison.Decoder, for: GoogleApi.DataCatalog.V1.Model.SetIamPolicyRequest do def decode(value, options) do GoogleApi.DataCatalog.V1.Model.SetIamPolicyRequest.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DataCatalog.V1.Model.SetIamPolicyRequest do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
36.787234
311
0.749566
79bc95ef0fba99eb6a04716780cd08e2c20c39fb
18,547
ex
Elixir
clients/admin/lib/google_api/admin/directory_v1/api/roles.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/admin/lib/google_api/admin/directory_v1/api/roles.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/admin/lib/google_api/admin/directory_v1/api/roles.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
1
2020-10-04T10:12:44.000Z
2020-10-04T10:12:44.000Z
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.Admin.Directory_v1.Api.Roles do @moduledoc """ API calls for all endpoints tagged `Roles`. """ alias GoogleApi.Admin.Directory_v1.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Deletes a role. ## Parameters * `connection` (*type:* `GoogleApi.Admin.Directory_v1.Connection.t`) - Connection to server * `customer` (*type:* `String.t`) - Immutable ID of the G Suite account. * `role_id` (*type:* `String.t`) - Immutable ID of the role. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %{}}` on success * `{:error, info}` on failure """ @spec directory_roles_delete(Tesla.Env.client(), String.t(), String.t(), keyword(), keyword()) :: {:ok, nil} | {:ok, Tesla.Env.t()} | {:error, any()} def directory_roles_delete(connection, customer, role_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/admin/directory/v1/customer/{customer}/roles/{roleId}", %{ "customer" => URI.encode(customer, &URI.char_unreserved?/1), "roleId" => URI.encode(role_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [decode: false]) end @doc """ Retrieves a role. ## Parameters * `connection` (*type:* `GoogleApi.Admin.Directory_v1.Connection.t`) - Connection to server * `customer` (*type:* `String.t`) - Immutable ID of the G Suite account. * `role_id` (*type:* `String.t`) - Immutable ID of the role. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Admin.Directory_v1.Model.Role{}}` on success * `{:error, info}` on failure """ @spec directory_roles_get(Tesla.Env.client(), String.t(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Admin.Directory_v1.Model.Role.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def directory_roles_get(connection, customer, role_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query } request = Request.new() |> Request.method(:get) |> Request.url("/admin/directory/v1/customer/{customer}/roles/{roleId}", %{ "customer" => URI.encode(customer, &URI.char_unreserved?/1), "roleId" => URI.encode(role_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Admin.Directory_v1.Model.Role{}]) end @doc """ Creates a role. ## Parameters * `connection` (*type:* `GoogleApi.Admin.Directory_v1.Connection.t`) - Connection to server * `customer` (*type:* `String.t`) - Immutable ID of the G Suite account. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Admin.Directory_v1.Model.Role.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Admin.Directory_v1.Model.Role{}}` on success * `{:error, info}` on failure """ @spec directory_roles_insert(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Admin.Directory_v1.Model.Role.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def directory_roles_insert(connection, customer, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/admin/directory/v1/customer/{customer}/roles", %{ "customer" => URI.encode(customer, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Admin.Directory_v1.Model.Role{}]) end @doc """ Retrieves a paginated list of all the roles in a domain. ## Parameters * `connection` (*type:* `GoogleApi.Admin.Directory_v1.Connection.t`) - Connection to server * `customer` (*type:* `String.t`) - Immutable ID of the G Suite account. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:maxResults` (*type:* `integer()`) - Maximum number of results to return. * `:pageToken` (*type:* `String.t`) - Token to specify the next page in the list. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Admin.Directory_v1.Model.Roles{}}` on success * `{:error, info}` on failure """ @spec directory_roles_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Admin.Directory_v1.Model.Roles.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def directory_roles_list(connection, customer, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :maxResults => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/admin/directory/v1/customer/{customer}/roles", %{ "customer" => URI.encode(customer, &URI.char_unreserved?/1) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Admin.Directory_v1.Model.Roles{}]) end @doc """ Patch role via Apiary Patch Orchestration ## Parameters * `connection` (*type:* `GoogleApi.Admin.Directory_v1.Connection.t`) - Connection to server * `customer` (*type:* `String.t`) - Immutable ID of the G Suite account. * `role_id` (*type:* `String.t`) - Immutable ID of the role. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Admin.Directory_v1.Model.Role.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Admin.Directory_v1.Model.Role{}}` on success * `{:error, info}` on failure """ @spec directory_roles_patch(Tesla.Env.client(), String.t(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Admin.Directory_v1.Model.Role.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def directory_roles_patch(connection, customer, role_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/admin/directory/v1/customer/{customer}/roles/{roleId}", %{ "customer" => URI.encode(customer, &URI.char_unreserved?/1), "roleId" => URI.encode(role_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Admin.Directory_v1.Model.Role{}]) end @doc """ Updates a role. ## Parameters * `connection` (*type:* `GoogleApi.Admin.Directory_v1.Connection.t`) - Connection to server * `customer` (*type:* `String.t`) - Immutable ID of the G Suite account. * `role_id` (*type:* `String.t`) - Immutable ID of the role. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:"$.xgafv"` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:body` (*type:* `GoogleApi.Admin.Directory_v1.Model.Role.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Admin.Directory_v1.Model.Role{}}` on success * `{:error, info}` on failure """ @spec directory_roles_update(Tesla.Env.client(), String.t(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.Admin.Directory_v1.Model.Role.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def directory_roles_update(connection, customer, role_id, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :body => :body } request = Request.new() |> Request.method(:put) |> Request.url("/admin/directory/v1/customer/{customer}/roles/{roleId}", %{ "customer" => URI.encode(customer, &URI.char_unreserved?/1), "roleId" => URI.encode(role_id, &(URI.char_unreserved?(&1) || &1 == ?/)) }) |> Request.add_optional_params(optional_params_config, optional_params) |> Request.library_version(@library_version) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.Admin.Directory_v1.Model.Role{}]) end end
46.600503
196
0.615679
79bcf1571182c858db19b636965eff3762dda629
676
ex
Elixir
lib/bus_car/application.ex
elbow-jason/bus_car
cd70b9f6b8dd404eb518f642491e0a4430e2d9f9
[ "MIT" ]
18
2016-09-25T21:36:39.000Z
2021-02-17T15:09:52.000Z
lib/bus_car/application.ex
elbow-jason/bus_car
cd70b9f6b8dd404eb518f642491e0a4430e2d9f9
[ "MIT" ]
7
2016-12-08T05:01:23.000Z
2018-04-05T08:55:11.000Z
lib/bus_car/application.ex
elbow-jason/bus_car
cd70b9f6b8dd404eb518f642491e0a4430e2d9f9
[ "MIT" ]
1
2020-04-24T02:10:15.000Z
2020-04-24T02:10:15.000Z
defmodule BusCar.Application do use Application # See http://elixir-lang.org/docs/stable/elixir/Application.html # for more information on OTP Applications def start(_type, _args) do import Supervisor.Spec, warn: false # Define workers and child supervisors to be supervised children = [ # Starts a worker by calling: BusCar.Worker.start_link(arg1, arg2, arg3) # worker(BusCar.Worker, [arg1, arg2, arg3]), ] # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: BusCar.Supervisor] Supervisor.start_link(children, opts) end end
33.8
78
0.717456
79bcf32982c4f2cccd65b9a727bcaa1fc3533d7c
1,770
exs
Elixir
config/prod.exs
nbw/gems
eb4e253af230646563f0ddb307c499a0cab0aa2d
[ "MIT" ]
63
2021-12-02T13:20:03.000Z
2022-03-02T14:32:19.000Z
config/prod.exs
nbw/gems
eb4e253af230646563f0ddb307c499a0cab0aa2d
[ "MIT" ]
1
2022-01-03T02:21:58.000Z
2022-01-03T23:44:28.000Z
config/prod.exs
nbw/gems
eb4e253af230646563f0ddb307c499a0cab0aa2d
[ "MIT" ]
5
2021-12-02T15:17:10.000Z
2022-02-02T20:18:53.000Z
import Config # For production, don't forget to configure the url host # to something meaningful, Phoenix uses this information # when generating URLs. # # Note we also include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. config :gems, GEMSWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" # Do not print debug messages in production config :logger, level: :info # ## SSL Support # # To get SSL working, you will need to add the `https` key # to the previous section and set your `:url` port to 443: # # config :gems, GEMSWeb.Endpoint, # ..., # url: [host: "example.com", port: 443], # https: [ # ..., # port: 443, # cipher_suite: :strong, # keyfile: System.get_env("SOME_APP_SSL_KEY_PATH"), # certfile: System.get_env("SOME_APP_SSL_CERT_PATH") # ] # # The `cipher_suite` is set to `:strong` to support only the # latest and more secure SSL ciphers. This means old browsers # and clients may not be supported. You can set it to # `:compatible` for wider support. # # `:keyfile` and `:certfile` expect an absolute path to the key # and cert in disk or a relative path inside priv, for example # "priv/ssl/server.key". For all supported SSL configuration # options, see https://hexdocs.pm/plug/Plug.SSL.html#configure/1 # # We also recommend setting `force_ssl` in your endpoint, ensuring # no data is ever sent via http, always redirecting to https: # # config :gems, GEMSWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`.
34.705882
66
0.703955
79bd046cc36ea54a91492ef666a2e18d7765cd94
235
ex
Elixir
lib/straw_hat_review/interactor.ex
straw-hat-team/straw_hat_review
342dbbfac0ac96287111babd59b5321efdd8728d
[ "MIT" ]
11
2018-04-09T06:32:02.000Z
2019-09-11T14:18:21.000Z
lib/straw_hat_review/interactor.ex
straw-hat-labs/straw_hat_review
342dbbfac0ac96287111babd59b5321efdd8728d
[ "MIT" ]
64
2018-03-30T06:21:49.000Z
2019-11-01T13:57:34.000Z
lib/straw_hat_review/interactor.ex
straw-hat-labs/straw_hat_review
342dbbfac0ac96287111babd59b5321efdd8728d
[ "MIT" ]
1
2018-06-21T23:00:00.000Z
2018-06-21T23:00:00.000Z
defmodule StrawHat.Review.Interactor do @moduledoc false defmacro __using__(_opts) do quote do import Ecto.Query, only: [from: 2] alias StrawHat.{Error, Response} alias StrawHat.Review.Repo end end end
19.583333
40
0.689362
79bd72295a469086cedaf5f8f6a56e8058fd201e
3,940
ex
Elixir
lib/mole_web/controllers/game_controller.ex
the-mikedavis/mole
73d884b5dca4e5371b1b399d7e65c0f4a0229851
[ "BSD-3-Clause" ]
1
2020-07-15T14:39:10.000Z
2020-07-15T14:39:10.000Z
lib/mole_web/controllers/game_controller.ex
the-mikedavis/mole
73d884b5dca4e5371b1b399d7e65c0f4a0229851
[ "BSD-3-Clause" ]
59
2018-11-05T23:09:10.000Z
2020-07-11T20:44:14.000Z
lib/mole_web/controllers/game_controller.ex
the-mikedavis/mole
73d884b5dca4e5371b1b399d7e65c0f4a0229851
[ "BSD-3-Clause" ]
null
null
null
defmodule MoleWeb.GameController do use MoleWeb, :controller require Logger alias Mole.{Accounts, Content} alias MoleWeb.Plugs.Survey # order matters here plug(:logged_in) # removed for #42 # plug(:consent) plug(:pre_survey when action == :index) plug(:learn) alias Mole.GameplayServer def index(conn, _params) do set_number = GameplayServer.set_number(conn.assigns.current_user.id) + 1 render(conn, "index.html", set_number: set_number) end def show(%{assigns: %{current_user: user}} = conn, _params) do high_scores = Accounts.list_leaderboard() sets_left = GameplayServer.sets_left(user.id) with false <- Enum.any?(high_scores, &(&1.user_id == user.id)), 0 <- sets_left, %{score: barrier_score} <- List.last(high_scores), true <- user.score > barrier_score do # show name entry page redirect(conn, to: Routes.game_path(conn, :enter_name)) else # this user is already in the list of high scores # we don't lead them to the name entry page because they've already entered a name true -> # update their high score Accounts.upsert_high_score(%{user_id: user.id, score: user.score}) # re-list the leaderboard, it changed (potentially) high_scores = Accounts.list_leaderboard() render(conn, "show.html", sets_left: sets_left, high_scores: high_scores) # there are sets left n when is_integer(n) and n > 0 -> render(conn, "show.html", sets_left: n, high_scores: high_scores) # list of high scores is empty nil -> # show name entry page redirect(conn, to: Routes.game_path(conn, :enter_name)) # this user is not a high scorer :'( false -> render(conn, "show.html", sets_left: 0, high_scores: high_scores) end end def name_entry(%{assigns: %{current_user: user}} = conn, _params) do changeset = Accounts.change_high_score(%{user_id: user.id, score: user.score}) render(conn, "enter_name.html", changeset: changeset) end def enter_name(%{assigns: %{current_user: user}} = conn, %{"high_score" => %{"name" => name}}) do %{user_id: user.id, score: user.score, name: name} |> Accounts.upsert_high_score() |> case do {:ok, _high_score} -> redirect(conn, to: Routes.game_path(conn, :index)) {:error, %Ecto.Changeset{} = changeset} -> render(conn, "enter_name.html", changeset: changeset) end end # ensure the user is logged in before they access a game defp logged_in(conn, _opts) do if conn.assigns[:current_user] do conn else moniker = get_session(conn, :moniker) {:ok, user} = Accounts.create_user(%{moniker: moniker}) conn |> put_session(:user_id_token, encrypt(conn, user.id)) |> assign(:user_id, user.id) |> assign(:current_user, user) |> configure_session(renew: true) end end defp encrypt(conn, data), do: Phoenix.Token.sign(conn, MoleWeb.signing_token(), data) # defp consent(conn, _opts) do # if conn.assigns.survey_id && !conn.assigns.consent? do # conn # |> redirect(to: Routes.consent_path(conn, :index)) # |> halt() # else # conn # end # end defp learn(conn, _opts) do if conn.assigns[:learned?] do conn else conn |> redirect(to: Routes.learning_path(conn, :show, 0)) |> halt() end end defp pre_survey(conn, _opts) do with true <- Survey.pre_survey?(conn), %{prelink: prelink} <- Content.get_survey(conn.assigns.survey_id), link <- link(prelink, conn) do conn |> Survey.check() |> redirect(external: link) |> halt() else _ -> conn end end # build a link that gives the username and condition as query parameters defp link(link, %{assigns: %{current_user: user}}) do "#{link}?username=#{user.id}&condition=#{user.condition}" end end
29.185185
99
0.639594
79bd856b78e5b2adee1afd0cf866eb70c9f058c3
2,358
ex
Elixir
clients/container_analysis/lib/google_api/container_analysis/v1beta1/model/status.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
clients/container_analysis/lib/google_api/container_analysis/v1beta1/model/status.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/container_analysis/lib/google_api/container_analysis/v1beta1/model/status.ex
mcrumm/elixir-google-api
544f22797cec52b3a23dfb6e39117f0018448610
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.ContainerAnalysis.V1beta1.Model.Status do @moduledoc """ The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). ## Attributes * `code` (*type:* `integer()`, *default:* `nil`) - The status code, which should be an enum value of google.rpc.Code. * `details` (*type:* `list(map())`, *default:* `nil`) - A list of messages that carry the error details. There is a common set of message types for APIs to use. * `message` (*type:* `String.t`, *default:* `nil`) - A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :code => integer(), :details => list(map()), :message => String.t() } field(:code) field(:details, type: :list) field(:message) end defimpl Poison.Decoder, for: GoogleApi.ContainerAnalysis.V1beta1.Model.Status do def decode(value, options) do GoogleApi.ContainerAnalysis.V1beta1.Model.Status.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.ContainerAnalysis.V1beta1.Model.Status do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
44.490566
427
0.726887
79bda5c5436c884e5eaf3f23530d4a0485efdf89
1,869
ex
Elixir
chromoid_web/lib/chromoid/devices/color.ex
ConnorRigby/chromoid
6424a9234227d18d7c287ded869caeb31511bb97
[ "Apache-2.0" ]
7
2020-11-18T11:29:20.000Z
2022-01-16T03:16:14.000Z
chromoid_web/lib/chromoid/devices/color.ex
ConnorRigby/chromoid
6424a9234227d18d7c287ded869caeb31511bb97
[ "Apache-2.0" ]
null
null
null
chromoid_web/lib/chromoid/devices/color.ex
ConnorRigby/chromoid
6424a9234227d18d7c287ded869caeb31511bb97
[ "Apache-2.0" ]
1
2021-01-06T15:40:46.000Z
2021-01-06T15:40:46.000Z
defmodule Chromoid.Devices.Color do use GenServer require Logger import Chromoid.Devices.DeviceRegistry, only: [via: 1] @endpoint ChromoidWeb.Endpoint alias Phoenix.Socket.Broadcast def random_color() do Enum.random([ "white", "silver", "gray", "black", "red", "maroon", "yellow", "olive", "lime", "green", "aqua", "teal", "blue", "navy", "fuchsia", "purple" ]) end def format_color(color) do inspect(color, base: :hex) end def set_color(addr, rgb) do GenServer.call(via({__MODULE__, to_string(addr)}), {:set_color, rgb}) end @doc false def start_link({device_id, address}) do GenServer.start_link(__MODULE__, {device_id, address}, name: via({__MODULE__, address})) end @impl GenServer def init({device_id, address}) do @endpoint.subscribe("devices:#{device_id}") {:ok, %{device_id: device_id, address: address, caller: nil}} end @impl GenServer def handle_call({:set_color, rgb}, from, state) do @endpoint.broadcast("devices:#{state.device_id}:ble-#{state.address}", "set_color", %{ color: rgb }) {:noreply, %{state | caller: from}} end def handle_info(_, %{caller: nil} = state) do {:noreply, state} end @impl GenServer def handle_info( %Broadcast{ event: "presence_diff", payload: %{joins: joins, leaves: _leaves}, topic: "devices:" <> _device_id }, %{address: address} = state ) do IO.inspect(joins) state = Enum.reduce(joins, state, fn {"ble-" <> ^address, meta}, state -> Logger.info("Color Call complete") GenServer.reply(state.caller, meta) %{state | caller: nil} _, state -> state end) {:noreply, state} end end
21.732558
92
0.582129
79bdaec610bca9775f1accd73df0380ab1208029
856
exs
Elixir
mix.exs
sticksnleaves/bamboo_eex
81ab27dac258350b90a697c8bdbb62de01547f14
[ "MIT" ]
6
2017-10-03T22:12:22.000Z
2019-08-18T21:26:05.000Z
mix.exs
sticksnleaves/bamboo_eex
81ab27dac258350b90a697c8bdbb62de01547f14
[ "MIT" ]
3
2018-06-29T16:34:59.000Z
2021-02-26T22:54:06.000Z
mix.exs
sticksnleaves/bamboo_eex
81ab27dac258350b90a697c8bdbb62de01547f14
[ "MIT" ]
3
2018-06-28T17:45:33.000Z
2021-08-19T11:56:09.000Z
defmodule Bamboo.EEx.Mixfile do use Mix.Project def project do [ app: :bamboo_eex, description: "EEx template support for Bamboo", version: "0.1.1", elixir: "~> 1.5", start_permanent: Mix.env == :prod, deps: deps(), elixirc_paths: elixirc_paths(Mix.env), package: package() ] end def application do [ extra_applications: [ :logger ] ] end defp deps do [ { :bamboo, ">= 0.8.0 and < 2.0.0" }, # dev { :ex_doc, ">= 0.0.0", only: [ :dev ] } ] end defp elixirc_paths(:test), do: [ "lib", "test/support" ] defp elixirc_paths(_env), do: [ "lib" ] defp package() do %{ maintainers: [ "Anthony Smith" ], licenses: [ "MIT" ], links: %{ GitHub: "https://github.com/sticksnleaves/bamboo_eex" } } end end
19.454545
61
0.533879
79bdd3e9607175609b2778d179811079da741755
1,623
ex
Elixir
lib/ex_okex/api.ex
acuityinnovations/ex_okex
52acf16e8d00446ca32607ccb2cd75add0acaceb
[ "MIT" ]
null
null
null
lib/ex_okex/api.ex
acuityinnovations/ex_okex
52acf16e8d00446ca32607ccb2cd75add0acaceb
[ "MIT" ]
4
2019-04-12T17:13:00.000Z
2020-04-06T07:28:47.000Z
lib/ex_okex/api.ex
acuityinnovations/ex_okex
52acf16e8d00446ca32607ccb2cd75add0acaceb
[ "MIT" ]
5
2019-04-10T00:41:17.000Z
2021-12-23T14:49:02.000Z
defmodule ExOkex.Api do @moduledoc false @type path :: String.t() @type config :: map @type params :: map @type status_code :: integer @type body :: term @type response :: {:ok, term} | {:error, term} | {:error, body, status_code} @spec url(path, config) :: String.t() def url(path, config), do: config.api_url <> path @spec query_string(path, params) :: String.t() def query_string(path, params) when map_size(params) == 0, do: path def query_string(path, params) do query = params |> Enum.map(fn {key, val} -> "#{key}=#{val}" end) |> Enum.join("&") path <> "?" <> query end @spec parse_response( {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()} ) :: response def parse_response(response) do case response do {:ok, %HTTPoison.Response{body: body, status_code: status_code}} -> if status_code in 200..299 do {:ok, Jason.decode!(body)} else case Jason.decode(body) do {:ok, %{"code" => code, "message" => message}} -> {:error, {code, message}, status_code} {:ok, %{"error_code" => code, "error_message" => message}} -> {:error, {code, message}, status_code} {:ok, %{"message" => message, "error_message" => error_message}} -> {:error, {message, error_message}, status_code} {:error, _} -> {:error, body, status_code} end end {:error, %HTTPoison.Error{reason: reason}} -> {:error, reason} end end end
29.509091
79
0.553913
79be08ffbc350fdab80cc0887438438e207eef12
2,750
ex
Elixir
clients/compute/lib/google_api/compute/v1/model/router_list.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/compute/lib/google_api/compute/v1/model/router_list.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/compute/lib/google_api/compute/v1/model/router_list.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.Compute.V1.Model.RouterList do @moduledoc """ Contains a list of Router resources. ## Attributes * `id` (*type:* `String.t`, *default:* `nil`) - [Output Only] Unique identifier for the resource; defined by the server. * `items` (*type:* `list(GoogleApi.Compute.V1.Model.Router.t)`, *default:* `nil`) - A list of Router resources. * `kind` (*type:* `String.t`, *default:* `compute#routerList`) - [Output Only] Type of resource. Always compute#router for routers. * `nextPageToken` (*type:* `String.t`, *default:* `nil`) - [Output Only] This token allows you to get the next page of results for list requests. If the number of results is larger than maxResults, use the nextPageToken as a value for the query parameter pageToken in the next list request. Subsequent list requests will have their own nextPageToken to continue paging through the results. * `selfLink` (*type:* `String.t`, *default:* `nil`) - [Output Only] Server-defined URL for this resource. * `warning` (*type:* `GoogleApi.Compute.V1.Model.RouterListWarning.t`, *default:* `nil`) - [Output Only] Informational warning message. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :id => String.t(), :items => list(GoogleApi.Compute.V1.Model.Router.t()), :kind => String.t(), :nextPageToken => String.t(), :selfLink => String.t(), :warning => GoogleApi.Compute.V1.Model.RouterListWarning.t() } field(:id) field(:items, as: GoogleApi.Compute.V1.Model.Router, type: :list) field(:kind) field(:nextPageToken) field(:selfLink) field(:warning, as: GoogleApi.Compute.V1.Model.RouterListWarning) end defimpl Poison.Decoder, for: GoogleApi.Compute.V1.Model.RouterList do def decode(value, options) do GoogleApi.Compute.V1.Model.RouterList.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Compute.V1.Model.RouterList do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
44.354839
393
0.709091
79be514d18f712e3b0b65d98f4e51269f8be5e39
998
ex
Elixir
clients/custom_search/lib/google_api/custom_search/v1/connection.ex
kaaboaye/elixir-google-api
1896784c4342151fd25becd089a5beb323eff567
[ "Apache-2.0" ]
null
null
null
clients/custom_search/lib/google_api/custom_search/v1/connection.ex
kaaboaye/elixir-google-api
1896784c4342151fd25becd089a5beb323eff567
[ "Apache-2.0" ]
null
null
null
clients/custom_search/lib/google_api/custom_search/v1/connection.ex
kaaboaye/elixir-google-api
1896784c4342151fd25becd089a5beb323eff567
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.CustomSearch.V1.Connection do @moduledoc """ Handle Tesla connections for GoogleApi.CustomSearch.V1. """ @type t :: Tesla.Env.client() use GoogleApi.Gax.Connection, scopes: [], otp_app: :google_api_custom_search, base_url: "https://www.googleapis.com/customsearch/" end
33.266667
74
0.748497
79be7070bf1bd618148544e874187d15aeca7fcf
76
exs
Elixir
test/orga_web/views/layout_view_test.exs
sinorga/orga.tw
d567347f224e5a995f5eb7edf5bd049988a3a48d
[ "MIT" ]
null
null
null
test/orga_web/views/layout_view_test.exs
sinorga/orga.tw
d567347f224e5a995f5eb7edf5bd049988a3a48d
[ "MIT" ]
null
null
null
test/orga_web/views/layout_view_test.exs
sinorga/orga.tw
d567347f224e5a995f5eb7edf5bd049988a3a48d
[ "MIT" ]
null
null
null
defmodule OrgaWeb.LayoutViewTest do use OrgaWeb.ConnCase, async: true end
19
35
0.815789
79be73a09b22b378f2f4d01728d23f8d34c18904
2,113
exs
Elixir
test/particle/variables_test.exs
tompesman/particle-elixir
90226405b868f8e8ff308c84c34e88ea68a8570a
[ "MIT" ]
null
null
null
test/particle/variables_test.exs
tompesman/particle-elixir
90226405b868f8e8ff308c84c34e88ea68a8570a
[ "MIT" ]
null
null
null
test/particle/variables_test.exs
tompesman/particle-elixir
90226405b868f8e8ff308c84c34e88ea68a8570a
[ "MIT" ]
null
null
null
defmodule Particle.VariablesTest do use ExUnit.Case use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney setup_all do ExVCR.Config.cassette_library_dir("fixture/vcr_cassettes/particle/variables") ExVCR.Config.filter_sensitive_data("Bearer .+", "TOKEN") ExVCR.Config.filter_sensitive_data("(.*)" <> (System.get_env("device_id") || "DEVICE_ID") <> "(.*)", "\\1DEVICE_ID\\2") ExVCR.Config.filter_sensitive_data("(?:\\d{1,3}\\.){3}\\d{1,3}", "0.0.0.0") :ok end describe "get with a valid device_id and variable_name" do test "it returns the value of the variable" do use_cassette "get" do device_id = System.get_env("device_id") || "DEVICE_ID" response = Particle.Variables.get(device_id, "power") assert {:ok, r} = response assert r.result == 0 end end end describe "get with an invalid device_id" do test "it returns an error tuple" do use_cassette "get_invalid_device_id" do response = Particle.Variables.get("MISSING", "power") assert response == {:error, %Particle.Error{reason: "Permission Denied", code: 403, info: "I didn't recognize that device name or ID, try opening https://api.particle.io/v1/devices?access_token=undefined"}} end end end describe "get with an invalid variable_name" do test "it returns an error tuple" do use_cassette "get_invalid_variable_name" do device_id = System.get_env("device_id") || "DEVICE_ID" response = Particle.Variables.get(device_id, "MISSING") assert response == {:error, %Particle.Error{reason: "Variable not found", code: 404}} end end end describe "get_all_with_values" do test "it returns a map of variables with their values" do use_cassette "get_all_with_values" do device_id = System.get_env("device_id") || "DEVICE_ID" response = Particle.Variables.get_all_with_values(device_id) assert {:ok, r} = response assert r == %{min_average: 90.7249984741211, power: 0, temp_off: 65, temp_on: 60, temperature: 90.7249984741211} end end end end
39.12963
214
0.673923
79be87b11d930ce712a2e9a7c8b09ebe317acfda
802
ex
Elixir
apps/docker/test/support/adapter/mock.ex
makerdao/qa_backend_gateway
38e9a3f3f4b66212f1ee9d38b3b698a2a1f9a809
[ "Apache-2.0" ]
1
2020-10-23T19:25:27.000Z
2020-10-23T19:25:27.000Z
apps/docker/test/support/adapter/mock.ex
makerdao/qa_backend_gateway
38e9a3f3f4b66212f1ee9d38b3b698a2a1f9a809
[ "Apache-2.0" ]
5
2019-01-11T11:48:08.000Z
2019-01-16T17:29:23.000Z
apps/docker/test/support/adapter/mock.ex
makerdao/qa_backend_gateway
38e9a3f3f4b66212f1ee9d38b3b698a2a1f9a809
[ "Apache-2.0" ]
7
2019-10-09T05:49:52.000Z
2022-03-23T16:48:45.000Z
defmodule Staxx.Docker.Adapter.Mock do @moduledoc """ Set of docker commands that will be running on read docker daemon """ @behaviour Staxx.Docker require Logger alias Staxx.Docker.Container @impl true def start(_id), do: :ok @impl true def run(%Container{name: name} = container), do: {:ok, %Container{container | id: name}} @impl true def logs(_id), do: "" @impl true def rm(_id), do: :ok @impl true def stop(""), do: {:error, "No container id passed"} def stop(_container_id), do: :ok @impl true def create_network(id), do: {:ok, id} @impl true def rm_network(_id), do: :ok @impl true def prune_networks(), do: :ok @impl true def join_network(id, _container_id), do: {:ok, id} @impl true def inspect_container(_, _), do: "" end
18.651163
67
0.647132
79be8fa88dbed0a5648313cacd5cd5de0c0613e8
2,107
ex
Elixir
clients/deployment_manager/lib/google_api/deployment_manager/v2/model/operation_warnings.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/deployment_manager/lib/google_api/deployment_manager/v2/model/operation_warnings.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/deployment_manager/lib/google_api/deployment_manager/v2/model/operation_warnings.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2020-10-04T10:12:44.000Z
2020-10-04T10:12:44.000Z
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This file is auto generated by the elixir code generator program. # Do not edit this file manually. defmodule GoogleApi.DeploymentManager.V2.Model.OperationWarnings do @moduledoc """ ## Attributes * `code` (*type:* `String.t`, *default:* `nil`) - [Output Only] A warning code, if applicable. For example, Compute Engine returns NO_RESULTS_ON_PAGE if there are no results in the response. * `data` (*type:* `list(GoogleApi.DeploymentManager.V2.Model.OperationWarningsData.t)`, *default:* `nil`) - [Output Only] Metadata about this warning in key: value format. For example: "data": [ { "key": "scope", "value": "zones/us-east1-d" } * `message` (*type:* `String.t`, *default:* `nil`) - [Output Only] A human-readable description of the warning code. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :code => String.t(), :data => list(GoogleApi.DeploymentManager.V2.Model.OperationWarningsData.t()), :message => String.t() } field(:code) field(:data, as: GoogleApi.DeploymentManager.V2.Model.OperationWarningsData, type: :list) field(:message) end defimpl Poison.Decoder, for: GoogleApi.DeploymentManager.V2.Model.OperationWarnings do def decode(value, options) do GoogleApi.DeploymentManager.V2.Model.OperationWarnings.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DeploymentManager.V2.Model.OperationWarnings do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
39.018519
194
0.723778
79bea3391d9b8cc9dc8ffe2f6575d75d2e63a7d8
3,125
exs
Elixir
test/surface/components/form/textarea_test.exs
thorsten-de/surface
67ebc2eadec22a22e043394f37d0d8d0e0e81b77
[ "MIT" ]
null
null
null
test/surface/components/form/textarea_test.exs
thorsten-de/surface
67ebc2eadec22a22e043394f37d0d8d0e0e81b77
[ "MIT" ]
null
null
null
test/surface/components/form/textarea_test.exs
thorsten-de/surface
67ebc2eadec22a22e043394f37d0d8d0e0e81b77
[ "MIT" ]
null
null
null
defmodule Surface.Components.Form.TextAreaTest do use Surface.ConnCase, async: true alias Surface.Components.Form.TextArea test "empty textarea" do html = render_surface do ~F""" <TextArea form="user" field="summary" /> """ end assert html =~ """ <textarea id="user_summary" name="user[summary]"> </textarea> """ end test "textarea with atom field" do html = render_surface do ~F""" <TextArea form="user" field={:summary} /> """ end assert html =~ """ <textarea id="user_summary" name="user[summary]"> </textarea> """ end test "setting the value" do html = render_surface do ~F""" <TextArea form="user" field="summary" value="some content" /> """ end assert html =~ """ <textarea id="user_summary" name="user[summary]"> some content</textarea> """ end test "setting the class" do html = render_surface do ~F""" <TextArea form="user" field="summary" class="input" /> """ end assert html =~ ~r/class="input"/ end test "setting multiple classes" do html = render_surface do ~F""" <TextArea form="user" field="summary" class="input primary" /> """ end assert html =~ ~r/class="input primary"/ end test "passing other options" do html = render_surface do ~F""" <TextArea form="user" field="summary" opts={autofocus: "autofocus"} /> """ end assert html =~ """ <textarea autofocus="autofocus" id="user_summary" name="user[summary]"> </textarea> """ end test "events with parent live view as target" do html = render_surface do ~F""" <TextArea form="user" field="summary" click="my_click" /> """ end assert html =~ ~s(phx-click="my_click") end test "setting id and name through props" do html = render_surface do ~F""" <TextArea form="user" field="summary" id="blog_summary" name="blog_summary" /> """ end assert html =~ """ <textarea id="blog_summary" name="blog_summary"> </textarea> """ end test "setting the phx-value-* values" do html = render_surface do ~F""" <TextArea form="user" field="summary" values={a: "one", b: :two, c: 3} /> """ end assert html =~ """ <textarea id="user_summary" name="user[summary]" phx-value-a="one" phx-value-b="two" phx-value-c="3"> </textarea> """ end end defmodule Surface.Components.Form.TextAreaConfigTest do use Surface.ConnCase alias Surface.Components.Form.TextArea test ":default_class config" do using_config TextArea, default_class: "default_class" do html = render_surface do ~F""" <TextArea/> """ end assert html =~ ~r/class="default_class"/ end end end
22.007042
112
0.5392
79bea63fdd72d2565b810c317bdbc740efb12e3c
4,760
ex
Elixir
lib/expected/store/test.ex
ejpcmac/expected
c2b03bfa9bcb7efd52cf4003fb46f1309e8aa3c4
[ "MIT" ]
33
2018-01-18T12:16:19.000Z
2021-07-30T00:33:26.000Z
lib/expected/store/test.ex
ejpcmac/expected
c2b03bfa9bcb7efd52cf4003fb46f1309e8aa3c4
[ "MIT" ]
5
2018-01-18T12:56:28.000Z
2019-09-30T07:16:00.000Z
lib/expected/store/test.ex
ejpcmac/expected
c2b03bfa9bcb7efd52cf4003fb46f1309e8aa3c4
[ "MIT" ]
1
2018-08-08T12:02:44.000Z
2018-08-08T12:02:44.000Z
defmodule Expected.Store.Test do @moduledoc """ A module for testing `Expected.Store` implementations. In order to test a new `Expected.Store`, create a test module and use `Expected.Store.Test` by specifying the store to test: defmodule MyExpected.StoreTest do use ExUnit.Case use Expected.Store.Test, store: MyExpected.Store # Must be defined for Expected.Store.Test to work. defp init_store(_) do # Insert @login1 defined in Expected.Store.Test in your store. # ... # Return a map containing your options as `opts`. %{opts: init(table: :expected)} end # Test your init function describe "init/1" do test "returns the table name" do assert init(table: :expected) == :expected end end end With this minimal code, the behaviours of the implementations for `c:Expected.Store.list_user_logins/2`, `c:Expected.Store.get/3`, `c:Expected.Store.put/2`, `c:Expected.Store.delete/3` and `c:Expected.Store.clean_old_logins/2` are automatically tested. """ defmacro __using__(opts) do store = Keyword.fetch!(opts, :store) quote do import unquote(store) alias Expected.Login @now System.os_time() @three_months 7_776_000 @four_months System.convert_time_unit(10_368_000, :seconds, :native) @four_months_ago @now - @four_months @login1 %Login{ username: "user", serial: "1", token: "token", sid: "sid", created_at: @now, last_login: @now, last_ip: {127, 0, 0, 1}, last_useragent: "ExUnit" } @login2 %{@login1 | serial: "2", token: "token2", sid: "sid2"} @login3 %{@login1 | username: "user2", token: "token3", sid: "sid3"} @old_login %{@login2 | last_login: @four_months_ago} @logins %{ "user" => %{ "1" => @login1 } } describe "list_user_logins/2" do setup [:init_store] test "lists the logins present in the store for a user", %{ opts: opts } do assert list_user_logins("user", opts) == [@login1] end test "works as well when the user is not present in the store", %{ opts: opts } do assert list_user_logins("test", opts) == [] end end describe "get/3" do setup [:init_store] test "gets the login for the given username and serial", %{ opts: opts } do assert {:ok, @login1} = get("user", "1", opts) end test "returns an error if there is no correspondant login", %{ opts: opts } do assert {:error, :no_login} = get("user", "9", opts) assert {:error, :no_login} = get("test", "1", opts) end end describe "put/2" do setup [:init_store] test "creates a new entry if there is none for the given serial", %{ opts: opts } do assert :ok = put(@login2, opts) user_logins = list_user_logins("user", opts) assert @login1 in user_logins assert @login2 in user_logins end test "creates a new entry if there is none for the given username", %{ opts: opts } do assert :ok = put(@login3, opts) assert list_user_logins("user2", opts) == [@login3] end test "replaces an existing entry if there is one already", %{ opts: opts } do updated_login = %{@login1 | token: "new_token"} assert :ok = put(updated_login, opts) assert list_user_logins("user", opts) == [updated_login] end end describe "delete/3" do setup [:init_store] test "deletes a login given its username and serial", %{opts: opts} do assert :ok = delete("user", "1", opts) assert list_user_logins("user", opts) == [] end test "works as well if there is no corresponding login", %{ opts: opts } do assert :ok = delete("test", "1", opts) end end describe "clean_old_logins/2" do setup [:init_store] test "deletes old logins from the store", %{opts: opts} do :ok = put(@old_login, opts) clean_old_logins(@three_months, opts) assert {:ok, @login1} = get("user", "1", opts) assert {:error, :no_login} = get("user", "2", opts) end test "returns the list of deleted logins", %{opts: opts} do :ok = put(@old_login, opts) assert clean_old_logins(@three_months, opts) == [@old_login] end end end end end
28.674699
78
0.561975
79beb7f6acb454f69fb260e46476a171786445b0
1,383
ex
Elixir
test/support/data_case.ex
ivoferro/CSIAN_Blog_Management
ad95a7e479090adb04c80e1fc635a400b3aa69c2
[ "MIT" ]
null
null
null
test/support/data_case.ex
ivoferro/CSIAN_Blog_Management
ad95a7e479090adb04c80e1fc635a400b3aa69c2
[ "MIT" ]
null
null
null
test/support/data_case.ex
ivoferro/CSIAN_Blog_Management
ad95a7e479090adb04c80e1fc635a400b3aa69c2
[ "MIT" ]
null
null
null
defmodule BlogApi.DataCase do @moduledoc """ This module defines the setup for tests requiring access to the application's data layer. You may define functions here to be used as helpers in your tests. Finally, if the test case interacts with the database, it cannot be async. For this reason, every test runs inside a transaction which is reset at the beginning of the test unless the test case is marked as async. """ use ExUnit.CaseTemplate using do quote do alias BlogApi.Repo import Ecto import Ecto.Changeset import Ecto.Query import BlogApi.DataCase end end setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(BlogApi.Repo) unless tags[:async] do Ecto.Adapters.SQL.Sandbox.mode(BlogApi.Repo, {:shared, self()}) end :ok end @doc """ A helper that transform changeset errors to a map of messages. assert {:error, changeset} = Accounts.create_user(%{password: "short"}) assert "password is too short" in errors_on(changeset).password assert %{password: ["password is too short"]} = errors_on(changeset) """ def errors_on(changeset) do Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -> Enum.reduce(opts, message, fn {key, value}, acc -> String.replace(acc, "%{#{key}}", to_string(value)) end) end) end end
25.611111
77
0.679682
79bf71f225b33e05ea87231b813837ad2c60dab5
7,726
ex
Elixir
clients/you_tube_analytics/lib/google_api/you_tube_analytics/v2/api/reports.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/you_tube_analytics/lib/google_api/you_tube_analytics/v2/api/reports.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
null
null
null
clients/you_tube_analytics/lib/google_api/you_tube_analytics/v2/api/reports.ex
chingor13/elixir-google-api
85e13fa25c4c9f4618bb463ab4c79245fc6d2a7b
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an &quot;AS IS&quot; BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # NOTE: This class is auto generated by the elixir code generator program. # Do not edit the class manually. defmodule GoogleApi.YouTubeAnalytics.V2.Api.Reports do @moduledoc """ API calls for all endpoints tagged `Reports`. """ alias GoogleApi.YouTubeAnalytics.V2.Connection alias GoogleApi.Gax.{Request, Response} @doc """ Retrieve your YouTube Analytics reports. ## Parameters * `connection` (*type:* `GoogleApi.YouTubeAnalytics.V2.Connection.t`) - Connection to server * `optional_params` (*type:* `keyword()`) - Optional parameters * `:$.xgafv` (*type:* `String.t`) - V1 error format. * `:access_token` (*type:* `String.t`) - OAuth access token. * `:alt` (*type:* `String.t`) - Data format for response. * `:callback` (*type:* `String.t`) - JSONP * `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response. * `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. * `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user. * `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks. * `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. * `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart"). * `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart"). * `:currency` (*type:* `String.t`) - The currency to which financial metrics should be converted. The default is US Dollar (USD). If the result contains no financial metrics, this flag will be ignored. Responds with an error if the specified currency is not recognized.", pattern: [A-Z]{3} * `:dimensions` (*type:* `String.t`) - A comma-separated list of YouTube Analytics dimensions, such as `views` or `ageGroup,gender`. See the [Available Reports](/youtube/analytics/v2/available_reports) document for a list of the reports that you can retrieve and the dimensions used for those reports. Also see the [Dimensions](/youtube/analytics/v2/dimsmets/dims) document for definitions of those dimensions." pattern: [0-9a-zA-Z,]+ * `:endDate` (*type:* `String.t`) - The end date for fetching YouTube Analytics data. The value should be in `YYYY-MM-DD` format. required: true, pattern: [0-9]{4}-[0-9]{2}-[0-9]{2} * `:filters` (*type:* `String.t`) - A list of filters that should be applied when retrieving YouTube Analytics data. The [Available Reports](/youtube/analytics/v2/available_reports) document identifies the dimensions that can be used to filter each report, and the [Dimensions](/youtube/analytics/v2/dimsmets/dims) document defines those dimensions. If a request uses multiple filters, join them together with a semicolon (`;`), and the returned result table will satisfy both filters. For example, a filters parameter value of `video==dMH0bHeiRNg;country==IT` restricts the result set to include data for the given video in Italy.", * `:ids` (*type:* `String.t`) - Identifies the YouTube channel or content owner for which you are retrieving YouTube Analytics data. - To request data for a YouTube user, set the `ids` parameter value to `channel==CHANNEL_ID`, where `CHANNEL_ID` specifies the unique YouTube channel ID. - To request data for a YouTube CMS content owner, set the `ids` parameter value to `contentOwner==OWNER_NAME`, where `OWNER_NAME` is the CMS name of the content owner. required: true, pattern: [a-zA-Z]+==[a-zA-Z0-9_+-]+ * `:includeHistoricalChannelData` (*type:* `boolean()`) - If set to true historical data (i.e. channel data from before the linking of the channel to the content owner) will be retrieved.", * `:maxResults` (*type:* `integer()`) - The maximum number of rows to include in the response.", minValue: 1 * `:metrics` (*type:* `String.t`) - A comma-separated list of YouTube Analytics metrics, such as `views` or `likes,dislikes`. See the [Available Reports](/youtube/analytics/v2/available_reports) document for a list of the reports that you can retrieve and the metrics available in each report, and see the [Metrics](/youtube/analytics/v2/dimsmets/mets) document for definitions of those metrics. required: true, pattern: [0-9a-zA-Z,]+ * `:sort` (*type:* `String.t`) - A comma-separated list of dimensions or metrics that determine the sort order for YouTube Analytics data. By default the sort order is ascending. The '`-`' prefix causes descending sort order.", pattern: [-0-9a-zA-Z,]+ * `:startDate` (*type:* `String.t`) - The start date for fetching YouTube Analytics data. The value should be in `YYYY-MM-DD` format. required: true, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2} * `:startIndex` (*type:* `integer()`) - An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter (one-based, inclusive).", minValue: 1 * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.YouTubeAnalytics.V2.Model.QueryResponse{}}` on success * `{:error, info}` on failure """ @spec youtube_analytics_reports_query(Tesla.Env.client(), keyword(), keyword()) :: {:ok, GoogleApi.YouTubeAnalytics.V2.Model.QueryResponse.t()} | {:error, Tesla.Env.t()} def youtube_analytics_reports_query(connection, optional_params \\ [], opts \\ []) do optional_params_config = %{ :"$.xgafv" => :query, :access_token => :query, :alt => :query, :callback => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :uploadType => :query, :upload_protocol => :query, :currency => :query, :dimensions => :query, :endDate => :query, :filters => :query, :ids => :query, :includeHistoricalChannelData => :query, :maxResults => :query, :metrics => :query, :sort => :query, :startDate => :query, :startIndex => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v2/reports", %{}) |> Request.add_optional_params(optional_params_config, optional_params) connection |> Connection.execute(request) |> Response.decode(opts ++ [struct: %GoogleApi.YouTubeAnalytics.V2.Model.QueryResponse{}]) end end
52.557823
196
0.644965
79bf95177ecbf832513cc29b2897789a278aea00
2,422
ex
Elixir
day14/lib/day14.ex
jwarwick/aoc_2016
62a1d975835570f3fa7b60d32aa2e84da706be53
[ "MIT" ]
null
null
null
day14/lib/day14.ex
jwarwick/aoc_2016
62a1d975835570f3fa7b60d32aa2e84da706be53
[ "MIT" ]
null
null
null
day14/lib/day14.ex
jwarwick/aoc_2016
62a1d975835570f3fa7b60d32aa2e84da706be53
[ "MIT" ]
null
null
null
defmodule Day14 do @moduledoc """ One time pad """ defmodule State do defstruct curr_idx: 0, remaining: 0, salt: nil, cache: Map.new end @doc """ Find the index for a given key """ def find_index(idx, salt) do hash_search(%State{curr_idx: 0, remaining: idx, salt: salt}) end defp hash_search(%State{curr_idx: idx, remaining: 0}), do: idx-1 defp hash_search(state = %State{curr_idx: idx, salt: salt, remaining: remaining, cache: cache}) do {result, cache} = test_hash(salt, idx, cache) if result == true do IO.puts "Key #{inspect idx}, remaining: #{inspect remaining}" end remaining = case result do true -> remaining - 1 _ -> remaining end hash_search(%State{state | curr_idx: idx + 1, remaining: remaining, cache: cache}) end def test_hash(salt, idx, cache) do {md5, cache} = compute_hash(salt, idx, cache) # IO.puts "idx: #{inspect idx}, testing: #{inspect md5}" case has_three?(md5) do {true, match} -> test_sub_hash(match |> String.at(0) |> String.duplicate(5), salt, idx + 1, 1000, cache) _ -> {false, cache} end end defp test_sub_hash(_str, _salt, _idx, 0, cache), do: {false, cache} defp test_sub_hash(str, salt, idx, remaining, cache) do # IO.puts "Testing sub-hash: #{inspect idx}, remaining: #{inspect remaining}" {md5, cache} = compute_hash(salt, idx, cache) # IO.inspect md5 if String.contains?(md5, str) do {true, cache} else test_sub_hash(str, salt, idx+1, remaining-1, cache) end end defp compute_hash(salt, idx, cache) do case Map.fetch(cache, idx) do {:ok, val} -> {val, cache} :error -> update_hash(cache, salt, idx) end end defp update_hash(hash, salt, idx) do val = _compute_hash(salt, idx) {val, Map.put(hash, idx, val)} end defp _compute_hash(salt, idx) do # IO.puts "Computing hash #{inspect idx}" salt <> Integer.to_string(idx) |> hash |> subhash(2016) end defp subhash(str, 0), do: str defp subhash(str, remaining) do subhash(hash(str), remaining - 1) end defp hash(str) do :crypto.hash(:md5 , str) |> Base.encode16() |> String.downcase end @regex Regex.compile("([a-z0-9])\\1\\1") defp has_three?(str) do {:ok, reg} = @regex case Regex.run(reg, str) do nil -> {:false, nil} [first | _rest] -> {:true, first} end end end
26.326087
110
0.619736
79bfbfc3b8ddb0dc28358dec912f3926e151d129
259
ex
Elixir
lib/sisnuvempay.ex
jairpro/nlw4-elixir_sisnuvempay
5a1ca3f45f9396ce766bf147b45ace545e7704d4
[ "MIT" ]
null
null
null
lib/sisnuvempay.ex
jairpro/nlw4-elixir_sisnuvempay
5a1ca3f45f9396ce766bf147b45ace545e7704d4
[ "MIT" ]
null
null
null
lib/sisnuvempay.ex
jairpro/nlw4-elixir_sisnuvempay
5a1ca3f45f9396ce766bf147b45ace545e7704d4
[ "MIT" ]
null
null
null
defmodule Sisnuvempay do @moduledoc """ Sisnuvempay keeps the contexts that define your domain and business logic. Contexts are also responsible for managing your data, regardless if it comes from the database, an external API or others. """ end
25.9
66
0.760618
79bfdc9f0382c4a3293fa2643a91fd5e39b72f10
70
ex
Elixir
web/views/comment_view.ex
davepersing/blog_engine
8605732f72c169d6cc2c2261a9acef0de7769403
[ "MIT" ]
null
null
null
web/views/comment_view.ex
davepersing/blog_engine
8605732f72c169d6cc2c2261a9acef0de7769403
[ "MIT" ]
null
null
null
web/views/comment_view.ex
davepersing/blog_engine
8605732f72c169d6cc2c2261a9acef0de7769403
[ "MIT" ]
null
null
null
defmodule BlogEngine.CommentView do use BlogEngine.Web, :view end
17.5
35
0.785714
79c01bf0ff8d3479d112048657c38ac70a350000
53
ex
Elixir
web/views/page_view.ex
simonasdev/splurty
0bee8871803b25d19d4ba96c872d51321ce81d2f
[ "MIT" ]
null
null
null
web/views/page_view.ex
simonasdev/splurty
0bee8871803b25d19d4ba96c872d51321ce81d2f
[ "MIT" ]
null
null
null
web/views/page_view.ex
simonasdev/splurty
0bee8871803b25d19d4ba96c872d51321ce81d2f
[ "MIT" ]
null
null
null
defmodule Splurty.PageView do use Splurty.View end
13.25
29
0.811321