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
list
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
list
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
list
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
ff8d52f968363a7c2efd81c823d455893e3c76aa
1,379
ex
Elixir
lib/hierbautberlin/geo_data/geo_item.ex
gildesmarais/website-1
7a19bd98d06a064e52fa279e226002e9c3b986f0
[ "MIT" ]
null
null
null
lib/hierbautberlin/geo_data/geo_item.ex
gildesmarais/website-1
7a19bd98d06a064e52fa279e226002e9c3b986f0
[ "MIT" ]
null
null
null
lib/hierbautberlin/geo_data/geo_item.ex
gildesmarais/website-1
7a19bd98d06a064e52fa279e226002e9c3b986f0
[ "MIT" ]
null
null
null
defmodule Hierbautberlin.GeoData.GeoItem do use Ecto.Schema import Ecto.Changeset alias Hierbautberlin.GeoData.Source @states [ "intended", "in_preparation", "in_planning", "under_construction", "active", "finished", nil ] schema "geo_items" do field :external_id, :string field :title, :string field :subtitle, :string field :description, :string field :url, :string field :state, :string field :date_start, :utc_datetime field :date_end, :utc_datetime field :geo_point, Geo.PostGIS.Geometry field :geo_geometry, Geo.PostGIS.Geometry field :participation_open, :boolean, default: false field :additional_link, :string field :additional_link_name, :string belongs_to :source, Source timestamps(type: :utc_datetime) end def changeset(geo_item, attrs) do geo_item |> cast(attrs, [ :external_id, :title, :subtitle, :description, :url, :state, :date_start, :date_end, :geo_point, :geo_geometry, :source_id, :participation_open, :additional_link, :additional_link_name, :inserted_at, :updated_at ]) |> validate_inclusion(:state, @states) |> validate_required([:source_id, :external_id, :title]) |> unique_constraint([:source_id, :external_id]) end end
22.241935
60
0.649021
ff8d55d43f707336174bd60e4a518175156e5506
16,268
ex
Elixir
clients/compute/lib/google_api/compute/v1/api/region_ssl_certificates.ex
jamesvl/elixir-google-api
6c87fb31d996f08fb42ce6066317e9d652a87acc
[ "Apache-2.0" ]
null
null
null
clients/compute/lib/google_api/compute/v1/api/region_ssl_certificates.ex
jamesvl/elixir-google-api
6c87fb31d996f08fb42ce6066317e9d652a87acc
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/compute/lib/google_api/compute/v1/api/region_ssl_certificates.ex
myskoach/elixir-google-api
4f8cbc2fc38f70ffc120fd7ec48e27e46807b563
[ "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.Compute.V1.Api.RegionSslCertificates do @moduledoc """ API calls for all endpoints tagged `RegionSslCertificates`. """ alias GoogleApi.Compute.V1.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Deletes the specified SslCertificate resource in the region. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `ssl_certificate` (*type:* `String.t`) - Name of the SslCertificate resource to delete. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `: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`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:requestId` (*type:* `String.t`) - An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec compute_region_ssl_certificates_delete( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_region_ssl_certificates_delete( connection, project, region, ssl_certificate, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :requestId => :query } request = Request.new() |> Request.method(:delete) |> Request.url("/projects/{project}/regions/{region}/sslCertificates/{sslCertificate}", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "sslCertificate" => URI.encode(ssl_certificate, &(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.Compute.V1.Model.Operation{}]) end @doc """ Returns the specified SslCertificate resource in the specified region. Get a list of available SSL certificates by making a list() request. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `ssl_certificate` (*type:* `String.t`) - Name of the SslCertificate resource to return. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `: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`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.SslCertificate{}}` on success * `{:error, info}` on failure """ @spec compute_region_ssl_certificates_get( Tesla.Env.client(), String.t(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.SslCertificate.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_region_ssl_certificates_get( connection, project, region, ssl_certificate, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query } request = Request.new() |> Request.method(:get) |> Request.url("/projects/{project}/regions/{region}/sslCertificates/{sslCertificate}", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &URI.char_unreserved?/1), "sslCertificate" => URI.encode(ssl_certificate, &(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.Compute.V1.Model.SslCertificate{}]) end @doc """ Creates a SslCertificate resource in the specified project and region using the data included in the request ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `: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`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:requestId` (*type:* `String.t`) - An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000). * `:body` (*type:* `GoogleApi.Compute.V1.Model.SslCertificate.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec compute_region_ssl_certificates_insert( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_region_ssl_certificates_insert( connection, project, region, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :requestId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/projects/{project}/regions/{region}/sslCertificates", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &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.Compute.V1.Model.Operation{}]) end @doc """ Retrieves the list of SslCertificate resources available to the specified project in the specified region. ## Parameters * `connection` (*type:* `GoogleApi.Compute.V1.Connection.t`) - Connection to server * `project` (*type:* `String.t`) - Project ID for this request. * `region` (*type:* `String.t`) - Name of the region scoping this request. * `optional_params` (*type:* `keyword()`) - Optional parameters * `:alt` (*type:* `String.t`) - Data format for the response. * `: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`) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters. * `:userIp` (*type:* `String.t`) - Deprecated. Please use quotaUser instead. * `:filter` (*type:* `String.t`) - A filter expression that filters resources listed in the response. The expression must specify the field name, a comparison operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The comparison operator must be either `=`, `!=`, `>`, or `<`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` * `:maxResults` (*type:* `integer()`) - The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`) * `:orderBy` (*type:* `String.t`) - Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported. * `:pageToken` (*type:* `String.t`) - Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results. * `:returnPartialSuccess` (*type:* `boolean()`) - Opt-in for partial success behavior which provides partial results in case of failure. The default value is false and the logic is the same as today. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.Compute.V1.Model.SslCertificateList{}}` on success * `{:error, info}` on failure """ @spec compute_region_ssl_certificates_list( Tesla.Env.client(), String.t(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.Compute.V1.Model.SslCertificateList.t()} | {:ok, Tesla.Env.t()} | {:error, any()} def compute_region_ssl_certificates_list( connection, project, region, optional_params \\ [], opts \\ [] ) do optional_params_config = %{ :alt => :query, :fields => :query, :key => :query, :oauth_token => :query, :prettyPrint => :query, :quotaUser => :query, :userIp => :query, :filter => :query, :maxResults => :query, :orderBy => :query, :pageToken => :query, :returnPartialSuccess => :query } request = Request.new() |> Request.method(:get) |> Request.url("/projects/{project}/regions/{region}/sslCertificates", %{ "project" => URI.encode(project, &URI.char_unreserved?/1), "region" => URI.encode(region, &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.Compute.V1.Model.SslCertificateList{}]) end end
49.90184
434
0.651647
ff8d836252d05f193acc23f68983d57b093c833c
167
exs
Elixir
test/builds_test.exs
kddeisz/travis.ex
5d54cf61342f1b470d363c10b608a28ce97ee580
[ "MIT" ]
null
null
null
test/builds_test.exs
kddeisz/travis.ex
5d54cf61342f1b470d363c10b608a28ce97ee580
[ "MIT" ]
null
null
null
test/builds_test.exs
kddeisz/travis.ex
5d54cf61342f1b470d363c10b608a28ce97ee580
[ "MIT" ]
null
null
null
defmodule Travis.BuildsTest do use ExUnit.Case test "#show" do %{"commit" => %{"committer_name" => "José Valim"}} = Travis.Builds.show("149411520") end end
20.875
88
0.658683
ff8d9184e50e683a4096fcb768cd86688ddb3f54
1,871
ex
Elixir
clients/web_security_scanner/lib/google_api/web_security_scanner/v1/model/list_crawled_urls_response.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/web_security_scanner/lib/google_api/web_security_scanner/v1/model/list_crawled_urls_response.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/web_security_scanner/lib/google_api/web_security_scanner/v1/model/list_crawled_urls_response.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.WebSecurityScanner.V1.Model.ListCrawledUrlsResponse do @moduledoc """ Response for the `ListCrawledUrls` method. ## Attributes * `crawledUrls` (*type:* `list(GoogleApi.WebSecurityScanner.V1.Model.CrawledUrl.t)`, *default:* `nil`) - The list of CrawledUrls returned. * `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__{ :crawledUrls => list(GoogleApi.WebSecurityScanner.V1.Model.CrawledUrl.t()), :nextPageToken => String.t() } field(:crawledUrls, as: GoogleApi.WebSecurityScanner.V1.Model.CrawledUrl, type: :list) field(:nextPageToken) end defimpl Poison.Decoder, for: GoogleApi.WebSecurityScanner.V1.Model.ListCrawledUrlsResponse do def decode(value, options) do GoogleApi.WebSecurityScanner.V1.Model.ListCrawledUrlsResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.WebSecurityScanner.V1.Model.ListCrawledUrlsResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
37.42
157
0.747728
ff8dc513dc8cb1e85344df37d2c6047a9db80ab1
1,787
exs
Elixir
apps/ewallet/test/ewallet/fetchers/user_fetcher_test.exs
jimpeebles/ewallet
ad4a9750ec8dc5adc4c0dfe6c22f0ef760825405
[ "Apache-2.0" ]
null
null
null
apps/ewallet/test/ewallet/fetchers/user_fetcher_test.exs
jimpeebles/ewallet
ad4a9750ec8dc5adc4c0dfe6c22f0ef760825405
[ "Apache-2.0" ]
null
null
null
apps/ewallet/test/ewallet/fetchers/user_fetcher_test.exs
jimpeebles/ewallet
ad4a9750ec8dc5adc4c0dfe6c22f0ef760825405
[ "Apache-2.0" ]
null
null
null
# Copyright 2018 OmiseGO Pte Ltd # # 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. defmodule EWallet.UserFetcherTest do use EWallet.DBCase, async: true import EWalletDB.Factory alias EWallet.UserFetcher alias EWalletDB.User setup do {:ok, user} = :user |> params_for() |> User.insert() %{user: user} end describe "get/1" do test "retrieves a user from its id", meta do {:ok, user} = UserFetcher.fetch(%{"user_id" => meta.user.id}) assert user.uuid == meta.user.uuid end test "retrieves a user from its provider_user_id", meta do {:ok, user} = UserFetcher.fetch(%{"provider_user_id" => meta.user.provider_user_id}) assert user.uuid == meta.user.uuid end test "Raise user_id_not_found if the user_id doesn't exist" do {:error, error} = UserFetcher.fetch(%{"user_id" => "fake"}) assert error == :user_id_not_found end test "Raise provider_user_id_not_found if the user_id doesn't exist" do {:error, error} = UserFetcher.fetch(%{"provider_user_id" => "fake"}) assert error == :provider_user_id_not_found end test "Raise invalid_parameter if no user_id or provider_user_id" do {:error, error} = UserFetcher.fetch(%{}) assert error == :invalid_parameter end end end
33.716981
90
0.698937
ff8dd888fdb04d51b8215ec1ea52888be89516aa
4,561
ex
Elixir
lib/plug_cache_control/header.ex
krasenyp/plug_cache_control
e179b96cc02df92ff53c891ec625b5b5e824448a
[ "Apache-2.0" ]
6
2021-11-05T21:35:57.000Z
2021-11-12T01:31:20.000Z
lib/plug_cache_control/header.ex
krasenyp/plug_cache_control
e179b96cc02df92ff53c891ec625b5b5e824448a
[ "Apache-2.0" ]
4
2021-11-06T17:05:30.000Z
2022-01-15T13:16:48.000Z
lib/plug_cache_control/header.ex
krasenyp/plug_cache_control
e179b96cc02df92ff53c891ec625b5b5e824448a
[ "Apache-2.0" ]
null
null
null
defmodule PlugCacheControl.Header do @moduledoc false @typep maybe(t) :: t | nil @type t :: %__MODULE__{ must_revalidate: maybe(boolean()), no_cache: maybe(boolean()), no_store: maybe(boolean()), no_transform: maybe(boolean()), proxy_revalidate: maybe(boolean()), private: maybe(boolean()), public: maybe(boolean()), max_age: maybe(integer()), s_maxage: maybe(integer()), stale_while_revalidate: maybe(integer()), stale_if_error: maybe(integer()) } @directives [ :must_revalidate, :no_cache, :no_store, :no_transform, :proxy_revalidate, :private, :public, :max_age, :s_maxage, :stale_while_revalidate, :stale_if_error ] @numeric_dir [:max_age, :s_maxage, :stale_while_revalidate, :stale_if_error] defstruct @directives defguardp is_directive(directive) when directive in @directives defguardp is_numeric(directive) when directive in @numeric_dir defguardp is_delta(time) when is_integer(time) and time >= 0 @doc """ Creates a new header struct. """ @spec new() :: t() def new, do: %__MODULE__{} @doc """ Creates a new header struct from an enumerable. """ @spec new(Enum.t()) :: t() def new(directives) do put_many(%__MODULE__{}, directives) end @doc """ Puts a value of a directive in the header struct. """ @spec put(t(), Utils.directive(), term()) :: t() def put(%__MODULE__{} = header, directive, value) do do_put(header, directive, value) end @spec put_many(t(), Enum.t()) :: t() def put_many(%__MODULE__{} = header, directives) do Enum.reduce(directives, header, fn {directive, value}, header -> put(header, directive, value) end) end @spec to_string(t()) :: String.t() def to_string(%__MODULE__{} = header) do Kernel.to_string(header) end defp do_put(_, directive, _) when not is_directive(directive) do raise ArgumentError, "Invalid directive #{inspect(directive)}" end defp do_put(header, :public, value) when is_boolean(value) do %{header | public: value, private: !value} end defp do_put(header, :private, value) when is_boolean(value) do %{header | public: !value, private: value} end defp do_put(header, :no_cache, fields) when is_list(fields) do joined_fields = Enum.join(fields, ", ") %{header | no_cache: "\"#{joined_fields}\""} end defp do_put(header, directive, {time, _unit} = dur) when is_numeric(directive) and is_delta(time) do do_put(header, directive, duration_to_seconds(dur)) end defp do_put(header, directive, field) when is_numeric(directive) and is_delta(field) do struct_put!(header, directive, field) end defp do_put(header, directive, value) when is_boolean(value) do struct_put!(header, directive, value) end defp do_put(_, directive, value) do raise ArgumentError, "Invalid value #{inspect(value)} for directive #{inspect(directive)}." end defimpl String.Chars do defp atom_to_directive(atom) when is_atom(atom) do atom |> Atom.to_string() |> String.replace("_", "-") end def to_string(header) do header |> Map.from_struct() |> Enum.reduce([], fn {_key, nil}, acc -> acc {_key, false}, acc -> acc {key, true}, acc -> [atom_to_directive(key) | acc] {key, value}, acc -> ["#{atom_to_directive(key)}=#{value}" | acc] end) |> Enum.join(", ") end end defp duration_to_seconds({period, _unit} = dur) when is_integer(period) and period >= 0, do: do_duration_to_seconds(dur) defp do_duration_to_seconds({period, unit}) when unit in [:second, :seconds], do: period defp do_duration_to_seconds({period, unit}) when unit in [:minute, :minutes], do: period * 60 defp do_duration_to_seconds({period, unit}) when unit in [:hour, :hours], do: period * 60 * 60 defp do_duration_to_seconds({period, unit}) when unit in [:day, :days], do: period * 60 * 60 * 24 defp do_duration_to_seconds({period, unit}) when unit in [:week, :weeks], do: period * 60 * 60 * 24 * 7 defp do_duration_to_seconds({period, unit}) when unit in [:year, :years], do: period * 60 * 60 * 24 * 365 defp do_duration_to_seconds({_, unit}), do: raise(ArgumentError, "Invalid unit #{inspect(unit)}.") defp struct_put!(struct, field, value) when is_struct(struct) and is_atom(field) do to_merge = Map.put(%{}, field, value) struct!(struct, to_merge) end end
29.050955
96
0.645911
ff8de857cbeed410c0970c240f140bb1af25a3a9
185
exs
Elixir
day11/dumbo_octopus/test/dumbo_octopus_web/controllers/page_controller_test.exs
alopezz/advent_of_code-2021
90f0d7e3290a5c8ba5d18b2a5d9240ea6b1682bd
[ "MIT" ]
null
null
null
day11/dumbo_octopus/test/dumbo_octopus_web/controllers/page_controller_test.exs
alopezz/advent_of_code-2021
90f0d7e3290a5c8ba5d18b2a5d9240ea6b1682bd
[ "MIT" ]
null
null
null
day11/dumbo_octopus/test/dumbo_octopus_web/controllers/page_controller_test.exs
alopezz/advent_of_code-2021
90f0d7e3290a5c8ba5d18b2a5d9240ea6b1682bd
[ "MIT" ]
null
null
null
defmodule DumboOctopusWeb.PageControllerTest do use DumboOctopusWeb.ConnCase test "GET /", %{conn: conn} do conn = get(conn, "/") assert html_response(conn, 200) end end
20.555556
47
0.702703
ff8df8c1665d61c2d782815cd468694905c72e24
33,400
exs
Elixir
lib/elixir/test/elixir/file_test.exs
knewter/elixir
8310d62499e292d78d5c9d79d5d15a64e32fb738
[ "Apache-2.0" ]
null
null
null
lib/elixir/test/elixir/file_test.exs
knewter/elixir
8310d62499e292d78d5c9d79d5d15a64e32fb738
[ "Apache-2.0" ]
null
null
null
lib/elixir/test/elixir/file_test.exs
knewter/elixir
8310d62499e292d78d5c9d79d5d15a64e32fb738
[ "Apache-2.0" ]
null
null
null
Code.require_file "test_helper.exs", __DIR__ defmodule Elixir.FileCase do use ExUnit.CaseTemplate import PathHelpers using do quote do import PathHelpers end end setup do File.mkdir_p!(tmp_path) :ok end teardown do File.rm_rf(tmp_path) :ok end end defmodule FileTest do use Elixir.FileCase import Regex, only: [escape: 1] defmodule Cp do use Elixir.FileCase test :cp_with_src_file_and_dest_file do src = fixture_path("file.txt") dest = tmp_path("sample.txt") File.touch(dest) try do assert File.exists?(dest) assert File.cp(src, dest) == :ok assert File.exists?(dest) after File.rm(dest) end end test :cp_with_src_file_and_dest_dir do src = fixture_path("file.txt") dest = tmp_path("tmp") final = Path.join(dest, "file.txt") File.mkdir(dest) try do refute File.exists?(final) assert File.cp(src, dest) == :ok assert File.exists?(final) after File.rm_rf dest end end test :cp_with_src_file_and_dest_unknown do src = fixture_path("file.txt") dest = tmp_path("tmp.file") try do refute File.exists?(dest) assert File.cp(src, dest) == :ok assert File.exists?(dest) after File.rm_rf dest end end test :cp_with_src_dir do src = fixture_path("cp_r") dest = tmp_path("tmp.file") assert File.cp(src, dest) == { :error, :eisdir } end test :cp_with_conflict do src = fixture_path("file.txt") dest = tmp_path("tmp.file") File.write!(dest, "hello") try do assert File.exists?(dest) assert File.cp(src, dest) == :ok assert File.read!(dest) == "FOO\n" after File.rm_rf dest end end test :cp_with_conflict_with_function do src = fixture_path("file.txt") dest = tmp_path("tmp.file") File.write!(dest, "hello") try do assert File.exists?(dest) assert File.cp(src, dest, fn(src_file, dest_file) -> assert src_file == src assert dest_file == dest false end) == :ok assert File.read!(dest) == "hello" after File.rm_rf dest end end test :cp_with_src_file_and_dest_file! do src = fixture_path("file.txt") dest = tmp_path("sample.txt") File.touch(dest) try do assert File.exists?(dest) assert File.cp!(src, dest) == :ok assert File.exists?(dest) after File.rm(dest) end end test :cp_with_src_dir! do src = fixture_path("cp_r") dest = tmp_path("tmp.file") assert_raise File.CopyError, "could not copy recursively from #{src} to #{dest}: " <> "illegal operation on a directory", fn -> File.cp!(src, dest) end end test :cp_r_with_src_file_and_dest_file do src = fixture_path("file.txt") dest = tmp_path("sample.txt") File.touch(dest) try do assert File.exists?(dest) assert File.cp_r(src, dest) == { :ok, [dest] } assert File.exists?(dest) after File.rm(dest) end end test :cp_r_with_src_file_and_dest_dir do src = fixture_path("file.txt") dest = tmp_path("tmp") final = Path.join(dest, "file.txt") File.mkdir(dest) try do refute File.exists?(final) assert File.cp_r(src, dest) == { :ok, [final] } assert File.exists?(final) after File.rm_rf dest end end test :cp_r_with_src_file_and_dest_unknown do src = fixture_path("file.txt") dest = tmp_path("tmp.file") try do refute File.exists?(dest) assert File.cp_r(src, dest) == { :ok, [dest] } assert File.exists?(dest) after File.rm_rf dest end end test :cp_r_with_src_dir_and_dest_dir do src = fixture_path("cp_r") dest = tmp_path("tmp") File.mkdir(dest) try do refute File.exists?(tmp_path("tmp/cp_r/a/1.txt")) refute File.exists?(tmp_path("tmp/cp_r/a/a/2.txt")) refute File.exists?(tmp_path("tmp/cp_r/b/3.txt")) { :ok, files } = File.cp_r(src, dest) assert length(files) == 7 assert tmp_path("tmp/cp_r/a") in files assert tmp_path("tmp/cp_r/a/1.txt") in files assert File.exists?(tmp_path("tmp/cp_r/a/1.txt")) assert File.exists?(tmp_path("tmp/cp_r/a/a/2.txt")) assert File.exists?(tmp_path("tmp/cp_r/b/3.txt")) after File.rm_rf dest end end test :cp_r_with_src_dir_dot_and_dest_dir do src = fixture_path("cp_r/.") dest = tmp_path("tmp") File.mkdir(dest) try do refute File.exists?(tmp_path("tmp/a/1.txt")) refute File.exists?(tmp_path("tmp/a/a/2.txt")) refute File.exists?(tmp_path("tmp/b/3.txt")) { :ok, files } = File.cp_r(src, dest) assert length(files) == 7 assert File.exists?(tmp_path("tmp/a/1.txt")) assert File.exists?(tmp_path("tmp/a/a/2.txt")) assert File.exists?(tmp_path("tmp/b/3.txt")) after File.rm_rf dest end end test :cp_r_with_src_dir_and_dest_file do src = fixture_path("cp_r") dest = tmp_path("tmp.file") try do File.touch!(dest) assert (File.cp_r(src, dest) |> is_io_error?) after File.rm_rf dest end end test :cp_r_with_src_dir_and_dest_unknown do src = fixture_path("cp_r") dest = tmp_path("tmp") try do refute File.exists?(tmp_path("tmp/cp_r/a/1.txt")) refute File.exists?(tmp_path("tmp/cp_r/a/a/2.txt")) refute File.exists?(tmp_path("tmp/cp_r/b/3.txt")) { :ok, files } = File.cp_r(src, dest) assert length(files) == 7 assert File.exists?(tmp_path("tmp/cp_r/a/1.txt")) assert File.exists?(tmp_path("tmp/cp_r/a/a/2.txt")) assert File.exists?(tmp_path("tmp/cp_r/b/3.txt")) after File.rm_rf dest end end test :cp_r_with_src_unknown do src = fixture_path("unknown") dest = tmp_path("tmp") assert File.cp_r(src, dest) == { :error, :enoent, src } end test :cp_r_with_dir_and_file_conflict do src = fixture_path("cp_r/.") dest = tmp_path("tmp") try do File.mkdir(dest) File.write!(Path.join(dest, "a"), "hello") assert (File.cp_r(src, dest) |> is_io_error?) after File.rm_rf dest end end test :cp_r_with_src_dir_and_dest_dir_using_lists do src = fixture_path("cp_r/.") |> to_char_list dest = tmp_path("tmp") |> to_char_list File.mkdir(dest) try do refute File.exists?(tmp_path("tmp/a/1.txt")) refute File.exists?(tmp_path("tmp/a/a/2.txt")) refute File.exists?(tmp_path("tmp/b/3.txt")) { :ok, files } = File.cp_r(src, dest) assert length(files) == 7 assert is_list(hd(files)) assert File.exists?(tmp_path("tmp/a/1.txt")) assert File.exists?(tmp_path("tmp/a/a/2.txt")) assert File.exists?(tmp_path("tmp/b/3.txt")) after File.rm_rf dest end end test :cp_r_with_src_with_file_conflict do src = fixture_path("cp_r/.") dest = tmp_path("tmp") File.mkdir_p tmp_path("tmp/a") File.write! tmp_path("tmp/a/1.txt"), "hello" try do assert File.exists?(tmp_path("tmp/a/1.txt")) File.cp_r(src, dest) assert File.read!(tmp_path("tmp/a/1.txt")) == "" after File.rm_rf dest end end test :cp_r_with_src_with_file_conflict_callback do src = fixture_path("cp_r/.") dest = tmp_path("tmp") File.mkdir_p tmp_path("tmp/a") File.write! tmp_path("tmp/a/1.txt"), "hello" try do assert File.exists?(tmp_path("tmp/a/1.txt")) File.cp_r(src, dest, fn(src_file, dest_file) -> assert src_file == fixture_path("cp_r/a/1.txt") assert dest_file == tmp_path("tmp/a/1.txt") false end) assert File.read!(tmp_path("tmp/a/1.txt")) == "hello" after File.rm_rf dest end end test :cp_r! do src = fixture_path("cp_r/.") dest = tmp_path("tmp") File.mkdir(dest) try do refute File.exists?(tmp_path("tmp/a/1.txt")) refute File.exists?(tmp_path("tmp/a/a/2.txt")) refute File.exists?(tmp_path("tmp/b/3.txt")) assert length(File.cp_r!(src, dest)) == 7 assert File.exists?(tmp_path("tmp/a/1.txt")) assert File.exists?(tmp_path("tmp/a/a/2.txt")) assert File.exists?(tmp_path("tmp/b/3.txt")) after File.rm_rf dest end end test :cp_r_with_src_unknown! do src = fixture_path("unknown") dest = tmp_path("tmp") assert_raise File.CopyError, "could not copy recursively from #{src} to #{dest}. #{src}: no such file or directory", fn -> File.cp_r!(src, dest) end end test :cp_preserves_mode do File.mkdir_p!(tmp_path("tmp")) src = fixture_path("cp_mode") dest = tmp_path("tmp/cp_mode") File.cp!(src, dest) File.Stat[mode: src_mode] = File.stat! src File.Stat[mode: dest_mode] = File.stat! dest assert src_mode == dest_mode # On overwrite File.cp! src, dest, fn(_, _) -> true end File.Stat[mode: src_mode] = File.stat! src File.Stat[mode: dest_mode] = File.stat! dest assert src_mode == dest_mode end defp is_io_error?(result) do elem(result, 1) in [:enotdir, :eio, :enoent, :eisdir] end end defmodule Queries do use ExUnit.Case test :regular do assert File.regular?(__FILE__) assert File.regular?(String.to_char_list!(__FILE__)) refute File.regular?("#{__FILE__}.unknown") end test :exists do assert File.exists?(__FILE__) assert File.exists?(fixture_path) assert File.exists?(fixture_path("file.txt")) refute File.exists?(fixture_path("missing.txt")) refute File.exists?("_missing.txt") end end test :ls do { :ok, value } = File.ls(fixture_path) assert "code_sample.exs" in value assert "file.txt" in value { :error, :enoent } = File.ls(fixture_path("non-existent-subdirectory")) end test :ls! do value = File.ls!(fixture_path) assert "code_sample.exs" in value assert "file.txt" in value assert_raise File.Error, fn -> File.ls!(fixture_path("non-existent-subdirectory")) end end defmodule OpenReadWrite do use Elixir.FileCase test :read_with_binary do assert { :ok, "FOO\n" } = File.read(fixture_path("file.txt")) assert { :error, :enoent } = File.read(fixture_path("missing.txt")) end test :read_with_list do assert { :ok, "FOO\n" } = File.read(Path.expand('../fixtures/file.txt', __FILE__)) assert { :error, :enoent } = File.read(Path.expand('../fixtures/missing.txt', __FILE__)) end test :read_with_utf8 do assert { :ok, "Русский\n日\n" } = File.read(Path.expand('../fixtures/utf8.txt', __FILE__)) end test :read! do assert File.read!(fixture_path("file.txt")) == "FOO\n" expected_message = "could not read file fixtures/missing.txt: no such file or directory" assert_raise File.Error, expected_message, fn -> File.read!("fixtures/missing.txt") end end test :write_ascii_content do fixture = tmp_path("tmp_test.txt") try do refute File.exists?(fixture) assert File.write(fixture, 'test text') == :ok assert File.read(fixture) == { :ok, "test text" } after File.rm(fixture) end end test :write_utf8 do fixture = tmp_path("tmp_test.txt") try do refute File.exists?(fixture) assert File.write(fixture, "Русский\n日\n") == :ok assert { :ok, "Русский\n日\n" } == File.read(fixture) after File.rm(fixture) end end test :write_with_options do fixture = tmp_path("tmp_test.txt") try do refute File.exists?(fixture) assert File.write(fixture, "Русский\n日\n") == :ok assert File.write(fixture, "test text", [:append]) == :ok assert { :ok, "Русский\n日\ntest text" } == File.read(fixture) after File.rm(fixture) end end test :open_file_without_modes do { :ok, file } = File.open(fixture_path("file.txt")) assert IO.gets(file, "") == "FOO\n" assert File.close(file) == :ok end test :open_file_with_charlist do { :ok, file } = File.open(fixture_path("file.txt"), [:charlist]) assert IO.gets(file, "") == 'FOO\n' assert File.close(file) == :ok end test :open_utf8_by_default do { :ok, file } = File.open(fixture_path("utf8.txt"), [:utf8]) assert IO.gets(file, "") == "Русский\n" assert File.close(file) == :ok end test :open_readonly_by_default do { :ok, file } = File.open(fixture_path("file.txt")) assert_raise ArgumentError, fn -> IO.write(file, "foo") end assert File.close(file) == :ok end test :open_with_write_permission do fixture = tmp_path("tmp_text.txt") try do { :ok, file } = File.open(fixture, [:write]) assert IO.write(file, "foo") == :ok assert File.close(file) == :ok assert File.read(fixture) == { :ok, "foo" } after File.rm(fixture) end end test :open_with_binwrite_permission do fixture = tmp_path("tmp_text.txt") try do { :ok, file } = File.open(fixture, [:write]) assert IO.binwrite(file, "Русский") == :ok assert File.close(file) == :ok assert File.read(fixture) == { :ok, "Русский" } after File.rm(fixture) end end test :open_utf8_and_charlist do { :ok, file } = File.open(fixture_path("utf8.txt"), [:charlist, :utf8]) assert IO.gets(file, "") == [1056, 1091, 1089, 1089, 1082, 1080, 1081, 10] assert File.close(file) == :ok end test :open_respects_encoding do { :ok, file } = File.open(fixture_path("utf8.txt"), [{:encoding, :latin1}]) assert IO.gets(file, "") == <<195, 144, 194, 160, 195, 145, 194, 131, 195, 145, 194, 129, 195, 145, 194, 129, 195, 144, 194, 186, 195, 144, 194, 184, 195, 144, 194, 185, 10>> assert File.close(file) == :ok end test :open_a_missing_file do assert File.open('missing.txt') == {:error, :enoent} end test :open_a_file_with_function do file = fixture_path("file.txt") assert File.open(file, &IO.read(&1, :line)) == { :ok, "FOO\n" } end test :open_a_missing_file! do message = "could not open missing.txt: no such file or directory" assert_raise File.Error, message, fn -> File.open!('missing.txt') end end test :open_a_file_with_function! do file = fixture_path("file.txt") assert File.open!(file, &IO.read(&1, :line)) == "FOO\n" end end defmodule Mkdir do use Elixir.FileCase test :mkdir_with_binary do fixture = tmp_path("tmp_test") try do refute File.exists?(fixture) assert File.mkdir(fixture) == :ok assert File.exists?(fixture) after File.rmdir fixture end end test :mkdir_with_list do fixture = tmp_path("tmp_test") |> to_char_list try do refute File.exists?(fixture) assert File.mkdir(fixture) == :ok assert File.exists?(fixture) after File.rmdir fixture end end test :mkdir_with_invalid_path do fixture = fixture_path("file.txt") invalid = Path.join fixture, "test" assert File.exists?(fixture) assert (File.mkdir(invalid) |> is_io_error?) refute File.exists?(invalid) end test :mkdir! do fixture = tmp_path("tmp_test") try do refute File.exists?(fixture) assert File.mkdir!(fixture) == :ok assert File.exists?(fixture) after File.rmdir fixture end end test :mkdir_with_invalid_path! do fixture = fixture_path("file.txt") invalid = Path.join fixture, "test" assert File.exists?(fixture) assert_raise File.Error, %r"^could not make directory #{escape invalid}: (not a directory|no such file or directory)", fn -> File.mkdir!(invalid) end end test :mkdir_p_with_one_directory do fixture = tmp_path("tmp_test") try do refute File.exists?(fixture) assert File.mkdir_p(fixture) == :ok assert File.exists?(fixture) after File.rm_rf fixture end end test :mkdir_p_with_nested_directory_and_binary do base = tmp_path("tmp_test") fixture = Path.join(base, "test") refute File.exists?(base) try do assert File.mkdir_p(fixture) == :ok assert File.exists?(base) assert File.exists?(fixture) after File.rm_rf base end end test :mkdir_p_with_nested_directory_and_list do base = tmp_path("tmp_test") |> to_char_list fixture = Path.join(base, "test") refute File.exists?(base) try do assert File.mkdir_p(fixture) == :ok assert File.exists?(base) assert File.exists?(fixture) after File.rm_rf base end end test :mkdir_p_with_nested_directory_and_existing_parent do base = tmp_path("tmp_test") fixture = Path.join(base, "test") File.mkdir(base) try do assert File.mkdir_p(fixture) == :ok assert File.exists?(base) assert File.exists?(fixture) after File.rm_rf base end end test :mkdir_p_with_invalid_path do assert File.exists?(fixture_path("file.txt")) invalid = Path.join fixture_path("file.txt"), "test/foo" assert (File.mkdir(invalid) |> is_io_error?) refute File.exists?(invalid) end test :mkdir_p! do fixture = tmp_path("tmp_test") try do refute File.exists?(fixture) assert File.mkdir_p!(fixture) == :ok assert File.exists?(fixture) after File.rm_rf fixture end end test :mkdir_p_with_invalid_path! do fixture = fixture_path("file.txt") invalid = Path.join fixture, "test" assert File.exists?(fixture) assert_raise File.Error, %r"^could not make directory \(with -p\) #{escape invalid}: (not a directory|no such file or directory)", fn -> File.mkdir_p!(invalid) end end defp is_io_error?(result) do {:error,errorcode} = result errorcode in [:enotdir, :eio, :enoent, :eisdir] end end defmodule Rm do use Elixir.FileCase test :rm_file do fixture = tmp_path("tmp_test.txt") File.write(fixture, "test") assert File.exists?(fixture) assert File.rm(fixture) == :ok refute File.exists?(fixture) end test :rm_file_with_dir do assert File.rm(fixture_path) == { :error, :eperm } end test :rm_nonexistent_file do assert File.rm('missing.txt') == { :error, :enoent } end test :rm! do fixture = tmp_path("tmp_test.txt") File.write(fixture, "test") assert File.exists?(fixture) assert File.rm!(fixture) == :ok refute File.exists?(fixture) end test :rm_with_invalid_file! do assert_raise File.Error, "could not remove file missing.file: no such file or directory", fn -> File.rm!("missing.file") end end test :rmdir do fixture = tmp_path("tmp_test") File.mkdir_p(fixture) assert File.dir?(fixture) assert File.rmdir(fixture) == :ok refute File.exists?(fixture) end test :rmdir_with_file do assert (File.rmdir(fixture_path("file.txt")) |> is_io_error?) end test :rmdir! do fixture = tmp_path("tmp_test") File.mkdir_p(fixture) assert File.dir?(fixture) assert File.rmdir!(fixture) == :ok refute File.exists?(fixture) end test :rmdir_with_file! do fixture = fixture_path("file.txt") assert_raise File.Error, %r"^could not remove directory #{escape fixture}: (not a directory|I/O error)", fn -> File.rmdir!(fixture) end end test :rm_rf do fixture = tmp_path("tmp") File.mkdir(fixture) File.cp_r!(fixture_path("cp_r/."), fixture) assert File.exists?(tmp_path("tmp/a/1.txt")) assert File.exists?(tmp_path("tmp/a/a/2.txt")) assert File.exists?(tmp_path("tmp/b/3.txt")) { :ok, files } = File.rm_rf(fixture) assert length(files) == 7 assert fixture in files assert tmp_path("tmp/a/1.txt") in files refute File.exists?(tmp_path("tmp/a/1.txt")) refute File.exists?(tmp_path("tmp/a/a/2.txt")) refute File.exists?(tmp_path("tmp/b/3.txt")) refute File.exists?(fixture) end test :rm_rf_with_symlink do from = tmp_path("tmp/from") to = tmp_path("tmp/to") File.mkdir_p!(to) File.write!(Path.join(to, "hello"), "world") :file.make_symlink(to, from) if File.exists?(from) or not is_win? do assert File.exists?(from) { :ok, files } = File.rm_rf(from) assert length(files) == 1 assert File.exists?(Path.join(to, "hello")) refute File.exists?(from) end after File.rm(tmp_path("tmp/from")) end test :rm_rf_with_char_list do fixture = tmp_path("tmp") |> to_char_list File.mkdir(fixture) File.cp_r!(fixture_path("cp_r/."), fixture) assert File.exists?(tmp_path("tmp/a/1.txt")) assert File.exists?(tmp_path("tmp/a/a/2.txt")) assert File.exists?(tmp_path("tmp/b/3.txt")) { :ok, files } = File.rm_rf(fixture) assert length(files) == 7 assert fixture in files assert (tmp_path("tmp/a/1.txt") |> to_char_list) in files refute File.exists?(tmp_path("tmp/a/1.txt")) refute File.exists?(tmp_path("tmp/a/a/2.txt")) refute File.exists?(tmp_path("tmp/b/3.txt")) refute File.exists?(fixture) end test :rm_rf_with_file do fixture = tmp_path("tmp") File.write(fixture, "hello") assert File.rm_rf(fixture) == { :ok, [fixture] } end test :rm_rf_with_unknown do fixture = tmp_path("tmp.unknown") assert File.rm_rf(fixture) == { :ok, [] } end test :rm_rf_with_invalid do fixture = fixture_path "file.txt/path" assert File.rm_rf(fixture) == { :ok, [] } end test :rm_rf! do fixture = tmp_path("tmp") File.mkdir(fixture) File.cp_r!(fixture_path("cp_r/."), fixture) assert File.exists?(tmp_path("tmp/a/1.txt")) assert File.exists?(tmp_path("tmp/a/a/2.txt")) assert File.exists?(tmp_path("tmp/b/3.txt")) files = File.rm_rf!(fixture) assert length(files) == 7 assert fixture in files assert tmp_path("tmp/a/1.txt") in files refute File.exists?(tmp_path("tmp/a/1.txt")) refute File.exists?(tmp_path("tmp/a/a/2.txt")) refute File.exists?(tmp_path("tmp/b/3.txt")) refute File.exists?(fixture) end test :rm_rf_with_invalid! do fixture = fixture_path "file.txt/path" assert File.rm_rf!(fixture) == [] end defp is_io_error?(result) do elem(result, 1) in [:enotdir, :eio, :enoent, :eisdir] end end test :stat do {:ok, info} = File.stat(__FILE__) assert info.mtime end test :stat! do assert File.stat!(__FILE__).mtime end test :stat_with_invalid_file do assert { :error, _ } = File.stat("./invalid_file") end test :stat_with_invalid_file! do assert_raise File.Error, fn -> File.stat!("./invalid_file") end end test :io_stream do src = File.open! fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do stream = IO.stream(src, :line) File.open dest, [:write], fn(target) -> Enum.each stream, fn(line) -> IO.write target, String.replace(line, "O", "A") end end assert File.read(dest) == { :ok, "FAA\n" } after File.rm(dest) end end test :stream_line do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do stream = File.stream!(src) File.open dest, [:write], fn(target) -> Enum.each stream, fn(line) -> IO.write target, String.replace(line, "O", "A") end end assert File.read(dest) == { :ok, "FAA\n" } after File.rm(dest) end end test :stream_bytes do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do stream = File.stream!(src, [], 1) File.open dest, [:write], fn(target) -> Enum.each stream, fn(line) -> IO.write target, String.replace(line, "OO", "AA") end end assert File.read(dest) == { :ok, "FOO\n" } after File.rm(dest) end end test :stream! do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do stream = File.stream!(src) File.open dest, [:write], fn(target) -> Enum.each stream, fn(line) -> IO.write target, String.replace(line, "O", "A") end end assert File.read(dest) == { :ok, "FAA\n" } after File.rm(dest) end end test :io_binstream do src = File.open! fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do stream = IO.binstream(src, :line) File.open dest, [:write], fn(target) -> Enum.each stream, fn(line) -> IO.write target, String.replace(line, "O", "A") end end assert File.read(dest) == { :ok, "FAA\n" } after File.rm(dest) end end test :binstream_line do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do stream = File.binstream!(src) File.open dest, [:write], fn(target) -> Enum.each stream, fn(line) -> IO.write target, String.replace(line, "O", "A") end end assert File.read(dest) == { :ok, "FAA\n" } after File.rm(dest) end end test :binstream_bytes do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do stream = File.binstream!(src, [], 1) File.open dest, [:write], fn(target) -> Enum.each stream, fn(line) -> IO.write target, String.replace(line, "OO", "AA") end end assert File.read(dest) == { :ok, "FOO\n" } after File.rm(dest) end end test :binstream! do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do stream = File.binstream!(src) File.open dest, [:write], fn(target) -> Enum.each stream, fn(line) -> IO.write target, String.replace(line, "O", "A") end end assert File.read(dest) == { :ok, "FAA\n" } after File.rm(dest) end end test :copy do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do refute File.exists?(dest) assert File.copy(src, dest) == { :ok, 4 } assert File.read(dest) == { :ok, "FOO\n" } after File.rm(dest) end end test :copy_with_bytes_count do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do refute File.exists?(dest) assert File.copy(src, dest, 2) == { :ok, 2 } assert { :ok, "FO" } == File.read(dest) after File.rm(dest) end end test :copy_with_invalid_file do src = fixture_path("invalid.txt") dest = tmp_path("tmp_test.txt") assert File.copy(src, dest, 2) == { :error, :enoent } end test :copy! do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do refute File.exists?(dest) assert File.copy!(src, dest) == 4 assert { :ok, "FOO\n" } == File.read(dest) after File.rm(dest) end end test :copy_with_bytes_count! do src = fixture_path("file.txt") dest = tmp_path("tmp_test.txt") try do refute File.exists?(dest) assert File.copy!(src, dest, 2) == 2 assert { :ok, "FO" } == File.read(dest) after File.rm(dest) end end test :copy_with_invalid_file! do src = fixture_path("invalid.txt") dest = tmp_path("tmp_test.txt") assert_raise File.CopyError, "could not copy from #{src} to #{dest}: no such file or directory", fn -> File.copy!(src, dest, 2) end end test :cwd_and_cd do { :ok, current } = File.cwd try do assert File.cd(fixture_path) == :ok assert File.exists?("file.txt") after File.cd!(current) end end if :file.native_name_encoding == :utf8 do test :cwd_and_cd_with_utf8 do File.mkdir_p(tmp_path("héllò")) File.cd!(tmp_path("héllò"), fn -> assert Path.basename(File.cwd!) == "héllò" end) after File.rm_rf tmp_path("héllò") end end test :invalid_cd do assert(File.cd(fixture_path("file.txt")) |> is_io_error?) end test :invalid_cd! do message = %r"^could not set current working directory to #{escape fixture_path("file.txt")}: (not a directory|no such file or directory)" assert_raise File.Error, message, fn -> File.cd!(fixture_path("file.txt")) end end test :cd_with_function do assert File.cd!(fixture_path, fn -> assert File.exists?("file.txt") :cd_result end) == :cd_result end test :touch_with_no_file do fixture = tmp_path("tmp_test.txt") time = { { 2010, 4, 17 }, { 14, 0, 0 }} try do refute File.exists?(fixture) assert File.touch(fixture, time) == :ok assert { :ok, "" } == File.read(fixture) assert File.stat!(fixture).mtime == time after File.rm(fixture) end end test :touch_with_timestamp do fixture = tmp_path("tmp_test.txt") try do assert File.touch!(fixture) == :ok stat = File.stat!(fixture) assert File.touch!(fixture, last_year) == :ok assert stat.mtime > File.stat!(fixture).mtime after File.rm(fixture) end end test :touch_with_dir do assert File.touch(fixture_path) == :ok end test :touch_with_failure do fixture = fixture_path("file.txt/bar") assert (File.touch(fixture) |> is_io_error?) end test :touch_with_success! do assert File.touch!(fixture_path) == :ok end test :touch_with_failure! do fixture = fixture_path("file.txt/bar") assert_raise File.Error, %r"could not touch #{escape fixture}: (not a directory|no such file or directory)", fn -> File.touch!(fixture) end end test :chmod_with_success do fixture = tmp_path("tmp_test.txt") File.touch(fixture) try do assert File.chmod(fixture, 0100666) == :ok stat = File.stat!(fixture) assert stat.mode == 0100666 unless is_win? do assert File.chmod(fixture, 0100777) == :ok stat = File.stat!(fixture) assert stat.mode == 0100777 end after File.rm(fixture) end end test :chmod_with_success! do fixture = tmp_path("tmp_test.txt") File.touch(fixture) try do assert File.chmod!(fixture, 0100666) == :ok stat = File.stat!(fixture) assert stat.mode == 0100666 unless is_win? do assert File.chmod!(fixture, 0100777) == :ok stat = File.stat!(fixture) assert stat.mode == 0100777 end after File.rm(fixture) end end test :chmod_with_failue do fixture = tmp_path("tmp_test.txt") File.rm(fixture) assert File.chmod(fixture, 0100777) == {:error,:enoent} end test :chmod_with_failue! do fixture = tmp_path("tmp_test.txt") File.rm(fixture) message = %r"could not change mode for #{escape fixture}: no such file or directory" assert_raise File.Error, message, fn -> File.chmod!(fixture, 0100777) end end test :chgrp_with_failue do fixture = tmp_path("tmp_test.txt") File.rm(fixture) assert File.chgrp(fixture, 1) == {:error,:enoent} end test :chgrp_with_failue! do fixture = tmp_path("tmp_test.txt") File.rm(fixture) message = %r"could not change group for #{escape fixture}: no such file or directory" assert_raise File.Error, message, fn -> File.chgrp!(fixture, 1) end end test :chown_with_failue do fixture = tmp_path("tmp_test.txt") File.rm(fixture) assert File.chown(fixture, 1) == {:error,:enoent} end test :chown_with_failue! do fixture = tmp_path("tmp_test.txt") File.rm(fixture) message = %r"could not change owner for #{escape fixture}: no such file or directory" assert_raise File.Error, message, fn -> File.chown!(fixture, 1) end end defp last_year do last_year :calendar.local_time end defp last_year({ { year, month, day }, time }) do { { year - 1, month, day }, time } end defp is_io_error?(result) do {:error,errorcode} = result errorcode in [:enotdir, :eio, :enoent, :eisdir] end end
26.012461
180
0.594251
ff8e077b8182babd521f006321d0e8bf428d0823
233
exs
Elixir
priv/repo/migrations/20191220203015_alter_distributions.exs
runhyve/webapp
434b074f98c1ebac657b56062c1c1a54e683dea1
[ "BSD-2-Clause" ]
12
2019-07-02T14:30:06.000Z
2022-03-12T08:22:18.000Z
priv/repo/migrations/20191220203015_alter_distributions.exs
runhyve/webapp
434b074f98c1ebac657b56062c1c1a54e683dea1
[ "BSD-2-Clause" ]
9
2020-03-16T20:10:50.000Z
2021-06-17T17:45:44.000Z
priv/repo/migrations/20191220203015_alter_distributions.exs
runhyve/webapp
434b074f98c1ebac657b56062c1c1a54e683dea1
[ "BSD-2-Clause" ]
null
null
null
defmodule Webapp.Repo.Migrations.AlterDistributions do use Ecto.Migration def change do alter table(:distributions) do add(:archived_at, :utc_datetime, default: nil, null: true) end end end
23.3
68
0.660944
ff8e0a6f249735112713c47ddcb3b22b18162a39
1,995
ex
Elixir
clients/cloud_run/lib/google_api/cloud_run/v1alpha1/model/env_var_source.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/cloud_run/lib/google_api/cloud_run/v1alpha1/model/env_var_source.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/cloud_run/lib/google_api/cloud_run/v1alpha1/model/env_var_source.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.CloudRun.V1alpha1.Model.EnvVarSource do @moduledoc """ EnvVarSource represents a source for the value of an EnvVar. ## Attributes * `configMapKeyRef` (*type:* `GoogleApi.CloudRun.V1alpha1.Model.ConfigMapKeySelector.t`, *default:* `nil`) - (Optional) Not supported by Cloud Run Selects a key of a ConfigMap. * `secretKeyRef` (*type:* `GoogleApi.CloudRun.V1alpha1.Model.SecretKeySelector.t`, *default:* `nil`) - (Optional) Selects a key (version) of a secret in Secret Manager. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :configMapKeyRef => GoogleApi.CloudRun.V1alpha1.Model.ConfigMapKeySelector.t() | nil, :secretKeyRef => GoogleApi.CloudRun.V1alpha1.Model.SecretKeySelector.t() | nil } field(:configMapKeyRef, as: GoogleApi.CloudRun.V1alpha1.Model.ConfigMapKeySelector) field(:secretKeyRef, as: GoogleApi.CloudRun.V1alpha1.Model.SecretKeySelector) end defimpl Poison.Decoder, for: GoogleApi.CloudRun.V1alpha1.Model.EnvVarSource do def decode(value, options) do GoogleApi.CloudRun.V1alpha1.Model.EnvVarSource.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.CloudRun.V1alpha1.Model.EnvVarSource do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
39.9
180
0.753383
ff8e316118fc39ae86332fa0f036cf72d047480a
1,417
exs
Elixir
problem33.exs
greenfork/project_euler
aeee87404f91e71c4e25c039fb2ec8be769964a8
[ "Unlicense" ]
1
2018-03-11T04:03:20.000Z
2018-03-11T04:03:20.000Z
problem33.exs
greenfork/project_euler
aeee87404f91e71c4e25c039fb2ec8be769964a8
[ "Unlicense" ]
null
null
null
problem33.exs
greenfork/project_euler
aeee87404f91e71c4e25c039fb2ec8be769964a8
[ "Unlicense" ]
null
null
null
defmodule DigitCancellingFractions do def run do {numerator, denominator} = Enum.reduce(fractions(), {1, 1}, fn {a, b, _, _}, {n, d} -> {n * a, d * b} end) gcd = gcd(numerator, denominator) div(denominator, gcd) end def fractions do for n <- 10..98, k <- (n + 1)..99, rem(n, 10) != 0 && rem(k, 10) != 0, d = gcd(n, k), d > 1, dn = digits(n), dk = digits(k), {a, b} <- intersection(dn, dk), a != 0, nr = div(n, d), kr = div(k, d), dab = gcd(a, b), ar = div(a, dab), br = div(b, dab), nr == ar && kr == br do {n, k, a, b} end end def gcd(a, b) when b == 0, do: a def gcd(a, b) when b > a, do: gcd(b, a) def gcd(a, b), do: gcd(b, Integer.mod(a, b)) def digits(n) when is_integer(n), do: do_digits(n, []) defp do_digits(n, acc) when n < 10, do: [n | acc] defp do_digits(n, acc), do: do_digits(div(n, 10), [rem(n, 10) | acc]) def intersection([a, b], [c, d]) do me = cond do b == 0 -> {0, 1} a == c && b < d -> {b, d} a == d && b < c -> {b, c} true -> {0, 1} end mi = cond do a == 0 -> {0, 1} b == c && a < d -> {a, d} b == d && a < c -> {a, c} true -> {0, 1} end [me, mi] end end IO.inspect(DigitCancellingFractions.run()) # 49/98
22.492063
71
0.425547
ff8e35dc1acf88ae58d9cc1b54d068136af96d09
1,673
ex
Elixir
clients/firestore/lib/google_api/firestore/v1beta1/model/order.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/firestore/lib/google_api/firestore/v1beta1/model/order.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/firestore/lib/google_api/firestore/v1beta1/model/order.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.Firestore.V1beta1.Model.Order do @moduledoc """ An order on a field. ## Attributes * `direction` (*type:* `String.t`, *default:* `nil`) - The direction to order by. Defaults to `ASCENDING`. * `field` (*type:* `GoogleApi.Firestore.V1beta1.Model.FieldReference.t`, *default:* `nil`) - The field to order by. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :direction => String.t(), :field => GoogleApi.Firestore.V1beta1.Model.FieldReference.t() } field(:direction) field(:field, as: GoogleApi.Firestore.V1beta1.Model.FieldReference) end defimpl Poison.Decoder, for: GoogleApi.Firestore.V1beta1.Model.Order do def decode(value, options) do GoogleApi.Firestore.V1beta1.Model.Order.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Firestore.V1beta1.Model.Order do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
33.46
119
0.727436
ff8e4da0ebbfbf1a872beb964de16ec4f116673a
2,880
ex
Elixir
clients/game_services/lib/google_api/game_services/v1/model/game_server_cluster.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/game_services/lib/google_api/game_services/v1/model/game_server_cluster.ex
MasashiYokota/elixir-google-api
975dccbff395c16afcb62e7a8e411fbb58e9ab01
[ "Apache-2.0" ]
null
null
null
clients/game_services/lib/google_api/game_services/v1/model/game_server_cluster.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.GameServices.V1.Model.GameServerCluster do @moduledoc """ A game server cluster resource. ## Attributes * `connectionInfo` (*type:* `GoogleApi.GameServices.V1.Model.GameServerClusterConnectionInfo.t`, *default:* `nil`) - The game server cluster connection information. This information is used to manage game server clusters. * `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The creation time. * `description` (*type:* `String.t`, *default:* `nil`) - Human readable description of the cluster. * `etag` (*type:* `String.t`, *default:* `nil`) - ETag of the resource. * `labels` (*type:* `map()`, *default:* `nil`) - The labels associated with this game server cluster. Each label is a key-value pair. * `name` (*type:* `String.t`, *default:* `nil`) - Required. The resource name of the game server cluster. Uses the form: `projects/{project}/locations/{location}/realms/{realm}/gameServerClusters/{cluster}`. For example, `projects/my-project/locations/{location}/realms/zanzibar/gameServerClusters/my-onprem-cluster`. * `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The last-modified time. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :connectionInfo => GoogleApi.GameServices.V1.Model.GameServerClusterConnectionInfo.t(), :createTime => DateTime.t(), :description => String.t(), :etag => String.t(), :labels => map(), :name => String.t(), :updateTime => DateTime.t() } field(:connectionInfo, as: GoogleApi.GameServices.V1.Model.GameServerClusterConnectionInfo) field(:createTime, as: DateTime) field(:description) field(:etag) field(:labels, type: :map) field(:name) field(:updateTime, as: DateTime) end defimpl Poison.Decoder, for: GoogleApi.GameServices.V1.Model.GameServerCluster do def decode(value, options) do GoogleApi.GameServices.V1.Model.GameServerCluster.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.GameServices.V1.Model.GameServerCluster do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
44.307692
321
0.709722
ff8e55bc9f1519cae9c0a75858808fb668bea333
3,110
exs
Elixir
mix.exs
iboard/ax_webclient
e192a0534671bf036ad36bcece03940c337958dd
[ "MIT" ]
null
null
null
mix.exs
iboard/ax_webclient
e192a0534671bf036ad36bcece03940c337958dd
[ "MIT" ]
null
null
null
mix.exs
iboard/ax_webclient
e192a0534671bf036ad36bcece03940c337958dd
[ "MIT" ]
null
null
null
defmodule WebClient.MixProject do use Mix.Project @deps [ # Phoenix and tools {:phoenix, "~> 1.6.6"}, {:phoenix_html, "~> 3.0"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, {:phoenix_live_view, "~> 0.17.5"}, {:floki, ">= 0.30.0"}, {:phoenix_live_dashboard, "~> 0.6"}, {:esbuild, "~> 0.3", runtime: Mix.env() == :dev}, {:swoosh, "~> 1.3"}, {:telemetry_metrics, "~> 0.6"}, {:telemetry_poller, "~> 1.0"}, {:gettext, "~> 0.18"}, {:jason, "~> 1.2"}, {:plug_cowboy, "~> 2.5"}, # other utilities {:ex_doc, "~> 0.28"}, # Blog {:tailwind, "~> 0.1", only: [:dev,:prod]}, {:earmark, git: "https://github.com/pragdave/earmark.git", override: true}, {:earmark_parser, git: "https://github.com/RobertDober/earmark_parser.git", override: true}, {:nimble_publisher, git: "https://github.com/dashbitco/nimble_publisher.git", override: true}, {:makeup_elixir, ">= 0.0.0"}, {:makeup_erlang, ">= 0.0.0"}, # Altex {:axrepo, "~> 0.1"} ] defp description() do ~s""" A simple Phoenix/Liveview client for [Altex](https://github.com/iboard/altex). Use it as a scaffold. """ end defp package do [ name: "ax_webclient", files: ["lib", "mix.exs", "README*", "LICENSE*"], maintainers: ["Andreas Altendorfer"], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/iboard/web_client"} ] end def project do [ app: :ax_webclient, version: "0.1.2", elixir: "~> 1.13", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:gettext] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), xref: [exclude: [:crypto]], # Hex package: package(), description: description(), licenses: ["MIT"], links: ["https://github.com/iboard/altex"], # Docs name: "Altex.WebClient", source_url: "https://github.com/iboard/ax_webclient", homepage_url: "https://github.com/iboard/ax_webclient", docs: [ # The main page in the docs main: "readme", extras: ["README.md"] ] ] end # Configuration for the OTP application. # # Type `mix help compile.app` for more information. def application do [ mod: {WebClient.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 @deps end # Aliases are shortcuts or tasks specific to the current project. # For example, to install project dependencies and perform other setup tasks, run: # # $ mix setup # # See the documentation for `Mix` for more info on aliases. defp aliases do [ setup: ["deps.get"], "assets.deploy": ["tailwind default --minify", "esbuild default --minify", "phx.digest"] ] end end
27.767857
98
0.581672
ff8e63d43a8a4953f1ceef342597e1381aa13a33
124
exs
Elixir
test/washer_dryer_test.exs
martijn/washer_dryer
619659e9672d3688035d8167d8d3d898dfc79a32
[ "Unlicense" ]
4
2017-01-07T17:46:37.000Z
2017-02-17T19:34:39.000Z
test/washer_dryer_test.exs
martijn/washer_dryer
619659e9672d3688035d8167d8d3d898dfc79a32
[ "Unlicense" ]
null
null
null
test/washer_dryer_test.exs
martijn/washer_dryer
619659e9672d3688035d8167d8d3d898dfc79a32
[ "Unlicense" ]
null
null
null
defmodule WasherDryerTest do use ExUnit.Case doctest WasherDryer test "the truth" do assert 1 + 1 == 2 end end
13.777778
28
0.693548
ff8ebc753d37db3cde92c6eae033ef071448ba31
1,154
exs
Elixir
test/cards/card_test.exs
mfeckie/pin_elixir
8b360c0d189109b2a71a34f7f80c78ce9bc9092c
[ "MIT" ]
6
2015-11-16T08:13:08.000Z
2016-05-26T04:00:58.000Z
test/cards/card_test.exs
mfeckie/pin_elixir
8b360c0d189109b2a71a34f7f80c78ce9bc9092c
[ "MIT" ]
null
null
null
test/cards/card_test.exs
mfeckie/pin_elixir
8b360c0d189109b2a71a34f7f80c78ce9bc9092c
[ "MIT" ]
null
null
null
defmodule PinElixirTest.Card do use ExUnit.Case use HyperMock alias PinElixir.Card alias PinElixirTest.Fixtures.Card, as: CardFixture import PinElixirTest.Utils test "Creates a card token from a credit card" do request = %HyperMock.Request{ headers: ["Content-Type": "application/json"], method: :post, uri: "https://test-api.pin.net.au/1/cards", body: CardFixture.create_request } response = response CardFixture.create, 201 HyperMock.intercept_with request, response do {:ok, card_create_response} = Card.create(card_map) assert card_create_response.card.token == "card_pIQJKMs93GsCc9vLSLevbw" end end test "Create card failure" do request = %HyperMock.Request{ headers: ["Content-Type": "application/json"], method: :post, uri: "https://test-api.pin.net.au/1/cards", body: CardFixture.create_request } response = response CardFixture.error, 422 HyperMock.intercept_with request, response do {:error, card_create_response} = Card.create(card_map) assert card_create_response.error == "invalid_resource" end end end
28.146341
77
0.697574
ff8ec06020b7fb4a652120243313311821e06781
9,293
ex
Elixir
lib/ex_clubhouse/api/epic.ex
pootsbook/exclubhouse
3b93cded0124e4e5df489db4f9262a560595bb8e
[ "MIT" ]
4
2020-03-17T00:42:10.000Z
2021-04-11T16:39:52.000Z
lib/ex_clubhouse/api/epic.ex
pootsbook/exclubhouse
3b93cded0124e4e5df489db4f9262a560595bb8e
[ "MIT" ]
7
2020-03-21T20:22:13.000Z
2021-12-30T16:32:07.000Z
lib/ex_clubhouse/api/epic.ex
pootsbook/exclubhouse
3b93cded0124e4e5df489db4f9262a560595bb8e
[ "MIT" ]
4
2020-03-25T18:34:49.000Z
2021-09-13T16:44:00.000Z
defmodule ExClubhouse.Api.Epic do @moduledoc """ Epic API """ alias ExClubhouse.Ops alias ExClubhouse.{Client, Session, Config} alias ExClubhouse.Parse.Parser alias ExClubhouse.Model.Input ############################################## ### Default config based utility functions ### ############################################## @doc """ Lists all epics ## Example iex> ExClubhouse.Api.Epic.list() {:ok, [%ExClubhouse.Model.EpicSlim{...}, ...]} """ @spec list :: {:ok, [ExClubhouse.Model.EpicSlim.t()]} | {:error, ExClubhouse.Error.t()} def list do Config.default() |> Session.from() |> list() end @doc """ Get a single Epic by id ## Example iex> ExClubhouse.Api.Epic.get(1) {:ok, %ExClubhouse.Model.Epic{...}} """ @spec get(integer) :: {:ok, nil | ExClubhouse.Model.Epic.t()} | {:error, ExClubhouse.Error.t()} def get(category_public_id) do Config.default() |> Session.from() |> get(category_public_id) end @doc """ Create an Epic ## Example iex> ExClubhouse.Api.Epic.create(ExClubhouse.Model.Input.Epic{...}) {:ok, %ExClubhouse.Model.Epic{...}} """ @spec create(ExClubhouse.Model.Input.Epic.t()) :: {:ok, ExClubhouse.Model.Epic.t()} | {:error, ExClubhouse.Error.t()} def create(%Input.Epic{} = epic_input) do Config.default() |> Session.from() |> create(epic_input) end @doc """ Update an Epic ## Example iex> ExClubhouse.Api.Epic.update(1, ExClubhouse.Model.Input.Epic{...}) {:ok, %ExClubhouse.Model.Epic{...}} """ @spec update(integer, ExClubhouse.Model.Input.Epic.t()) :: {:ok, ExClubhouse.Model.Epic.t()} | {:error, ExClubhouse.Error.t()} def update(epic_public_id, %Input.Epic{} = epic_input) do Config.default() |> Session.from() |> update(epic_public_id, epic_input) end @doc """ Delete an Epic ## Example iex> ExClubhouse.Api.Epic.delete(1) :ok """ @spec delete(integer) :: :ok | {:error, ExClubhouse.Error.t()} def delete(epic_public_id) do Config.default() |> Session.from() |> delete(epic_public_id) end @doc """ Lists all Epic comments ## Example iex> ExClubhouse.Api.Epic.comments_list(1) {:ok, [%ExClubhouse.Model.ThreadedComment{...}, ...]} """ @spec comments_list(integer) :: {:ok, [ExClubhouse.Model.ThreadedComment.t()]} | {:error, ExClubhouse.Error.t()} def comments_list(epic_public_id) do Config.default() |> Session.from() |> comments_list(epic_public_id) end @doc """ Create an Epic comment ## Example iex> ExClubhouse.Api.Epic.create(1, ExClubhouse.Model.Input.Comment{...}) {:ok, %ExClubhouse.Model.ThreadedComment{...}} """ @spec create_comment(integer(), ExClubhouse.Model.Input.Comment.t()) :: {:ok, ExClubhouse.Model.ThreadedComment.t()} | {:error, ExClubhouse.Error.t()} def create_comment(epic_public_id, %Input.Comment{} = comment_input) do Config.default() |> Session.from() |> create_comment(epic_public_id, comment_input) end @doc """ Get a single Epic by id ## Example iex> ExClubhouse.Api.Epic.get_comment(1, 2) {:ok, %ExClubhouse.Model.ThreadedComment{...}} """ @spec get_comment(integer(), integer()) :: {:ok, ExClubhouse.Model.ThreadedComment.t() | nil} | {:error, ExClubhouse.Error.t()} def get_comment(epic_public_id, comment_public_id) do Config.default() |> Session.from() |> get_comment(epic_public_id, comment_public_id) end @spec create_comment_comment(integer(), integer(), ExClubhouse.Model.Input.Comment.t()) :: {:ok, ExClubhouse.Model.ThreadedComment.t()} | {:error, ExClubhouse.Error.t()} def create_comment_comment(epic_public_id, comment_public_id, %Input.Comment{} = comment_input) do Config.default() |> Session.from() |> create_comment_comment(epic_public_id, comment_public_id, comment_input) end @doc """ Update an Epic comment ## Example iex> ExClubhouse.Api.Epic.update_comment(1, 2, ExClubhouse.Model.Input.UpdateComment{...}) {:ok, %ExClubhouse.Model.Epic{...}} """ @spec update_comment(integer(), integer(), ExClubhouse.Model.Input.UpdateComment.t()) :: {:ok, ExClubhouse.Model.ThreadedComment.t()} | {:error, ExClubhouse.Error.t()} def update_comment(epic_public_id, comment_public_id, %Input.UpdateComment{} = update_comment_input) do Config.default() |> Session.from() |> update_comment(epic_public_id, comment_public_id, update_comment_input) end @doc """ Delete a comment ## Example iex> ExClubhouse.Api.Epic.delete_comment(1, 2) :ok """ @spec delete_comment(integer, integer()) :: :ok | {:error, ExClubhouse.Error.t()} def delete_comment(epic_public_id, comment_public_id) do Config.default() |> Session.from() |> delete_comment(epic_public_id, comment_public_id) end @doc """ Lists all stories from an epic ## Example iex> ExClubhouse.Api.Epic.stories_list(1) {:ok, [%ExClubhouse.Model.EpicSlim{...}, ...]} """ @spec stories_list(integer()) :: {:ok, [ExClubhouse.Model.StorySlim.t()]} | {:error, ExClubhouse.Error.t()} def stories_list(epic_public_id) do Config.default() |> Session.from() |> stories_list(epic_public_id) end ################################## ### Session specific functions ### ################################## @spec list(ExClubhouse.Session.t()) :: {:ok, [ExClubhouse.Model.EpicSlim.t()]} | {:error, ExClubhouse.Error.t()} def list(%Session{} = sess) do Ops.Epic.list() |> Client.HTTP.request(sess) |> Parser.parse() end @spec get(ExClubhouse.Session.t(), integer()) :: {:ok, ExClubhouse.Model.Epic.t() | nil} | {:error, ExClubhouse.Error.t()} def get(%Session{} = session, epic_public_id) do Ops.Epic.get(epic_public_id) |> Client.HTTP.request(session) |> Parser.parse() end @spec create(ExClubhouse.Session.t(), ExClubhouse.Model.Input.Epic.t()) :: {:ok, ExClubhouse.Model.Epic.t()} | {:error, ExClubhouse.Error.t()} def create(%Session{} = session, %Input.Epic{} = epic_input) do Ops.Epic.create(epic_input) |> Client.HTTP.request(session) |> Parser.parse() end @spec update(ExClubhouse.Session.t(), integer(), ExClubhouse.Model.Input.Epic.t()) :: {:ok, ExClubhouse.Model.Epic.t()} | {:error, ExClubhouse.Error.t()} def update(%Session{} = session, epic_public_id, %Input.Epic{} = epic_input) do Ops.Epic.update(epic_public_id, epic_input) |> Client.HTTP.request(session) |> Parser.parse() end @spec delete(ExClubhouse.Session.t(), integer) :: :ok | {:error, ExClubhouse.Error.t()} def delete(%Session{} = session, epic_public_id) do Ops.Epic.delete(epic_public_id) |> Client.HTTP.request(session) |> Parser.parse() end @spec comments_list(ExClubhouse.Session.t(), integer()) :: {:ok, [ExClubhouse.Model.ThreadedComment.t()]} | {:error, ExClubhouse.Error.t()} def comments_list(%Session{} = sess, epic_public_id) do Ops.Epic.comments_list(epic_public_id) |> Client.HTTP.request(sess) |> Parser.parse() end @spec create_comment(ExClubhouse.Session.t(), integer(), ExClubhouse.Model.Input.Comment.t()) :: {:ok, ExClubhouse.Model.ThreadedComment.t()} | {:error, ExClubhouse.Error.t()} def create_comment(%Session{} = session, epic_public_id, %Input.Comment{} = comment_input) do Ops.Epic.create_comment(epic_public_id, comment_input) |> Client.HTTP.request(session) |> Parser.parse() end @spec get_comment(ExClubhouse.Session.t(), integer(), integer()) :: {:ok, ExClubhouse.Model.Epic.t() | nil} | {:error, ExClubhouse.Error.t()} def get_comment(%Session{} = session, epic_public_id, comment_public_id) do Ops.Epic.get_comment(epic_public_id, comment_public_id) |> Client.HTTP.request(session) |> Parser.parse() end @spec create_comment_comment(ExClubhouse.Session.t(), integer(), integer(), ExClubhouse.Model.Input.Comment.t()) :: {:ok, ExClubhouse.Model.ThreadedComment.t()} | {:error, ExClubhouse.Error.t()} def create_comment_comment(%Session{} = session, epic_public_id, comment_public_id, %Input.Comment{} = comment_input) do Ops.Epic.create_comment_comment(epic_public_id, comment_public_id, comment_input) |> Client.HTTP.request(session) |> Parser.parse() end @spec update_comment(ExClubhouse.Session.t(), integer(), integer(), ExClubhouse.Model.Input.UpdateComment.t()) :: {:ok, ExClubhouse.Model.Epic.t()} | {:error, ExClubhouse.Error.t()} def update_comment(%Session{} = session, epic_public_id, comment_public_id, %Input.UpdateComment{} = update_comment_input) do Ops.Epic.update_comment(epic_public_id, comment_public_id, update_comment_input) |> Client.HTTP.request(session) |> Parser.parse() end @spec delete_comment(ExClubhouse.Session.t(), integer, integer()) :: :ok | {:error, ExClubhouse.Error.t()} def delete_comment(%Session{} = session, epic_public_id, comment_public_id) do Ops.Epic.delete_comment(epic_public_id, comment_public_id) |> Client.HTTP.request(session) |> Parser.parse() end @spec stories_list(ExClubhouse.Session.t(), integer()) :: {:ok, [ExClubhouse.Model.StorySlim.t()]} | {:error, ExClubhouse.Error.t()} def stories_list(%Session{} = sess, epic_public_id) do Ops.Epic.stories_list(epic_public_id) |> Client.HTTP.request(sess) |> Parser.parse() end end
41.672646
143
0.670397
ff8ec2e114cbd49d970bd374130dfdb94ab9538d
3,841
ex
Elixir
lib/astarte_flow/blocks/json_mapper.ex
Annopaolo/astarte_flow
d6846917d2adb87127cb06ab6aeb11d6c0d10de8
[ "Apache-2.0" ]
11
2020-01-30T17:44:35.000Z
2022-01-13T19:17:21.000Z
lib/astarte_flow/blocks/json_mapper.ex
Annopaolo/astarte_flow
d6846917d2adb87127cb06ab6aeb11d6c0d10de8
[ "Apache-2.0" ]
100
2020-02-11T10:01:35.000Z
2022-02-17T10:39:35.000Z
lib/astarte_flow/blocks/json_mapper.ex
Annopaolo/astarte_flow
d6846917d2adb87127cb06ab6aeb11d6c0d10de8
[ "Apache-2.0" ]
7
2020-01-30T11:33:20.000Z
2021-05-03T09:48:41.000Z
# # This file is part of Astarte. # # Copyright 2019 Ispirata Srl # # 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. # defmodule Astarte.Flow.Blocks.JsonMapper do @moduledoc """ This is a map block that takes `data` from incoming `Message` and makes a Message having a JSON serialized payload. The `subtype` of the message is set to "application/json" and the `type` is `:binary`. """ use GenStage alias Astarte.Flow.Message require Logger defmodule Config do @moduledoc false defstruct [ :pretty, :template ] @type t() :: %__MODULE__{pretty: boolean(), template: any()} @type option() :: {:pretty, boolean()} | {:template, any()} @doc """ Initialize config from a keyword list. ## Options * `:pretty` - serialize the output to pretty format that is easier to read for humans. * `:template` - a JSONTemplate applied right before serialization. """ @spec from_keyword(list(option())) :: {:ok, t()} def from_keyword(kl) do pretty = Keyword.get(kl, :pretty, false) case Keyword.fetch(kl, :template) do {:ok, template} -> with {:ok, compiled_template} <- ExJSONTemplate.compile_template(template) do {:ok, %Config{ pretty: pretty, template: compiled_template }} end :error -> {:ok, %Config{ pretty: pretty }} end end end @doc """ Starts the `JsonMapper`. ## Options * `:pretty` - serialize the output to pretty format that is easier to read for humans. * `:template` - a JSONTemplate applied right before serialization. """ @spec start_link(list(Config.option())) :: GenServer.on_start() def start_link(opts) do GenStage.start_link(__MODULE__, opts) end @impl true def init(opts) do with {:ok, config} <- Config.from_keyword(opts) do {:producer_consumer, config, dispatcher: GenStage.BroadcastDispatcher} else {:error, reason} -> {:stop, reason} end end @impl true def handle_events(events, _from, %Config{} = config) do msgs_list = Enum.reduce(events, [], fn msg, acc -> case to_json(msg, config) do {:ok, msg} -> [msg | acc] any -> _ = Logger.warn("Error while mapping message to json.", message: msg, data: any) acc end end) |> Enum.reverse() {:noreply, msgs_list, config} end @doc """ Makes a new Message with JSON serialzed data, `:binary` type and "application/json" subtype. """ @spec to_json(Message.t(), Config.t()) :: {:ok, Message.t()} | {:error, any()} def to_json(%Message{} = msg, %Config{pretty: pretty, template: compiled_template}) do with {:ok, data} <- maybe_apply_template(msg, compiled_template), {:ok, encoded} <- Jason.encode(data, pretty: pretty) do {:ok, %Message{msg | type: :binary, subtype: "application/json", data: encoded}} end end defp maybe_apply_template(%Message{data: data, type: type} = _msg, _no_template = nil) do {:ok, Message.wrap_data(data, type)} end defp maybe_apply_template(msg, compiled_template) do input = %{"message" => Message.to_map(msg)} ExJSONTemplate.render(compiled_template, input) end end
28.664179
98
0.631086
ff8ecd3d68070c091135b269cb0a56b96184165e
4,436
ex
Elixir
lib/noven_web/controllers/user_auth.ex
ConnorRigby/noven
2c34953490585b77b6c7ae8dd772da5028f6a948
[ "Apache-2.0" ]
8
2020-09-10T09:18:17.000Z
2022-03-25T03:43:25.000Z
lib/noven_web/controllers/user_auth.ex
ConnorRigby/noven
2c34953490585b77b6c7ae8dd772da5028f6a948
[ "Apache-2.0" ]
null
null
null
lib/noven_web/controllers/user_auth.ex
ConnorRigby/noven
2c34953490585b77b6c7ae8dd772da5028f6a948
[ "Apache-2.0" ]
4
2020-12-28T06:13:51.000Z
2021-04-27T18:00:06.000Z
defmodule NovenWeb.UserAuth do import Plug.Conn import Phoenix.Controller alias Noven.Accounts alias NovenWeb.Router.Helpers, as: Routes # Make the remember me cookie valid for 60 days. # If you want bump or reduce this value, also change # the token expiry itself in UserToken. @max_age 60 * 60 * 24 * 60 @remember_me_cookie "user_remember_me" @remember_me_options [sign: true, max_age: @max_age] @doc """ Logs the user in. It renews the session ID and clears the whole session to avoid fixation attacks. See the renew_session function to customize this behaviour. It also sets a `:live_socket_id` key in the session, so LiveView sessions are identified and automatically disconnected on log out. The line can be safely removed if you are not using LiveView. """ def log_in_user(conn, user, params \\ %{}) do token = Accounts.generate_user_session_token(user) user_return_to = get_session(conn, :user_return_to) conn |> renew_session() |> put_session(:user_token, token) |> put_session(:live_socket_id, "users_sessions:#{Base.url_encode64(token)}") |> maybe_write_remember_me_cookie(token, params) |> redirect(to: user_return_to || signed_in_path(conn)) end defp maybe_write_remember_me_cookie(conn, token, %{"remember_me" => "true"}) do put_resp_cookie(conn, @remember_me_cookie, token, @remember_me_options) end defp maybe_write_remember_me_cookie(conn, _token, _params) do conn end # This function renews the session ID and erases the whole # session to avoid fixation attacks. If there is any data # in the session you may want to preserve after log in/log out, # you must explicitly fetch the session data before clearing # and then immediately set it after clearing, for example: # # defp renew_session(conn) do # preferred_locale = get_session(conn, :preferred_locale) # # conn # |> configure_session(renew: true) # |> clear_session() # |> put_session(:preferred_locale, preferred_locale) # end # defp renew_session(conn) do conn |> configure_session(renew: true) |> clear_session() end @doc """ Logs the user out. It clears all session data for safety. See renew_session. """ def log_out_user(conn) do user_token = get_session(conn, :user_token) user_token && Accounts.delete_session_token(user_token) if live_socket_id = get_session(conn, :live_socket_id) do NovenWeb.Endpoint.broadcast(live_socket_id, "disconnect", %{}) end conn |> renew_session() |> delete_resp_cookie(@remember_me_cookie) |> redirect(to: "/") end @doc """ Authenticates the user by looking into the session and remember me token. """ def fetch_current_user(conn, _opts) do {user_token, conn} = ensure_user_token(conn) user = user_token && Accounts.get_user_by_session_token(user_token) assign(conn, :current_user, user) end defp ensure_user_token(conn) do if user_token = get_session(conn, :user_token) do {user_token, conn} else conn = fetch_cookies(conn, signed: [@remember_me_cookie]) if user_token = conn.cookies[@remember_me_cookie] do {user_token, put_session(conn, :user_token, user_token)} else {nil, conn} end end end @doc """ Used for routes that require the user to not be authenticated. """ def redirect_if_user_is_authenticated(conn, _opts) do if conn.assigns[:current_user] do conn |> redirect(to: signed_in_path(conn)) |> halt() else conn end end @doc """ Used for routes that require the user to be authenticated. If you want to enforce the user e-mail is confirmed before they use the application at all, here would be a good place. """ def require_authenticated_user(conn, _opts) do if conn.assigns[:current_user] do conn |> put_session("current_user_id", conn.assigns[:current_user].id) else conn |> put_flash(:error, "You must log in to access this page.") |> maybe_store_return_to() |> redirect(to: Routes.user_session_path(conn, :new)) |> halt() end end defp maybe_store_return_to(%{method: "GET", request_path: request_path} = conn) do put_session(conn, :user_return_to, request_path) end defp maybe_store_return_to(conn), do: conn defp signed_in_path(_conn), do: "/" end
29.377483
84
0.694545
ff8ed624f4c573621b479829303489356f7219a4
1,312
exs
Elixir
config/config.exs
nayed/noaax
ef694a36b44a490a7c54341d5cd9ea8b3d53bbd0
[ "MIT" ]
null
null
null
config/config.exs
nayed/noaax
ef694a36b44a490a7c54341d5cd9ea8b3d53bbd0
[ "MIT" ]
null
null
null
config/config.exs
nayed/noaax
ef694a36b44a490a7c54341d5cd9ea8b3d53bbd0
[ "MIT" ]
null
null
null
# This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. use Mix.Config config :elixir, ansi_enabled: true config :noaax, noaa_url: "http://w1.weather.gov/xml/current_obs" config :noaax, state_station_url: "http://w1.weather.gov/xml/current_obs/seek.php?state=" # 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 :noaax, key: :value # # and access this configuration in your application as: # # Application.get_env(:noaax, :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"
35.459459
89
0.752287
ff8ed6d2a2b20c4b153c8ef873dbed217da1b326
968
exs
Elixir
test/Day2_test.exs
joaopgmaria/aoc-solutions-elixir
c5eb35b698b7cccd754876be600a73ee0fedbf0e
[ "MIT" ]
null
null
null
test/Day2_test.exs
joaopgmaria/aoc-solutions-elixir
c5eb35b698b7cccd754876be600a73ee0fedbf0e
[ "MIT" ]
null
null
null
test/Day2_test.exs
joaopgmaria/aoc-solutions-elixir
c5eb35b698b7cccd754876be600a73ee0fedbf0e
[ "MIT" ]
null
null
null
defmodule Day2Test do use ExUnit.Case doctest Day2 @tag day: 2 test "executes stop instruction" do program = [1,1,1,1,1,1,1,1,1] assert {:stop, program} == Day2.execute([99,0,0,0], program) end @tag day: 2 test "executes instruction 1" do assert {:ok, [2,1,1,1,1,1,1,1,1]} == Day2.execute([1,0,0,0], [1,1,1,1,1,1,1,1,1]) assert {:ok, [1,1,10,10,20,1,1,1,1]} == Day2.execute([1,2,3,4], [1,1,10,10,1,1,1,1,1]) end @tag day: 2 test "executes instruction 2" do assert {:ok, [1,1,1,1,1,1,1,1,1]} == Day2.execute([2,0,0,0], [1,1,1,1,1,1,1,1,1]) assert {:ok, [1,1,10,10,100,1,1,1,1]} == Day2.execute([2,2,3,4], [1,1,10,10,1,1,1,1,1]) end @tag day: 2 test "computes" do assert [2,0,0,0,99] == Day2.compute([1,0,0,0,99]) assert [2,3,0,6,99] == Day2.compute([2,3,0,3,99]) assert [2,4,4,5,99,9801] == Day2.compute([2,4,4,5,99,0]) assert [30,1,1,4,2,5,6,0,99] == Day2.compute([1,1,1,4,99,5,6,0,99]) end end
30.25
91
0.56095
ff8eddf4dfe5fbf0b750b55a09cfc5404d197eb7
2,382
exs
Elixir
test/file_utils_test.exs
bitchef/exocco
b0e93b01794d71c0458f52907b2f66b03e3f207e
[ "MIT" ]
null
null
null
test/file_utils_test.exs
bitchef/exocco
b0e93b01794d71c0458f52907b2f66b03e3f207e
[ "MIT" ]
1
2016-02-09T12:27:42.000Z
2016-02-09T12:27:42.000Z
test/file_utils_test.exs
bitchef/exocco
b0e93b01794d71c0458f52907b2f66b03e3f207e
[ "MIT" ]
null
null
null
defmodule FileUtilsTest do use ExUnit.Case, async: true import DirHelpers import PathHelpers import :hamcrest, only: [ assert_that: 2 ] import :hamcrest_matchers setup_all do :ok = setupDirTree(fixture_path) on_exit fn -> deleteDirTree(fixture_path) end :ok end test "FileUtils.list_files/1 returns an empty list if given a non-existant file or directory name" do result = FileUtils.list_files( "dummy" ) assert_that result, is [] end test "FileUtils.list_files/1 returns an empty list if given the name of an empty directory" do result = FileUtils.list_files( fixture_path("dir1") ) assert_that result, is [] end test "FileUtils.list_files/1 returns back the filename for a given file" do result = FileUtils.list_files( fixture_path("file1.ex") ) assert_that result, is [fixture_path("file1.ex")] end test "FileUtils.list_files/1 returns a list of files contained in a given directory" do result = FileUtils.list_files( fixture_path ) assert_that result , has_length 2 assert_that result, contains_member fixture_path("file1.ex") assert_that result, contains_member fixture_path("file2.ex") end test "FileUtils.list_files_r/1 returns an empty list if given a non-existant file or directory name" do result = FileUtils.list_files_r( ["dummy"] ) assert_that result, is [] end test "FileUtils.list_files_r/1 returns an empty list if given the name of an empty directory" do result = FileUtils.list_files_r( fixture_path("dir1") ) assert_that result, is [] end test "FileUtils.list_files_r/1 returns back the filename of a given file" do result = FileUtils.list_files_r( fixture_path("file1.ex") ) assert_that result, is [fixture_path("file1.ex")] end test "FileUtils.list_files_r/1 returns a list of files contained in a given directory and its subdirectories" do result = FileUtils.list_files_r( fixture_path ) assert_that result , has_length 5 assert_that result, contains_member fixture_path("file1.ex") assert_that result, contains_member fixture_path("file2.ex") assert_that result, contains_member fixture_path("dir2/file3.ex") assert_that result, contains_member fixture_path("dir2/file4.ex") assert_that result, contains_member fixture_path("dir2/subdir1/file5.ex") end end
37.21875
114
0.730898
ff8ee55c7d1d5cb9ec79595b63d3b0f18ed12bd7
9,527
ex
Elixir
clients/docs/lib/google_api/docs/v1/model/paragraph_style.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/docs/lib/google_api/docs/v1/model/paragraph_style.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/docs/lib/google_api/docs/v1/model/paragraph_style.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.Docs.V1.Model.ParagraphStyle do @moduledoc """ Styles that apply to a whole paragraph. Inherited paragraph styles are represented as unset fields in this message. A paragraph style's parent depends on where the paragraph style is defined: * The ParagraphStyle on a Paragraph inherits from the paragraph's corresponding named style type. * The ParagraphStyle on a named style inherits from the normal text named style. * The ParagraphStyle of the normal text named style inherits from the default paragraph style in the Docs editor. * The ParagraphStyle on a Paragraph element that is contained in a table may inherit its paragraph style from the table style. If the paragraph style does not inherit from a parent, unsetting fields will revert the style to a value matching the defaults in the Docs editor. ## Attributes * `alignment` (*type:* `String.t`, *default:* `nil`) - The text alignment for this paragraph. * `avoidWidowAndOrphan` (*type:* `boolean()`, *default:* `nil`) - Whether to avoid widows and orphans for the paragraph. If unset, the value is inherited from the parent. * `borderBetween` (*type:* `GoogleApi.Docs.V1.Model.ParagraphBorder.t`, *default:* `nil`) - The border between this paragraph and the next and previous paragraphs. If unset, the value is inherited from the parent. The between border is rendered when the adjacent paragraph has the same border and indent properties. Paragraph borders cannot be partially updated. When making changes to a paragraph border the new border must be specified in its entirety. * `borderBottom` (*type:* `GoogleApi.Docs.V1.Model.ParagraphBorder.t`, *default:* `nil`) - The border at the bottom of this paragraph. If unset, the value is inherited from the parent. The bottom border is rendered when the paragraph below has different border and indent properties. Paragraph borders cannot be partially updated. When making changes to a paragraph border the new border must be specified in its entirety. * `borderLeft` (*type:* `GoogleApi.Docs.V1.Model.ParagraphBorder.t`, *default:* `nil`) - The border to the left of this paragraph. If unset, the value is inherited from the parent. Paragraph borders cannot be partially updated. When making changes to a paragraph border the new border must be specified in its entirety. * `borderRight` (*type:* `GoogleApi.Docs.V1.Model.ParagraphBorder.t`, *default:* `nil`) - The border to the right of this paragraph. If unset, the value is inherited from the parent. Paragraph borders cannot be partially updated. When making changes to a paragraph border the new border must be specified in its entirety. * `borderTop` (*type:* `GoogleApi.Docs.V1.Model.ParagraphBorder.t`, *default:* `nil`) - The border at the top of this paragraph. If unset, the value is inherited from the parent. The top border is rendered when the paragraph above has different border and indent properties. Paragraph borders cannot be partially updated. When making changes to a paragraph border the new border must be specified in its entirety. * `direction` (*type:* `String.t`, *default:* `nil`) - The text direction of this paragraph. If unset, the value defaults to LEFT_TO_RIGHT since paragraph direction is not inherited. * `headingId` (*type:* `String.t`, *default:* `nil`) - The heading ID of the paragraph. If empty, then this paragraph is not a heading. This property is read-only. * `indentEnd` (*type:* `GoogleApi.Docs.V1.Model.Dimension.t`, *default:* `nil`) - The amount of indentation for the paragraph on the side that corresponds to the end of the text, based on the current paragraph direction. If unset, the value is inherited from the parent. * `indentFirstLine` (*type:* `GoogleApi.Docs.V1.Model.Dimension.t`, *default:* `nil`) - The amount of indentation for the first line of the paragraph. If unset, the value is inherited from the parent. * `indentStart` (*type:* `GoogleApi.Docs.V1.Model.Dimension.t`, *default:* `nil`) - The amount of indentation for the paragraph on the side that corresponds to the start of the text, based on the current paragraph direction. If unset, the value is inherited from the parent. * `keepLinesTogether` (*type:* `boolean()`, *default:* `nil`) - Whether all lines of the paragraph should be laid out on the same page or column if possible. If unset, the value is inherited from the parent. * `keepWithNext` (*type:* `boolean()`, *default:* `nil`) - Whether at least a part of this paragraph should be laid out on the same page or column as the next paragraph if possible. If unset, the value is inherited from the parent. * `lineSpacing` (*type:* `number()`, *default:* `nil`) - The amount of space between lines, as a percentage of normal, where normal is represented as 100.0. If unset, the value is inherited from the parent. * `namedStyleType` (*type:* `String.t`, *default:* `nil`) - The named style type of the paragraph. Since updating the named style type affects other properties within ParagraphStyle, the named style type is applied before the other properties are updated. * `shading` (*type:* `GoogleApi.Docs.V1.Model.Shading.t`, *default:* `nil`) - The shading of the paragraph. If unset, the value is inherited from the parent. * `spaceAbove` (*type:* `GoogleApi.Docs.V1.Model.Dimension.t`, *default:* `nil`) - The amount of extra space above the paragraph. If unset, the value is inherited from the parent. * `spaceBelow` (*type:* `GoogleApi.Docs.V1.Model.Dimension.t`, *default:* `nil`) - The amount of extra space below the paragraph. If unset, the value is inherited from the parent. * `spacingMode` (*type:* `String.t`, *default:* `nil`) - The spacing mode for the paragraph. * `tabStops` (*type:* `list(GoogleApi.Docs.V1.Model.TabStop.t)`, *default:* `nil`) - A list of the tab stops for this paragraph. The list of tab stops is not inherited. This property is read-only. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :alignment => String.t(), :avoidWidowAndOrphan => boolean(), :borderBetween => GoogleApi.Docs.V1.Model.ParagraphBorder.t(), :borderBottom => GoogleApi.Docs.V1.Model.ParagraphBorder.t(), :borderLeft => GoogleApi.Docs.V1.Model.ParagraphBorder.t(), :borderRight => GoogleApi.Docs.V1.Model.ParagraphBorder.t(), :borderTop => GoogleApi.Docs.V1.Model.ParagraphBorder.t(), :direction => String.t(), :headingId => String.t(), :indentEnd => GoogleApi.Docs.V1.Model.Dimension.t(), :indentFirstLine => GoogleApi.Docs.V1.Model.Dimension.t(), :indentStart => GoogleApi.Docs.V1.Model.Dimension.t(), :keepLinesTogether => boolean(), :keepWithNext => boolean(), :lineSpacing => number(), :namedStyleType => String.t(), :shading => GoogleApi.Docs.V1.Model.Shading.t(), :spaceAbove => GoogleApi.Docs.V1.Model.Dimension.t(), :spaceBelow => GoogleApi.Docs.V1.Model.Dimension.t(), :spacingMode => String.t(), :tabStops => list(GoogleApi.Docs.V1.Model.TabStop.t()) } field(:alignment) field(:avoidWidowAndOrphan) field(:borderBetween, as: GoogleApi.Docs.V1.Model.ParagraphBorder) field(:borderBottom, as: GoogleApi.Docs.V1.Model.ParagraphBorder) field(:borderLeft, as: GoogleApi.Docs.V1.Model.ParagraphBorder) field(:borderRight, as: GoogleApi.Docs.V1.Model.ParagraphBorder) field(:borderTop, as: GoogleApi.Docs.V1.Model.ParagraphBorder) field(:direction) field(:headingId) field(:indentEnd, as: GoogleApi.Docs.V1.Model.Dimension) field(:indentFirstLine, as: GoogleApi.Docs.V1.Model.Dimension) field(:indentStart, as: GoogleApi.Docs.V1.Model.Dimension) field(:keepLinesTogether) field(:keepWithNext) field(:lineSpacing) field(:namedStyleType) field(:shading, as: GoogleApi.Docs.V1.Model.Shading) field(:spaceAbove, as: GoogleApi.Docs.V1.Model.Dimension) field(:spaceBelow, as: GoogleApi.Docs.V1.Model.Dimension) field(:spacingMode) field(:tabStops, as: GoogleApi.Docs.V1.Model.TabStop, type: :list) end defimpl Poison.Decoder, for: GoogleApi.Docs.V1.Model.ParagraphStyle do def decode(value, options) do GoogleApi.Docs.V1.Model.ParagraphStyle.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Docs.V1.Model.ParagraphStyle do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
52.346154
169
0.704314
ff8ef9b70485566a8d3c4e76031811942683d14c
653
exs
Elixir
test/unit/extra/atom_test.exs
dbrody/playwright-elixir
48611c08dbdb8e36aa4dd8aa2d97a4014b753815
[ "MIT" ]
30
2021-06-01T16:59:35.000Z
2022-03-25T16:56:19.000Z
test/unit/extra/atom_test.exs
dbrody/playwright-elixir
48611c08dbdb8e36aa4dd8aa2d97a4014b753815
[ "MIT" ]
35
2021-06-10T17:05:31.000Z
2022-02-11T22:30:36.000Z
test/unit/extra/atom_test.exs
dbrody/playwright-elixir
48611c08dbdb8e36aa4dd8aa2d97a4014b753815
[ "MIT" ]
4
2021-08-13T20:38:18.000Z
2022-01-31T04:32:35.000Z
defmodule Playwright.Extra.AtomTest do use ExUnit.Case, async: true alias Playwright.Extra describe "from_string" do test "string", do: assert(Extra.Atom.from_string("banana") == :banana) test "already an atom", do: assert(Extra.Atom.from_string(:banana) == :banana) test "nil", do: assert_raise(ArgumentError, fn -> Extra.Atom.from_string(nil) end) end describe "to_string" do test "atom", do: assert(Extra.Atom.to_string(:banana) == "banana") test "already a string", do: assert(Extra.Atom.to_string("banana") == "banana") test "nil", do: assert_raise(ArgumentError, fn -> Extra.Atom.to_string(nil) end) end end
36.277778
86
0.698315
ff8f16bd2880375d97b73dabf5d796dae523ea60
1,866
ex
Elixir
test/process_managers/support/example_process_manager.ex
jwilger/commanded
2d9950fd3ce76a23a3c410c99857b812f5705d66
[ "MIT" ]
1,220
2017-10-31T10:56:40.000Z
2022-03-31T17:40:19.000Z
test/process_managers/support/example_process_manager.ex
jwilger/commanded
2d9950fd3ce76a23a3c410c99857b812f5705d66
[ "MIT" ]
294
2017-11-03T10:33:41.000Z
2022-03-24T08:36:42.000Z
test/process_managers/support/example_process_manager.ex
jwilger/commanded
2d9950fd3ce76a23a3c410c99857b812f5705d66
[ "MIT" ]
208
2017-11-03T10:56:47.000Z
2022-03-14T05:49:38.000Z
defmodule Commanded.ProcessManagers.ExampleProcessManager do @moduledoc false alias Commanded.ProcessManagers.ExampleApp alias Commanded.ProcessManagers.ExampleProcessManager alias Commanded.ProcessManagers.ExampleAggregate.Commands.Stop alias Commanded.ProcessManagers.ExampleAggregate.Events.{ Errored, Interested, Paused, Raised, Started, Stopped } use Commanded.ProcessManagers.ProcessManager, application: ExampleApp, name: "ExampleProcessManager" @derive Jason.Encoder defstruct [:status, items: []] def interested?(%Started{aggregate_uuid: aggregate_uuid}), do: {:start, aggregate_uuid} def interested?(%Interested{aggregate_uuid: aggregate_uuid}), do: {:continue, aggregate_uuid} def interested?(%Paused{aggregate_uuid: aggregate_uuid}), do: {:continue, aggregate_uuid} def interested?(%Errored{aggregate_uuid: aggregate_uuid}), do: {:continue, aggregate_uuid} def interested?(%Raised{aggregate_uuid: aggregate_uuid}), do: {:continue, aggregate_uuid} def interested?(%Stopped{aggregate_uuid: aggregate_uuid}), do: {:stop, aggregate_uuid} def handle(%ExampleProcessManager{}, %Interested{index: 10, aggregate_uuid: aggregate_uuid}) do %Stop{aggregate_uuid: aggregate_uuid} end # Simulate a "stuck" process def handle(%ExampleProcessManager{}, %Paused{}) do :timer.sleep(:infinity) end def handle(%ExampleProcessManager{}, %Errored{}), do: {:error, :failed} def handle(%ExampleProcessManager{}, %Raised{}), do: raise("failed") # State mutators def apply(%ExampleProcessManager{} = process_manager, %Started{}) do %ExampleProcessManager{process_manager | status: :started} end def apply(%ExampleProcessManager{items: items} = process_manager, %Interested{index: index}) do %ExampleProcessManager{process_manager | items: items ++ [index]} end end
34.555556
97
0.751876
ff8f3fd72ed8c131f3e34c844ebd027ce3cc6149
2,344
exs
Elixir
lib/elixir/test/elixir/test_helper.exs
wstrinz/elixir
1048b34d6c816f8e5dbd4fdbaaf9baa41b4f0d95
[ "Apache-2.0" ]
2
2018-11-15T06:38:14.000Z
2018-11-17T18:03:14.000Z
lib/elixir/test/elixir/test_helper.exs
wstrinz/elixir
1048b34d6c816f8e5dbd4fdbaaf9baa41b4f0d95
[ "Apache-2.0" ]
1
2018-09-10T23:36:45.000Z
2018-09-10T23:36:45.000Z
lib/elixir/test/elixir/test_helper.exs
wstrinz/elixir
1048b34d6c816f8e5dbd4fdbaaf9baa41b4f0d95
[ "Apache-2.0" ]
1
2021-09-30T01:21:02.000Z
2021-09-30T01:21:02.000Z
# Beam files compiled on demand path = Path.expand("../../tmp/beams", __DIR__) File.rm_rf!(path) File.mkdir_p!(path) Code.prepend_path(path) Code.compiler_options(debug_info: true) defmodule PathHelpers do def fixture_path() do Path.expand("fixtures", __DIR__) end def tmp_path() do Path.expand("../../tmp", __DIR__) end def fixture_path(extra) do Path.join(fixture_path(), extra) end def tmp_path(extra) do Path.join(tmp_path(), extra) end def elixir(args) do runcmd(elixir_executable(), args) end def elixir_executable do executable_path("elixir") end def elixirc(args) do runcmd(elixirc_executable(), args) end def elixirc_executable do executable_path("elixirc") end def write_beam({:module, name, bin, _} = res) do File.mkdir_p!(unquote(path)) beam_path = Path.join(unquote(path), Atom.to_string(name) <> ".beam") File.write!(beam_path, bin) res end defp runcmd(executable, args) do :os.cmd( :binary.bin_to_list( "#{executable} #{IO.chardata_to_string(args)}#{redirect_std_err_on_win()}" ) ) end defp executable_path(name) do Path.expand("../../../../bin/#{name}#{executable_extension()}", __DIR__) end if match?({:win32, _}, :os.type()) do def windows?, do: true def executable_extension, do: ".bat" def redirect_std_err_on_win, do: " 2>&1" else def windows?, do: false def executable_extension, do: "" def redirect_std_err_on_win, do: "" end end defmodule CodeFormatterHelpers do defmacro assert_same(good, opts \\ []) do quote bind_quoted: [good: good, opts: opts] do assert IO.iodata_to_binary(Code.format_string!(good, opts)) == String.trim(good) end end defmacro assert_format(bad, good, opts \\ []) do quote bind_quoted: [bad: bad, good: good, opts: opts] do result = String.trim(good) assert IO.iodata_to_binary(Code.format_string!(bad, opts)) == result assert IO.iodata_to_binary(Code.format_string!(good, opts)) == result end end end assert_timeout = String.to_integer(System.get_env("ELIXIR_ASSERT_TIMEOUT") || "500") exclude = if PathHelpers.windows?(), do: [unix: true], else: [windows: true] ExUnit.start( trace: "--trace" in System.argv(), assert_receive_timeout: assert_timeout, exclude: exclude )
24.416667
86
0.673635
ff8f40ca0937c654a7d5ea9296c039bbc4862ec6
301
ex
Elixir
src/lib/changelog_web/views/live_view.ex
thenets/docker-chocoquest
856fa5ff41a5831ed67b1ef865cd8951df5af023
[ "MIT" ]
null
null
null
src/lib/changelog_web/views/live_view.ex
thenets/docker-chocoquest
856fa5ff41a5831ed67b1ef865cd8951df5af023
[ "MIT" ]
null
null
null
src/lib/changelog_web/views/live_view.ex
thenets/docker-chocoquest
856fa5ff41a5831ed67b1ef865cd8951df5af023
[ "MIT" ]
null
null
null
defmodule ChangelogWeb.LiveView do use ChangelogWeb, :public_view alias Changelog.Wavestreamer alias ChangelogWeb.{EpisodeView, PersonView, PodcastView} def host_or_guest(episode, person) do if Enum.member?(episode.hosts, person) do "Host" else "Guest" end end end
20.066667
59
0.72093
ff8f5e32617f97e56b2eaaae03845dc6d2776b5b
577
exs
Elixir
mix.exs
LuizFerK/Freelancex
baa35cb02920a95e207e9dc246b4e97d7ad6c10e
[ "MIT" ]
null
null
null
mix.exs
LuizFerK/Freelancex
baa35cb02920a95e207e9dc246b4e97d7ad6c10e
[ "MIT" ]
null
null
null
mix.exs
LuizFerK/Freelancex
baa35cb02920a95e207e9dc246b4e97d7ad6c10e
[ "MIT" ]
null
null
null
defmodule GenReport.MixProject do use Mix.Project def project do [ app: :gen_report, version: "0.1.0", elixir: "~> 1.11", start_permanent: Mix.env() == :prod, deps: deps() ] end # Run "mix help compile.app" to learn about applications. def application do [ extra_applications: [:logger] ] end # Run "mix help deps" to learn about dependencies. defp deps do [ # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} ] end end
19.896552
87
0.580589
ff8f69b48f6cab0e22a5d04c8cc8e95f4789cb41
767
exs
Elixir
apps/engine/test/engine/ethereum/event/listener/storage_test.exs
omgnetwork/omg-childchain-v2
31cc9cf9e42718fc3b9bd6668f24a627cac80b4f
[ "Apache-2.0" ]
4
2020-11-30T17:38:57.000Z
2021-01-23T21:29:41.000Z
apps/engine/test/engine/ethereum/event/listener/storage_test.exs
omgnetwork/omg-childchain-v2
31cc9cf9e42718fc3b9bd6668f24a627cac80b4f
[ "Apache-2.0" ]
24
2020-11-30T17:32:48.000Z
2021-02-22T06:25:22.000Z
apps/engine/test/engine/ethereum/event/listener/storage_test.exs
omgnetwork/omg-childchain-v2
31cc9cf9e42718fc3b9bd6668f24a627cac80b4f
[ "Apache-2.0" ]
null
null
null
defmodule Engine.Ethereum.Event.Listener.StorageTest do use ExUnit.Case, async: true alias Engine.Ethereum.Event.Listener.Storage describe "listener_chickin/0/1" do test "that the ets table is a set", %{test: name} do Storage.listener_checkin(name) info = :ets.info(name) assert Keyword.fetch!(info, :named_table) == true assert Keyword.fetch!(info, :type) == :set end end describe "get_local_synced_height/2, update_synced_height/3" do test "can insert and lookup", %{test: name} do Storage.listener_checkin(name) :ok = Storage.update_synced_height(:yolo, 42, name) 42 = Storage.get_local_synced_height(:yolo, name) 0 = Storage.get_local_synced_height(:does_not_exist, name) end end end
31.958333
65
0.701434
ff8fbe760708ce1b8e9150c3754d169530932e31
738
ex
Elixir
server/lib/domsegserver/datasets/segment_type.ex
arpieb/domseg
0c7165d69181e59902730c6e7ac41e8e849edd70
[ "Apache-2.0" ]
null
null
null
server/lib/domsegserver/datasets/segment_type.ex
arpieb/domseg
0c7165d69181e59902730c6e7ac41e8e849edd70
[ "Apache-2.0" ]
9
2021-12-09T18:19:21.000Z
2022-01-09T03:45:33.000Z
server/lib/domsegserver/datasets/segment_type.ex
arpieb/domseg
0c7165d69181e59902730c6e7ac41e8e849edd70
[ "Apache-2.0" ]
null
null
null
defmodule DOMSegServer.Datasets.SegmentType do use Ecto.Schema import Ecto.Changeset embedded_schema do field :name, :string field :color, :string field :temp_id, :string, virtual: true, default: nil field :delete, :boolean, virtual: true, default: false end def changeset(segtype, attrs \\ %{}) do fields = [:name, :color, :delete] segtype |> cast(attrs, fields) |> validate_required(fields -- [:delete]) |> maybe_mark_for_deletion() end defp maybe_mark_for_deletion(%{data: %{id: nil}} = changeset), do: changeset defp maybe_mark_for_deletion(changeset) do if get_change(changeset, :delete) do %{changeset | action: :delete} else changeset end end end
23.0625
78
0.670732
ff8fbf2fcf54830915e51a5cb158a0a055dac271
935
ex
Elixir
back/lib/zx_web/views/partner_view.ex
giovanecosta/zebra-xantis
92e5937d51c44e75544bb539f5d95f6b0cc61b94
[ "MIT" ]
null
null
null
back/lib/zx_web/views/partner_view.ex
giovanecosta/zebra-xantis
92e5937d51c44e75544bb539f5d95f6b0cc61b94
[ "MIT" ]
null
null
null
back/lib/zx_web/views/partner_view.ex
giovanecosta/zebra-xantis
92e5937d51c44e75544bb539f5d95f6b0cc61b94
[ "MIT" ]
1
2019-08-29T17:37:51.000Z
2019-08-29T17:37:51.000Z
defmodule ZxWeb.PartnerView do use ZxWeb, :view alias ZxWeb.PartnerView def render("index.json", %{partners: partners}) do %{data: render_many(partners, PartnerView, "partner.json")} end def render("show.json", %{partner: partner}) do %{data: render_one(partner, PartnerView, "partner.json")} end def render("partner.json", %{partner: partner}) do %{id: partner.id, tradingName: partner.trading_name, ownerName: partner.owner_name, document: partner.document, distance: partner.distance, coverageArea: %{ type: "MultiPolygon", coordinates: Enum.map(partner.coverage_area.coordinates, fn sublist -> Enum.map(sublist, fn subsublist -> Enum.map(subsublist, &Tuple.to_list/1) end) end) }, address: %{ type: "Point", coordinates: Tuple.to_list(partner.address.coordinates) } } end end
27.5
78
0.631016
ff8fcd1c6f845d9b717cb9c1291f472f4893ed7c
4,219
ex
Elixir
lib/couchjitsu_track/activity_history.ex
taylonr/couchjitsu_track
0a31c450ac734f9d8b69849cb766de0e99f178c4
[ "MIT" ]
null
null
null
lib/couchjitsu_track/activity_history.ex
taylonr/couchjitsu_track
0a31c450ac734f9d8b69849cb766de0e99f178c4
[ "MIT" ]
null
null
null
lib/couchjitsu_track/activity_history.ex
taylonr/couchjitsu_track
0a31c450ac734f9d8b69849cb766de0e99f178c4
[ "MIT" ]
null
null
null
defmodule CouchjitsuTrack.ActivityHistory do @moduledoc """ A collection of queries for activities. """ import Ecto.Query alias CouchjitsuTrack.Record alias CouchjitsuTrack.Activity @doc """ Gets all activities for a specified user id. Will return a list of %{date, name, time, note, activity_id} """ def get_history_for_user(user_id) do query = from r in Record, join: a in Activity, on: r.activity_id == a.id, where: a.user_id == ^user_id, select: %{date: r.date, name: a.name, time: r.duration, note: r.note, activity_id: a.id, id: r.id }, order_by: [desc: r.date] CouchjitsuTrack.Repo.all(query) end def get_history_for_user_and_span(user_id, number_of_months) do interval =%Postgrex.Interval{months: number_of_months} query = from r in Record, join: a in Activity, on: r.activity_id == a.id, where: a.user_id == ^user_id and fragment("? > now() - ? * Interval '1 month'", r.date, ^number_of_months), select: %{date: r.date, name: a.name, time: r.duration, default_duration: a.default_duration, note: r.note, activity_id: a.id, id: r.id }, order_by: [desc: r.date] CouchjitsuTrack.Repo.all(query) end @doc """ Gets the history for a specific date and user. This can be used to find what activities a user did on a specific day. """ def get_history_for_user_and_date(user_id, date) do query = from r in Record, join: a in Activity, on: r.activity_id == a.id, where: a.user_id == ^user_id and r.date == ^date, select: %{date: r.date, name: a.name, time: r.duration, note: r.note, activity_id: a.id, id: r.id }, order_by: fragment("lower(?)", a.name) CouchjitsuTrack.Repo.all(query) end @doc """ Gets all the history for a specific activity id. Will return a list of activities grouped by month & year, and a sum of all the activities for that month. """ def get_history_for_id(activity_id) do query = from r in Record, where: r.activity_id == ^activity_id, select: %{month: fragment("date_part('month', ?)::integer", r.date), year: fragment("date_part('year', ?)::integer", r.date), hours: sum(r.duration) }, group_by: fragment("date_part('month', ?), date_part('year', ?)", r.date, r.date), order_by: fragment("date_part('year', ?), date_part('month', ?)", r.date, r.date) CouchjitsuTrack.Repo.all(query) end @doc """ Takes a list of `Activity` structs, finds the max and min values and sets them on the list """ def set_statistics(activities) do max_val = Enum.max_by(activities, &get_hours/1) min_val = Enum.min_by(activities, &get_hours/1) Enum.map(activities, fn(a) -> a |> Map.put_new(:max, a.hours == max_val.hours) |> Map.put_new(:min, a.hours == min_val.hours) end) end defp get_hours(activity) do activity.hours end @doc """ Gets the name for the specified activity id """ def get_name(activity_id) do CouchjitsuTrack.Repo.get(Activity, activity_id).name end @doc """ Gets a distinct list of dates for a specified user id. """ def get_dates_for_user(user_id) do query = from r in Record, join: a in Activity, on: r.activity_id == a.id, where: a.user_id == ^user_id, select: r.date, distinct: true, order_by: [desc: r.date] CouchjitsuTrack.Repo.all(query) end end
34.024194
122
0.529035
ff8fcf2c7aa06afe46230f13ae7b4d4a86fdd20d
6,665
ex
Elixir
lib/confispex/schema.ex
prosapient/confispex
340d3dd8fe9bd5673bb07ccb5da23298c293898c
[ "Apache-2.0" ]
7
2021-05-12T11:03:47.000Z
2021-12-16T08:26:28.000Z
lib/confispex/schema.ex
prosapient/confispex
340d3dd8fe9bd5673bb07ccb5da23298c293898c
[ "Apache-2.0" ]
2
2021-11-20T23:09:33.000Z
2021-12-03T22:09:46.000Z
lib/confispex/schema.ex
prosapient/confispex
340d3dd8fe9bd5673bb07ccb5da23298c293898c
[ "Apache-2.0" ]
2
2021-07-19T09:40:39.000Z
2021-11-20T20:09:02.000Z
defmodule Confispex.Schema do @moduledoc """ ## Example defmodule MyApp.RuntimeConfigSchema do import Confispex.Schema @behaviour Confispex.Schema alias Confispex.Type defvariables(%{ "RUNTIME_CONFIG_REPORT" => %{ cast: {Type.Enum, values: ["disabled", "detailed", "brief"]}, default: "disabled", groups: [:misc] }, "TZDATA_AUTOUPDATE_ENABLED" => %{ doc: "Autoupdate timezones from IANA Time Zone Database", cast: Type.Boolean, default: "false", groups: [:base], context: [env: [:dev, :prod]] }, "LOG_LEVEL" => %{ cast: {Type.Enum, values: [ "emergency", "alert", "critical", "error", "warning", "notice", "info", "debug", "none" ]}, default_lazy: fn %{env: :test} -> "warning" %{env: :dev} -> "debug" %{env: :prod} -> "debug" end, groups: [:base] }, "DATABASE_URL" => %{ aliases: ["DB_URL"], doc: "Full DB URL", cast: Type.URL, context: [env: [:prod]], groups: [:primary_db], required: [:primary_db] }, "DATABASE_POOL_SIZE" => %{ aliases: ["DB_POOL_SIZE", "POOL_SIZE"], cast: {Type.Integer, scope: :positive}, default: "10", context: [env: [:prod]], groups: [:primary_db] } }) end """ @type variable_name :: term() @typedoc """ A spec for a single variable * `:cast` - describes how value should be cast. * `:groups` - a list of groups which are affected by variable. * `:doc` - a description about variable, shown in generated `.envrc` file. * `:default` - default value. Must be set in raw format. Raw format was choosen to populate `.envrc` file with default values. * `:defaut_lazy` - default value based on given context. Useful when default value must be different for different environments. Cannot be used alongside with `:default` parameter. Return `nil` if default value should be ignored. * `:template_value_generator` - a function that is used in `confispex.gen.envrc_template` mix task to generate a value for a variable. Such value will always be uncommented even if it is not required. This is useful for variables like "SECRET_KEY_BASE" which should be generated only once. * `:required` - a list of groups or a function that returns a list of groups in which variable is required. When all required variables of the group are cast successfully, then the group is considered as ready for using. * `:context` - specifies context in which variable is used. * `:aliases` - a list of alias names. """ @type variable_spec :: %{ required(:cast) => module() | {module(), opts :: keyword()}, required(:groups) => [atom()], optional(:doc) => String.t(), optional(:default) => String.t(), optional(:default_lazy) => (Confispex.context() -> String.t() | nil), optional(:template_value_generator) => (() -> String.t()), optional(:required) => [atom()] | (Confispex.context() -> [atom()]), optional(:context) => [{atom(), atom()}], optional(:aliases) => [variable_name()] } @callback variables_schema() :: %{variable_name() => variable_spec()} @doc """ A helper which performs basic validations of the input schema and then defines `variables_schema/0` function. """ defmacro defvariables(variables) do quote do validate_variables!(unquote(variables)) @impl unquote(__MODULE__) def variables_schema do unquote(variables) end end end @doc false def validate_variables!(variables) when is_map(variables) do Enum.each(variables, fn {variable_name, spec} -> assert(spec[:cast], "param :cast is required", variable_name) assert(spec[:groups], "param :groups is required", variable_name) assert(is_list(spec[:groups]), "param :groups must be a list", variable_name) assert( is_nil(spec[:default]) or is_nil(spec[:default_lazy]), "param :default cannot be used with :default_lazy", variable_name ) assert( is_nil(spec[:required]) or is_nil(spec[:default]), "param :default cannot be used with :required", variable_name ) assert( not Map.has_key?(spec, :required) or is_list(spec.required) or is_function(spec.required, 1), "param :required must be a list or function with arity 1", variable_name ) assert( not Map.has_key?(spec, :aliases) or is_list(spec.aliases), "param :aliases must be a list", variable_name ) assert( not Map.has_key?(spec, :template_value_generator) or is_function(spec.template_value_generator, 0), "param :template_value_generator must be a function with arity 0", variable_name ) assert( not Map.has_key?(spec, :default_lazy) or is_function(spec.default_lazy, 1), "param :default_lazy must be a function with arity 1", variable_name ) end) end defp assert(condition, msg, variable_name) do if condition do :ok else raise ArgumentError, "Assertion failed for #{variable_name}: " <> msg end end @doc false def variable_required?(spec, group, context) do case spec[:required] do nil -> false required when is_list(required) -> group in required required when is_function(required, 1) -> group in required.(context) end end @doc false def variables_in_context(variables_schema, context) do Enum.filter(variables_schema, fn {_variable_name, spec} -> spec_in_context?(spec, context) end) end defp spec_in_context?(spec, context) do case Map.fetch(spec, :context) do {:ok, context_spec} -> Enum.all?(context_spec, fn {context_key, allowed_values} -> Map.fetch!(context, context_key) in allowed_values end) :error -> true end end @doc false def grouped_variables(variables_schema) do variables_schema |> Enum.flat_map(fn {_variable_name, spec} = item -> Enum.map(spec.groups, &{&1, item}) end) |> Enum.group_by(&elem(&1, 0), &elem(&1, 1)) end end
34.179487
291
0.587247
ff8fe7889be024cac5d1870ee5c5a2137b2e0278
259
exs
Elixir
apps/gingerbread_shop_service/priv/repo/migrations/20170620140350_enable_extension_post_gis.exs
ScrimpyCat/gingerbread_shop
ce01f5599fd1d39c79df461373c8f4f73bc144f2
[ "BSD-2-Clause" ]
null
null
null
apps/gingerbread_shop_service/priv/repo/migrations/20170620140350_enable_extension_post_gis.exs
ScrimpyCat/gingerbread_shop
ce01f5599fd1d39c79df461373c8f4f73bc144f2
[ "BSD-2-Clause" ]
null
null
null
apps/gingerbread_shop_service/priv/repo/migrations/20170620140350_enable_extension_post_gis.exs
ScrimpyCat/gingerbread_shop
ce01f5599fd1d39c79df461373c8f4f73bc144f2
[ "BSD-2-Clause" ]
null
null
null
defmodule GingerbreadShop.Service.Repo.Migrations.EnableExtensionPostGIS do use Ecto.Migration def up do execute "CREATE EXTENSION IF NOT EXISTS postgis" end def down do execute "DROP EXTENSION IF EXISTS postgis" end end
21.583333
75
0.714286
ff8ff980ff464560f6529dc06b0afb8f674dcc2c
974
ex
Elixir
apps/service_receive/lib/receive/accept/supervisor.ex
jdenen/hindsight
ef69b4c1a74c94729dd838a9a0849a48c9b6e04c
[ "Apache-2.0" ]
12
2020-01-27T19:43:02.000Z
2021-07-28T19:46:29.000Z
apps/service_receive/lib/receive/accept/supervisor.ex
jdenen/hindsight
ef69b4c1a74c94729dd838a9a0849a48c9b6e04c
[ "Apache-2.0" ]
81
2020-01-28T18:07:23.000Z
2021-11-22T02:12:13.000Z
apps/service_receive/lib/receive/accept/supervisor.ex
jdenen/hindsight
ef69b4c1a74c94729dd838a9a0849a48c9b6e04c
[ "Apache-2.0" ]
10
2020-02-13T21:24:09.000Z
2020-05-21T18:39:35.000Z
defmodule Receive.Accept.Supervisor do @moduledoc """ Supervision helpers wrapping `DynamicSupervisor` usage. """ use DynamicSupervisor def start_link(args) do DynamicSupervisor.start_link(__MODULE__, args, name: __MODULE__) end @impl DynamicSupervisor def init(_args) do DynamicSupervisor.init(strategy: :one_for_one) end def start_child(child_spec) do DynamicSupervisor.start_child(__MODULE__, child_spec) end def terminate_child(pid) do DynamicSupervisor.terminate_child(__MODULE__, pid) end def kill_all_children() do child_pids = DynamicSupervisor.which_children(__MODULE__) |> Enum.map(fn {_, pid, _, _} -> pid end) refs = Enum.map(child_pids, &Process.monitor/1) Enum.each(child_pids, &terminate_child/1) Enum.each(refs, fn ref -> receive do {:DOWN, ^ref, _, _, _} -> :ok after 1_000 -> raise "Unable to kill child #{__MODULE__}" end end) end end
23.190476
68
0.687885
ff903226b59f00c17b022e74dbf51c2a0088ca17
1,552
ex
Elixir
lib/env.ex
epiphone/sammal
0058359f62fcdf048743fdd62bd84913b98b7773
[ "MIT" ]
2
2017-05-02T14:15:11.000Z
2021-12-11T11:13:15.000Z
lib/env.ex
epiphone/sammal
0058359f62fcdf048743fdd62bd84913b98b7773
[ "MIT" ]
null
null
null
lib/env.ex
epiphone/sammal
0058359f62fcdf048743fdd62bd84913b98b7773
[ "MIT" ]
null
null
null
defmodule Sammal.Env do @moduledoc """ Sammal evaluation environment. """ defstruct parent: nil, vars: %{}, macros: %{} # Handle basic arithmetic operators as outlined in the Scheme spec: # https://www.gnu.org/software/mit-scheme/documentation/mit-scheme-ref/Numerical-operations.html def subtract([]), do: 0 def subtract([x]), do: -x def subtract(xs), do: Enum.reduce(xs, &(&2 - &1)) def product([]), do: 1 def product([x|xs]), do: x * product(xs) def division([]), do: 1 def division([x]), do: 1 / x def division(xs), do: Enum.reduce(xs, &(&2 / &1)) def global do %__MODULE__{ parent: nil, vars: %{ list: &List.wrap/1, +: &Enum.sum/1, -: &subtract/1, *: &product/1, /: &division/1 }, macros: %{} } end @doc """ Assign variable into given environment. """ def assign(%__MODULE__{vars: vars} = env, var, val) when is_atom(var) do {:ok, %{env | vars: Map.put(vars, var, val)}} end @doc """ Look up variable first from local scope, then from parent scopes. """ def lookup_var(nil, _), do: {:error, nil} def lookup_var(%__MODULE__{parent: parent, vars: vars}, var) when is_atom(var) do if Map.has_key?(vars, var) do {:ok, vars[var]} else lookup_var(parent, var) end end @doc """ Return true if given env is the top-level (or global) scope. Some operations (e.g. `define`) are only valid in the top-level scope. """ def top_level?(%__MODULE__{parent: parent}), do: is_nil(parent) end
25.866667
98
0.603093
ff9045180fb9d1a14d8efe1eeb2cc05bcf4899f7
1,263
ex
Elixir
farmbot_core/lib/farmbot_core/config_storage/network_interface.ex
SeppPenner/farmbot_os
39ba5c5880f8aef71792e2c009514bed1177089c
[ "MIT" ]
1
2019-08-06T11:51:48.000Z
2019-08-06T11:51:48.000Z
farmbot_core/lib/farmbot_core/config_storage/network_interface.ex
SeppPenner/farmbot_os
39ba5c5880f8aef71792e2c009514bed1177089c
[ "MIT" ]
null
null
null
farmbot_core/lib/farmbot_core/config_storage/network_interface.ex
SeppPenner/farmbot_os
39ba5c5880f8aef71792e2c009514bed1177089c
[ "MIT" ]
null
null
null
defmodule FarmbotCore.Config.NetworkInterface do @moduledoc false use Ecto.Schema import Ecto.Changeset schema "network_interfaces" do field(:name, :string, null: false) field(:type, :string, null: false) ## For wireless interfaces field(:ssid, :string) field(:psk, :string) field(:security, :string) ## EAP stuff field(:identity, :string) field(:password, :string) # Advanced settings. # this should be ipv4_address_method field(:ipv4_method, :string) field(:ipv4_address, :string) field(:ipv4_gateway, :string) field(:ipv4_subnet_mask, :string) field(:domain, :string) # This is a typo. It should be `nameservers` field(:name_servers, :string) field(:regulatory_domain, :string, default: "US") end @required_fields [:name, :type] def changeset(config, params \\ %{}) do config |> cast(params, @required_fields ++ [:ssid, :psk, :security, :identity, :password, :ipv4_method, :ipv4_address, :ipv4_gateway, :ipv4_subnet_mask, :domain, :name_servers ]) |> validate_required(@required_fields) |> validate_inclusion(:type, ["wireless", "wired"]) |> unique_constraint(:name) end end
22.963636
55
0.638955
ff9050d7d68c62588e0aadfd3760174e6d36c7a7
828
ex
Elixir
nashelixir+elixir/apps/cqrs_bank/lib/cqrs_bank/account.ex
NashFP/cqrs-bank
6071db4a0c5ec681554aea8bebe783310c5d1525
[ "MIT" ]
7
2017-05-17T00:36:50.000Z
2021-11-02T03:02:03.000Z
nashelixir+elixir/apps/cqrs_bank/lib/cqrs_bank/account.ex
NashFP/cqrs-bank
6071db4a0c5ec681554aea8bebe783310c5d1525
[ "MIT" ]
3
2017-05-17T00:31:28.000Z
2017-05-18T04:50:37.000Z
nashelixir+elixir/apps/cqrs_bank/lib/cqrs_bank/account.ex
NashFP/cqrs-bank
6071db4a0c5ec681554aea8bebe783310c5d1525
[ "MIT" ]
5
2017-05-16T23:13:19.000Z
2021-12-02T06:45:25.000Z
defmodule CqrsBank.Account do use GenServer def create_bank_account(account_id, account_holder, pin) do registration = via_tuple(account_id) GenServer.start_link(__MODULE__, [account_id], name: registration) via_tuple(account_id) |> GenServer.call({:create_account, account_id, account_holder, pin} ) end def deposit_money_into_bank_account(account_id, amount) do via_tuple(account_id) |> GenServer.call({:deposit, account_id, amount}) end defp via_tuple(account_id) do {:via, Registry, {:account_to_pid_registry, account_id}} end def handle_call({:create_account, account_id, account_holder, pin}, _from, state) do %{account_id: account_id, account_holder: account_holder, pin: pin} {:reply, :ack, state} end end
30.666667
88
0.692029
ff909f4c4167b7d174e8a5c7b372808f9b8d2585
2,168
exs
Elixir
example/config/prod.exs
rstacruz/phoenix_expug
ba14a81728cecbd3af23bb7f3e7d33d50d005544
[ "MIT" ]
24
2016-06-28T09:40:44.000Z
2022-01-14T23:00:26.000Z
example/config/prod.exs
edjroot/phoenix_expug
d6d235597cd3dc56c307541e4ba9ba822c81782b
[ "MIT" ]
5
2017-10-18T12:13:18.000Z
2020-02-19T22:41:51.000Z
example/config/prod.exs
edjroot/phoenix_expug
d6d235597cd3dc56c307541e4ba9ba822c81782b
[ "MIT" ]
8
2016-11-15T11:12:25.000Z
2019-09-18T05:09:07.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 :example, Example.Endpoint, http: [port: {:system, "PORT"}], url: [host: "example.com", port: 80], cache_static_manifest: "priv/static/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 :example, Example.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 :example, Example.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 :example, Example.Endpoint, server: true # # You will also need to set the application root to `.` in order # for the new static assets to be served after a hot upgrade: # # config :example, Example.Endpoint, root: "." # Finally import the config/prod.secret.exs # which should be versioned separately. import_config "prod.secret.exs"
32.848485
67
0.712177
ff90ad45a9da42c67e8988e5ab84b33630ec0acd
1,313
ex
Elixir
backend/lib/edgehog/config/geolocation_providers.ex
harlem88/edgehog
7a278d119c3d592431fdbba406207376e194f7eb
[ "Apache-2.0" ]
null
null
null
backend/lib/edgehog/config/geolocation_providers.ex
harlem88/edgehog
7a278d119c3d592431fdbba406207376e194f7eb
[ "Apache-2.0" ]
null
null
null
backend/lib/edgehog/config/geolocation_providers.ex
harlem88/edgehog
7a278d119c3d592431fdbba406207376e194f7eb
[ "Apache-2.0" ]
null
null
null
# # This file is part of Edgehog. # # Copyright 2022 SECO Mind Srl # # 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. # defmodule Edgehog.Config.GeolocationProviders do use Skogsra.Type @providers %{ "freegeoip" => Edgehog.Geolocation.Providers.FreeGeoIp, "google" => Edgehog.Geolocation.Providers.GoogleGeolocation } @impl Skogsra.Type def cast(value) def cast(value) when is_binary(value) do list = value |> String.split(~r/,/) |> Stream.map(&String.trim/1) |> Stream.map(&String.downcase/1) |> Stream.map(&@providers[&1]) |> Stream.reject(&is_nil/1) |> Enum.to_list() {:ok, list} end def cast(value) when is_list(value) do if Enum.all?(value, &is_atom/1), do: {:ok, value}, else: :error end def cast(_) do :error end end
25.745098
74
0.686215
ff90c4e755d39e15c721bd09e315b7f8045f878b
195
ex
Elixir
lib/docception/error.ex
axelson/docception
09ba947b483518c1e123de24f64de912d996cbba
[ "Apache-2.0" ]
3
2019-04-03T08:23:40.000Z
2019-09-02T17:22:14.000Z
lib/docception/error.ex
axelson/docception
09ba947b483518c1e123de24f64de912d996cbba
[ "Apache-2.0" ]
5
2019-09-02T21:49:40.000Z
2021-10-04T14:12:05.000Z
lib/docception/error.ex
axelson/docception
09ba947b483518c1e123de24f64de912d996cbba
[ "Apache-2.0" ]
2
2019-09-02T17:46:56.000Z
2021-05-07T12:44:42.000Z
defmodule Docception.Error do @moduledoc """ An error during Docception. """ defexception [:message] @impl true def exception(message) do %__MODULE__{message: message} end end
16.25
33
0.697436
ff910182b0fa389d5da82ae0f597c66f6c8d12a2
2,321
exs
Elixir
apps/omg_child_chain_rpc/test/omg_child_chain_rpc/release_tasks/set_endpoint_test.exs
karmonezz/elixir-omg
3b26fc072fa553992277e1b9c4bad37b3d61ec6a
[ "Apache-2.0" ]
1
2020-05-01T12:30:09.000Z
2020-05-01T12:30:09.000Z
apps/omg_child_chain_rpc/test/omg_child_chain_rpc/release_tasks/set_endpoint_test.exs
karmonezz/elixir-omg
3b26fc072fa553992277e1b9c4bad37b3d61ec6a
[ "Apache-2.0" ]
null
null
null
apps/omg_child_chain_rpc/test/omg_child_chain_rpc/release_tasks/set_endpoint_test.exs
karmonezz/elixir-omg
3b26fc072fa553992277e1b9c4bad37b3d61ec6a
[ "Apache-2.0" ]
null
null
null
# Copyright 2019 OmiseGO Pte Ltd # # 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. defmodule OMG.ChildChainRPC.ReleaseTasks.SetEndpointTest do use ExUnit.Case, async: false alias OMG.ChildChainRPC.ReleaseTasks.SetEndpoint alias OMG.ChildChainRPC.Web.Endpoint @app :omg_child_chain_rpc @test_host "cc.test.example.com" @test_port "9999999999999999" @test_port_int String.to_integer(@test_port) @configuration_old Application.get_env(@app, Endpoint) setup do on_exit(fn -> :ok = Application.put_env(@app, Endpoint, @configuration_old, persistent: true) end) end test "if environment variables get applied in the configuration" do :ok = System.put_env("PORT", @test_port) :ok = System.put_env("HOSTNAME", @test_host) :ok = SetEndpoint.init([]) configuration = Enum.sort(deep_sort(Application.get_env(@app, Endpoint))) http_updated = configuration[:http] url_updated = configuration[:url] [host: @test_host, port: 80] = Enum.sort(url_updated) [port: @test_port_int] = Enum.sort(http_updated) ^configuration = @configuration_old |> Keyword.put(:http, port: @test_port_int) |> Keyword.put(:url, host: @test_host, port: 80) |> deep_sort() |> Enum.sort() end test "if default configuration is used when there's no environment variables" do :ok = System.delete_env("PORT") :ok = System.delete_env("HOSTNAME") :ok = SetEndpoint.init([]) configuration = Application.get_env(@app, Endpoint) sorted_configuration = Enum.sort(deep_sort(configuration)) ^sorted_configuration = Enum.sort(deep_sort(@configuration_old)) end defp deep_sort(values) do Enum.map(values, fn {key, value} -> if is_list(value) do {key, Enum.sort(value)} else {key, value} end end) end end
34.132353
102
0.711331
ff91265fe4b250273be0e0fd139cda03caecba24
1,215
ex
Elixir
lib/pogo.ex
mtwilliams/pogo
f427970bac860f538cdfe258eb0950e6c06edfb0
[ "MIT" ]
1
2015-12-07T09:24:33.000Z
2015-12-07T09:24:33.000Z
lib/pogo.ex
envato/pogo
74459ff08e8fc40ad9361a191657b1cab3bdb798
[ "MIT" ]
null
null
null
lib/pogo.ex
envato/pogo
74459ff08e8fc40ad9361a191657b1cab3bdb798
[ "MIT" ]
null
null
null
defmodule Pogo do def alive?(node) do :net_adm.ping(node) == :pong end def alive!(node) do unless alive?(node), do: exit(1) exit(0) end def stop(node, timeout \\ 5000) do rpc(node, :init, :stop, timeout) end def restart(node, timeout \\ 10000) do rpc(node, :init, :restart, timeout) end def reboot(node, timeout \\ 10000) do rpc(node, :init, :reboot, timeout) end defp rpc(node, mod, fun, args \\ [], timeout) do case :rpc.call(node, mod, fun, args, timeout) do :ok -> wait_for_node(node, timeout) halt(0) { :badrpc, :nodedown } -> halt(1) end end defp wait_for_node(node, timeout) do wait_for_node(node, 1, 0, timeout) end defp wait_for_node(_, _, acc_wait, timeout) when acc_wait >= timeout do halt(1) end defp wait_for_node(node, interval, acc_wait, timeout) do if alive?(node) do pid = self ref = make_ref :erlang.send_after(interval, pid, { pid, ref }) receive do { ^pid, ^ref } -> acc_wait = acc_wait + interval wait_for_node(node, interval, acc_wait, timeout) end end end defp halt(status), do: System.halt(status) end
21.696429
73
0.6
ff9129955cf9f3404b1597eb9509ded27ca3f7c7
7,433
ex
Elixir
lib/annex/layer/dense.ex
arpieb/annex
6f472a30361bf0a1646e256d6dfe478706427f64
[ "MIT" ]
1
2020-10-23T13:41:07.000Z
2020-10-23T13:41:07.000Z
lib/annex/layer/dense.ex
arpieb/annex
6f472a30361bf0a1646e256d6dfe478706427f64
[ "MIT" ]
null
null
null
lib/annex/layer/dense.ex
arpieb/annex
6f472a30361bf0a1646e256d6dfe478706427f64
[ "MIT" ]
null
null
null
defmodule Annex.Layer.Dense do @moduledoc """ `rows` are the number outputs and `columns` are the number of inputs. """ use Annex.Debug, debug: true alias Annex.{ Data, Data.DMatrix, Data.List1D, Layer.Backprop, Layer.Dense, LayerConfig, Shape, Utils } require Data use Annex.Layer @type data :: Data.data() @type t :: %__MODULE__{ data_type: Data.type(), weights: data(), biases: data(), rows: pos_integer(), columns: pos_integer(), input: data() | nil, output: data() | nil } defp default_data_type do :annex |> Application.get_env(__MODULE__, []) |> Keyword.get(:data_type, DMatrix) end defstruct weights: nil, biases: nil, rows: nil, columns: nil, input: nil, output: nil, data_type: nil @impl Layer @spec init_layer(LayerConfig.t(Dense)) :: t() | no_return() def init_layer(%LayerConfig{} = cfg) do with( {:ok, :data_type, data_type} <- build_data_type(cfg), {:ok, :rows, rows} <- build_rows(cfg), {:ok, :columns, columns} <- build_columns(cfg), {:ok, :weights, weights} <- build_weights(cfg, data_type, rows, columns), {:ok, :biases, biases} <- build_biases(cfg, data_type, rows) ) do %Dense{ biases: biases, weights: weights, rows: rows, columns: columns, data_type: data_type } else {:error, _field, error} -> raise error end end defp build_rows(cfg) do with( {:ok, :rows, rows} <- LayerConfig.fetch(cfg, :rows), :ok <- validate :rows, "must be a positive integer" do is_int? = is_integer(rows) is_positive? = rows > 0 is_int? && is_positive? end ) do {:ok, :rows, rows} end end defp build_columns(cfg) do with( {:ok, :columns, columns} <- LayerConfig.fetch(cfg, :columns), :ok <- validate :columns, "must be a positive integer" do is_int? = is_integer(columns) is_positive? = columns > 0 is_int? && is_positive? end ) do {:ok, :columns, columns} end end defp build_data_type(cfg) do with( {:ok, :data_type, data_type} <- LayerConfig.fetch_lazy(cfg, :data_type, fn -> default_data_type() end), :ok <- validate :data_type, "must be a module" do Utils.is_module?(data_type) end ) do {:ok, :data_type, data_type} end end defp build_weights(cfg, data_type, rows, columns) do with( {:ok, :weights, weights} <- LayerConfig.fetch_lazy(cfg, :weights, fn -> List1D.new_random(rows * columns) end), :ok <- validate :weights, "must be an Annex.Data" do type = Data.infer_type(weights) Data.is_type?(type, weights) end, :ok <- validate :weights, "data size must be the same as the layer" do [weights_rows, weights_columns] = case Data.shape(weights) do [w_rows] -> [w_rows, 1] [w_rows, w_cols] -> [w_rows, w_cols] end weights_size = weights_rows * weights_columns layer_size = rows * columns weights_size == layer_size end, casted_weights <- Data.cast(data_type, weights, [rows, columns]) ) do {:ok, :weights, casted_weights} end end defp build_biases(cfg, data_type, rows) do with( {:ok, :biases, biases} <- LayerConfig.fetch_lazy(cfg, :biases, fn -> List1D.ones(rows) end), :ok <- validate :biases, "must be an Annex.Data" do type = Data.infer_type(biases) Data.is_type?(type, biases) end, :ok <- validate :biases, "data size must match rows" do [biases_rows, biases_columns] = case Data.shape(biases) do [b_rows] -> [b_rows, 1] [b_rows, b_cols] -> [b_rows, b_cols] end biases_rows * biases_columns == rows end, casted_biases <- Data.cast(data_type, biases, [rows, 1]) ) do {:ok, :biases, casted_biases} end end defp get_output(%Dense{output: o}), do: o defp get_weights(%Dense{weights: weights}), do: weights defp get_biases(%Dense{biases: biases}), do: biases defp get_input(%Dense{input: input}), do: input @spec rows(t()) :: pos_integer() def rows(%Dense{rows: n}), do: n @spec columns(t()) :: pos_integer() def columns(%Dense{columns: n}), do: n @impl Layer @spec feedforward(t(), Data.data()) :: {t(), Data.data()} def feedforward(%Dense{} = dense, inputs) do debug_assert "Dense.feedforward/2 input must be dottable with the weights" do weights = get_weights(dense) [_, dense_columns] = Data.shape(weights) [inputs_rows, _] = Data.shape(inputs) dense_columns == inputs_rows end biases = get_biases(dense) output = dense |> get_weights() |> Data.apply_op(:dot, [inputs]) |> Data.apply_op(:add, [biases]) updated_dense = %Dense{ dense | input: inputs, output: output } {updated_dense, output} end @impl Layer @spec backprop(t(), Data.data(), Backprop.t()) :: {t(), Data.data(), Backprop.t()} def backprop(%Dense{} = dense, error, props) do learning_rate = Backprop.get_learning_rate(props) derivative = Backprop.get_derivative(props) output = get_output(dense) debug_assert "backprop error must have the same shape as output" do output_shape = Data.shape(output) error_shape = Data.shape(error) output_shape == error_shape end weights = get_weights(dense) input = get_input(dense) biases = get_biases(dense) gradients = output |> Data.apply_op(:map, [derivative]) |> Data.apply_op(:multiply, [error]) |> Data.apply_op(:multiply, [learning_rate]) input_t = Data.apply_op(input, :transpose, []) debug_assert "gradients must be dottable with input_T" do [_, gradients_cols] = Data.shape(gradients) [input_rows, _] = Data.shape(input_t) gradients_cols == input_rows end weight_deltas = Data.apply_op(gradients, :dot, [input_t]) updated_weights = Data.apply_op(weights, :subtract, [weight_deltas]) updated_biases = Data.apply_op(biases, :subtract, [gradients]) next_error = weights |> Data.apply_op(:transpose, []) |> Data.apply_op(:dot, [error]) updated_dense = %Dense{ dense | input: nil, output: nil, weights: updated_weights, biases: updated_biases } {updated_dense, next_error, props} end @impl Layer @spec data_type(t()) :: Data.type() def data_type(%Dense{data_type: data_type}), do: data_type @impl Layer @spec shapes(t()) :: {Shape.t(), Shape.t()} def shapes(%Dense{} = dense) do rows = rows(dense) columns = columns(dense) {[rows, columns], [columns, rows]} end defimpl Inspect do def inspect(dense, _) do shapes = dense |> Dense.shapes() |> Kernel.inspect() data_type = dense |> Dense.data_type() |> inspect() "#Dense<[#{data_type}, #{shapes}]>" end end end
25.19661
84
0.576214
ff912dc215545651e828be6e48e14e12a9355936
819
exs
Elixir
apps/monitoring/mix.exs
paulanthonywilson/mcam
df9c5aaae00b568749dff22613636f5cb92f905a
[ "MIT" ]
null
null
null
apps/monitoring/mix.exs
paulanthonywilson/mcam
df9c5aaae00b568749dff22613636f5cb92f905a
[ "MIT" ]
8
2020-11-16T09:59:12.000Z
2020-11-16T10:13:07.000Z
apps/monitoring/mix.exs
paulanthonywilson/mcam
df9c5aaae00b568749dff22613636f5cb92f905a
[ "MIT" ]
null
null
null
defmodule Monitoring.MixProject do use Mix.Project def project do [ app: :monitoring, version: "0.1.0", build_path: "../../_build", config_path: "../../config/config.exs", deps_path: "../../deps", lockfile: "../../mix.lock", elixir: "~> 1.11", start_permanent: Mix.env() == :prod, deps: deps() ] end # Run "mix help compile.app" to learn about applications. def application do [ extra_applications: [:logger], mod: {Monitoring.Application, []} ] end # Run "mix help deps" to learn about dependencies. defp deps do [ # {:dep_from_hexpm, "~> 0.3.0"}, # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}, # {:sibling_app_in_umbrella, in_umbrella: true} ] end end
23.4
88
0.571429
ff9167b36ccc0f7d48d3b65dc472e5e7cab239cd
1,949
exs
Elixir
clients/android_device_provisioning/mix.exs
kaaboaye/elixir-google-api
1896784c4342151fd25becd089a5beb323eff567
[ "Apache-2.0" ]
null
null
null
clients/android_device_provisioning/mix.exs
kaaboaye/elixir-google-api
1896784c4342151fd25becd089a5beb323eff567
[ "Apache-2.0" ]
null
null
null
clients/android_device_provisioning/mix.exs
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.AndroidDeviceProvisioning.Mixfile do use Mix.Project @version "0.13.0" def project() do [ app: :google_api_android_device_provisioning, version: @version, elixir: "~> 1.6", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, description: description(), package: package(), deps: deps(), source_url: "https://github.com/googleapis/elixir-google-api/tree/master/clients/android_device_provisioning" ] end def application() do [extra_applications: [:logger]] end defp deps() do [ {:google_gax, "~> 0.2"}, {:ex_doc, "~> 0.16", only: :dev} ] end defp description() do """ Android Device Provisioning Partner API client library. Automates Android zero-touch enrollment for device resellers, customers, and EMMs. """ end defp package() do [ files: ["lib", "mix.exs", "README*", "LICENSE"], maintainers: ["Jeff Ching", "Daniel Azuma"], licenses: ["Apache 2.0"], links: %{ "GitHub" => "https://github.com/googleapis/elixir-google-api/tree/master/clients/android_device_provisioning", "Homepage" => "https://developers.google.com/zero-touch/" } ] end end
29.089552
142
0.67214
ff919a545887c47dfe5f7c93e79835e178992651
498
exs
Elixir
prag-programing/Part2/MultipleProcesses/example2.exs
mpahrens/fun-with-elixir
8e6720c7c2004421f674bb450045df0ab59b9c74
[ "Apache-2.0" ]
1
2017-03-29T04:10:50.000Z
2017-03-29T04:10:50.000Z
prag-programing/Part2/MultipleProcesses/example2.exs
mpahrens/fun-with-elixir
8e6720c7c2004421f674bb450045df0ab59b9c74
[ "Apache-2.0" ]
null
null
null
prag-programing/Part2/MultipleProcesses/example2.exs
mpahrens/fun-with-elixir
8e6720c7c2004421f674bb450045df0ab59b9c74
[ "Apache-2.0" ]
null
null
null
defmodule TokenPasser do def reply(sender) do receive do token -> send sender, token end end def run() do pid1 = spawn(TokenPasser, :reply, [self]) pid2 = spawn(TokenPasser, :reply, [self]) send pid1, "fred" send pid2, "betty" receive do name when is_bitstring(name) -> IO.puts "received: #{name}" end receive do name when is_bitstring(name) -> IO.puts "received: #{name}" end end end
17.785714
45
0.558233
ff91b90d717bda868792fc600504a2c0cf4201f4
75,844
ex
Elixir
clients/firebase_hosting/lib/google_api/firebase_hosting/v1beta1/api/sites.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/firebase_hosting/lib/google_api/firebase_hosting/v1beta1/api/sites.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/firebase_hosting/lib/google_api/firebase_hosting/v1beta1/api/sites.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.FirebaseHosting.V1beta1.Api.Sites do @moduledoc """ API calls for all endpoints tagged `Sites`. """ alias GoogleApi.FirebaseHosting.V1beta1.Connection alias GoogleApi.Gax.{Request, Response} @library_version Mix.Project.config() |> Keyword.get(:version, "") @doc """ Gets the Hosting metadata for a specific site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The site for which to get the SiteConfig, in the format: sites/ site-name/config * `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.FirebaseHosting.V1beta1.Model.SiteConfig{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_get_config(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.SiteConfig.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_get_config(connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.SiteConfig{}]) end @doc """ Sets the Hosting metadata for a specific site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The site for which to update the SiteConfig, in the format: sites/ site-name/config * `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"). * `:updateMask` (*type:* `String.t`) - A set of field names from your [site configuration](../sites.SiteConfig) that you want to update. A field will be overwritten if, and only if, it's in the mask. If a mask is not provided then a default mask of only [`max_versions`](../sites.SiteConfig.max_versions) will be used. * `:body` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Model.SiteConfig.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.SiteConfig{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_update_config(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.SiteConfig.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_update_config(connection, name, 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, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.SiteConfig{}]) end @doc """ Creates a new channel in the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The site in which to create this channel, in the format: sites/ SITE_ID * `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"). * `:channelId` (*type:* `String.t`) - Required. Immutable. A unique ID within the site that identifies the channel. * `:body` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Model.Channel.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Channel{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_channels_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Channel.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_channels_create(connection, parent, 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, :channelId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1beta1/{+parent}/channels", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.Channel{}]) end @doc """ Deletes the specified channel of the specified site. The `live` channel cannot be deleted. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The fully-qualified resource name for the channel, in the format: sites/SITE_ID/channels/CHANNEL_ID * `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.FirebaseHosting.V1beta1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_channels_delete( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_channels_delete(connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.Empty{}]) end @doc """ Retrieves information for the specified channel of the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The fully-qualified resource name for the channel, in the format: sites/SITE_ID/channels/CHANNEL_ID * `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.FirebaseHosting.V1beta1.Model.Channel{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_channels_get(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Channel.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_channels_get(connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.Channel{}]) end @doc """ Lists the channels for the specified site. All sites have a default `live` channel. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The site for which to list channels, in the format: sites/SITE_ID * `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"). * `:pageSize` (*type:* `integer()`) - The maximum number of channels to return. The service may return a lower number if fewer channels exist than this maximum number. If unspecified, defaults to 10. The maximum value is 100; values above 100 will be coerced to 100. * `:pageToken` (*type:* `String.t`) - A token from a previous call to `ListChannels` that tells the server where to resume listing. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.ListChannelsResponse{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_channels_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.ListChannelsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_channels_list(connection, parent, 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, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1beta1/{+parent}/channels", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.ListChannelsResponse{}] ) end @doc """ Updates information for the specified channel of the specified site. Implicitly creates the channel if it doesn't already exist. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The fully-qualified resource name for the channel, in the format: sites/ SITE_ID/channels/CHANNEL_ID * `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"). * `:updateMask` (*type:* `String.t`) - A comma-separated list of fields to be updated in this request. * `:body` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Model.Channel.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Channel{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_channels_patch(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Channel.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_channels_patch(connection, name, 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, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.Channel{}]) end @doc """ Creates a new release, which makes the content of the specified version actively display on the appropriate URL(s). ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The site or channel to which the release belongs, in either of the following formats: - sites/SITE_ID - sites/SITE_ID/channels/CHANNEL_ID * `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"). * `:versionName` (*type:* `String.t`) - The unique identifier for a version, in the format: sites/SITE_ID/versions/ VERSION_ID The SITE_ID in this version identifier must match the SITE_ID in the `parent` parameter. This query parameter must be empty if the `type` field in the request body is `SITE_DISABLE`. * `:body` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Model.Release.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Release{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_channels_releases_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Release.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_channels_releases_create( connection, parent, 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, :versionName => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1beta1/{+parent}/releases", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.Release{}]) end @doc """ Lists the releases that have been created for the specified site or channel. When used to list releases for a site, this list includes releases for both the default `live` channel and any active preview channels for the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The site or channel for which to list releases, in either of the following formats: - sites/SITE_ID - sites/SITE_ID/channels/CHANNEL_ID * `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"). * `:pageSize` (*type:* `integer()`) - The maximum number of releases to return. The service may return a lower number if fewer releases exist than this maximum number. If unspecified, defaults to 100. * `:pageToken` (*type:* `String.t`) - A token from a previous call to `releases.list` or `channels.releases.list` that tells the server where to resume listing. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.ListReleasesResponse{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_channels_releases_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.ListReleasesResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_channels_releases_list( connection, parent, 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, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1beta1/{+parent}/releases", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.ListReleasesResponse{}] ) end @doc """ Creates a domain mapping on the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The parent to create the domain association for, in the format: sites/site-name * `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.FirebaseHosting.V1beta1.Model.Domain.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Domain{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_domains_create(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Domain.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_domains_create(connection, parent, 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("/v1beta1/{+parent}/domains", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.Domain{}]) end @doc """ Deletes the existing domain mapping on the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The name of the domain association to delete. * `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.FirebaseHosting.V1beta1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_domains_delete(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_domains_delete(connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.Empty{}]) end @doc """ Gets a domain mapping on the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The name of the domain configuration to get. * `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.FirebaseHosting.V1beta1.Model.Domain{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_domains_get(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Domain.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_domains_get(connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.Domain{}]) end @doc """ Lists the domains for the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The parent for which to list domains, in the format: sites/ site-name * `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"). * `:pageSize` (*type:* `integer()`) - The page size to return. Defaults to 50. * `:pageToken` (*type:* `String.t`) - The next_page_token from a previous request, if provided. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.ListDomainsResponse{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_domains_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.ListDomainsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_domains_list(connection, parent, 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, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1beta1/{+parent}/domains", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.ListDomainsResponse{}] ) end @doc """ Updates the specified domain mapping, creating the mapping as if it does not exist. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The name of the domain association to update or create, if an association doesn't already exist. * `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.FirebaseHosting.V1beta1.Model.Domain.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Domain{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_domains_update(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Domain.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_domains_update(connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.Domain{}]) end @doc """ Creates a new release, which makes the content of the specified version actively display on the appropriate URL(s). ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The site or channel to which the release belongs, in either of the following formats: - sites/SITE_ID - sites/SITE_ID/channels/CHANNEL_ID * `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"). * `:versionName` (*type:* `String.t`) - The unique identifier for a version, in the format: sites/SITE_ID/versions/ VERSION_ID The SITE_ID in this version identifier must match the SITE_ID in the `parent` parameter. This query parameter must be empty if the `type` field in the request body is `SITE_DISABLE`. * `:body` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Model.Release.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Release{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_releases_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Release.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_releases_create(connection, parent, 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, :versionName => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1beta1/{+parent}/releases", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.Release{}]) end @doc """ Lists the releases that have been created for the specified site or channel. When used to list releases for a site, this list includes releases for both the default `live` channel and any active preview channels for the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The site or channel for which to list releases, in either of the following formats: - sites/SITE_ID - sites/SITE_ID/channels/CHANNEL_ID * `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"). * `:pageSize` (*type:* `integer()`) - The maximum number of releases to return. The service may return a lower number if fewer releases exist than this maximum number. If unspecified, defaults to 100. * `:pageToken` (*type:* `String.t`) - A token from a previous call to `releases.list` or `channels.releases.list` that tells the server where to resume listing. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.ListReleasesResponse{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_releases_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.ListReleasesResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_releases_list(connection, parent, 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, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1beta1/{+parent}/releases", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.ListReleasesResponse{}] ) end @doc """ Creates a new version on the specified target site using the content of the specified version. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The target site for the cloned version, in the format: sites/ SITE_ID * `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.FirebaseHosting.V1beta1.Model.CloneVersionRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Operation{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_versions_clone(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Operation.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_versions_clone(connection, parent, 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("/v1beta1/{+parent}/versions:clone", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.Operation{}]) end @doc """ Creates a new version for the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The site in which to create the version, in the format: sites/ SITE_ID * `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"). * `:sizeBytes` (*type:* `String.t`) - The self-reported size of the version. This value is used for a pre-emptive quota check for legacy version uploads. * `:versionId` (*type:* `String.t`) - A unique id for the new version. This is was only specified for legacy version creations, and should be blank. * `:body` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Model.Version.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Version{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_versions_create( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Version.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_versions_create(connection, parent, 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, :sizeBytes => :query, :versionId => :query, :body => :body } request = Request.new() |> Request.method(:post) |> Request.url("/v1beta1/{+parent}/versions", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.Version{}]) end @doc """ Deletes the specified version. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - Required. The fully-qualified resource name for the version, in the format: sites/SITE_ID/versions/VERSION_ID * `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.FirebaseHosting.V1beta1.Model.Empty{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_versions_delete( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Empty.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_versions_delete(connection, name, 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("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.Empty{}]) end @doc """ Lists the versions that have been created for the specified site. This list includes versions for both the default `live` channel and any active preview channels for the specified site. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The site or channel for which to list versions, in either of the following formats: - sites/SITE_ID - sites/SITE_ID/channels/CHANNEL_ID * `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"). * `:filter` (*type:* `String.t`) - A filter string used to return a subset of versions in the response. The currently supported fields for filtering are: `name`, `status`, and `create_time`. Learn more about filtering in Google's [AIP 160 standard](https://google.aip.dev/160). * `:pageSize` (*type:* `integer()`) - The maximum number of versions to return. The service may return a lower number if fewer versions exist than this maximum number. If unspecified, defaults to 25. The maximum value is 100; values above 100 will be coerced to 100. * `:pageToken` (*type:* `String.t`) - A token from a previous call to `ListVersions` that tells the server where to resume listing. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.ListVersionsResponse{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_versions_list(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.ListVersionsResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_versions_list(connection, parent, 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, :filter => :query, :pageSize => :query, :pageToken => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1beta1/{+parent}/versions", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.ListVersionsResponse{}] ) end @doc """ Updates the specified metadata for the specified version. This method will fail with `FAILED_PRECONDITION` in the event of an invalid state transition. The supported [state](../sites.versions#versionstatus) transitions for a version are from `CREATED` to `FINALIZED`. Use [`DeleteVersion`](delete) to set the status of a version to `DELETED`. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `name` (*type:* `String.t`) - The fully-qualified resource name for the version, in the format: sites/ SITE_ID/versions/VERSION_ID This name is provided in the response body when you call [`CreateVersion`](sites.versions/create). * `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"). * `:updateMask` (*type:* `String.t`) - A set of field names from your [version](../sites.versions) that you want to update. A field will be overwritten if, and only if, it's in the mask. If a mask is not provided then a default mask of only [`status`](../sites.versions#Version.FIELDS.status) will be used. * `:body` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Model.Version.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.Version{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_versions_patch(Tesla.Env.client(), String.t(), keyword(), keyword()) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.Version.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_versions_patch(connection, name, 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, :updateMask => :query, :body => :body } request = Request.new() |> Request.method(:patch) |> Request.url("/v1beta1/{+name}", %{ "name" => URI.encode(name, &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.FirebaseHosting.V1beta1.Model.Version{}]) end @doc """ Adds content files to the specified version. Each file must be under 2 GB. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The version to which to add files, in the format: sites/SITE_ID /versions/VERSION_ID * `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.FirebaseHosting.V1beta1.Model.PopulateVersionFilesRequest.t`) - * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.PopulateVersionFilesResponse{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_versions_populate_files( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.PopulateVersionFilesResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_versions_populate_files( connection, parent, 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("/v1beta1/{+parent}:populateFiles", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.PopulateVersionFilesResponse{}] ) end @doc """ Lists the remaining files to be uploaded for the specified version. ## Parameters * `connection` (*type:* `GoogleApi.FirebaseHosting.V1beta1.Connection.t`) - Connection to server * `parent` (*type:* `String.t`) - Required. The version for which to list files, in the format: sites/SITE_ID /versions/VERSION_ID * `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"). * `:pageSize` (*type:* `integer()`) - The maximum number of version files to return. The service may return a lower number if fewer version files exist than this maximum number. If unspecified, defaults to 1000. * `:pageToken` (*type:* `String.t`) - A token from a previous call to `ListVersionFiles` that tells the server where to resume listing. * `:status` (*type:* `String.t`) - The type of files that should be listed for the specified version. * `opts` (*type:* `keyword()`) - Call options ## Returns * `{:ok, %GoogleApi.FirebaseHosting.V1beta1.Model.ListVersionFilesResponse{}}` on success * `{:error, info}` on failure """ @spec firebasehosting_sites_versions_files_list( Tesla.Env.client(), String.t(), keyword(), keyword() ) :: {:ok, GoogleApi.FirebaseHosting.V1beta1.Model.ListVersionFilesResponse.t()} | {:ok, Tesla.Env.t()} | {:ok, list()} | {:error, any()} def firebasehosting_sites_versions_files_list( connection, parent, 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, :pageSize => :query, :pageToken => :query, :status => :query } request = Request.new() |> Request.method(:get) |> Request.url("/v1beta1/{+parent}/files", %{ "parent" => URI.encode(parent, &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.FirebaseHosting.V1beta1.Model.ListVersionFilesResponse{}] ) end end
48.83709
345
0.62378
ff91c48d396e045d5517de5248989afdad2edc78
82
exs
Elixir
test/shelving_web/views/page_view_test.exs
markglenn/shelving
d76a2df11186ace3fbca14e00a2b5010692b5ee0
[ "MIT" ]
null
null
null
test/shelving_web/views/page_view_test.exs
markglenn/shelving
d76a2df11186ace3fbca14e00a2b5010692b5ee0
[ "MIT" ]
null
null
null
test/shelving_web/views/page_view_test.exs
markglenn/shelving
d76a2df11186ace3fbca14e00a2b5010692b5ee0
[ "MIT" ]
null
null
null
defmodule ShelvingWeb.PageViewTest do use ShelvingWeb.ConnCase, async: true end
20.5
39
0.829268
ff91c8f1a2e7dedff794011dd10df7597bf161e7
2,106
ex
Elixir
clients/content/lib/google_api/content/v21/model/orders_custom_batch_request_entry_refund_item_shipping.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/content/lib/google_api/content/v21/model/orders_custom_batch_request_entry_refund_item_shipping.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/content/lib/google_api/content/v21/model/orders_custom_batch_request_entry_refund_item_shipping.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.Content.V21.Model.OrdersCustomBatchRequestEntryRefundItemShipping do @moduledoc """ ## Attributes * `amount` (*type:* `GoogleApi.Content.V21.Model.Price.t`, *default:* `nil`) - The amount that is refunded. If this is not the first refund for the shipment, this should be the newly refunded amount. * `fullRefund` (*type:* `boolean()`, *default:* `nil`) - If set to true, all shipping costs for the order will be refunded. If this is true, amount should not be provided and will be ignored. If set to false, submit the amount of the partial shipping refund, excluding the shipping tax. The shipping tax is calculated and handled on Google's side. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :amount => GoogleApi.Content.V21.Model.Price.t() | nil, :fullRefund => boolean() | nil } field(:amount, as: GoogleApi.Content.V21.Model.Price) field(:fullRefund) end defimpl Poison.Decoder, for: GoogleApi.Content.V21.Model.OrdersCustomBatchRequestEntryRefundItemShipping do def decode(value, options) do GoogleApi.Content.V21.Model.OrdersCustomBatchRequestEntryRefundItemShipping.decode( value, options ) end end defimpl Poison.Encoder, for: GoogleApi.Content.V21.Model.OrdersCustomBatchRequestEntryRefundItemShipping do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
38.290909
351
0.743115
ff91ce8769934f322a80d937224c99c7298b2fc3
572
ex
Elixir
lib/trento/domain/cluster/events/cluster_details_updated.ex
trento-project/web
3260b30c781bffbbb0e5205cd650966c4026b9ac
[ "Apache-2.0" ]
1
2022-03-22T16:59:34.000Z
2022-03-22T16:59:34.000Z
lib/trento/domain/cluster/events/cluster_details_updated.ex
trento-project/web
3260b30c781bffbbb0e5205cd650966c4026b9ac
[ "Apache-2.0" ]
24
2022-03-22T16:45:25.000Z
2022-03-31T13:00:02.000Z
lib/trento/domain/cluster/events/cluster_details_updated.ex
trento-project/web
3260b30c781bffbbb0e5205cd650966c4026b9ac
[ "Apache-2.0" ]
1
2022-03-30T14:16:16.000Z
2022-03-30T14:16:16.000Z
defmodule Trento.Domain.Events.ClusterDetailsUpdated do @moduledoc """ This event is emitted when cluster details are updated. """ use Trento.Event alias Trento.Domain.HanaClusterDetails defevent do field :cluster_id, :string field :name, :string field :type, Ecto.Enum, values: [:hana_scale_up, :hana_scale_out, :unknown] field :sid, :string field :provider, Ecto.Enum, values: [:azure, :aws, :gcp, :unknown] field :resources_number, :integer field :hosts_number, :integer embeds_one :details, HanaClusterDetails end end
26
79
0.715035
ff91d3bc20fef1ae6c30d6cf2b5eaf1dc00bd249
1,255
exs
Elixir
deps/poison/mix.exs
scouten/crash_esqlite_case
986f0b0721399c7ed520f6b9df133980906e3f51
[ "MIT" ]
4
2017-10-01T18:00:25.000Z
2022-02-23T18:26:53.000Z
deps/poison/mix.exs
scouten/crash_esqlite_case
986f0b0721399c7ed520f6b9df133980906e3f51
[ "MIT" ]
107
2016-08-03T18:16:51.000Z
2021-07-23T08:42:51.000Z
deps/poison/mix.exs
scouten/crash_esqlite_case
986f0b0721399c7ed520f6b9df133980906e3f51
[ "MIT" ]
10
2017-10-31T16:16:05.000Z
2022-02-16T10:31:04.000Z
defmodule Poison.Mixfile do use Mix.Project @version File.read!("VERSION") |> String.strip def project do [app: :poison, version: @version, elixir: "~> 1.0", description: "The fastest JSON library for Elixir", deps: deps, package: package, consolidate_protocols: Mix.env != :test] end # Configuration for the OTP application # # Type `mix help compile.app` for more information def application do [applications: []] end # Dependencies can be hex.pm packages: # # {:mydep, "~> 0.3.0"} # # Or git/path repositories: # # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1"} # # Type `mix help deps` for more examples and options defp deps do [{:earmark, "~> 0.2", only: :docs}, {:ex_doc, "~> 0.11", only: :docs}, {:benchfella, "~> 0.3", only: :bench}, {:jiffy, github: "davisp/jiffy", only: :bench}, {:exjsx, github: "talentdeficit/exjsx", only: :bench}, {:jazz, github: "meh/jazz", only: :bench}] end defp package do [files: ~w(lib mix.exs README.md LICENSE UNLICENSE VERSION), maintainers: ["Devin Torres"], licenses: ["Unlicense"], links: %{"GitHub" => "https://github.com/devinus/poison"}] end end
26.145833
75
0.607171
ff91f73787f80c5c7e943c27dcefd43d651710bb
58
exs
Elixir
test/lib/timber/context_test.exs
axelson/timber-elixir
def9de8ebbb64a6f6d5dd85f8958d8b24f8d6c31
[ "0BSD" ]
244
2016-10-10T15:30:32.000Z
2021-08-11T08:45:53.000Z
test/lib/timber/context_test.exs
axelson/timber-elixir
def9de8ebbb64a6f6d5dd85f8958d8b24f8d6c31
[ "0BSD" ]
242
2016-10-10T19:34:44.000Z
2020-11-20T18:56:43.000Z
test/lib/timber/context_test.exs
axelson/timber-elixir
def9de8ebbb64a6f6d5dd85f8958d8b24f8d6c31
[ "0BSD" ]
35
2016-12-04T07:33:04.000Z
2020-06-17T20:22:11.000Z
defmodule Timber.ContextTest do use Timber.TestCase end
14.5
31
0.827586
ff91ff890f6ab6f09f410d162cea69e51e0127be
2,657
exs
Elixir
test/stub_test.exs
FarmBot/farmbot_os
5ebdca3afd672eb6b0af5c71cfca02488b32569a
[ "MIT" ]
843
2016-10-05T23:46:05.000Z
2022-03-14T04:31:55.000Z
test/stub_test.exs
FarmBot/farmbot_os
5ebdca3afd672eb6b0af5c71cfca02488b32569a
[ "MIT" ]
455
2016-10-15T08:49:16.000Z
2022-03-15T12:23:04.000Z
test/stub_test.exs
FarmBot/farmbot_os
5ebdca3afd672eb6b0af5c71cfca02488b32569a
[ "MIT" ]
261
2016-10-10T04:37:06.000Z
2022-03-13T21:07:38.000Z
defmodule FarmbotCore.Celery.SysCallGlue.StubsTest do use ExUnit.Case alias FarmbotCore.Celery.SysCallGlue.Stubs test "various stubs" do # This test is to: # * Catch early problems caused by a downstream stub # * Keep coverage consistent # * Detect unusued stubs over time. args = "args" axis = "axis" channels = "channels" comment = "comment" email = "email" env_name = "env_name" env_value = "env_value" expr = "expr" expression = "expression" force? = "force?" id = "id" kind = "kind" message = "message" millis = "millis" mode = "mode" named_pin_type = "named_pin_type" package = "package" params = "params" pin = "pin" pin_mode = "pin_mode" pin_num = "pin_num" pin_value = "pin_value" point_type = "point_type" resource_id = "resource_id" secret = "secret" server = "server" speed = "speed" sx = "sx" sy = "sy" sz = "sz" type = "type" value = "value" x = "x" y = "y" z = "z" Stubs.calibrate(axis) Stubs.change_ownership(email, secret, server) Stubs.check_update() Stubs.coordinate(x, y, z) Stubs.emergency_lock() Stubs.emergency_unlock() Stubs.perform_lua(expression, [], comment) Stubs.execute_script(package, args) Stubs.factory_reset(package) Stubs.find_home(axis) Stubs.find_points_via_group(id) Stubs.firmware_reboot() Stubs.flash_firmware(package) Stubs.get_cached_x() Stubs.get_cached_y() Stubs.get_cached_z() Stubs.get_current_x() Stubs.get_current_y() Stubs.get_current_z() Stubs.get_sequence(resource_id) Stubs.get_toolslot_for_tool(resource_id) Stubs.home(axis, speed) Stubs.install_first_party_farmware() Stubs.log(message, force?) Stubs.move_absolute(x, y, z, speed) Stubs.move_absolute(x, y, z, sx, sy, sz) Stubs.named_pin(named_pin_type, resource_id) Stubs.nothing() Stubs.point(point_type, resource_id) Stubs.power_off() Stubs.perform_lua(expr, [], nil) Stubs.read_cached_pin(pin_num) Stubs.read_pin(pin_num, pin_mode) Stubs.read_status() Stubs.reboot() Stubs.send_message(type, message, channels) Stubs.sequence_complete_log(message) Stubs.sequence_init_log(message) Stubs.set_pin_io_mode(pin, mode) Stubs.set_servo_angle(pin, value) Stubs.set_user_env(env_name, env_value) Stubs.sync() Stubs.toggle_pin(pin_num) Stubs.update_farmware(package) Stubs.update_resource(kind, id, params) Stubs.wait(millis) Stubs.write_pin(pin_num, pin_mode, pin_value) Stubs.zero(axis) end end
27.677083
57
0.665036
ff920108d450a65ad142a55a33312cd84ac7408b
780
ex
Elixir
9-elixir-phoenix/web/channels/post_channel.ex
smddzcy/learning-new-technologies
cf3645ff649f6dfe89c77e90ceaf089b66da2482
[ "MIT" ]
3
2017-02-22T08:45:53.000Z
2017-04-29T13:40:23.000Z
9-elixir-phoenix/web/channels/post_channel.ex
smddzcy/learning-new-technologies
cf3645ff649f6dfe89c77e90ceaf089b66da2482
[ "MIT" ]
null
null
null
9-elixir-phoenix/web/channels/post_channel.ex
smddzcy/learning-new-technologies
cf3645ff649f6dfe89c77e90ceaf089b66da2482
[ "MIT" ]
null
null
null
defmodule AwesomeprojectBackend.PostChannel do use AwesomeprojectBackend.Web, :channel def join("room:posts", payload, socket) do if authorized?(payload) do {:ok, socket} else {:error, %{reason: "unauthorized"}} end end # Channels can be used in a request/response fashion # by sending replies to requests from the client def handle_in("ping", payload, socket) do {:reply, {:ok, payload}, socket} end # It is also common to receive messages from the client and # broadcast to everyone in the current topic (room:posts). def handle_in("shout", payload, socket) do broadcast socket, "shout", payload {:noreply, socket} end # Add authorization logic here as required. defp authorized?(_payload) do true end end
26
61
0.69359
ff9211a2e22b296afd0133793155a4691368be26
52,163
ex
Elixir
lib/codes/codes_m48.ex
badubizzle/icd_code
4c625733f92b7b1d616e272abc3009bb8b916c0c
[ "Apache-2.0" ]
null
null
null
lib/codes/codes_m48.ex
badubizzle/icd_code
4c625733f92b7b1d616e272abc3009bb8b916c0c
[ "Apache-2.0" ]
null
null
null
lib/codes/codes_m48.ex
badubizzle/icd_code
4c625733f92b7b1d616e272abc3009bb8b916c0c
[ "Apache-2.0" ]
null
null
null
defmodule IcdCode.ICDCode.Codes_M48 do alias IcdCode.ICDCode def _M4800 do %ICDCode{full_code: "M4800", category_code: "M48", short_code: "00", full_name: "Spinal stenosis, site unspecified", short_name: "Spinal stenosis, site unspecified", category_name: "Spinal stenosis, site unspecified" } end def _M4801 do %ICDCode{full_code: "M4801", category_code: "M48", short_code: "01", full_name: "Spinal stenosis, occipito-atlanto-axial region", short_name: "Spinal stenosis, occipito-atlanto-axial region", category_name: "Spinal stenosis, occipito-atlanto-axial region" } end def _M4802 do %ICDCode{full_code: "M4802", category_code: "M48", short_code: "02", full_name: "Spinal stenosis, cervical region", short_name: "Spinal stenosis, cervical region", category_name: "Spinal stenosis, cervical region" } end def _M4803 do %ICDCode{full_code: "M4803", category_code: "M48", short_code: "03", full_name: "Spinal stenosis, cervicothoracic region", short_name: "Spinal stenosis, cervicothoracic region", category_name: "Spinal stenosis, cervicothoracic region" } end def _M4804 do %ICDCode{full_code: "M4804", category_code: "M48", short_code: "04", full_name: "Spinal stenosis, thoracic region", short_name: "Spinal stenosis, thoracic region", category_name: "Spinal stenosis, thoracic region" } end def _M4805 do %ICDCode{full_code: "M4805", category_code: "M48", short_code: "05", full_name: "Spinal stenosis, thoracolumbar region", short_name: "Spinal stenosis, thoracolumbar region", category_name: "Spinal stenosis, thoracolumbar region" } end def _M4806 do %ICDCode{full_code: "M4806", category_code: "M48", short_code: "06", full_name: "Spinal stenosis, lumbar region", short_name: "Spinal stenosis, lumbar region", category_name: "Spinal stenosis, lumbar region" } end def _M4807 do %ICDCode{full_code: "M4807", category_code: "M48", short_code: "07", full_name: "Spinal stenosis, lumbosacral region", short_name: "Spinal stenosis, lumbosacral region", category_name: "Spinal stenosis, lumbosacral region" } end def _M4808 do %ICDCode{full_code: "M4808", category_code: "M48", short_code: "08", full_name: "Spinal stenosis, sacral and sacrococcygeal region", short_name: "Spinal stenosis, sacral and sacrococcygeal region", category_name: "Spinal stenosis, sacral and sacrococcygeal region" } end def _M4810 do %ICDCode{full_code: "M4810", category_code: "M48", short_code: "10", full_name: "Ankylosing hyperostosis [Forestier], site unspecified", short_name: "Ankylosing hyperostosis [Forestier], site unspecified", category_name: "Ankylosing hyperostosis [Forestier], site unspecified" } end def _M4811 do %ICDCode{full_code: "M4811", category_code: "M48", short_code: "11", full_name: "Ankylosing hyperostosis [Forestier], occipito-atlanto-axial region", short_name: "Ankylosing hyperostosis [Forestier], occipito-atlanto-axial region", category_name: "Ankylosing hyperostosis [Forestier], occipito-atlanto-axial region" } end def _M4812 do %ICDCode{full_code: "M4812", category_code: "M48", short_code: "12", full_name: "Ankylosing hyperostosis [Forestier], cervical region", short_name: "Ankylosing hyperostosis [Forestier], cervical region", category_name: "Ankylosing hyperostosis [Forestier], cervical region" } end def _M4813 do %ICDCode{full_code: "M4813", category_code: "M48", short_code: "13", full_name: "Ankylosing hyperostosis [Forestier], cervicothoracic region", short_name: "Ankylosing hyperostosis [Forestier], cervicothoracic region", category_name: "Ankylosing hyperostosis [Forestier], cervicothoracic region" } end def _M4814 do %ICDCode{full_code: "M4814", category_code: "M48", short_code: "14", full_name: "Ankylosing hyperostosis [Forestier], thoracic region", short_name: "Ankylosing hyperostosis [Forestier], thoracic region", category_name: "Ankylosing hyperostosis [Forestier], thoracic region" } end def _M4815 do %ICDCode{full_code: "M4815", category_code: "M48", short_code: "15", full_name: "Ankylosing hyperostosis [Forestier], thoracolumbar region", short_name: "Ankylosing hyperostosis [Forestier], thoracolumbar region", category_name: "Ankylosing hyperostosis [Forestier], thoracolumbar region" } end def _M4816 do %ICDCode{full_code: "M4816", category_code: "M48", short_code: "16", full_name: "Ankylosing hyperostosis [Forestier], lumbar region", short_name: "Ankylosing hyperostosis [Forestier], lumbar region", category_name: "Ankylosing hyperostosis [Forestier], lumbar region" } end def _M4817 do %ICDCode{full_code: "M4817", category_code: "M48", short_code: "17", full_name: "Ankylosing hyperostosis [Forestier], lumbosacral region", short_name: "Ankylosing hyperostosis [Forestier], lumbosacral region", category_name: "Ankylosing hyperostosis [Forestier], lumbosacral region" } end def _M4818 do %ICDCode{full_code: "M4818", category_code: "M48", short_code: "18", full_name: "Ankylosing hyperostosis [Forestier], sacral and sacrococcygeal region", short_name: "Ankylosing hyperostosis [Forestier], sacral and sacrococcygeal region", category_name: "Ankylosing hyperostosis [Forestier], sacral and sacrococcygeal region" } end def _M4819 do %ICDCode{full_code: "M4819", category_code: "M48", short_code: "19", full_name: "Ankylosing hyperostosis [Forestier], multiple sites in spine", short_name: "Ankylosing hyperostosis [Forestier], multiple sites in spine", category_name: "Ankylosing hyperostosis [Forestier], multiple sites in spine" } end def _M4820 do %ICDCode{full_code: "M4820", category_code: "M48", short_code: "20", full_name: "Kissing spine, site unspecified", short_name: "Kissing spine, site unspecified", category_name: "Kissing spine, site unspecified" } end def _M4821 do %ICDCode{full_code: "M4821", category_code: "M48", short_code: "21", full_name: "Kissing spine, occipito-atlanto-axial region", short_name: "Kissing spine, occipito-atlanto-axial region", category_name: "Kissing spine, occipito-atlanto-axial region" } end def _M4822 do %ICDCode{full_code: "M4822", category_code: "M48", short_code: "22", full_name: "Kissing spine, cervical region", short_name: "Kissing spine, cervical region", category_name: "Kissing spine, cervical region" } end def _M4823 do %ICDCode{full_code: "M4823", category_code: "M48", short_code: "23", full_name: "Kissing spine, cervicothoracic region", short_name: "Kissing spine, cervicothoracic region", category_name: "Kissing spine, cervicothoracic region" } end def _M4824 do %ICDCode{full_code: "M4824", category_code: "M48", short_code: "24", full_name: "Kissing spine, thoracic region", short_name: "Kissing spine, thoracic region", category_name: "Kissing spine, thoracic region" } end def _M4825 do %ICDCode{full_code: "M4825", category_code: "M48", short_code: "25", full_name: "Kissing spine, thoracolumbar region", short_name: "Kissing spine, thoracolumbar region", category_name: "Kissing spine, thoracolumbar region" } end def _M4826 do %ICDCode{full_code: "M4826", category_code: "M48", short_code: "26", full_name: "Kissing spine, lumbar region", short_name: "Kissing spine, lumbar region", category_name: "Kissing spine, lumbar region" } end def _M4827 do %ICDCode{full_code: "M4827", category_code: "M48", short_code: "27", full_name: "Kissing spine, lumbosacral region", short_name: "Kissing spine, lumbosacral region", category_name: "Kissing spine, lumbosacral region" } end def _M4830 do %ICDCode{full_code: "M4830", category_code: "M48", short_code: "30", full_name: "Traumatic spondylopathy, site unspecified", short_name: "Traumatic spondylopathy, site unspecified", category_name: "Traumatic spondylopathy, site unspecified" } end def _M4831 do %ICDCode{full_code: "M4831", category_code: "M48", short_code: "31", full_name: "Traumatic spondylopathy, occipito-atlanto-axial region", short_name: "Traumatic spondylopathy, occipito-atlanto-axial region", category_name: "Traumatic spondylopathy, occipito-atlanto-axial region" } end def _M4832 do %ICDCode{full_code: "M4832", category_code: "M48", short_code: "32", full_name: "Traumatic spondylopathy, cervical region", short_name: "Traumatic spondylopathy, cervical region", category_name: "Traumatic spondylopathy, cervical region" } end def _M4833 do %ICDCode{full_code: "M4833", category_code: "M48", short_code: "33", full_name: "Traumatic spondylopathy, cervicothoracic region", short_name: "Traumatic spondylopathy, cervicothoracic region", category_name: "Traumatic spondylopathy, cervicothoracic region" } end def _M4834 do %ICDCode{full_code: "M4834", category_code: "M48", short_code: "34", full_name: "Traumatic spondylopathy, thoracic region", short_name: "Traumatic spondylopathy, thoracic region", category_name: "Traumatic spondylopathy, thoracic region" } end def _M4835 do %ICDCode{full_code: "M4835", category_code: "M48", short_code: "35", full_name: "Traumatic spondylopathy, thoracolumbar region", short_name: "Traumatic spondylopathy, thoracolumbar region", category_name: "Traumatic spondylopathy, thoracolumbar region" } end def _M4836 do %ICDCode{full_code: "M4836", category_code: "M48", short_code: "36", full_name: "Traumatic spondylopathy, lumbar region", short_name: "Traumatic spondylopathy, lumbar region", category_name: "Traumatic spondylopathy, lumbar region" } end def _M4837 do %ICDCode{full_code: "M4837", category_code: "M48", short_code: "37", full_name: "Traumatic spondylopathy, lumbosacral region", short_name: "Traumatic spondylopathy, lumbosacral region", category_name: "Traumatic spondylopathy, lumbosacral region" } end def _M4838 do %ICDCode{full_code: "M4838", category_code: "M48", short_code: "38", full_name: "Traumatic spondylopathy, sacral and sacrococcygeal region", short_name: "Traumatic spondylopathy, sacral and sacrococcygeal region", category_name: "Traumatic spondylopathy, sacral and sacrococcygeal region" } end def _M4840XA do %ICDCode{full_code: "M4840XA", category_code: "M48", short_code: "40XA", full_name: "Fatigue fracture of vertebra, site unspecified, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, site unspecified, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, site unspecified, initial encounter for fracture" } end def _M4840XD do %ICDCode{full_code: "M4840XD", category_code: "M48", short_code: "40XD", full_name: "Fatigue fracture of vertebra, site unspecified, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, site unspecified, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, site unspecified, subsequent encounter for fracture with routine healing" } end def _M4840XG do %ICDCode{full_code: "M4840XG", category_code: "M48", short_code: "40XG", full_name: "Fatigue fracture of vertebra, site unspecified, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, site unspecified, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, site unspecified, subsequent encounter for fracture with delayed healing" } end def _M4840XS do %ICDCode{full_code: "M4840XS", category_code: "M48", short_code: "40XS", full_name: "Fatigue fracture of vertebra, site unspecified, sequela of fracture", short_name: "Fatigue fracture of vertebra, site unspecified, sequela of fracture", category_name: "Fatigue fracture of vertebra, site unspecified, sequela of fracture" } end def _M4841XA do %ICDCode{full_code: "M4841XA", category_code: "M48", short_code: "41XA", full_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, initial encounter for fracture" } end def _M4841XD do %ICDCode{full_code: "M4841XD", category_code: "M48", short_code: "41XD", full_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, subsequent encounter for fracture with routine healing" } end def _M4841XG do %ICDCode{full_code: "M4841XG", category_code: "M48", short_code: "41XG", full_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, subsequent encounter for fracture with delayed healing" } end def _M4841XS do %ICDCode{full_code: "M4841XS", category_code: "M48", short_code: "41XS", full_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, sequela of fracture", short_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, sequela of fracture", category_name: "Fatigue fracture of vertebra, occipito-atlanto-axial region, sequela of fracture" } end def _M4842XA do %ICDCode{full_code: "M4842XA", category_code: "M48", short_code: "42XA", full_name: "Fatigue fracture of vertebra, cervical region, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, cervical region, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, cervical region, initial encounter for fracture" } end def _M4842XD do %ICDCode{full_code: "M4842XD", category_code: "M48", short_code: "42XD", full_name: "Fatigue fracture of vertebra, cervical region, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, cervical region, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, cervical region, subsequent encounter for fracture with routine healing" } end def _M4842XG do %ICDCode{full_code: "M4842XG", category_code: "M48", short_code: "42XG", full_name: "Fatigue fracture of vertebra, cervical region, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, cervical region, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, cervical region, subsequent encounter for fracture with delayed healing" } end def _M4842XS do %ICDCode{full_code: "M4842XS", category_code: "M48", short_code: "42XS", full_name: "Fatigue fracture of vertebra, cervical region, sequela of fracture", short_name: "Fatigue fracture of vertebra, cervical region, sequela of fracture", category_name: "Fatigue fracture of vertebra, cervical region, sequela of fracture" } end def _M4843XA do %ICDCode{full_code: "M4843XA", category_code: "M48", short_code: "43XA", full_name: "Fatigue fracture of vertebra, cervicothoracic region, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, cervicothoracic region, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, cervicothoracic region, initial encounter for fracture" } end def _M4843XD do %ICDCode{full_code: "M4843XD", category_code: "M48", short_code: "43XD", full_name: "Fatigue fracture of vertebra, cervicothoracic region, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, cervicothoracic region, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, cervicothoracic region, subsequent encounter for fracture with routine healing" } end def _M4843XG do %ICDCode{full_code: "M4843XG", category_code: "M48", short_code: "43XG", full_name: "Fatigue fracture of vertebra, cervicothoracic region, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, cervicothoracic region, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, cervicothoracic region, subsequent encounter for fracture with delayed healing" } end def _M4843XS do %ICDCode{full_code: "M4843XS", category_code: "M48", short_code: "43XS", full_name: "Fatigue fracture of vertebra, cervicothoracic region, sequela of fracture", short_name: "Fatigue fracture of vertebra, cervicothoracic region, sequela of fracture", category_name: "Fatigue fracture of vertebra, cervicothoracic region, sequela of fracture" } end def _M4844XA do %ICDCode{full_code: "M4844XA", category_code: "M48", short_code: "44XA", full_name: "Fatigue fracture of vertebra, thoracic region, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, thoracic region, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, thoracic region, initial encounter for fracture" } end def _M4844XD do %ICDCode{full_code: "M4844XD", category_code: "M48", short_code: "44XD", full_name: "Fatigue fracture of vertebra, thoracic region, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, thoracic region, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, thoracic region, subsequent encounter for fracture with routine healing" } end def _M4844XG do %ICDCode{full_code: "M4844XG", category_code: "M48", short_code: "44XG", full_name: "Fatigue fracture of vertebra, thoracic region, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, thoracic region, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, thoracic region, subsequent encounter for fracture with delayed healing" } end def _M4844XS do %ICDCode{full_code: "M4844XS", category_code: "M48", short_code: "44XS", full_name: "Fatigue fracture of vertebra, thoracic region, sequela of fracture", short_name: "Fatigue fracture of vertebra, thoracic region, sequela of fracture", category_name: "Fatigue fracture of vertebra, thoracic region, sequela of fracture" } end def _M4845XA do %ICDCode{full_code: "M4845XA", category_code: "M48", short_code: "45XA", full_name: "Fatigue fracture of vertebra, thoracolumbar region, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, thoracolumbar region, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, thoracolumbar region, initial encounter for fracture" } end def _M4845XD do %ICDCode{full_code: "M4845XD", category_code: "M48", short_code: "45XD", full_name: "Fatigue fracture of vertebra, thoracolumbar region, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, thoracolumbar region, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, thoracolumbar region, subsequent encounter for fracture with routine healing" } end def _M4845XG do %ICDCode{full_code: "M4845XG", category_code: "M48", short_code: "45XG", full_name: "Fatigue fracture of vertebra, thoracolumbar region, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, thoracolumbar region, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, thoracolumbar region, subsequent encounter for fracture with delayed healing" } end def _M4845XS do %ICDCode{full_code: "M4845XS", category_code: "M48", short_code: "45XS", full_name: "Fatigue fracture of vertebra, thoracolumbar region, sequela of fracture", short_name: "Fatigue fracture of vertebra, thoracolumbar region, sequela of fracture", category_name: "Fatigue fracture of vertebra, thoracolumbar region, sequela of fracture" } end def _M4846XA do %ICDCode{full_code: "M4846XA", category_code: "M48", short_code: "46XA", full_name: "Fatigue fracture of vertebra, lumbar region, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, lumbar region, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, lumbar region, initial encounter for fracture" } end def _M4846XD do %ICDCode{full_code: "M4846XD", category_code: "M48", short_code: "46XD", full_name: "Fatigue fracture of vertebra, lumbar region, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, lumbar region, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, lumbar region, subsequent encounter for fracture with routine healing" } end def _M4846XG do %ICDCode{full_code: "M4846XG", category_code: "M48", short_code: "46XG", full_name: "Fatigue fracture of vertebra, lumbar region, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, lumbar region, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, lumbar region, subsequent encounter for fracture with delayed healing" } end def _M4846XS do %ICDCode{full_code: "M4846XS", category_code: "M48", short_code: "46XS", full_name: "Fatigue fracture of vertebra, lumbar region, sequela of fracture", short_name: "Fatigue fracture of vertebra, lumbar region, sequela of fracture", category_name: "Fatigue fracture of vertebra, lumbar region, sequela of fracture" } end def _M4847XA do %ICDCode{full_code: "M4847XA", category_code: "M48", short_code: "47XA", full_name: "Fatigue fracture of vertebra, lumbosacral region, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, lumbosacral region, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, lumbosacral region, initial encounter for fracture" } end def _M4847XD do %ICDCode{full_code: "M4847XD", category_code: "M48", short_code: "47XD", full_name: "Fatigue fracture of vertebra, lumbosacral region, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, lumbosacral region, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, lumbosacral region, subsequent encounter for fracture with routine healing" } end def _M4847XG do %ICDCode{full_code: "M4847XG", category_code: "M48", short_code: "47XG", full_name: "Fatigue fracture of vertebra, lumbosacral region, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, lumbosacral region, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, lumbosacral region, subsequent encounter for fracture with delayed healing" } end def _M4847XS do %ICDCode{full_code: "M4847XS", category_code: "M48", short_code: "47XS", full_name: "Fatigue fracture of vertebra, lumbosacral region, sequela of fracture", short_name: "Fatigue fracture of vertebra, lumbosacral region, sequela of fracture", category_name: "Fatigue fracture of vertebra, lumbosacral region, sequela of fracture" } end def _M4848XA do %ICDCode{full_code: "M4848XA", category_code: "M48", short_code: "48XA", full_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, initial encounter for fracture", short_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, initial encounter for fracture", category_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, initial encounter for fracture" } end def _M4848XD do %ICDCode{full_code: "M4848XD", category_code: "M48", short_code: "48XD", full_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, subsequent encounter for fracture with routine healing", short_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, subsequent encounter for fracture with routine healing", category_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, subsequent encounter for fracture with routine healing" } end def _M4848XG do %ICDCode{full_code: "M4848XG", category_code: "M48", short_code: "48XG", full_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, subsequent encounter for fracture with delayed healing", short_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, subsequent encounter for fracture with delayed healing", category_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, subsequent encounter for fracture with delayed healing" } end def _M4848XS do %ICDCode{full_code: "M4848XS", category_code: "M48", short_code: "48XS", full_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, sequela of fracture", short_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, sequela of fracture", category_name: "Fatigue fracture of vertebra, sacral and sacrococcygeal region, sequela of fracture" } end def _M4850XA do %ICDCode{full_code: "M4850XA", category_code: "M48", short_code: "50XA", full_name: "Collapsed vertebra, not elsewhere classified, site unspecified, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, site unspecified, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, site unspecified, initial encounter for fracture" } end def _M4850XD do %ICDCode{full_code: "M4850XD", category_code: "M48", short_code: "50XD", full_name: "Collapsed vertebra, not elsewhere classified, site unspecified, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, site unspecified, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, site unspecified, subsequent encounter for fracture with routine healing" } end def _M4850XG do %ICDCode{full_code: "M4850XG", category_code: "M48", short_code: "50XG", full_name: "Collapsed vertebra, not elsewhere classified, site unspecified, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, site unspecified, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, site unspecified, subsequent encounter for fracture with delayed healing" } end def _M4850XS do %ICDCode{full_code: "M4850XS", category_code: "M48", short_code: "50XS", full_name: "Collapsed vertebra, not elsewhere classified, site unspecified, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, site unspecified, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, site unspecified, sequela of fracture" } end def _M4851XA do %ICDCode{full_code: "M4851XA", category_code: "M48", short_code: "51XA", full_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, initial encounter for fracture" } end def _M4851XD do %ICDCode{full_code: "M4851XD", category_code: "M48", short_code: "51XD", full_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, subsequent encounter for fracture with routine healing" } end def _M4851XG do %ICDCode{full_code: "M4851XG", category_code: "M48", short_code: "51XG", full_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, subsequent encounter for fracture with delayed healing" } end def _M4851XS do %ICDCode{full_code: "M4851XS", category_code: "M48", short_code: "51XS", full_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, occipito-atlanto-axial region, sequela of fracture" } end def _M4852XA do %ICDCode{full_code: "M4852XA", category_code: "M48", short_code: "52XA", full_name: "Collapsed vertebra, not elsewhere classified, cervical region, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, cervical region, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, cervical region, initial encounter for fracture" } end def _M4852XD do %ICDCode{full_code: "M4852XD", category_code: "M48", short_code: "52XD", full_name: "Collapsed vertebra, not elsewhere classified, cervical region, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, cervical region, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, cervical region, subsequent encounter for fracture with routine healing" } end def _M4852XG do %ICDCode{full_code: "M4852XG", category_code: "M48", short_code: "52XG", full_name: "Collapsed vertebra, not elsewhere classified, cervical region, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, cervical region, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, cervical region, subsequent encounter for fracture with delayed healing" } end def _M4852XS do %ICDCode{full_code: "M4852XS", category_code: "M48", short_code: "52XS", full_name: "Collapsed vertebra, not elsewhere classified, cervical region, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, cervical region, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, cervical region, sequela of fracture" } end def _M4853XA do %ICDCode{full_code: "M4853XA", category_code: "M48", short_code: "53XA", full_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, initial encounter for fracture" } end def _M4853XD do %ICDCode{full_code: "M4853XD", category_code: "M48", short_code: "53XD", full_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, subsequent encounter for fracture with routine healing" } end def _M4853XG do %ICDCode{full_code: "M4853XG", category_code: "M48", short_code: "53XG", full_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, subsequent encounter for fracture with delayed healing" } end def _M4853XS do %ICDCode{full_code: "M4853XS", category_code: "M48", short_code: "53XS", full_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, cervicothoracic region, sequela of fracture" } end def _M4854XA do %ICDCode{full_code: "M4854XA", category_code: "M48", short_code: "54XA", full_name: "Collapsed vertebra, not elsewhere classified, thoracic region, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, thoracic region, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, thoracic region, initial encounter for fracture" } end def _M4854XD do %ICDCode{full_code: "M4854XD", category_code: "M48", short_code: "54XD", full_name: "Collapsed vertebra, not elsewhere classified, thoracic region, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, thoracic region, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, thoracic region, subsequent encounter for fracture with routine healing" } end def _M4854XG do %ICDCode{full_code: "M4854XG", category_code: "M48", short_code: "54XG", full_name: "Collapsed vertebra, not elsewhere classified, thoracic region, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, thoracic region, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, thoracic region, subsequent encounter for fracture with delayed healing" } end def _M4854XS do %ICDCode{full_code: "M4854XS", category_code: "M48", short_code: "54XS", full_name: "Collapsed vertebra, not elsewhere classified, thoracic region, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, thoracic region, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, thoracic region, sequela of fracture" } end def _M4855XA do %ICDCode{full_code: "M4855XA", category_code: "M48", short_code: "55XA", full_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, initial encounter for fracture" } end def _M4855XD do %ICDCode{full_code: "M4855XD", category_code: "M48", short_code: "55XD", full_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, subsequent encounter for fracture with routine healing" } end def _M4855XG do %ICDCode{full_code: "M4855XG", category_code: "M48", short_code: "55XG", full_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, subsequent encounter for fracture with delayed healing" } end def _M4855XS do %ICDCode{full_code: "M4855XS", category_code: "M48", short_code: "55XS", full_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, thoracolumbar region, sequela of fracture" } end def _M4856XA do %ICDCode{full_code: "M4856XA", category_code: "M48", short_code: "56XA", full_name: "Collapsed vertebra, not elsewhere classified, lumbar region, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, lumbar region, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, lumbar region, initial encounter for fracture" } end def _M4856XD do %ICDCode{full_code: "M4856XD", category_code: "M48", short_code: "56XD", full_name: "Collapsed vertebra, not elsewhere classified, lumbar region, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, lumbar region, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, lumbar region, subsequent encounter for fracture with routine healing" } end def _M4856XG do %ICDCode{full_code: "M4856XG", category_code: "M48", short_code: "56XG", full_name: "Collapsed vertebra, not elsewhere classified, lumbar region, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, lumbar region, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, lumbar region, subsequent encounter for fracture with delayed healing" } end def _M4856XS do %ICDCode{full_code: "M4856XS", category_code: "M48", short_code: "56XS", full_name: "Collapsed vertebra, not elsewhere classified, lumbar region, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, lumbar region, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, lumbar region, sequela of fracture" } end def _M4857XA do %ICDCode{full_code: "M4857XA", category_code: "M48", short_code: "57XA", full_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, initial encounter for fracture" } end def _M4857XD do %ICDCode{full_code: "M4857XD", category_code: "M48", short_code: "57XD", full_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, subsequent encounter for fracture with routine healing" } end def _M4857XG do %ICDCode{full_code: "M4857XG", category_code: "M48", short_code: "57XG", full_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, subsequent encounter for fracture with delayed healing" } end def _M4857XS do %ICDCode{full_code: "M4857XS", category_code: "M48", short_code: "57XS", full_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, lumbosacral region, sequela of fracture" } end def _M4858XA do %ICDCode{full_code: "M4858XA", category_code: "M48", short_code: "58XA", full_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, initial encounter for fracture", short_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, initial encounter for fracture", category_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, initial encounter for fracture" } end def _M4858XD do %ICDCode{full_code: "M4858XD", category_code: "M48", short_code: "58XD", full_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, subsequent encounter for fracture with routine healing", short_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, subsequent encounter for fracture with routine healing", category_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, subsequent encounter for fracture with routine healing" } end def _M4858XG do %ICDCode{full_code: "M4858XG", category_code: "M48", short_code: "58XG", full_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, subsequent encounter for fracture with delayed healing", short_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, subsequent encounter for fracture with delayed healing", category_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, subsequent encounter for fracture with delayed healing" } end def _M4858XS do %ICDCode{full_code: "M4858XS", category_code: "M48", short_code: "58XS", full_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, sequela of fracture", short_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, sequela of fracture", category_name: "Collapsed vertebra, not elsewhere classified, sacral and sacrococcygeal region, sequela of fracture" } end def _M488X1 do %ICDCode{full_code: "M488X1", category_code: "M48", short_code: "8X1", full_name: "Other specified spondylopathies, occipito-atlanto-axial region", short_name: "Other specified spondylopathies, occipito-atlanto-axial region", category_name: "Other specified spondylopathies, occipito-atlanto-axial region" } end def _M488X2 do %ICDCode{full_code: "M488X2", category_code: "M48", short_code: "8X2", full_name: "Other specified spondylopathies, cervical region", short_name: "Other specified spondylopathies, cervical region", category_name: "Other specified spondylopathies, cervical region" } end def _M488X3 do %ICDCode{full_code: "M488X3", category_code: "M48", short_code: "8X3", full_name: "Other specified spondylopathies, cervicothoracic region", short_name: "Other specified spondylopathies, cervicothoracic region", category_name: "Other specified spondylopathies, cervicothoracic region" } end def _M488X4 do %ICDCode{full_code: "M488X4", category_code: "M48", short_code: "8X4", full_name: "Other specified spondylopathies, thoracic region", short_name: "Other specified spondylopathies, thoracic region", category_name: "Other specified spondylopathies, thoracic region" } end def _M488X5 do %ICDCode{full_code: "M488X5", category_code: "M48", short_code: "8X5", full_name: "Other specified spondylopathies, thoracolumbar region", short_name: "Other specified spondylopathies, thoracolumbar region", category_name: "Other specified spondylopathies, thoracolumbar region" } end def _M488X6 do %ICDCode{full_code: "M488X6", category_code: "M48", short_code: "8X6", full_name: "Other specified spondylopathies, lumbar region", short_name: "Other specified spondylopathies, lumbar region", category_name: "Other specified spondylopathies, lumbar region" } end def _M488X7 do %ICDCode{full_code: "M488X7", category_code: "M48", short_code: "8X7", full_name: "Other specified spondylopathies, lumbosacral region", short_name: "Other specified spondylopathies, lumbosacral region", category_name: "Other specified spondylopathies, lumbosacral region" } end def _M488X8 do %ICDCode{full_code: "M488X8", category_code: "M48", short_code: "8X8", full_name: "Other specified spondylopathies, sacral and sacrococcygeal region", short_name: "Other specified spondylopathies, sacral and sacrococcygeal region", category_name: "Other specified spondylopathies, sacral and sacrococcygeal region" } end def _M488X9 do %ICDCode{full_code: "M488X9", category_code: "M48", short_code: "8X9", full_name: "Other specified spondylopathies, site unspecified", short_name: "Other specified spondylopathies, site unspecified", category_name: "Other specified spondylopathies, site unspecified" } end def _M489 do %ICDCode{full_code: "M489", category_code: "M48", short_code: "9", full_name: "Spondylopathy, unspecified", short_name: "Spondylopathy, unspecified", category_name: "Spondylopathy, unspecified" } end end
48.796071
161
0.684872
ff922a95190637355de967a367766a685696a251
304
ex
Elixir
lib/graphql/validation.ex
marvinhagemeister/graphql
43bccc041438f05d14c8c6f40f193c3d7957ca9d
[ "BSD-3-Clause" ]
719
2016-03-18T03:10:46.000Z
2022-02-02T10:07:29.000Z
lib/graphql/validation.ex
marvinhagemeister/graphql
43bccc041438f05d14c8c6f40f193c3d7957ca9d
[ "BSD-3-Clause" ]
51
2015-08-30T03:15:17.000Z
2016-03-02T07:13:26.000Z
lib/graphql/validation.ex
marvinhagemeister/graphql
43bccc041438f05d14c8c6f40f193c3d7957ca9d
[ "BSD-3-Clause" ]
34
2016-03-30T12:56:11.000Z
2021-08-30T09:21:54.000Z
defmodule GraphQL.Validation do @moduledoc ~S""" Helpers that are useful within validation rules. """ @doc """ Returns an updated accumulator containing the validation error. """ def report_error(acc, error) do %{acc | validation_errors: [error] ++ acc[:validation_errors]} end end
21.714286
66
0.700658
ff9267b2547ac220e9929e5848e9ae43c20980b2
3,079
ex
Elixir
clients/analytics/lib/google_api/analytics/v3/model/goals.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/analytics/lib/google_api/analytics/v3/model/goals.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/analytics/lib/google_api/analytics/v3/model/goals.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.Analytics.V3.Model.Goals do @moduledoc """ A goal collection lists Analytics goals to which the user has access. Each view (profile) can have a set of goals. Each resource in the Goal collection corresponds to a single Analytics goal. ## Attributes * `items` (*type:* `list(GoogleApi.Analytics.V3.Model.Goal.t)`, *default:* `nil`) - A list of goals. * `itemsPerPage` (*type:* `integer()`, *default:* `nil`) - The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter. * `kind` (*type:* `String.t`, *default:* `analytics#goals`) - Collection type. * `nextLink` (*type:* `String.t`, *default:* `nil`) - Link to next page for this goal collection. * `previousLink` (*type:* `String.t`, *default:* `nil`) - Link to previous page for this goal collection. * `startIndex` (*type:* `integer()`, *default:* `nil`) - The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter. * `totalResults` (*type:* `integer()`, *default:* `nil`) - The total number of results for the query, regardless of the number of resources in the result. * `username` (*type:* `String.t`, *default:* `nil`) - Email ID of the authenticated user """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :items => list(GoogleApi.Analytics.V3.Model.Goal.t()) | nil, :itemsPerPage => integer() | nil, :kind => String.t() | nil, :nextLink => String.t() | nil, :previousLink => String.t() | nil, :startIndex => integer() | nil, :totalResults => integer() | nil, :username => String.t() | nil } field(:items, as: GoogleApi.Analytics.V3.Model.Goal, type: :list) field(:itemsPerPage) field(:kind) field(:nextLink) field(:previousLink) field(:startIndex) field(:totalResults) field(:username) end defimpl Poison.Decoder, for: GoogleApi.Analytics.V3.Model.Goals do def decode(value, options) do GoogleApi.Analytics.V3.Model.Goals.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Analytics.V3.Model.Goals do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
45.279412
299
0.692433
ff927c7c7912891af824c8a5bf40a80a86fed75c
4,992
ex
Elixir
clients/cloud_identity/lib/google_api/cloud_identity/v1/model/device.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/cloud_identity/lib/google_api/cloud_identity/v1/model/device.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/cloud_identity/lib/google_api/cloud_identity/v1/model/device.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.CloudIdentity.V1.Model.Device do @moduledoc """ Represents a Device known to Google Cloud, independent of the device ownership, type, and whether it is assigned or in use by a user. ## Attributes * `androidSpecificAttributes` (*type:* `GoogleApi.CloudIdentity.V1.Model.AndroidAttributes.t`, *default:* `nil`) - Output only. Attributes specific to Android devices. * `assetTag` (*type:* `String.t`, *default:* `nil`) - Asset tag of the device. * `brand` (*type:* `String.t`, *default:* `nil`) - Output only. Device brand. Example: Samsung. * `compromisedState` (*type:* `String.t`, *default:* `nil`) - Output only. Represents whether the Device is compromised. * `createTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. When the Company-Owned device was imported. This field is empty for BYOD devices. * `deviceType` (*type:* `String.t`, *default:* `nil`) - Output only. Type of device. * `imei` (*type:* `String.t`, *default:* `nil`) - Output only. IMEI number of device if GSM device; empty otherwise. * `lastSyncTime` (*type:* `DateTime.t`, *default:* `nil`) - Most recent time when device synced with this service. * `managementState` (*type:* `String.t`, *default:* `nil`) - Output only. Management state of the device * `manufacturer` (*type:* `String.t`, *default:* `nil`) - Output only. Device manufacturer. Example: Motorola. * `meid` (*type:* `String.t`, *default:* `nil`) - Output only. MEID number of device if CDMA device; empty otherwise. * `model` (*type:* `String.t`, *default:* `nil`) - Output only. Model name of device. Example: Pixel 3. * `name` (*type:* `String.t`, *default:* `nil`) - Output only. [Resource name](https://cloud.google.com/apis/design/resource_names) of the Device in format: `devices/{device_id}`, where device_id is the unique id assigned to the Device. * `networkOperator` (*type:* `String.t`, *default:* `nil`) - Output only. Mobile or network operator of device, if available. * `osVersion` (*type:* `String.t`, *default:* `nil`) - Output only. OS version of the device. Example: Android 8.1.0. * `ownerType` (*type:* `String.t`, *default:* `nil`) - Whether the device is owned by the company or an individual * `releaseVersion` (*type:* `String.t`, *default:* `nil`) - Output only. OS release version. Example: 6.0. * `serialNumber` (*type:* `String.t`, *default:* `nil`) - Serial Number of device. Example: HT82V1A01076. * `wifiMacAddresses` (*type:* `list(String.t)`, *default:* `nil`) - WiFi MAC addresses of device. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :androidSpecificAttributes => GoogleApi.CloudIdentity.V1.Model.AndroidAttributes.t(), :assetTag => String.t(), :brand => String.t(), :compromisedState => String.t(), :createTime => DateTime.t(), :deviceType => String.t(), :imei => String.t(), :lastSyncTime => DateTime.t(), :managementState => String.t(), :manufacturer => String.t(), :meid => String.t(), :model => String.t(), :name => String.t(), :networkOperator => String.t(), :osVersion => String.t(), :ownerType => String.t(), :releaseVersion => String.t(), :serialNumber => String.t(), :wifiMacAddresses => list(String.t()) } field(:androidSpecificAttributes, as: GoogleApi.CloudIdentity.V1.Model.AndroidAttributes) field(:assetTag) field(:brand) field(:compromisedState) field(:createTime, as: DateTime) field(:deviceType) field(:imei) field(:lastSyncTime, as: DateTime) field(:managementState) field(:manufacturer) field(:meid) field(:model) field(:name) field(:networkOperator) field(:osVersion) field(:ownerType) field(:releaseVersion) field(:serialNumber) field(:wifiMacAddresses, type: :list) end defimpl Poison.Decoder, for: GoogleApi.CloudIdentity.V1.Model.Device do def decode(value, options) do GoogleApi.CloudIdentity.V1.Model.Device.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.CloudIdentity.V1.Model.Device do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
47.542857
171
0.666266
ff92a9574e6f08c2a9c4071921e2838bd1823bde
6,533
ex
Elixir
lib/mix/tasks/siwapp.demo.ex
peillis/siwapp
f8c11ad2660574395d636674aa449c959f0f87f1
[ "MIT" ]
4
2015-02-12T09:23:47.000Z
2022-03-09T18:11:06.000Z
lib/mix/tasks/siwapp.demo.ex
peillis/siwapp
f8c11ad2660574395d636674aa449c959f0f87f1
[ "MIT" ]
254
2021-12-09T14:40:41.000Z
2022-03-31T08:09:37.000Z
lib/mix/tasks/siwapp.demo.ex
peillis/siwapp
f8c11ad2660574395d636674aa449c959f0f87f1
[ "MIT" ]
1
2022-03-07T10:25:49.000Z
2022-03-07T10:25:49.000Z
defmodule Mix.Tasks.Siwapp.Demo do @shortdoc "Deletes all data and puts some demo data" @moduledoc """ Only 'force' option can be provided in order to avoid being asked for confirmation. If any other is given, task won't be completed ## Examples $ mix siwapp.demo This will remove all data in database. Are you sure? [y/n] $ mix siwapp.demo force ... All data's been substituted by demo $ mix siwapp.demo DoesNotExistArg Sorry, can't understand that command """ use Mix.Task alias Siwapp.Accounts alias Siwapp.Commons alias Siwapp.Customers alias Siwapp.Invoices alias Siwapp.RecurringInvoices alias Siwapp.Repo alias Siwapp.Settings alias Siwapp.Templates @models [ Invoices.Item, Invoices.Payment, Accounts.User, Accounts.UserToken, Invoices.Invoice, RecurringInvoices.RecurringInvoice, Commons.Tax, Commons.Series, Customers.Customer, Settings.Setting, Templates.Template ] @impl Mix.Task def run(args) do Enum.each([:postgrex, :ecto, :cachex], &Application.ensure_all_started(&1)) Siwapp.Repo.start_link() Cachex.start_link(:siwapp_cache) validate_args!(args) take_action(args) end @spec take_action(list) :: :ok | no_return() defp take_action(["force"]) do demo_db() end defp take_action(_args) do case IO.gets("\n This will remove all data in database. Are you sure? [y/n]\t") do "y\n" -> demo_db() _ -> IO.puts("Operation aborted") end end @spec validate_args!(list | term()) :: no_return() defp validate_args!(["force"]), do: :ok defp validate_args!([]), do: :ok defp validate_args!(_) do raise_with_help("Sorry, can't understand that command") end @spec raise_with_help(binary) :: no_return() defp raise_with_help(msg) do Mix.raise(""" #{msg} mix siwapp.demo only accepts 'force' argument as an option to confirm operation and avoid confirmation need You can try interactive task: mix siwapp.demo or force that with: mix siwapp.demo force """) end @spec demo_db :: :ok defp demo_db do sequence_name = fn x -> case x |> to_string() |> String.split(".") |> List.last() |> String.downcase() do "recurringinvoice" -> "recurring_invoice" "tax" -> "taxe" "series" -> "serie" model -> model end <> "s_id_seq" end Enum.each( @models, &(Repo.delete_all(&1) && Repo.query("ALTER SEQUENCE #{sequence_name.(&1)} RESTART")) ) settings = [ company: "Doofinder", company_vat_id: "1fg5t7", company_phone: "632278941", company_email: "demo@example", company_website: "www.mywebsite.com", currency: "USD", days_to_due: "#{Faker.random_between(0, 5)}", company_address: "Newton Avenue, 32. NY", legal_terms: "Clauses of our contract" ] Enum.each(settings, &Settings.create(&1)) {:ok, print_default} = File.read("priv/repo/fixtures/print_default.html.heex") {:ok, email_default} = File.read("priv/repo/fixtures/email_default.html.heex") Templates.create(%{ name: "Print Default", template: print_default }) {:ok, email_template} = Templates.create(%{ name: "Email Default", template: email_default, subject: "Invoice: <%= SiwappWeb.PageView.reference(series.code, number)%> " }) Templates.set_default(:email, email_template) series = [ %{name: "A-series", code: "A"}, %{name: "B-series", code: "B"}, %{name: "C-series", code: "C"} ] Enum.each(series, &Commons.create_series(&1)) taxes = [ %{name: "VAT", value: 21, default: true}, %{name: "RETENTION", value: -15} ] Enum.each(taxes, &Commons.create_tax(&1)) customers = Enum.map(0..15, fn _i -> %{name: Faker.Person.name(), id: Faker.Code.issn()} end) Enum.each( customers, &Customers.create(%{ name: &1.name, identification: &1.id, email: Faker.Internet.email(), contact_person: Faker.Person.name(), invoicing_address: "#{Faker.Address.street_address()}\n#{Faker.Address.postcode()} #{Faker.Address.country()}" }) ) currencies = ["USD", "USD", "USD", "EUR", "GBP"] booleans = [true, false] invoices = Enum.map(0..30, fn _i -> %{customer: Enum.random(customers), issue_date: Faker.Date.backward(31)} end) Enum.each( invoices, &Invoices.create(%{ name: &1.customer.name, identification: &1.customer.id, paid: Enum.random(booleans), sent_by_email: Enum.random(booleans), issue_date: &1.issue_date, due_date: Date.add(&1.issue_date, Faker.random_between(1, 31)), series_id: Enum.random(Enum.map(Commons.list_series(), fn x -> x.id end)), currency: Enum.random(currencies), items: [ %{ quantity: Faker.random_between(1, 2), description: "#{Faker.App.name()} App Development", unitary_cost: Faker.random_between(10_000, 1_000_000), taxes: ["VAT", "RETENTION"] } ] }) ) period_types = ["Daily", "Monthly", "Yearly"] taxes_list = [["VAT"], ["RETENTION"], ["VAT", "RETENTION"], []] recurring_invoices = Enum.map(0..30, fn _i -> %{customer: Enum.random(customers), starting_date: Faker.Date.backward(31)} end) Enum.each( recurring_invoices, &RecurringInvoices.create(%{ name: &1.customer.name, identification: &1.customer.id, period: Faker.random_between(1, 12), period_type: Enum.random(period_types), starting_date: &1.starting_date, series_id: Enum.random(Enum.map(Commons.list_series(), fn x -> x.id end)), currency: Enum.random(currencies), send_by_email: Enum.random(booleans), items: %{ "0" => %{ "quantity" => Faker.random_between(1, 2), "description" => "#{Faker.App.name()} App Development", "unitary_cost" => Faker.random_between(10_000, 1_000_000), "discount" => Faker.random_between(0, 5), "taxes" => Enum.random(taxes_list) } } }) ) Siwapp.Accounts.register_user(%{ email: "demo@example.com", password: "secretsecret", admin: "true" }) IO.puts("All data's been substituted by demo") end end
26.995868
101
0.603551
ff92b3544e216503a4e47e4f5ac27a084a2189ad
108
exs
Elixir
test/adz_test.exs
operable/adz
648c292d40740f96e26deb42b23308218de7e66a
[ "Apache-2.0" ]
null
null
null
test/adz_test.exs
operable/adz
648c292d40740f96e26deb42b23308218de7e66a
[ "Apache-2.0" ]
null
null
null
test/adz_test.exs
operable/adz
648c292d40740f96e26deb42b23308218de7e66a
[ "Apache-2.0" ]
null
null
null
defmodule AdzTest do use ExUnit.Case doctest Adz test "the truth" do assert 1 + 1 == 2 end end
12
21
0.648148
ff92d6600b5f54a06108212c78419e618e301c85
16,241
ex
Elixir
lib/breaker.ex
awochna/breaker
84a7855939b1350376bac555fb1ee1475a842e9a
[ "MIT" ]
33
2017-01-26T23:37:00.000Z
2021-05-17T16:39:35.000Z
lib/breaker.ex
awochna/breaker
84a7855939b1350376bac555fb1ee1475a842e9a
[ "MIT" ]
9
2017-02-14T22:12:02.000Z
2019-08-06T20:46:41.000Z
lib/breaker.ex
awochna/breaker
84a7855939b1350376bac555fb1ee1475a842e9a
[ "MIT" ]
4
2018-01-23T02:36:14.000Z
2019-08-06T15:42:01.000Z
defmodule Breaker do @moduledoc """ A circuit-breaker wrapped around `HTTPotion` to make requests to external resources and help your application gracefully fail. Defines a function for each HTTP method (ie `Breaker.get()`) that returns a Task that will execute the HTTP request (using `HTTPotion`) and record the response in the circuit breaker. """ use GenServer @typedoc """ A Map containing information for the circuit. It holds: * `url`: The base url associated with the breaker. * `headers`: Additional headers to use when making requests. * `timeout`: The time to wait (in ms) before giving up on a request. * `open`: The current state of the breaker. * `error_threshold`: The percent of requests allowed to fail, as a float. * `window_length`: The number of buckets in the health calculation window. * `bucket_length`: The number of milliseconds for each bucket. * `sum`: The current sum of total requests and errors. * `window`: The window of buckets adding up to `sum`. """ @type t :: %{ url: String.t, headers: [...], timeout: number, open: boolean, error_threshold: float, window_length: number, bucket_length: number, sum: %{total: number, errors: number}, window: [%{total: number, errors: number}] } ### Public API @doc """ Create a new circuit-breaker with the given options keyword list. ## Parameters: ## * `options`: A Keyword list of options, described below. * `name`: The name to register the GenServer. ## Available options are: ## * `url`: The base url to use for the breaker. This is ideally a single external resource, complete with protocal, domain name, port, and an optional subpath. Required. * `headers`: A keyword list of headers, passed to `HTTPotion`. * `timeout`: How long to wait until considering the request timed out. Passed to HTTPotion. * `open`: Boolean defining if the circuit is broken. Defaults to false. * `error_threshold`: The percent of requests allowed to fail, as a float. Defaults to 0.05 (5%) * `window_length`: The number of buckets in the health calculation window. Defaults to 10. * `bucket_length`: The number of milliseconds for each bucket. Defaults to 1000, meaning health is caluculated over the past 10 seconds using the defaults. ## Examples: ## iex> options = [url: "http://httpbin.org/"] iex> {:ok, circuit} = Breaker.start_link(options) iex> is_pid(circuit) true """ @spec start_link([url: String.t], atom | tuple) :: {:ok, pid} def start_link(options, name \\ nil) do GenServer.start_link(__MODULE__, options, name: name) end @doc """ Checks if the given response is either a `%Breaker.OpenCircuitError{}`, a timeout, or has a 500 status code. ## Parameters: ## * `response`: The response recieved from one of the HTTP method calls. ## Examples: ## iex> Breaker.error?(%Breaker.OpenCircuitError{}) true iex> Breaker.error?(%HTTPotion.ErrorResponse{}) true iex> Breaker.error?(%HTTPotion.Response{status_code: 500}) true iex> Breaker.error?(%HTTPotion.Response{status_code: 200}) false """ @spec error?(%Breaker.OpenCircuitError{} | %HTTPotion.ErrorResponse{} | %HTTPotion.Response{}) :: boolean def error?(response) do response.__struct__ == Breaker.OpenCircuitError || response.__struct__ == HTTPotion.ErrorResponse || response.status_code == 500 end @doc """ Trip the circuit. This sets the "open" status to true and has no effect if the "open" status is already true. This has the effect of cutting off communications using the circuit and starts the restoration process to test if the external source is healthy. ## Parameters ## * `circuit`: The pid of the breaker to trip. ## Examples: ## iex> {:ok, circuit} = Breaker.start_link([url: "http://httpbin.org/"]) iex> response = Breaker.get(circuit, "/get") |> Task.await iex> response.status_code 200 iex> Breaker.trip(circuit) iex> Breaker.get(circuit, "/get") |> Task.await %Breaker.OpenCircuitError{message: "circuit is open"} """ @spec trip(pid) :: :ok def trip(circuit), do: GenServer.call(circuit, :trip) @doc """ Reset the circuit breaker. This sets the "open" status to false and has no effect if the "open" status is already false. This has the effect of restoring communications using the circuit, but it does not clear any recent unhealthy requests. As such, it could recalculate and trip itself again at the end of the next request or after a roll. ## Parameters: ## * `circuit`: The pid of the breaker to reset. ## Examples: ## iex> options = [url: "http://httpbin.org/", open: true] iex> {:ok, circuit} = Breaker.start_link(options) iex> Breaker.open?(circuit) true iex> Breaker.reset(circuit) iex> Breaker.open?(circuit) false """ @spec reset(pid) :: :ok def reset(circuit), do: GenServer.call(circuit, :reset) @doc """ Ask if the circuit is open or not. Don't forget, an open circuit is one that is not properly connected and thus does not allow electrons to flow. In this case, it does not allow communication to the external resource. I get this mixed up in my head sometimes. ## Parameters: ## * `circuit`: The pid of the breaker to check. ## Examples: ## iex> options = [url: "http://httpbin.org/"] iex> {:ok, circuit} = Breaker.start_link(options) iex> Breaker.open?(circuit) false """ @spec open?(pid) :: boolean def open?(circuit), do: GenServer.call(circuit, :open?) @doc """ Roll the window, creating a new bucket and possibly pushing out an old one, updating the sum values as necessary. ## Parameters: ## * `circuit`: The pid of the breaker to roll. ## Examples: ## iex> options = [url: "http://httpbin.org/", window: [%{total: 1, errors: 0}]] iex> {:ok, circuit} = Breaker.start_link(options) iex> Breaker.roll(circuit) :ok """ @spec roll(pid) :: :ok def roll(circuit), do: GenServer.cast(circuit, :roll) @doc """ Count a given response in the breaker's current bucket and sums. Adds the response to the current bucket of the health window, the total sum, and finalizes by recalculating the breaker's status. **You probably won't need to use this manually.** This is done automatically when a request is made through this module. ## Parameters: ## * `circuit`: The pid of the breaker to count in. * `response`: The response received from a request. ## Examples: ## iex> {:ok, circuit} = Breaker.start_link([url: "http://httpbin.org/"]) iex> Breaker.count(circuit, %HTTPotion.ErrorResponse{}) :ok """ @spec count(pid, %HTTPotion.Response{} | %HTTPotion.ErrorResponse{}) :: :ok def count(circuit, response), do: GenServer.cast(circuit, {:count, response}) ##### # Request calls @doc """ Make an async GET request to the specified path using the given breaker. Task returning alias for `make_request(circuit, path, :get, options)`. ## Parameters: ## * `circuit`: The breaker to perform the request. * `path`: The path string to append to the end of the breaker's `url`. * `options`: Additional options passed to HTTPotion. ## Examples: ## iex> {:ok, breaker} = Breaker.start_link([url: "http://httpbin.org/"]) iex> request = Breaker.get(breaker, "/get") iex> response = Task.await(request) iex> response.status_code 200 """ @spec get(pid, String.t, []) :: Task.t def get(circuit, path, options \\ []) do Task.async(__MODULE__, :make_request, [circuit, path, :get, options]) end @doc """ Make an async PUT request to the specified path using the given breaker. Task returning alias for `make_request(circuit, path, :put, options)`. ## Parameters: ## * `circuit`: The breaker to perform the request. * `path`: The path string to append to the end of the breaker's `url`. * `options`: Additional options passed to HTTPotion. """ @spec put(pid, String.t, []) :: Task.t def put(circuit, path, options \\ []) do Task.async(__MODULE__, :make_request, [circuit, path, :put, options]) end @doc """ Make an async HEAD request to the specified path using the given breaker. Task returning alias for `make_request(circuit, path, :head, options)`. ## Parameters: ## * `circuit`: The breaker to perform the request. * `path`: The path string to append to the end of the breaker's `url`. * `options`: Additional options passed to HTTPotion. """ @spec head(pid, String.t, []) :: Task.t def head(circuit, path, options \\ []) do Task.async(__MODULE__, :make_request, [circuit, path, :head, options]) end @doc """ Make an async POST request to the specified path using the given breaker. Task returning alias for `make_request(circuit, path, :post, options)`. ## Parameters: ## * `circuit`: The breaker to perform the request. * `path`: The path string to append to the end of the breaker's `url`. * `options`: Additional options passed to HTTPotion. """ @spec post(pid, String.t, []) :: Task.t def post(circuit, path, options \\ []) do Task.async(__MODULE__, :make_request, [circuit, path, :post, options]) end @doc """ Make an async PATCH request to the specified path using the given breaker. Task returning alias for `make_request(circuit, path, :patch, options)`. ## Parameters: ## * `circuit`: The breaker to perform the request. * `path`: The path string to append to the end of the breaker's `url`. * `options`: Additional options passed to HTTPotion. """ @spec patch(pid, String.t, []) :: Task.t def patch(circuit, path, options \\ []) do Task.async(__MODULE__, :make_request, [circuit, path, :patch, options]) end @doc """ Make an async DELETE request to the specified path using the given breaker. Task returning alias for `make_request(circuit, path, :delete, options)`. ## Parameters: ## * `circuit`: The breaker to perform the request. * `path`: The path string to append to the end of the breaker's `url`. * `options`: Additional options passed to HTTPotion. """ @spec delete(pid, String.t, []) :: Task.t def delete(circuit, path, options \\ []) do Task.async(__MODULE__, :make_request, [circuit, path, :delete, options]) end @doc """ Make an async OPTIONS request to the specified path using the given breaker. Task returning alias for `make_request(circuit, path, :options, options)`. ## Parameters: ## * `circuit`: The breaker to perform the request. * `path`: The path string to append to the end of the breaker's `url`. * `options`: Additional options passed to HTTPotion. """ @spec options(pid, String.t, []) :: Task.t def options(circuit, path, options \\ []) do Task.async(__MODULE__, :make_request, [circuit, path, :options, options]) end @doc """ Make an HTTP(S) request using the specified breaker, using the given method. This function isn't probably one you would want to use on your own and instead, use the method-specific functions (`Breaker.get()`). They return Tasks and are async, while this is sync. ## Parameters: ## * `circuit`: The circuit to make the request with. * `path`: The request path, this is add to the circuit's `url`. * `method`: An atom specifying the HTTP method, used by HTTPotion. * `options`: Extra options to pass to HTTPotion. The circuit's `timeout` and `headers` are also added to this. ## Examples: ## iex> {:ok, breaker} = Breaker.start_link([url: "http://httpbin.org/"]) iex> response = Breaker.make_request(breaker, "/get", :get) iex> response.status_code 200 """ @spec make_request(pid, String.t, atom, []) :: %HTTPotion.Response{} | %HTTPotion.ErrorResponse{} | %Breaker.OpenCircuitError{} def make_request(circuit, path, method, options \\ []) do case GenServer.call(circuit, :options) do %Breaker.OpenCircuitError{} -> %Breaker.OpenCircuitError{} {headers, timeout, url} -> headers = options |> Keyword.get(:headers, []) |> Keyword.merge(headers, fn(_key, v1, _v2) -> v1 end) options = options |> Keyword.put_new(:timeout, timeout) |> Keyword.put(:headers, headers) request_address = URI.merge(url, path) response = HTTPotion.request(method, request_address, options) Breaker.count(circuit, response) response end end ### GenServer API @spec init(keyword) :: {:ok | :stop, :missing_url | map} def init(options) do if Keyword.has_key?(options, :url) do state = options |> Enum.into(%{}) |> Map.put_new(:headers, []) |> Map.put_new(:timeout, 3000) |> Map.put_new(:open, false) |> Map.put_new(:error_threshold, 0.05) |> Map.put_new(:window_length, 10) |> Map.put_new(:bucket_length, 1000) |> Map.put_new(:window, [%{total: 0, errors: 0}]) |> Map.put_new(:sum, %{total: 0, errors: 0}) :timer.apply_interval(state.bucket_length, __MODULE__, :roll, [self()]) {:ok, state} else {:stop, :missing_url} end end @spec handle_call(atom | tuple, pid, Breaker.t) :: {atom, any, Breaker.t} def handle_call(:open?, _from, state) do {:reply, state.open, state} end def handle_call(:options, _from, state) do if state.open do {:reply, %Breaker.OpenCircuitError{}, state} else {:reply, {state.headers, state.timeout, state.url}, state} end end def handle_call(:trip, _from, state) do {:reply, :ok, Map.put(state, :open, true)} end def handle_call(:reset, _from, state) do {:reply, :ok, Map.put(state, :open, false)} end @spec handle_cast(atom | tuple, Breaker.t) :: {atom, Breaker.t} def handle_cast({:count, response}, state) do if Breaker.error?(response) do state = state |> count_miss() |> calculate_status() {:noreply, state} else state = state |> count_hit() |> calculate_status() {:noreply, state} end end def handle_cast(:recalculate, state) do {:noreply, calculate_status(state)} end def handle_cast(:roll, state) do state = state |> shift_window() |> trim_window() |> calculate_status() {:noreply, state} end ### Private API defp count_hit(state) do state |> add_to_current_window(:total) |> add_to_sum(:total) end defp count_miss(state) do state |> add_to_current_window(:error) |> add_to_sum(:error) end defp add_to_current_window(state, :total) do Map.update!(state, :window, fn([current | rest]) -> [Map.update!(current, :total, &(&1 + 1)) | rest] end) end defp add_to_current_window(state, :error) do Map.update!(state, :window, fn([current | rest]) -> current = current |> Map.update!(:total, &(&1 + 1)) |> Map.update!(:errors, &(&1 + 1)) [current | rest] end) end defp add_to_sum(state, :total) do Map.update!(state, :sum, fn(sum) -> Map.update!(sum, :total, &(&1 + 1)) end) end defp add_to_sum(state, :error) do Map.update!(state, :sum, fn(sum) -> sum |> Map.update!(:total, &(&1 + 1)) |> Map.update!(:errors, &(&1 + 1)) end) end defp calculate_status(state) do if state.sum.total == 0 do Map.put(state, :open, false) else error_rate = state.sum.errors / state.sum.total Map.put(state, :open, error_rate > state.error_threshold) end end defp shift_window(state) do Map.update!(state, :window, &([%{total: 0, errors: 0} | &1])) end defp trim_window(state) do if length(state.window) <= state.window_length do state else {removed, window} = pop(state.window) state |> Map.put(:window, window) |> Map.update!(:sum, fn(sum) -> sum |> Map.update!(:total, &(&1 - removed.total)) |> Map.update!(:errors, &(&1 - removed.errors)) end) end end defp pop(list) do {List.last(list), List.delete_at(list, -1)} end end
29.854779
83
0.64799
ff92d77a8e628e7061ace82150751744ff7146c0
12,885
ex
Elixir
lib/commanded/process_managers/process_manager.ex
SimpleBet/commanded
dc89737bd22daf4f6c5b3333b5d8d8de47fea5b8
[ "MIT" ]
1
2020-03-09T11:50:38.000Z
2020-03-09T11:50:38.000Z
lib/commanded/process_managers/process_manager.ex
perzanko/commanded
fd18ee3981cd237cbb874d1ccd8155e98d35d178
[ "MIT" ]
null
null
null
lib/commanded/process_managers/process_manager.ex
perzanko/commanded
fd18ee3981cd237cbb874d1ccd8155e98d35d178
[ "MIT" ]
null
null
null
defmodule Commanded.ProcessManagers.ProcessManager do @moduledoc """ Macro used to define a process manager. A process manager is responsible for coordinating one or more aggregates. It handles events and dispatches commands in response. Process managers have state that can be used to track which aggregates are being orchestrated. Use the `Commanded.ProcessManagers.ProcessManager` macro in your process manager module and implement the callback functions defined in the behaviour: - `c:interested?/1` - `c:handle/2` - `c:apply/2` - `c:error/3` ### Example defmodule ExampleProcessManager do use Commanded.ProcessManagers.ProcessManager, application: ExampleApp, name: "ExampleProcessManager" def interested?(%AnEvent{uuid: uuid}), do: {:start, uuid} def handle(%ExampleProcessManager{}, %ExampleEvent{}) do [ %ExampleCommand{} ] end def error({:error, failure}, %ExampleEvent{}, _failure_context) do # Retry, skip, ignore, or stop process manager on error handling event end def error({:error, failure}, %ExampleCommand{}, _failure_context) do # Retry, skip, ignore, or stop process manager on error dispatching command end end Start the process manager (or configure as a worker inside a [Supervisor](supervision.html)) {:ok, process_manager} = ExampleProcessManager.start_link() ## Error handling You can define an `c:error/3` callback function to handle any errors or exceptions during event handling or returned by commands dispatched from your process manager. The function is passed the error (e.g. `{:error, :failure}`), the failed event or command, and a failure context. See `Commanded.ProcessManagers.FailureContext` for details. Use pattern matching on the error and/or failed event/command to explicitly handle certain errors, events, or commands. You can choose to retry, skip, ignore, or stop the process manager after a command dispatch error. The default behaviour, if you don't provide an `c:error/3` callback, is to stop the process manager using the exact error reason returned from the event handler function or command dispatch. You should supervise your process managers to ensure they are restarted on error. ### Example defmodule ExampleProcessManager do use Commanded.ProcessManagers.ProcessManager, application: ExampleApp, name: "ExampleProcessManager" # stop process manager after three failures def error({:error, _failure}, _failed_command, %{context: %{failures: failures}}) when failures >= 2 do {:stop, :too_many_failures} end # retry command, record failure count in context map def error({:error, _failure}, _failed_command, %{context: context}) do context = Map.update(context, :failures, 1, fn failures -> failures + 1 end) {:retry, context} end end ## Idle process timeouts Each instance of a process manager will run indefinitely once started. To reduce memory usage you can configure an idle timeout, in milliseconds, after which the process will be shutdown. The process will be restarted whenever another event is routed to it and its state will be rehydrated from the instance snapshot. ### Example defmodule ExampleProcessManager do use Commanded.ProcessManagers.ProcessManager, application: ExampleApp, name: "ExampleProcessManager" idle_timeout: :timer.minutes(10) end ## Event handling timeout You can configure a timeout for event handling to ensure that events are processed in a timely manner without getting stuck. An `event_timeout` option, defined in milliseconds, may be provided when using the `Commanded.ProcessManagers.ProcessManager` macro at compile time: defmodule TransferMoneyProcessManager do use Commanded.ProcessManagers.ProcessManager, application: ExampleApp, name: "TransferMoneyProcessManager", router: BankRouter, event_timeout: :timer.minutes(10) end Or may be configured when starting a process manager: {:ok, _pid} = TransferMoneyProcessManager.start_link( event_timeout: :timer.hours(1) ) After the timeout has elapsed, indicating the process manager has not processed an event within the configured period, the process manager is stopped. The process manager will be restarted if supervised and will retry the event, this should help resolve transient problems. ## Consistency For each process manager you can define its consistency, as one of either `:strong` or `:eventual`. This setting is used when dispatching commands and specifying the `consistency` option. When you dispatch a command using `:strong` consistency, after successful command dispatch the process will block until all process managers configured to use `:strong` consistency have processed the domain events created by the command. The default setting is `:eventual` consistency. Command dispatch will return immediately upon confirmation of event persistence, not waiting for any process managers. ### Example defmodule ExampleProcessManager do use Commanded.ProcessManagers.ProcessManager, application: ExampleApp, name: "ExampleProcessManager", consistency: :strong end Please read the [Process managers](process-managers.html) guide for more detail. """ alias Commanded.ProcessManagers.FailureContext @type domain_event :: struct @type command :: struct @type process_manager :: struct @type process_uuid :: String.t() | [String.t()] @type consistency :: :eventual | :strong @doc """ Is the process manager interested in the given command? The `c:interested?/1` function is used to indicate which events the process manager receives. The response is used to route the event to an existing instance or start a new process instance: - `{:start, process_uuid}` - create a new instance of the process manager. - `{:start!, process_uuid}` - create a new instance of the process manager (strict). - `{:continue, process_uuid}` - continue execution of an existing process manager. - `{:continue!, process_uuid}` - continue execution of an existing process manager (strict). - `{:stop, process_uuid}` - stop an existing process manager, shutdown its process, and delete its persisted state. - `false` - ignore the event. You can return a list of process identifiers when a single domain event is to be handled by multiple process instances. ## Strict process routing Using strict routing, with `:start!` or `:continue`, enforces the following validation checks: - `{:start!, process_uuid}` - validate process does not already exist. - `{:continue!, process_uuid}` - validate process already exists. If the check fails an error will be passed to the `error/3` callback function: - `{:error, {:start!, :process_already_started}}` - `{:error, {:continue!, :process_not_started}}` The `error/3` function can choose to `:stop` the process or `:skip` the problematic event. """ @callback interested?(domain_event) :: {:start, process_uuid} | {:start!, process_uuid} | {:continue, process_uuid} | {:continue!, process_uuid} | {:stop, process_uuid} | false @doc """ Process manager instance handles a domain event, returning any commands to dispatch. A `c:handle/2` function can be defined for each `:start` and `:continue` tagged event previously specified. It receives the process manager's state and the event to be handled. It must return the commands to be dispatched. This may be none, a single command, or many commands. The `c:handle/2` function can be omitted if you do not need to dispatch a command and are only mutating the process manager's state. """ @callback handle(process_manager, domain_event) :: command | list(command) | {:error, term} @doc """ Mutate the process manager's state by applying the domain event. The `c:apply/2` function is used to mutate the process manager's state. It receives the current state and the domain event, and must return the modified state. This callback function is optional, the default behaviour is to retain the process manager's current state. """ @callback apply(process_manager, domain_event) :: process_manager @doc """ Called when a command dispatch or event handling returns an error. The `c:error/3` function allows you to control how command dispatch and event handling failures are handled. The function is passed the error (e.g. `{:error, :failure}`), the failed command (during failed dispatch) or failed event (during failed event handling), and a failure context struct (see `Commanded.ProcessManagers.FailureContext` for details). The failure context contains a context map you can use to pass transient state between failures. For example it can be used to count the number of failures. You can return one of the following responses depending upon the error severity: - `{:retry, context}` - retry the failed command, provide a context map containing any state passed to subsequent failures. This could be used to count the number of retries, failing after too many attempts. - `{:retry, delay, context}` - retry the failed command, after sleeping for the requested delay (in milliseconds). Context is a map as described in `{:retry, context}` above. - `{:skip, :discard_pending}` - discard the failed command and any pending commands. - `{:skip, :continue_pending}` - skip the failed command, but continue dispatching any pending commands. - `{:continue, commands, context}` - continue dispatching the given commands. This allows you to retry the failed command, modify it and retry, drop it, or drop all pending commands by passing an empty list `[]`. Context is a map as described in `{:retry, context}` above. - `{:stop, reason}` - stop the process manager with the given reason. """ @callback error( error :: {:error, term()}, failure_source :: command | domain_event, failure_context :: FailureContext.t() ) :: {:retry, context :: map()} | {:retry, delay :: non_neg_integer(), context :: map()} | {:skip, :discard_pending} | {:skip, :continue_pending} | {:continue, commands :: list(command), context :: map()} | {:stop, reason :: term()} alias Commanded.Event.Handler alias Commanded.ProcessManagers.ProcessManager alias Commanded.ProcessManagers.ProcessRouter @doc false defmacro __using__(opts) do quote location: :keep do @before_compile unquote(__MODULE__) @behaviour ProcessManager {application, name} = ProcessManager.compile_config(__MODULE__, unquote(opts)) @opts unquote(opts) @application application @name name def start_link(opts \\ []) do module_opts = Keyword.drop(@opts, [:application, :name]) opts = Handler.start_opts(__MODULE__, module_opts, opts, [:event_timeout, :idle_timeout]) ProcessRouter.start_link(@application, @name, __MODULE__, opts) end @doc """ Provides a child specification to allow the event handler to be easily supervised. ## Example Supervisor.start_link([ {ExampleProcessManager, []} ], strategy: :one_for_one) """ def child_spec(opts) do default = %{ id: {__MODULE__, @name}, start: {__MODULE__, :start_link, [opts]}, restart: :permanent, type: :worker } Supervisor.child_spec(default, []) end @doc false def __name__, do: @name end end @doc false defmacro __before_compile__(_env) do # include default fallback functions at end, with lowest precedence quote generated: true do @doc false def interested?(_event), do: false @doc false def handle(_process_manager, _event), do: [] @doc false def apply(process_manager, _event), do: process_manager @doc false def error({:error, reason}, _command, _failure_context), do: {:stop, reason} end end def compile_config(module, opts) do application = Keyword.get(opts, :application) unless application do raise ArgumentError, inspect(module) <> " expects :application option" end name = Handler.parse_name(module, Keyword.get(opts, :name)) {application, name} end end
35.108992
97
0.691579
ff92e7f9275c1e3104da1ed2094468a47a64ec89
1,234
exs
Elixir
test/livebook_web/plugs/user_plug_test.exs
brettcannon/livebook
d6c9ab1783efa083aea2ead81e078bb920d57ad6
[ "Apache-2.0" ]
null
null
null
test/livebook_web/plugs/user_plug_test.exs
brettcannon/livebook
d6c9ab1783efa083aea2ead81e078bb920d57ad6
[ "Apache-2.0" ]
1
2021-09-18T01:09:08.000Z
2021-09-18T01:09:08.000Z
test/livebook_web/plugs/user_plug_test.exs
brettcannon/livebook
d6c9ab1783efa083aea2ead81e078bb920d57ad6
[ "Apache-2.0" ]
null
null
null
defmodule LivebookWeb.UserPlugTest do use ExUnit.Case, async: true use Plug.Test defp call(conn) do LivebookWeb.UserPlug.call(conn, LivebookWeb.UserPlug.init([])) end test "given no user id in the session, generates a new user id" do conn = conn(:get, "/") |> init_test_session(%{}) |> call() assert get_session(conn, :current_user_id) != nil end test "keeps user id in the session if present" do conn = conn(:get, "/") |> init_test_session(%{current_user_id: "valid_user_id"}) |> call() assert get_session(conn, :current_user_id) != nil end test "given no user_data cookie, generates and stores new data" do conn = conn(:get, "/") |> init_test_session(%{}) |> fetch_cookies() |> call() |> fetch_cookies() assert conn.cookies["user_data"] != nil end test "keeps user_data cookie if present" do cookie_value = ~s/{"name":"Jake Peralta","hex_color":"#000000"}/ conn = conn(:get, "/") |> init_test_session(%{}) |> put_req_cookie("user_data", cookie_value) |> fetch_cookies() |> call() |> fetch_cookies() assert conn.cookies["user_data"] == cookie_value end end
23.730769
68
0.612642
ff92f512e64d1dae5bce3305f9fb08c5ddb8db94
1,326
ex
Elixir
clients/compute/lib/google_api/compute/v1/model/disks_scoped_list_warning.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/compute/lib/google_api/compute/v1/model/disks_scoped_list_warning.ex
GoNZooo/elixir-google-api
cf3ad7392921177f68091f3d9001f1b01b92f1cc
[ "Apache-2.0" ]
null
null
null
clients/compute/lib/google_api/compute/v1/model/disks_scoped_list_warning.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.Compute.V1.Model.DisksScopedList_warning do @moduledoc """ [Output Only] Informational warning which replaces the list of disks when the list is empty. """ @derive [Poison.Encoder] defstruct [ :"code", :"data", :"message" ] end defimpl Poison.Decoder, for: GoogleApi.Compute.V1.Model.DisksScopedList_warning do import GoogleApi.Compute.V1.Deserializer def decode(value, options) do value |> deserialize(:"data", :list, GoogleApi.Compute.V1.Model.AcceleratorTypesScopedList_warning_data, options) end end
32.341463
111
0.751131
ff92f9939e107b1738f1b2abca535377c55c1b55
213
exs
Elixir
lib/cli.exs
uoysip/augcart
9323d3a525c0614c2585197779528ffa8cee68a2
[ "MIT" ]
1
2020-01-12T21:44:41.000Z
2020-01-12T21:44:41.000Z
lib/cli.exs
uoysip/augcart
9323d3a525c0614c2585197779528ffa8cee68a2
[ "MIT" ]
null
null
null
lib/cli.exs
uoysip/augcart
9323d3a525c0614c2585197779528ffa8cee68a2
[ "MIT" ]
null
null
null
require Logger defmodule CLI do def start() do Logger.info("Starting server. Press Ctrl+C to exit...") Task.async(ShoppingListServer, :start, []) |> Task.await(:infinity) end end CLI.start()
14.2
60
0.657277
ff933193a47fc8cb453b694b17d860cb8285393d
1,690
exs
Elixir
test/img_test.exs
betrybe/markright
1b81a2d9931b70645f9eff70d2605f0e9a58f396
[ "MIT" ]
15
2017-01-12T19:24:35.000Z
2021-04-27T14:44:08.000Z
test/img_test.exs
betrybe/markright
1b81a2d9931b70645f9eff70d2605f0e9a58f396
[ "MIT" ]
8
2017-02-13T17:01:35.000Z
2021-07-27T16:20:52.000Z
test/img_test.exs
betrybe/markright
1b81a2d9931b70645f9eff70d2605f0e9a58f396
[ "MIT" ]
1
2021-04-24T18:40:11.000Z
2021-04-24T18:40:11.000Z
defmodule Markright.Parsers.Img.Test do use ExUnit.Case doctest Markright.Parsers.Img @input ~S""" Hello, ![GitHub link](https://github.com). Hello, ![GitHub](https://github.com). Hello, ![Atlassian|https://atlassian.com]. Hello, ![https://example.com normal link]. """ @output {:article, %{}, [ {:p, %{}, [ "Hello, ", {:figure, %{}, [ {:img, %{alt: "GitHub link", src: "https://github.com"}, nil}, {:figcaption, %{}, "GitHub link"} ]}, "." ]}, {:p, %{}, [ "Hello, ", {:figure, %{}, [ {:img, %{alt: "GitHub", src: "https://github.com"}, nil}, {:figcaption, %{}, "GitHub"} ]}, "." ]}, {:p, %{}, [ "Hello, ", {:figure, %{}, [ {:img, %{alt: "Atlassian", src: "https://atlassian.com"}, nil}, {:figcaption, %{}, "Atlassian"} ]}, "." ]}, {:p, %{}, [ "Hello, ", {:figure, %{}, [ {:img, %{alt: "normal link", src: "https://example.com"}, nil}, {:figcaption, %{}, "normal link"} ]}, "." ]} ]} test "parses different types of links" do assert @input |> Markright.to_ast() == @output end end
26.40625
82
0.321893
ff933dd437a3fcf1ffbcd1360208949482e6abcd
613
exs
Elixir
test/web/views/error_view_test.exs
palindrom615/firestorm
0690493c9dcae5c04c63c5321532a7db923e5be7
[ "MIT" ]
null
null
null
test/web/views/error_view_test.exs
palindrom615/firestorm
0690493c9dcae5c04c63c5321532a7db923e5be7
[ "MIT" ]
4
2021-03-01T21:25:42.000Z
2022-02-10T23:50:11.000Z
test/web/views/error_view_test.exs
palindrom615/firestorm
0690493c9dcae5c04c63c5321532a7db923e5be7
[ "MIT" ]
1
2020-03-20T12:58:37.000Z
2020-03-20T12:58:37.000Z
defmodule FirestormWeb.Web.ErrorViewTest do use FirestormWeb.Web.ConnCase, async: true # Bring render/3 and render_to_string/3 for testing custom views import Phoenix.View test "renders 404.html" do assert render_to_string(FirestormWeb.Web.ErrorView, "404.html", []) == "Page not found" end test "render 500.html" do assert render_to_string(FirestormWeb.Web.ErrorView, "500.html", []) == "Internal server error" end test "render any other" do assert render_to_string(FirestormWeb.Web.ErrorView, "505.html", []) == "Internal server error" end end
27.863636
74
0.69168
ff9357e4f86cbfaca2c116fd7358197b0130e0d5
6,776
ex
Elixir
lib/central/helpers/timex_helper.ex
icexuick/teiserver
22f2e255e7e21f977e6b262acf439803626a506c
[ "MIT" ]
6
2021-02-08T10:42:53.000Z
2021-04-25T12:12:03.000Z
lib/central/helpers/timex_helper.ex
icexuick/teiserver
22f2e255e7e21f977e6b262acf439803626a506c
[ "MIT" ]
null
null
null
lib/central/helpers/timex_helper.ex
icexuick/teiserver
22f2e255e7e21f977e6b262acf439803626a506c
[ "MIT" ]
2
2021-02-23T22:34:00.000Z
2021-04-08T13:31:36.000Z
defmodule Central.Helpers.TimexHelper do @moduledoc """ """ alias Timex.{Timezone, Timezone.Local} # Was finding that in April it moved the time up an hour # every time I saved, turns out the issue was it was stored # as UTC but printed as +1 hour defp convert(timestamp, tz) do new_timestamp = timestamp |> Timezone.convert(tz) case new_timestamp do %Timex.AmbiguousDateTime{} -> timestamp _ -> new_timestamp end end @spec date_to_str(DateTime.t()) :: String.t() @spec date_to_str(DateTime.t(), list) :: String.t() def date_to_str(the_time), do: date_to_str(the_time, []) def date_to_str(nil, _), do: "" def date_to_str(the_time, format) when is_atom(format) do date_to_str(the_time, format: format) end def date_to_str(the_time, [format: :dmy_text, tz: tz]), do: dmy_text(the_time, tz) def date_to_str(the_time, args) do format = args[:format] || :dmy now = args[:now] || Timex.now() is_past = Timex.compare(now, the_time) == 1 until_id = case args[:until] do true -> "" false -> "" nil -> "" s -> s end the_time = convert(the_time, args[:tz] || Local.lookup()) time_str = case format do :day_name -> Timex.format!(the_time, "{WDfull}") :dmy -> Timex.format!(the_time, "{0D}/{0M}/{YYYY}") :ymd -> Timex.format!(the_time, "{YYYY}-{0M}-{0D}") :hms_dmy -> Timex.format!(the_time, "{h24}:{m}:{s} {0D}/{0M}/{YYYY}") :ymd_hms -> Timex.format!(the_time, "{YYYY}-{0M}-{0D} {h24}:{m}:{s}") :ymd_t_hms -> Timex.format!(the_time, "{YYYY}-{M}-{D}T{h24}:{m}:{s}") :hms -> Timex.format!(the_time, "{h24}:{m}:{s}") :hm_dmy -> Timex.format!(the_time, "{h24}:{m} {0D}/{0M}/{YYYY}") :hm -> Timex.format!(the_time, "{h24}:{m}") :clock24 -> Timex.format!(the_time, "{h24}{m}") :html_input -> Timex.format!(the_time, "{YYYY}-{0M}-{0D}T{h24}:{m}") :email_date -> Timex.format!(the_time, "{WDshort}, {0D} {Mshort} {YYYY} {h24}:{m}:{s} {Z}") :hms_or_hmsdmy -> _hms_or_hmsdmy(the_time, now) :hms_or_dmy -> _hms_or_dmy(the_time, now) :hm_or_dmy -> _hm_or_dmy(the_time, now) :everything -> Timex.format!(the_time, "{YYYY}-{0M}-{0D} {h24}:{m}:{s}, {WDfull}") end until_str = if args[:until] do case time_until(the_time, now) do "" -> "" until_str -> if is_past do ", " <> until_str <> " ago" else ", in " <> until_str end end end if until_id != "" do "#{time_str}<span id='#{until_id}'>#{until_str}</span>" else "#{time_str}#{until_str}" end end @spec time_until(DateTime.t()) :: String.t() @spec time_until(DateTime.t(), DateTime.t()) :: String.t() def time_until(the_time), do: time_until(the_time, Timex.now()) def time_until(nil, _), do: nil def time_until(the_time, now) do the_duration = Timex.diff(now, the_time, :duration) is_past = Timex.compare(now, the_time) == 1 days = Timex.Duration.to_days(the_duration) # We need to do this as we need days rounded off in the correct # direction to get the number of hours left hours = if is_past do Timex.Duration.to_hours(the_duration) - Float.floor(days) * 24 else Timex.Duration.to_hours(the_duration) - Float.ceil(days) * 24 end days = abs(days) hours = abs(hours) cond do 2 > days and days > 1 -> "1 day, #{round(hours)} hours" round(days) > 1 -> "#{round(days)} days" round(hours) > 1 -> "#{round(hours)} hours" days == 0 and hours == 0 -> "" true -> "#{Timex.format_duration(the_duration, :humanized)}" end end @spec _hms_or_hmsdmy(DateTime.t(), DateTime.t()) :: String.t() defp _hms_or_hmsdmy(the_time, today) do if Timex.compare(the_time |> Timex.to_date(), today) == 0 do Timex.format!(the_time, "Today at {h24}:{m}:{s}") else Timex.format!(the_time, "{h24}:{m}:{s} {0D}/{0M}/{YYYY}") end end @spec _hms_or_dmy(DateTime.t(), DateTime.t()) :: String.t() defp _hms_or_dmy(the_time, today) do if Timex.compare(the_time |> Timex.to_date(), today) == 0 do Timex.format!(the_time, "Today at {h24}:{m}:{s}") else Timex.format!(the_time, "{0D}/{0M}/{YYYY}") end end @spec _hm_or_dmy(DateTime.t(), DateTime.t()) :: String.t() defp _hm_or_dmy(the_time, today) do if Timex.compare(the_time |> Timex.to_date(), today) == 0 do Timex.format!(the_time, "Today at {h24}:{m}") else Timex.format!(the_time, "{0D}/{0M}/{YYYY}") end end # def dmy(nil), do: "" # def dmy(the_time) do # if Map.has_key?(the_time, "day") do # Timex.format!( # (for {key, val} <- the_time, into: %{}, do: {String.to_atom(key), val}), # "{0D}/{0M}/{YYYY}" # ) # else # Timex.format!(the_time, "{0D}/{0M}/{YYYY}") # end # end defp dmy_text(nil, _), do: nil defp dmy_text(the_time, tz) do suffix = the_time |> convert(tz || Local.lookup()) |> Timex.format!("{D}") |> String.to_integer() |> suffix Timex.format!(the_time, "{D}#{suffix} {Mfull} {YYYY}") end defp suffix(1), do: "st" defp suffix(21), do: "st" defp suffix(31), do: "st" defp suffix(2), do: "nd" defp suffix(22), do: "nd" defp suffix(32), do: "nd" defp suffix(3), do: "nd" defp suffix(23), do: "nd" defp suffix(33), do: "rd" defp suffix(_), do: "th" def parse_dmy(nil), do: nil def parse_dmy(""), do: nil def parse_dmy(s) do Timex.parse!(s, "{0D}/{0M}/{YYYY}") end def parse_ymd(nil), do: nil def parse_ymd(""), do: nil def parse_ymd(s) do Timex.parse!(s, "{YYYY}-{M}-{D}") end def parse_ymd_hms(nil), do: nil def parse_ymd_hms(""), do: nil def parse_ymd_hms(s) do Timex.parse!(s, "{YYYY}-{M}-{D} {h24}:{m}:{s}") end def parse_ymd_t_hms(s) do Timex.parse!(s, "{YYYY}-{M}-{D}T{h24}:{m}:{s}") end def parse_time_input(s) do cond do String.contains?(s, ":") -> parse_ymd_hms(s) String.contains?(s, "-") -> parse_ymd(s) true -> parse_dmy(s) end end # def duration(start_tick, end_tick) do # s = Timex.diff(end_tick, start_tick, :duration) # |> Timex.Duration.to_seconds() # days = :math.floor(s/86400) |> round # s = s - days * 86400 # hours = :math.floor(s/3600) |> round # s = s - hours * 3600 # mins = :math.floor(s/60) |> round # s = s - mins * 60 # s = round(s) # cond do # days > 0 -> "#{days} days" # hours > 0 -> "#{hours} hours" # mins > 0 -> "#{mins}:#{s}" # true -> "#{s}s" # end # end end
28.957265
99
0.566263
ff938a537ece922eab116454bb1a76548e2c9929
557
exs
Elixir
test/ucx_ucc/tab_bar_test.exs
josephkabraham/ucx_ucc
0dbd9e3eb5940336b4870cff033482ceba5f6ee7
[ "MIT" ]
null
null
null
test/ucx_ucc/tab_bar_test.exs
josephkabraham/ucx_ucc
0dbd9e3eb5940336b4870cff033482ceba5f6ee7
[ "MIT" ]
null
null
null
test/ucx_ucc/tab_bar_test.exs
josephkabraham/ucx_ucc
0dbd9e3eb5940336b4870cff033482ceba5f6ee7
[ "MIT" ]
null
null
null
defmodule UcxUcc.TabBarTest do use ExUnit.Case doctest UcxUcc.TabBar alias UcxUcc.TabBar setup do TabBar.delete_all :ok end test "remembers open tabs when switching" do TabBar.open_ftab 1, 2, "test", nil assert TabBar.get_ftab(1, 2) == {"test", nil} TabBar.open_ftab 1, 2, "other", %{name: "one"} assert TabBar.get_ftab(1, 2) == {"other", %{name: "one"}} TabBar.open_ftab 1, 2, "again", %{name: "two"} TabBar.open_ftab 1, 2, "other", nil assert TabBar.get_ftab(1, 2) == {"other", %{name: "one"}} end end
25.318182
61
0.628366
ff939a1bbb9c6aa107cf029b3040f446b2abff83
244
ex
Elixir
lib/ouidata/basic_data_map.ex
shamanime/ouidata
4acba55f56195c6f939b4eefd68472480548e7fe
[ "MIT" ]
null
null
null
lib/ouidata/basic_data_map.ex
shamanime/ouidata
4acba55f56195c6f939b4eefd68472480548e7fe
[ "MIT" ]
null
null
null
lib/ouidata/basic_data_map.ex
shamanime/ouidata
4acba55f56195c6f939b4eefd68472480548e7fe
[ "MIT" ]
null
null
null
defmodule Ouidata.BasicDataMap do @moduledoc false alias Ouidata.Parser def from_file_in_dir(dir_name) do make_map(Parser.read_file("latest.txt", dir_name)) end def make_map(vendors) do {:ok, %{vendors: vendors}} end end
17.428571
54
0.721311
ff93a03a8ae725ac774c2d9598717d553a688fe9
374
ex
Elixir
web/views/error_view.ex
FunctioningIdiots/jilo-server
a5911608bff636c1e50afbc1a0244bc25a363eb7
[ "MIT" ]
null
null
null
web/views/error_view.ex
FunctioningIdiots/jilo-server
a5911608bff636c1e50afbc1a0244bc25a363eb7
[ "MIT" ]
1
2016-01-26T13:08:13.000Z
2020-07-09T16:40:23.000Z
web/views/error_view.ex
FunctioningIdiots/jilo-server
a5911608bff636c1e50afbc1a0244bc25a363eb7
[ "MIT" ]
null
null
null
defmodule Jilosrv.ErrorView do use Jilosrv.Web, :view def render("404.html", _assigns) do "Page not found" end def render("500.html", _assigns) do "Server internal error" end # In case no render clause matches or no # template is found, let's render it as 500 def template_not_found(_template, assigns) do render "500.html", assigns end end
20.777778
47
0.697861
ff93a0ea00bed1ad85b50e5ff1ea0caac4301d02
123
exs
Elixir
priv/repo/seeds.exs
RobertDober/tamyda
ebcf60366a0475554b49c7b531c18c40a748e345
[ "Apache-2.0" ]
null
null
null
priv/repo/seeds.exs
RobertDober/tamyda
ebcf60366a0475554b49c7b531c18c40a748e345
[ "Apache-2.0" ]
null
null
null
priv/repo/seeds.exs
RobertDober/tamyda
ebcf60366a0475554b49c7b531c18c40a748e345
[ "Apache-2.0" ]
null
null
null
IO.puts """ #{IO.ANSI.yellow}Automatic seeding disabled, you can seed the database with:#{IO.ANSI.white} mix seed """
24.6
92
0.691057
ff93d9ce531895c62324553c59bf1bfa466d853b
1,488
ex
Elixir
clients/vault/lib/google_api/vault/v1/model/org_unit_info.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/vault/lib/google_api/vault/v1/model/org_unit_info.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/vault/lib/google_api/vault/v1/model/org_unit_info.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.Vault.V1.Model.OrgUnitInfo do @moduledoc """ The organizational unit to search ## Attributes * `orgUnitId` (*type:* `String.t`, *default:* `nil`) - The name of the organizational unit to search, as provided by the [Admin SDK Directory API](https://developers.google.com/admin-sdk/directory/). """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :orgUnitId => String.t() | nil } field(:orgUnitId) end defimpl Poison.Decoder, for: GoogleApi.Vault.V1.Model.OrgUnitInfo do def decode(value, options) do GoogleApi.Vault.V1.Model.OrgUnitInfo.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Vault.V1.Model.OrgUnitInfo do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
31.659574
203
0.733871
ff93fabab3d18013ae0eeb76647740878ea5963f
3,193
ex
Elixir
clients/you_tube/lib/google_api/you_tube/v3/model/playlist_item_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
1
2018-12-03T23:43:10.000Z
2018-12-03T23:43:10.000Z
clients/you_tube/lib/google_api/you_tube/v3/model/playlist_item_list_response.ex
matehat/elixir-google-api
c1b2523c2c4cdc9e6ca4653ac078c94796b393c3
[ "Apache-2.0" ]
null
null
null
clients/you_tube/lib/google_api/you_tube/v3/model/playlist_item_list_response.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.YouTube.V3.Model.PlaylistItemListResponse do @moduledoc """ ## Attributes * `etag` (*type:* `String.t`, *default:* `nil`) - Etag of this resource. * `eventId` (*type:* `String.t`, *default:* `nil`) - Serialized EventId of the request which produced this response. * `items` (*type:* `list(GoogleApi.YouTube.V3.Model.PlaylistItem.t)`, *default:* `nil`) - A list of playlist items that match the request criteria. * `kind` (*type:* `String.t`, *default:* `youtube#playlistItemListResponse`) - Identifies what kind of resource this is. Value: the fixed string "youtube#playlistItemListResponse". * `nextPageToken` (*type:* `String.t`, *default:* `nil`) - The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. * `pageInfo` (*type:* `GoogleApi.YouTube.V3.Model.PageInfo.t`, *default:* `nil`) - * `prevPageToken` (*type:* `String.t`, *default:* `nil`) - The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. * `tokenPagination` (*type:* `GoogleApi.YouTube.V3.Model.TokenPagination.t`, *default:* `nil`) - * `visitorId` (*type:* `String.t`, *default:* `nil`) - The visitorId identifies the visitor. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :etag => String.t(), :eventId => String.t(), :items => list(GoogleApi.YouTube.V3.Model.PlaylistItem.t()), :kind => String.t(), :nextPageToken => String.t(), :pageInfo => GoogleApi.YouTube.V3.Model.PageInfo.t(), :prevPageToken => String.t(), :tokenPagination => GoogleApi.YouTube.V3.Model.TokenPagination.t(), :visitorId => String.t() } field(:etag) field(:eventId) field(:items, as: GoogleApi.YouTube.V3.Model.PlaylistItem, type: :list) field(:kind) field(:nextPageToken) field(:pageInfo, as: GoogleApi.YouTube.V3.Model.PageInfo) field(:prevPageToken) field(:tokenPagination, as: GoogleApi.YouTube.V3.Model.TokenPagination) field(:visitorId) end defimpl Poison.Decoder, for: GoogleApi.YouTube.V3.Model.PlaylistItemListResponse do def decode(value, options) do GoogleApi.YouTube.V3.Model.PlaylistItemListResponse.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.YouTube.V3.Model.PlaylistItemListResponse do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
44.971831
184
0.700595
ff94013aac333b7fbe3ce4847c1e62dbaf01bba4
26,069
exs
Elixir
test/xema/ref_remote_test.exs
garret-smith/xema
f9629d66591644d53ad4cb9c7a97de8b10f6fa5e
[ "MIT" ]
null
null
null
test/xema/ref_remote_test.exs
garret-smith/xema
f9629d66591644d53ad4cb9c7a97de8b10f6fa5e
[ "MIT" ]
null
null
null
test/xema/ref_remote_test.exs
garret-smith/xema
f9629d66591644d53ad4cb9c7a97de8b10f6fa5e
[ "MIT" ]
null
null
null
defmodule Xema.RefRemoteTest do use ExUnit.Case, async: true import Xema, only: [valid?: 2, validate: 2] alias Test.{FileLoader, RemoteLoaderExon} alias Xema.{Ref, Schema, SchemaError, ValidationError} test "http server" do assert %{body: body} = HTTPoison.get!("http://localhost:1234/folder/folderInteger.exon") assert body == File.read!("test/fixtures/remote/folder/folderInteger.exon") end describe "invalid exon" do test "compile error" do expected = "http://localhost:1234/compile-error.exon:3: " <> "undefined function invalid/0" assert_raise CompileError, expected, fn -> Xema.new({:ref, "http://localhost:1234/compile-error.exon"}, loader: RemoteLoaderExon) end end test "syntax error" do expected = """ http://localhost:1234/syntax-error.exon:2: \ keyword argument must be followed by space after: a:\ """ assert_raise SyntaxError, expected, fn -> Xema.new({:ref, "http://localhost:1234/syntax-error.exon"}, loader: RemoteLoaderExon) end end end describe "invalid remote ref" do test "404" do expected = "Remote schema 'http://localhost:1234/not-found.exon' not found." assert_raise SchemaError, expected, fn -> Xema.new({:ref, "http://localhost:1234/not-found.exon"}, loader: RemoteLoaderExon) end end end describe "remote ref" do setup do %{schema: Xema.new({:ref, "http://localhost:1234/integer.exon#"}, loader: RemoteLoaderExon)} end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, 1) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{type: :integer, value: "1"} } = error } = validate(schema, "1") assert Exception.message(error) == ~s|Expected :integer, got \"1\".| end end describe "file circular ref in sub schema" do setup do %{schema: Xema.new({:ref, "main.exon"}, loader: FileLoader)} end test "check schema", %{schema: schema} do assert schema == %Xema{ refs: %{ "#/definitions/self" => %Schema{ properties: %{ a: %Schema{type: :string}, b: %Schema{ref: %Ref{pointer: "#/definitions/self"}} }, type: :map } }, schema: %Schema{ definitions: %{ self: %Schema{ properties: %{ a: %Schema{type: :string}, b: %Schema{ref: %Ref{pointer: "#/definitions/self"}} }, type: :map } }, ref: %Ref{pointer: "#/definitions/self"} } } end test "check with valid data", %{schema: schema} do assert Xema.valid?(schema, %{a: "a"}) == true assert Xema.valid?(schema, %{a: "a", b: %{a: "next"}}) == true end test "check with invalid data", %{schema: schema} do assert Xema.valid?(schema, %{a: 1}) == false assert Xema.valid?(schema, %{a: "a", b: %{a: :next}}) == false end end describe "file circular ref in sub schema [inline: false]" do setup do %{schema: Xema.new({:ref, "main.exon"}, loader: FileLoader, inline: false)} end test "check schema", %{schema: schema} do assert schema == %Xema{ refs: %{ "main.exon" => %Xema{ refs: %{}, schema: %Schema{ ref: %Ref{ pointer: "sub.exon", uri: %URI{path: "sub.exon"} } } }, "sub.exon" => %Xema{ refs: %{ "#/definitions/self" => %Schema{ properties: %{ a: %Schema{type: :string}, b: %Schema{ref: %Ref{pointer: "#/definitions/self"}} }, type: :map } }, schema: %Schema{ definitions: %{ self: %Schema{ properties: %{ a: %Schema{type: :string}, b: %Schema{ref: %Ref{pointer: "#/definitions/self"}} }, type: :map } }, ref: %Ref{pointer: "#/definitions/self"} } } }, schema: %Schema{ ref: %Ref{ pointer: "main.exon", uri: %URI{path: "main.exon"} } } } end end describe "file ref" do setup do %{schema: Xema.new({:ref, "integer.exon"}, loader: FileLoader)} end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, 1) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{type: :integer, value: "1"} } = error } = validate(schema, "1") assert Exception.message(error) == ~s|Expected :integer, got "1".| end end describe "fragment within remote ref" do setup do %{ schema: Xema.new({:ref, "http://localhost:1234/sub_schemas.exon#/definitions/int"}, loader: RemoteLoaderExon ) } end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, 1) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{type: :integer, value: "1"} } = error } = validate(schema, "1") assert Exception.message(error) == ~s|Expected :integer, got "1".| end test "schema structure", %{schema: schema} do assert schema == %Xema{refs: %{}, schema: %Xema.Schema{type: :integer}} end end describe "fragment within remote ref (non-inline)" do setup do %{ schema: Xema.new( {:ref, "http://localhost:1234/sub_schemas.exon#/definitions/int"}, inline: false, loader: RemoteLoaderExon ) } end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, 1) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{type: :integer, value: "1"} } = error } = validate(schema, "1") assert Exception.message(error) == ~s|Expected :integer, got "1".| end test "schema structure", %{schema: schema} do assert schema == %Xema{ refs: %{ "http://localhost:1234/sub_schemas.exon" => %Xema{ refs: %{"#/definitions/int" => %Schema{type: :integer}}, schema: %Schema{ definitions: %{ int: %Schema{type: :integer}, refToInt: %Schema{ ref: %Ref{pointer: "#/definitions/int"} } } } } }, schema: %Schema{ ref: %Ref{ pointer: "http://localhost:1234/sub_schemas.exon#/definitions/int", uri: %URI{ authority: "localhost:1234", fragment: "/definitions/int", host: "localhost", path: "/sub_schemas.exon", port: 1234, query: nil, scheme: "http", userinfo: nil } } } } end end describe "invalid fragment in remote ref" do test "Xema.new/1 raise error" do msg = "Ref #/definitions/invalid not found." assert_raise SchemaError, msg, fn -> Xema.new( { :ref, "http://localhost:1234/sub_schemas.exon#/definitions/invalid" }, loader: RemoteLoaderExon ) end end end describe "ref inside of a remote schema" do setup do %{schema: Xema.new({:ref, "http://localhost:1234/inside.exon"}, loader: RemoteLoaderExon)} end test "with valid data", %{schema: schema} do assert Xema.valid?(schema, %{limit: 5}) end test "with invalid data", %{schema: schema} do refute Xema.valid?(schema, %{limit: -5}) end end describe "ref inside of a remote schema (non-inline)" do setup do %{ schema: Xema.new({:ref, "http://localhost:1234/inside.exon"}, inline: false, loader: RemoteLoaderExon ) } end test "with valid data", %{schema: schema} do assert Xema.valid?(schema, %{limit: 5}) end test "with invalid data", %{schema: schema} do refute Xema.valid?(schema, %{limit: -5}) end end describe "ref within remote ref" do setup do %{ schema: Xema.new({:ref, "http://localhost:1234/sub_schemas.exon#/definitions/refToInt"}, loader: RemoteLoaderExon ) } end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, 1) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{type: :integer, value: "1"} } = error } = validate(schema, "1") assert Exception.message(error) == ~s|Expected :integer, got "1".| end end describe "ref within remote ref (non-inline)" do setup do %{ schema: Xema.new( {:ref, "http://localhost:1234/sub_schemas.exon#/definitions/refToInt"}, inline: false, loader: RemoteLoaderExon ) } end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, 1) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{type: :integer, value: "1"} } = error } = validate(schema, "1") assert Exception.message(error) == ~s|Expected :integer, got "1".| end test "Ref.fetch!/3 returns schema for a valid ref", %{schema: schema} do uri = "http://localhost:1234/sub_schemas.exon#/definitions/refToInt" ref = Ref.new(uri, URI.parse(uri)) assert {schema, root} = Ref.fetch!(ref, schema, nil) assert schema == %Xema.Schema{ ref: %Xema.Ref{pointer: "#/definitions/int"} } assert root == %Xema{ refs: %{ "#/definitions/int" => %Xema.Schema{type: :integer}, "#/definitions/refToInt" => %Xema.Schema{ ref: %Xema.Ref{pointer: "#/definitions/int"} } }, schema: %Xema.Schema{ definitions: %{ int: %Xema.Schema{type: :integer}, refToInt: %Xema.Schema{ ref: %Xema.Ref{pointer: "#/definitions/int"} } } } } end end describe "base URI change - change folder" do setup do data = { :map, id: "http://localhost:1234/scope_change_defs1.exon", properties: %{ list: {:ref, "#/definitions/baz"} }, definitions: %{ baz: {:list, id: "folder/", items: {:ref, "folderInteger.exon"}} } } %{ schema: Xema.new(data, loader: RemoteLoaderExon), non_inline: Xema.new(data, inline: false, loader: RemoteLoaderExon) } end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, %{list: [1]}) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert {:error, %ValidationError{ reason: %{ properties: %{ list: %{items: %{0 => %{type: :integer, value: "1"}}} } } } = error} = validate(schema, %{list: ["1"]}) assert Exception.message(error) == ~s|Expected :integer, got "1", at [:list, 0].| end test "inline schema structure", %{schema: schema} do assert Map.keys(schema.refs) == ["http://localhost:1234/scope_change_defs1.exon"] end test "non-inline schema structure", %{non_inline: schema} do assert Map.keys(schema.refs) == [ "#/definitions/baz", "folder/", "http://localhost:1234/folder/folderInteger.exon", "http://localhost:1234/scope_change_defs1.exon" ] end end describe "root ref in remote ref" do setup do %{ schema: Xema.new( { :map, id: "http://localhost:1234/object", properties: %{ name: {:ref, "xema_name.exon#/definitions/or_nil"} } }, loader: RemoteLoaderExon ) } end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, %{name: "foo"}) == :ok assert validate(schema, %{name: nil}) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{ properties: %{ name: %{ any_of: [ %{type: nil, value: 1}, %{type: :string, value: 1} ], value: 1 } } } } = error } = validate(schema, %{name: 1}) message = """ No match of any schema, at [:name]. Expected nil, got 1, at [:name]. Expected :string, got 1, at [:name].\ """ assert Exception.message(error) == message end end describe "root ref in remote ref (id without path)" do setup do %{ schema: Xema.new( { :map, id: "http://localhost:1234", properties: %{ name: {:ref, "xema_name.exon#/definitions/or_nil"} } }, loader: RemoteLoaderExon ) } end test "check schema", %{schema: schema} do assert schema.refs["http://localhost:1234/xema_name.exon"] == %Xema{ refs: %{ "#/definitions/or_nil" => %Xema.Schema{ any_of: [ %Xema.Schema{type: nil}, %Xema.Schema{ref: %Xema.Ref{pointer: "#"}} ] } }, schema: %Xema.Schema{ definitions: %{ or_nil: %Xema.Schema{ any_of: [ %Xema.Schema{type: nil}, %Xema.Schema{ref: %Xema.Ref{pointer: "#"}} ] } }, type: :string } } end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, %{name: "foo"}) == :ok assert validate(schema, %{name: nil}) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert {:error, %ValidationError{ reason: %{ properties: %{ name: %{ any_of: [ %{type: nil, value: 1}, %{type: :string, value: 1} ], value: 1 } } } } = error} = validate(schema, %{name: 1}) message = """ No match of any schema, at [:name]. Expected nil, got 1, at [:name]. Expected :string, got 1, at [:name].\ """ assert Exception.message(error) == message end end describe "remote ref in remote ref" do setup do %{ schema: Xema.new({:ref, "http://localhost:1234/obj_int.exon"}, loader: RemoteLoaderExon) } end test "check schema", %{schema: schema} do assert Map.keys(schema.refs) == [] end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, %{int: 1}) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{properties: %{int: %{type: :integer, value: "1"}}} } = error } = validate(schema, %{int: "1"}) assert Exception.message(error) == ~s|Expected :integer, got "1", at [:int].| end end describe "remote ref in remote ref (non-inline)" do setup do %{ schema: Xema.new({:ref, "http://localhost:1234/obj_int.exon"}, inline: false, loader: RemoteLoaderExon ) } end test "check schema", %{schema: schema} do assert Map.keys(schema.refs) == [ "http://localhost:1234/integer.exon", "http://localhost:1234/obj_int.exon" ] end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, %{int: 1}) == :ok end test "validate/2 with an invalid value", %{schema: schema} do assert { :error, %ValidationError{ reason: %{properties: %{int: %{type: :integer, value: "1"}}} } = error } = validate(schema, %{int: "1"}) assert Exception.message(error) == ~s|Expected :integer, got "1", at [:int].| end end describe "remote circular ref with ref" do setup do %{ schema: Xema.new({:ref, "http://localhost:1234/circular.exon"}, loader: FileLoader ) } end test "check schema", %{schema: schema} do assert schema == %Xema{ refs: %{ "circular.exon" => %Xema{ refs: %{}, schema: %Xema.Schema{ properties: %{ bar: %Xema.Schema{type: :integer}, foo: %Xema.Schema{ ref: %Xema.Ref{ pointer: "circular.exon", uri: %URI{path: "circular.exon"} } } }, type: :map } } }, schema: %Xema.Schema{ properties: %{ bar: %Xema.Schema{type: :integer}, foo: %Xema.Schema{ ref: %Xema.Ref{ pointer: "circular.exon", uri: %URI{path: "circular.exon"} } } }, type: :map } } end test "validate/2 with a valid value", %{schema: schema} do assert validate(schema, %{bar: 1, foo: %{bar: 2}}) == :ok end end describe "remote ref in remote ref in remote ref" do setup do %{ schema: Xema.new({:ref, "http://localhost:1234/obj_list_int.exon"}, loader: FileLoader ) } end test "check schema", %{schema: schema} do assert schema == %Xema{ refs: %{}, schema: %Xema.Schema{ properties: %{ ints: %Xema.Schema{ items: %Xema.Schema{type: :integer}, type: :list } }, type: :map } } end test "valid?/2 with valid data", %{schema: schema} do assert valid?(schema, %{ints: [1, 2, 3]}) end test "valid?/2 with invalid data", %{schema: schema} do refute valid?(schema, %{ints: [1, "2", 3]}) end end describe "remote ref in remote ref in remote ref (non-inline)" do setup do %{ schema: Xema.new({:ref, "http://localhost:1234/obj_list_int.exon"}, loader: FileLoader, inline: false ) } end test "check schema", %{schema: schema} do assert schema == %Xema{ refs: %{ "http://localhost:1234/integer.exon" => %Xema{ refs: %{}, schema: %Xema.Schema{type: :integer} }, "http://localhost:1234/list_int.exon" => %Xema{ refs: %{}, schema: %Xema.Schema{ items: %Xema.Schema{ ref: %Xema.Ref{ pointer: "http://localhost:1234/integer.exon", uri: %URI{ authority: "localhost:1234", host: "localhost", path: "/integer.exon", port: 1234, scheme: "http" } } }, type: :list } }, "http://localhost:1234/obj_list_int.exon" => %Xema{ refs: %{}, schema: %Xema.Schema{ properties: %{ ints: %Xema.Schema{ ref: %Xema.Ref{ pointer: "http://localhost:1234/list_int.exon", uri: %URI{ authority: "localhost:1234", host: "localhost", path: "/list_int.exon", port: 1234, scheme: "http" } } } }, type: :map } } }, schema: %Xema.Schema{ ref: %Xema.Ref{ pointer: "http://localhost:1234/obj_list_int.exon", uri: %URI{ authority: "localhost:1234", fragment: nil, host: "localhost", path: "/obj_list_int.exon", port: 1234, query: nil, scheme: "http", userinfo: nil } } } } end test "valid?/2 with valid data", %{schema: schema} do assert valid?(schema, %{ints: [1, 2, 3]}) end test "valid?/2 with invalid data", %{schema: schema} do refute valid?(schema, %{ints: [1, "2", 3]}) end end describe "complex remote refs" do setup do %{ schema: Xema.new({:ref, "complex.exon"}, loader: FileLoader ) } end test "check schema", %{schema: schema} do assert schema == %Xema{ refs: %{ "linked_ints.exon" => %Xema{ refs: %{}, schema: %Xema.Schema{ properties: %{ ints: %Xema.Schema{items: %Xema.Schema{type: :integer}, type: :list}, next: %Xema.Schema{ ref: %Xema.Ref{ pointer: "linked_ints.exon", uri: %URI{path: "linked_ints.exon"} } } }, type: :map } } }, schema: %Xema.Schema{ properties: %{ int: %Xema.Schema{type: :integer}, ints: %Xema.Schema{items: %Xema.Schema{type: :integer}, type: :list}, linked_ints: %Xema.Schema{ ref: %Xema.Ref{ pointer: "linked_ints.exon", uri: %URI{path: "linked_ints.exon"} } } }, type: :map } } end end describe "circular remote ref" do setup do %{schema: Xema.new({:ref, "http://localhost:1234/b_in_a.exon"}, loader: RemoteLoaderExon)} end test "check schema", %{schema: schema} do assert Map.keys(schema.refs) == [ "http://localhost:1234/a_in_b.exon", "http://localhost:1234/b_in_a.exon" ] end test "valid?/2 with valid data", %{schema: schema} do assert valid?(schema, %{a: %{b: 7}}) end test "valid?/2 with invalid data", %{schema: schema} do refute valid?(schema, %{a: %{b: "7"}}) end end end
29.7252
98
0.439603
ff94161411a6abdbda27f96047117924f88db7c5
1,794
ex
Elixir
clients/binary_authorization/lib/google_api/binary_authorization/v1/model/set_iam_policy_request.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/binary_authorization/lib/google_api/binary_authorization/v1/model/set_iam_policy_request.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/binary_authorization/lib/google_api/binary_authorization/v1/model/set_iam_policy_request.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.BinaryAuthorization.V1.Model.SetIamPolicyRequest do @moduledoc """ Request message for `SetIamPolicy` method. ## Attributes * `policy` (*type:* `GoogleApi.BinaryAuthorization.V1.Model.IamPolicy.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.BinaryAuthorization.V1.Model.IamPolicy.t() | nil } field(:policy, as: GoogleApi.BinaryAuthorization.V1.Model.IamPolicy) end defimpl Poison.Decoder, for: GoogleApi.BinaryAuthorization.V1.Model.SetIamPolicyRequest do def decode(value, options) do GoogleApi.BinaryAuthorization.V1.Model.SetIamPolicyRequest.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.BinaryAuthorization.V1.Model.SetIamPolicyRequest do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
38.170213
322
0.75864
ff9416fd2d2d7a66bc830e4489ced9e47822d432
998
ex
Elixir
backend/lib/edgehog/astarte/device/battery_status/battery_slot.ex
szakhlypa/edgehog
b1193c26f403132dead6964c1c052e5dcae533af
[ "Apache-2.0" ]
14
2021-12-02T16:31:16.000Z
2022-03-18T17:40:44.000Z
backend/lib/edgehog/astarte/device/battery_status/battery_slot.ex
szakhlypa/edgehog
b1193c26f403132dead6964c1c052e5dcae533af
[ "Apache-2.0" ]
77
2021-11-03T15:14:41.000Z
2022-03-30T14:13:32.000Z
backend/lib/edgehog/astarte/device/battery_status/battery_slot.ex
szakhlypa/edgehog
b1193c26f403132dead6964c1c052e5dcae533af
[ "Apache-2.0" ]
7
2021-11-03T10:58:37.000Z
2022-02-28T14:00:03.000Z
# # This file is part of Edgehog. # # Copyright 2021 SECO Mind Srl # # 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. # # SPDX-License-Identifier: Apache-2.0 # defmodule Edgehog.Astarte.Device.BatteryStatus.BatterySlot do defstruct [ :slot, :level_percentage, :level_absolute_error, :status ] @type t() :: %__MODULE__{ slot: String.t(), level_percentage: float() | nil, level_absolute_error: float() | nil, status: String.t() } end
27.722222
74
0.697395
ff9439845ca70262e36eeb7aa5b3e31ca3681e29
1,036
ex
Elixir
kousa/lib/broth/message/cast.ex
AhmetEsad/dogehouse
ba8c757bc0419ac07bd9bf062c67a39ab74cdfa6
[ "MIT" ]
1
2021-04-22T08:37:55.000Z
2021-04-22T08:37:55.000Z
kousa/lib/broth/message/cast.ex
mateuszklysz/dogehouse
ba8c757bc0419ac07bd9bf062c67a39ab74cdfa6
[ "MIT" ]
null
null
null
kousa/lib/broth/message/cast.ex
mateuszklysz/dogehouse
ba8c757bc0419ac07bd9bf062c67a39ab74cdfa6
[ "MIT" ]
null
null
null
defmodule Broth.Message.Cast do @moduledoc """ API contract statement for cast message modules """ defmacro __using__(_) do quote do use Ecto.Schema import Ecto.Changeset @behaviour Broth.Message.Cast Module.register_attribute(__MODULE__, :directions, accumulate: true, persist: true) @directions [:inbound] # default, overrideable intializer value @impl true def initialize(_state), do: struct(__MODULE__) defoverridable initialize: 1 end end alias Broth.SocketHandler alias Ecto.Changeset @callback changeset(Broth.json()) :: Ecto.Changeset.t() @callback changeset(struct | nil, Broth.json()) :: Ecto.Changeset.t() @callback initialize(SocketHandler.state()) :: struct() @callback execute(Changeset.t(), SocketHandler.state()) :: {:noreply, SocketHandler.state()} | {:error, map, SocketHandler.state()} | {:error, Changeset.t()} | {:exit, code :: 1000..9999, reason :: String.t()} end
27.263158
89
0.646718
ff9441cc5a98c31dc5104eb6baeb3e64135f1812
349
exs
Elixir
priv/repo/migrations/20170820142925_create_businesses.exs
danielcavanagh/lle-cymraeg
01aebc939254e0dd76427cb460722b830c232e82
[ "MIT" ]
null
null
null
priv/repo/migrations/20170820142925_create_businesses.exs
danielcavanagh/lle-cymraeg
01aebc939254e0dd76427cb460722b830c232e82
[ "MIT" ]
null
null
null
priv/repo/migrations/20170820142925_create_businesses.exs
danielcavanagh/lle-cymraeg
01aebc939254e0dd76427cb460722b830c232e82
[ "MIT" ]
null
null
null
defmodule LleCymraeg.Repo.Migrations.CreateBusinesses do use Ecto.Migration def change do create table(:businesses) do add :name, :string, null: false add :description, :text add :type_id, references(:business_types, on_delete: :nilify_all) timestamps() end create index(:businesses, [:type_id]) end end
21.8125
71
0.690544
ff94643e1df395a725f5d8b57f61e45c43c09ce9
1,550
ex
Elixir
hacker_news/test/support/data_case.ex
suulcoder/ElixirStories
6aaf8cdaf834b019d02f8c82461f0f7825540629
[ "MIT" ]
null
null
null
hacker_news/test/support/data_case.ex
suulcoder/ElixirStories
6aaf8cdaf834b019d02f8c82461f0f7825540629
[ "MIT" ]
null
null
null
hacker_news/test/support/data_case.ex
suulcoder/ElixirStories
6aaf8cdaf834b019d02f8c82461f0f7825540629
[ "MIT" ]
null
null
null
defmodule HackerNews.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, we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously by setting `use HackerNews.DataCase, async: true`, although this option is not recommended for other databases. """ use ExUnit.CaseTemplate using do quote do alias HackerNews.Repo import Ecto import Ecto.Changeset import Ecto.Query import HackerNews.DataCase end end setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(HackerNews.Repo) unless tags[:async] do Ecto.Adapters.SQL.Sandbox.mode(HackerNews.Repo, {:shared, self()}) end :ok end @doc """ A helper that transforms changeset errors into 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} -> Regex.replace(~r"%{(\w+)}", message, fn _, key -> opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() end) end) end end
27.678571
77
0.692258
ff9482f3d91960c9e078112c5ccb8708b38d409e
1,572
ex
Elixir
clients/data_catalog/lib/google_api/data_catalog/v1beta1/model/google_cloud_datacatalog_v1beta1_tag_field_enum_value.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/data_catalog/lib/google_api/data_catalog/v1beta1/model/google_cloud_datacatalog_v1beta1_tag_field_enum_value.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2020-12-18T09:25:12.000Z
2020-12-18T09:25:12.000Z
clients/data_catalog/lib/google_api/data_catalog/v1beta1/model/google_cloud_datacatalog_v1beta1_tag_field_enum_value.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.DataCatalog.V1beta1.Model.GoogleCloudDatacatalogV1beta1TagFieldEnumValue do @moduledoc """ Holds an enum value. ## Attributes * `displayName` (*type:* `String.t`, *default:* `nil`) - The display name of the enum value. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :displayName => String.t() } field(:displayName) end defimpl Poison.Decoder, for: GoogleApi.DataCatalog.V1beta1.Model.GoogleCloudDatacatalogV1beta1TagFieldEnumValue do def decode(value, options) do GoogleApi.DataCatalog.V1beta1.Model.GoogleCloudDatacatalogV1beta1TagFieldEnumValue.decode( value, options ) end end defimpl Poison.Encoder, for: GoogleApi.DataCatalog.V1beta1.Model.GoogleCloudDatacatalogV1beta1TagFieldEnumValue do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
30.230769
96
0.750636
ff94ab3d69f44403fe1a5f245e0c76be1782969e
1,619
ex
Elixir
clients/docs/lib/google_api/docs/v1/model/named_styles.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/docs/lib/google_api/docs/v1/model/named_styles.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
null
null
null
clients/docs/lib/google_api/docs/v1/model/named_styles.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.Docs.V1.Model.NamedStyles do @moduledoc """ The named styles. Paragraphs in the document can inherit their TextStyle and ParagraphStyle from these named styles. ## Attributes * `styles` (*type:* `list(GoogleApi.Docs.V1.Model.NamedStyle.t)`, *default:* `nil`) - The named styles. There is an entry for each of the possible named style types. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :styles => list(GoogleApi.Docs.V1.Model.NamedStyle.t()) } field(:styles, as: GoogleApi.Docs.V1.Model.NamedStyle, type: :list) end defimpl Poison.Decoder, for: GoogleApi.Docs.V1.Model.NamedStyles do def decode(value, options) do GoogleApi.Docs.V1.Model.NamedStyles.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.Docs.V1.Model.NamedStyles do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
31.745098
107
0.735022
ff94ae97c282aed0513f357f5077bad3aea0e7d1
14,525
ex
Elixir
lib/bamboo/adapters/smtp_adapter.ex
smigit/bamboo_smtp
4b2d64a23880f097b476aa9a4c34f9953c0ab2bc
[ "MIT" ]
null
null
null
lib/bamboo/adapters/smtp_adapter.ex
smigit/bamboo_smtp
4b2d64a23880f097b476aa9a4c34f9953c0ab2bc
[ "MIT" ]
null
null
null
lib/bamboo/adapters/smtp_adapter.ex
smigit/bamboo_smtp
4b2d64a23880f097b476aa9a4c34f9953c0ab2bc
[ "MIT" ]
null
null
null
defmodule Bamboo.SMTPAdapter do @moduledoc """ Sends email using SMTP. Use this adapter to send emails through SMTP. This adapter requires that some settings are set in the config. See the example section below. *Sensitive credentials should not be committed to source control and are best kept in environment variables. Using `{:system, "ENV_NAME"}` configuration is read from the named environment variable at runtime.* ## Example config # In config/config.exs, or config.prod.exs, etc. config :my_app, MyApp.Mailer, adapter: Bamboo.SMTPAdapter, server: "smtp.domain", hostname: "www.mydomain.com", port: 1025, username: "your.name@your.domain", # or {:system, "SMTP_USERNAME"} password: "pa55word", # or {:system, "SMTP_PASSWORD"} tls: :if_available, # can be `:always` or `:never` allowed_tls_versions: [:"tlsv1", :"tlsv1.1", :"tlsv1.2"], # or {":system", ALLOWED_TLS_VERSIONS"} w/ comma seprated values (e.g. "tlsv1.1,tlsv1.2") ssl: false, # can be `true`, retries: 1, no_mx_lookups: false, # can be `true` auth: :if_available # can be `:always`. If your smtp relay requires authentication set it to `:always`. # Define a Mailer. Maybe in lib/my_app/mailer.ex defmodule MyApp.Mailer do use Bamboo.Mailer, otp_app: :my_app end """ @behaviour Bamboo.Adapter require Logger @required_configuration [:server, :port] @default_configuration %{ tls: :if_available, ssl: false, retries: 1, transport: :gen_smtp_client, auth: :if_available } @tls_versions ~w(tlsv1 tlsv1.1 tlsv1.2) defmodule SMTPError do @moduledoc false defexception [:message, :raw] def exception(raw = {reason, detail}) do message = """ There was a problem sending the email through SMTP. The error is #{inspect(reason)} More detail below: #{inspect(detail)} """ %SMTPError{message: message, raw: raw} end end def deliver(email, config) do gen_smtp_config = config |> to_gen_smtp_server_config email |> Bamboo.Mailer.normalize_addresses() |> to_gen_smtp_message |> config[:transport].send_blocking(gen_smtp_config) |> handle_response end @doc false def handle_config(config) do config |> check_required_configuration |> put_default_configuration end @doc false def supports_attachments?, do: true defp handle_response({:error, :no_credentials = reason}) do raise SMTPError, {reason, "Username and password were not provided for authentication."} end defp handle_response({:error, reason, detail}) do raise SMTPError, {reason, detail} end defp handle_response(response) do {:ok, response} end defp add_bcc(body, %Bamboo.Email{bcc: []}) do body end defp add_bcc(body, %Bamboo.Email{bcc: recipients}) do add_smtp_header_line(body, :bcc, format_email_as_string(recipients, :bcc)) end defp add_cc(body, %Bamboo.Email{cc: []}) do body end defp add_cc(body, %Bamboo.Email{cc: recipients}) do add_smtp_header_line(body, :cc, format_email_as_string(recipients, :cc)) end defp add_custom_header(body, {key, value}) do add_smtp_header_line(body, key, value) end defp add_custom_headers(body, %Bamboo.Email{headers: headers}) do Enum.reduce(headers, body, &add_custom_header(&2, &1)) end defp add_ending_header(body) do add_smtp_line(body, "") end defp add_ending_multipart(body, delimiter) do add_smtp_line(body, "--#{delimiter}--") end defp add_html_body(body, %Bamboo.Email{html_body: html_body}, _multi_part_delimiter) when html_body == nil do body end defp add_html_body(body, %Bamboo.Email{html_body: html_body}, multi_part_delimiter) do base64_html_body = base64_and_split(html_body) body |> add_multipart_delimiter(multi_part_delimiter) |> add_smtp_header_line("Content-Type", "text/html;charset=UTF-8") |> add_smtp_line("Content-Transfer-Encoding: base64") |> add_smtp_line("") |> add_smtp_line(base64_html_body) end defp add_from(body, %Bamboo.Email{from: from}) do add_smtp_header_line(body, :from, format_email_as_string(from, :from)) end defp add_mime_header(body) do add_smtp_header_line(body, "MIME-Version", "1.0") end defp add_multipart_delimiter(body, delimiter) do add_smtp_line(body, "--#{delimiter}") end defp add_multipart_header(body, delimiter) do add_smtp_header_line(body, "Content-Type", ~s(multipart/alternative; boundary="#{delimiter}")) end defp add_multipart_mixed_header(body, delimiter) do add_smtp_header_line(body, "Content-Type", ~s(multipart/mixed; boundary="#{delimiter}")) end defp add_smtp_header_line(body, type, content) when is_list(content) do Enum.reduce(content, body, &add_smtp_header_line(&2, type, &1)) end defp add_smtp_header_line(body, type, content) when is_atom(type) do add_smtp_header_line(body, String.capitalize(to_string(type)), content) end defp add_smtp_header_line(body, type, content) when is_binary(type) do add_smtp_line(body, "#{type}: #{content}") end defp add_smtp_line(body, content), do: body <> content <> "\r\n" defp add_subject(body, %Bamboo.Email{subject: subject}) when is_nil(subject) do add_smtp_header_line(body, :subject, "") end defp add_subject(body, %Bamboo.Email{subject: subject}) do add_smtp_header_line(body, :subject, rfc822_encode(subject)) end defp rfc822_encode(content) do "=?UTF-8?B?#{Base.encode64(content)}?=" end def base64_and_split(data) do data |> Base.encode64() |> Stream.unfold(&String.split_at(&1, 76)) |> Enum.take_while(&(&1 != "")) |> Enum.join("\r\n") end defp add_text_body(body, %Bamboo.Email{text_body: text_body}, _multi_part_delimiter) when text_body == nil do body end defp add_text_body(body, %Bamboo.Email{text_body: text_body}, multi_part_delimiter) do body |> add_multipart_delimiter(multi_part_delimiter) |> add_smtp_header_line("Content-Type", "text/plain;charset=UTF-8") |> add_smtp_line("") |> add_smtp_line(text_body) end defp add_attachment_header(body, attachment) do <<random::size(32)>> = :crypto.strong_rand_bytes(4) body |> add_smtp_line("Content-Type: #{attachment.content_type}; name=\"#{attachment.filename}\"") |> add_smtp_line("Content-Disposition: attachment; filename=\"#{attachment.filename}\"") |> add_smtp_line("Content-Transfer-Encoding: base64") |> add_smtp_line("X-Attachment-Id: #{random}") end defp add_attachment_body(body, data) do base64_data = base64_and_split(data) add_smtp_line(body, base64_data) end defp add_attachment(nil, _), do: "" defp add_attachment(attachment, multi_part_mixed_delimiter) do "" |> add_multipart_delimiter(multi_part_mixed_delimiter) |> add_attachment_header(attachment) |> add_smtp_line("") |> add_attachment_body(attachment.data) end defp add_attachments(body, %Bamboo.Email{attachments: nil}, _), do: body defp add_attachments(body, %Bamboo.Email{attachments: attachments}, multi_part_mixed_delimiter) do attachment_part = attachments |> Enum.map(fn attachment -> add_attachment(attachment, multi_part_mixed_delimiter) end) "#{body}#{attachment_part}" end defp add_to(body, %Bamboo.Email{to: recipients}) do add_smtp_header_line(body, :to, format_email_as_string(recipients, :to)) end defp aggregate_errors(config, key, errors) do config |> Map.fetch(key) |> build_error(key, errors) end defp apply_default_configuration({:ok, value}, _default, config) when value != nil do config end defp apply_default_configuration(_not_found_value, {key, default_value}, config) do Map.put_new(config, key, default_value) end defp generate_multi_part_delimiter do <<random1::size(32), random2::size(32), random3::size(32)>> = :crypto.strong_rand_bytes(12) "----=_Part_#{random1}_#{random2}.#{random3}" end defp body(email = %Bamboo.Email{}) do multi_part_delimiter = generate_multi_part_delimiter() multi_part_mixed_delimiter = generate_multi_part_delimiter() "" |> add_subject(email) |> add_from(email) |> add_bcc(email) |> add_cc(email) |> add_to(email) |> add_custom_headers(email) |> add_mime_header |> add_multipart_mixed_header(multi_part_mixed_delimiter) |> add_ending_header |> add_multipart_delimiter(multi_part_mixed_delimiter) |> add_multipart_header(multi_part_delimiter) |> add_ending_header |> add_text_body(email, multi_part_delimiter) |> add_html_body(email, multi_part_delimiter) |> add_ending_multipart(multi_part_delimiter) |> add_attachments(email, multi_part_mixed_delimiter) |> add_ending_multipart(multi_part_mixed_delimiter) end defp build_error({:ok, value}, _key, errors) when value != nil, do: errors defp build_error(_not_found_value, key, errors) do ["Key #{key} is required for SMTP Adapter" | errors] end defp check_required_configuration(config) do @required_configuration |> Enum.reduce([], &aggregate_errors(config, &1, &2)) |> raise_on_missing_configuration(config) end defp format_email({nil, email}, _format), do: email defp format_email({name, email}, true), do: "#{rfc822_encode(name)} <#{email}>" defp format_email({_name, email}, false), do: email defp format_email(emails, format) when is_list(emails) do Enum.map(emails, &format_email(&1, format)) end defp format_email(email, type, format \\ true) do email |> Bamboo.Formatter.format_email_address(type) |> format_email(format) end defp format_email_as_string(emails) when is_list(emails) do Enum.join(emails, ", ") end defp format_email_as_string(email) do email end defp format_email_as_string(email, type) do email |> format_email(type) |> format_email_as_string end defp from_without_format(%Bamboo.Email{from: from}) do from |> format_email(:from, false) end defp put_default_configuration(config) do @default_configuration |> Enum.reduce(config, &put_default_configuration(&2, &1)) end defp put_default_configuration(config, default = {key, _default_value}) do config |> Map.fetch(key) |> apply_default_configuration(default, config) end defp raise_on_missing_configuration([], config), do: config defp raise_on_missing_configuration(errors, config) do formatted_errors = errors |> Enum.map(&"* #{&1}") |> Enum.join("\n") raise ArgumentError, """ The following settings have not been found in your settings: #{formatted_errors} They are required to make the SMTP adapter work. Here you configuration: #{inspect(config)} """ end defp to_without_format(email = %Bamboo.Email{}) do email |> Bamboo.Email.all_recipients() |> format_email(:to, false) end defp to_gen_smtp_message(email = %Bamboo.Email{}) do {from_without_format(email), to_without_format(email), body(email)} end defp to_gen_smtp_server_config(config) do Enum.reduce(config, [], &to_gen_smtp_server_config/2) end defp to_gen_smtp_server_config({:server, value}, config) when is_binary(value) do [{:relay, value} | config] end defp to_gen_smtp_server_config({:username, value}, config) when is_binary(value) do [{:username, value} | config] end defp to_gen_smtp_server_config({:password, value}, config) when is_binary(value) do [{:password, value} | config] end defp to_gen_smtp_server_config({:tls, "if_available"}, config) do [{:tls, :if_available} | config] end defp to_gen_smtp_server_config({:tls, "always"}, config) do [{:tls, :always} | config] end defp to_gen_smtp_server_config({:tls, "never"}, config) do [{:tls, :never} | config] end defp to_gen_smtp_server_config({:tls, value}, config) when is_atom(value) do [{:tls, value} | config] end defp to_gen_smtp_server_config({:allowed_tls_versions, value}, config) when is_binary(value) do [{:tls_options, [{:versions, string_to_tls_versions(value)}]} | config] end defp to_gen_smtp_server_config({:allowed_tls_versions, value}, config) when is_list(value) do [{:tls_options, [{:versions, value}]} | config] end defp to_gen_smtp_server_config({:port, value}, config) when is_binary(value) do [{:port, String.to_integer(value)} | config] end defp to_gen_smtp_server_config({:port, value}, config) when is_integer(value) do [{:port, value} | config] end defp to_gen_smtp_server_config({:ssl, "true"}, config) do [{:ssl, true} | config] end defp to_gen_smtp_server_config({:ssl, "false"}, config) do [{:ssl, false} | config] end defp to_gen_smtp_server_config({:ssl, value}, config) when is_boolean(value) do [{:ssl, value} | config] end defp to_gen_smtp_server_config({:retries, value}, config) when is_binary(value) do [{:retries, String.to_integer(value)} | config] end defp to_gen_smtp_server_config({:retries, value}, config) when is_integer(value) do [{:retries, value} | config] end defp to_gen_smtp_server_config({:hostname, value}, config) when is_binary(value) do [{:hostname, value} | config] end defp to_gen_smtp_server_config({:no_mx_lookups, "true"}, config) do [{:no_mx_lookups, true} | config] end defp to_gen_smtp_server_config({:no_mx_lookups, "false"}, config) do [{:no_mx_lookups, false} | config] end defp to_gen_smtp_server_config({:no_mx_lookups, value}, config) when is_boolean(value) do [{:no_mx_lookups, value} | config] end defp to_gen_smtp_server_config({:auth, "if_available"}, config) do [{:auth, :if_available} | config] end defp to_gen_smtp_server_config({:auth, "always"}, config) do [{:auth, :always} | config] end defp to_gen_smtp_server_config({:auth, value}, config) when is_atom(value) do [{:auth, value} | config] end defp to_gen_smtp_server_config({conf, {:system, var}}, config) do to_gen_smtp_server_config({conf, System.get_env(var)}, config) end defp to_gen_smtp_server_config({_key, _value}, config) do config end defp string_to_tls_versions(version_string) do version_string |> String.split(",") |> Enum.filter(&(&1 in @tls_versions)) |> Enum.map(&String.to_atom/1) end end
29.284274
111
0.697005
ff94bbc2487851b4f92d450ba1802d72b3137a3f
1,216
ex
Elixir
lib/bank_stone_web/views/error_helpers.ex
theguuholi/bank_stone
150a7c7ac9eb2d9bb977d1d784518b39df5c5ab5
[ "MIT" ]
3
2020-04-25T11:35:06.000Z
2021-10-06T19:59:47.000Z
lib/bank_stone_web/views/error_helpers.ex
theguuholi/bank_stone
150a7c7ac9eb2d9bb977d1d784518b39df5c5ab5
[ "MIT" ]
12
2019-11-04T11:06:37.000Z
2019-11-21T11:03:57.000Z
lib/bank_stone_web/views/error_helpers.ex
theguuholi/bank_stone
150a7c7ac9eb2d9bb977d1d784518b39df5c5ab5
[ "MIT" ]
1
2020-12-11T07:05:04.000Z
2020-12-11T07:05:04.000Z
defmodule BankStoneWeb.ErrorHelpers do @moduledoc """ Conveniences for translating and building error messages. """ @doc """ Translates an error message using gettext. """ def translate_error({msg, opts}) do # When using gettext, we typically pass the strings we want # to translate as a static argument: # # # Translate "is invalid" in the "errors" domain # dgettext("errors", "is invalid") # # # Translate the number of files with plural rules # dngettext("errors", "1 file", "%{count} files", count) # # Because the error messages we show in our forms and APIs # are defined inside Ecto, we need to translate them dynamically. # This requires us to call the Gettext module passing our gettext # backend as first argument. # # Note we use the "errors" domain, which means translations # should be written to the errors.po file. The :count option is # set by Ecto and indicates we should also apply plural rules. if count = opts[:count] do Gettext.dngettext(BankStoneWeb.Gettext, "errors", msg, msg, count, opts) else Gettext.dgettext(BankStoneWeb.Gettext, "errors", msg, opts) end end end
35.764706
78
0.672697
ff951a4eedcc7da71529f22354fa81c2ba4d786c
2,048
exs
Elixir
config/prod.exs
LeonardoSSev/phx-crud-users
52dabaae0c81adeee39afa48eb17331de261d3c4
[ "MIT" ]
null
null
null
config/prod.exs
LeonardoSSev/phx-crud-users
52dabaae0c81adeee39afa48eb17331de261d3c4
[ "MIT" ]
null
null
null
config/prod.exs
LeonardoSSev/phx-crud-users
52dabaae0c81adeee39afa48eb17331de261d3c4
[ "MIT" ]
null
null
null
use Mix.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 :phx_crud_users, PhxCrudUsersWeb.Endpoint, url: [host: "example.com", port: 80], 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 :phx_crud_users, PhxCrudUsersWeb.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"), # transport_options: [socket_opts: [:inet6]] # ] # # 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 :phx_crud_users, PhxCrudUsersWeb.Endpoint, # force_ssl: [hsts: true] # # Check `Plug.SSL` for all available options in `force_ssl`. # Finally import the config/prod.secret.exs which loads secrets # and configuration from environment variables. import_config "prod.secret.exs"
36.571429
66
0.719727
ff9527bcda45d829de81cd8c5c85e90a5f4801b2
65
ex
Elixir
lib/bounce_out_web/views/page_view.ex
tlietz/bounce-out
cefbb7ebcdb4e39b6afa8e1b3791d222674e0681
[ "WTFPL" ]
1
2022-01-16T16:07:37.000Z
2022-01-16T16:07:37.000Z
lib/bounce_out_web/views/page_view.ex
tlietz/slideball
cefbb7ebcdb4e39b6afa8e1b3791d222674e0681
[ "WTFPL" ]
null
null
null
lib/bounce_out_web/views/page_view.ex
tlietz/slideball
cefbb7ebcdb4e39b6afa8e1b3791d222674e0681
[ "WTFPL" ]
null
null
null
defmodule BounceOutWeb.PageView do use BounceOutWeb, :view end
16.25
34
0.815385
ff953cc933724764096b48f2c529d0936f6dad6f
1,632
ex
Elixir
lib/ie_chat_bot_web/endpoint.ex
IE-bourgeois-union/ie_chat_bot
c0f155288170f558ff26bfc5cbd37f777c79a05b
[ "MIT" ]
null
null
null
lib/ie_chat_bot_web/endpoint.ex
IE-bourgeois-union/ie_chat_bot
c0f155288170f558ff26bfc5cbd37f777c79a05b
[ "MIT" ]
null
null
null
lib/ie_chat_bot_web/endpoint.ex
IE-bourgeois-union/ie_chat_bot
c0f155288170f558ff26bfc5cbd37f777c79a05b
[ "MIT" ]
null
null
null
defmodule IeChatBotWeb.Endpoint do use Phoenix.Endpoint, otp_app: :ie_chat_bot # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. @session_options [ store: :cookie, key: "_ie_chat_bot_key", signing_salt: "fNW/KpSa" ] socket "/socket", IeChatBotWeb.UserSocket, websocket: true, longpoll: false socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]] # Serve at "/" the static files from "priv/static" directory. # # You should set gzip to true if you are running phx.digest # when deploying your static files in production. plug Plug.Static, at: "/", from: :ie_chat_bot, gzip: false, only: ~w(css fonts images js favicon.ico robots.txt) # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. if code_reloading? do socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket plug Phoenix.LiveReloader plug Phoenix.CodeReloader plug Phoenix.Ecto.CheckRepoStatus, otp_app: :ie_chat_bot end plug Phoenix.LiveDashboard.RequestLogger, param_key: "request_logger", cookie_key: "request_logger" plug Plug.RequestId plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Phoenix.json_library() plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options plug IeChatBotWeb.Router end
29.672727
97
0.721814
ff953f7477de0794bb8088d2bc7cb4d2e25e799b
2,626
ex
Elixir
clients/cloud_tasks/lib/google_api/cloud_tasks/v2beta2/model/renew_lease_request.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/cloud_tasks/lib/google_api/cloud_tasks/v2beta2/model/renew_lease_request.ex
mocknen/elixir-google-api
dac4877b5da2694eca6a0b07b3bd0e179e5f3b70
[ "Apache-2.0" ]
null
null
null
clients/cloud_tasks/lib/google_api/cloud_tasks/v2beta2/model/renew_lease_request.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.CloudTasks.V2beta2.Model.RenewLeaseRequest do @moduledoc """ Request message for renewing a lease using RenewLease. ## Attributes - leaseDuration (String.t): Required. The desired new lease duration, starting from now. The maximum lease duration is 1 week. &#x60;lease_duration&#x60; will be truncated to the nearest second. Defaults to: `null`. - responseView (String.t): The response_view specifies which subset of the Task will be returned. By default response_view is BASIC; not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains. Authorization for FULL requires &#x60;cloudtasks.tasks.fullView&#x60; [Google IAM](https://cloud.google.com/iam/) permission on the Task resource. Defaults to: `null`. - Enum - one of [VIEW_UNSPECIFIED, BASIC, FULL] - scheduleTime (DateTime.t): Required. The task&#39;s current schedule time, available in the schedule_time returned by LeaseTasks response or RenewLease response. This restriction is to ensure that your worker currently holds the lease. Defaults to: `null`. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :leaseDuration => any(), :responseView => any(), :scheduleTime => DateTime.t() } field(:leaseDuration) field(:responseView) field(:scheduleTime, as: DateTime) end defimpl Poison.Decoder, for: GoogleApi.CloudTasks.V2beta2.Model.RenewLeaseRequest do def decode(value, options) do GoogleApi.CloudTasks.V2beta2.Model.RenewLeaseRequest.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.CloudTasks.V2beta2.Model.RenewLeaseRequest do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
47.745455
513
0.755141
ff955aa9552d97804707c807347f8052bf194688
75
ex
Elixir
chromoid_web/lib/chromoid_web/views/user_confirmation_view.ex
ConnorRigby/chromoid
6424a9234227d18d7c287ded869caeb31511bb97
[ "Apache-2.0" ]
7
2020-11-18T11:29:20.000Z
2022-01-16T03:16:14.000Z
chromoid_web/lib/chromoid_web/views/user_confirmation_view.ex
ConnorRigby/chromoid
6424a9234227d18d7c287ded869caeb31511bb97
[ "Apache-2.0" ]
null
null
null
chromoid_web/lib/chromoid_web/views/user_confirmation_view.ex
ConnorRigby/chromoid
6424a9234227d18d7c287ded869caeb31511bb97
[ "Apache-2.0" ]
1
2021-01-06T15:40:46.000Z
2021-01-06T15:40:46.000Z
defmodule ChromoidWeb.UserConfirmationView do use ChromoidWeb, :view end
18.75
45
0.84
ff959b792a33b6dfb4b0a4ddb97c4d3d92dd995c
1,671
ex
Elixir
clients/dns/lib/google_api/dns/v1/model/managed_zone_cloud_logging_config.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/dns/lib/google_api/dns/v1/model/managed_zone_cloud_logging_config.ex
pojiro/elixir-google-api
928496a017d3875a1929c6809d9221d79404b910
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/dns/lib/google_api/dns/v1/model/managed_zone_cloud_logging_config.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.DNS.V1.Model.ManagedZoneCloudLoggingConfig do @moduledoc """ Cloud Logging configurations for publicly visible zones. ## Attributes * `enableLogging` (*type:* `boolean()`, *default:* `nil`) - If set, enable query logging for this ManagedZone. False by default, making logging opt-in. * `kind` (*type:* `String.t`, *default:* `dns#managedZoneCloudLoggingConfig`) - """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :enableLogging => boolean() | nil, :kind => String.t() | nil } field(:enableLogging) field(:kind) end defimpl Poison.Decoder, for: GoogleApi.DNS.V1.Model.ManagedZoneCloudLoggingConfig do def decode(value, options) do GoogleApi.DNS.V1.Model.ManagedZoneCloudLoggingConfig.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.DNS.V1.Model.ManagedZoneCloudLoggingConfig do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
33.42
155
0.732496
ff95b43fa01a82f9adf6408dafb0511d4f8da978
1,247
ex
Elixir
test/support/conn_case.ex
gjlbro/testdelivery
3d667cca67b3a561d7395673b6b968523ed3270a
[ "MIT" ]
null
null
null
test/support/conn_case.ex
gjlbro/testdelivery
3d667cca67b3a561d7395673b6b968523ed3270a
[ "MIT" ]
null
null
null
test/support/conn_case.ex
gjlbro/testdelivery
3d667cca67b3a561d7395673b6b968523ed3270a
[ "MIT" ]
null
null
null
defmodule DeliveryWeb.ConnCase do @moduledoc """ This module defines the test case to be used by tests that require setting up a connection. Such tests rely on `Phoenix.ConnTest` and also import other functionality to make it easier to build common data structures and query the data layer. Finally, if the test case interacts with the database, we enable the SQL sandbox, so changes done to the database are reverted at the end of every test. If you are using PostgreSQL, you can even run database tests asynchronously by setting `use DeliveryWeb.ConnCase, async: true`, although this option is not recommended for other databases. """ use ExUnit.CaseTemplate alias Ecto.Adapters.SQL.Sandbox using do quote do # Import conveniences for testing with connections import Plug.Conn import Phoenix.ConnTest import DeliveryWeb.ConnCase alias DeliveryWeb.Router.Helpers, as: Routes # The default endpoint for testing @endpoint DeliveryWeb.Endpoint end end setup tags do :ok = Sandbox.checkout(Delivery.Repo) unless tags[:async] do Sandbox.mode(Delivery.Repo, {:shared, self()}) end {:ok, conn: Phoenix.ConnTest.build_conn()} end end
27.108696
62
0.724138
ff95b65b8060daac1a15968b76b2d9da40987418
3,548
ex
Elixir
clients/proximity_beacon/lib/google_api/proximity_beacon/v1beta1/model/beacon_attachment.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2021-12-20T03:40:53.000Z
2021-12-20T03:40:53.000Z
clients/proximity_beacon/lib/google_api/proximity_beacon/v1beta1/model/beacon_attachment.ex
medikent/elixir-google-api
98a83d4f7bfaeac15b67b04548711bb7e49f9490
[ "Apache-2.0" ]
1
2020-08-18T00:11:23.000Z
2020-08-18T00:44:16.000Z
clients/proximity_beacon/lib/google_api/proximity_beacon/v1beta1/model/beacon_attachment.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.ProximityBeacon.V1beta1.Model.BeaconAttachment do @moduledoc """ Project-specific data associated with a beacon. ## Attributes * `attachmentName` (*type:* `String.t`, *default:* `nil`) - Resource name of this attachment. Attachment names have the format: <code>beacons/<var>beacon_id</var>/attachments/<var>attachment_id</var></code>. Leave this empty on creation. * `creationTimeMs` (*type:* `DateTime.t`, *default:* `nil`) - The UTC time when this attachment was created, in milliseconds since the UNIX epoch. * `data` (*type:* `String.t`, *default:* `nil`) - An opaque data container for client-provided data. Must be [base64](http://tools.ietf.org/html/rfc4648#section-4) encoded in HTTP requests, and will be so encoded (with padding) in responses. Required. * `maxDistanceMeters` (*type:* `float()`, *default:* `nil`) - The distance away from the beacon at which this attachment should be delivered to a mobile app. Setting this to a value greater than zero indicates that the app should behave as if the beacon is "seen" when the mobile device is less than this distance away from the beacon. Different attachments on the same beacon can have different max distances. Note that even though this value is expressed with fractional meter precision, real-world behavior is likley to be much less precise than one meter, due to the nature of current Bluetooth radio technology. Optional. When not set or zero, the attachment should be delivered at the beacon's outer limit of detection. Negative values are invalid and return an error. * `namespacedType` (*type:* `String.t`, *default:* `nil`) - Specifies what kind of attachment this is. Tells a client how to interpret the `data` field. Format is <var>namespace/type</var>. Namespace provides type separation between clients. Type describes the type of `data`, for use by the client when parsing the `data` field. Required. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :attachmentName => String.t(), :creationTimeMs => DateTime.t(), :data => String.t(), :maxDistanceMeters => float(), :namespacedType => String.t() } field(:attachmentName) field(:creationTimeMs, as: DateTime) field(:data) field(:maxDistanceMeters) field(:namespacedType) end defimpl Poison.Decoder, for: GoogleApi.ProximityBeacon.V1beta1.Model.BeaconAttachment do def decode(value, options) do GoogleApi.ProximityBeacon.V1beta1.Model.BeaconAttachment.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.ProximityBeacon.V1beta1.Model.BeaconAttachment do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
41.741176
138
0.714487
ff95e224345c2fd29466408fac7f063431565400
1,034
ex
Elixir
test/support/conn_case.ex
jchristopherinc/mars
a109958cb549ede8d983c3af8183d52528a5eaea
[ "MIT" ]
2
2020-08-28T19:17:33.000Z
2020-09-13T18:49:20.000Z
test/support/conn_case.ex
jchristopherinc/mars
a109958cb549ede8d983c3af8183d52528a5eaea
[ "MIT" ]
5
2018-10-28T14:39:26.000Z
2019-01-31T17:23:36.000Z
test/support/conn_case.ex
jchristopherinc/mars
a109958cb549ede8d983c3af8183d52528a5eaea
[ "MIT" ]
null
null
null
defmodule MarsWeb.ConnCase do @moduledoc """ This module defines the test case to be used by tests that require setting up a connection. Such tests rely on `Phoenix.ConnTest` and also import other functionality to make it easier to build common data structures and query the data layer. 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 alias Ecto.Adapters.SQL using do quote do # Import conveniences for testing with connections use Phoenix.ConnTest alias MarsWeb.Router.Helpers, as: Routes # The default endpoint for testing @endpoint MarsWeb.Endpoint end end setup tags do :ok = SQL.Sandbox.checkout(Mars.Repo) unless tags[:async] do SQL.Sandbox.mode(Mars.Repo, {:shared, self()}) end {:ok, conn: Phoenix.ConnTest.build_conn()} end end
25.219512
59
0.710832
ff960f644fe03e5b14b50bd6fcd198a4e55969b1
123
ex
Elixir
debian/menu.ex
certik/python2.6
3b8ab0cdb83bea160b2c5e11c620ffd1bdf04a59
[ "PSF-2.0" ]
4
2015-12-07T13:37:48.000Z
2021-03-24T16:27:52.000Z
debian/menu.ex
certik/python2.6
3b8ab0cdb83bea160b2c5e11c620ffd1bdf04a59
[ "PSF-2.0" ]
null
null
null
debian/menu.ex
certik/python2.6
3b8ab0cdb83bea160b2c5e11c620ffd1bdf04a59
[ "PSF-2.0" ]
null
null
null
?package(python):needs="X11|text|vc|wm" section="Applications/see-menu-manual"\ title="python" command="/usr/bin/python"
41
79
0.739837
ff960fd7294be9ac184718d04079b2239fd12b04
110
exs
Elixir
test/ssdp_test.exs
rosetta-home/ssdp
80bd4b75868d2605be5d497b5b9f36ac051ae459
[ "Apache-2.0" ]
1
2020-03-22T23:36:34.000Z
2020-03-22T23:36:34.000Z
test/ssdp_test.exs
rosetta-home/ssdp
80bd4b75868d2605be5d497b5b9f36ac051ae459
[ "Apache-2.0" ]
null
null
null
test/ssdp_test.exs
rosetta-home/ssdp
80bd4b75868d2605be5d497b5b9f36ac051ae459
[ "Apache-2.0" ]
null
null
null
defmodule SsdpTest do use ExUnit.Case doctest SSDP test "the truth" do assert 1 + 1 == 2 end end
12.222222
21
0.654545
ff96122e8a1c1620b2634cacc3be15d2b8aa09b4
83
ex
Elixir
lib/rube/erc20/events/burn.ex
icecube11/rube
5d813c5b9f7b984786ac7db6fd2eca0939bf5468
[ "MIT" ]
null
null
null
lib/rube/erc20/events/burn.ex
icecube11/rube
5d813c5b9f7b984786ac7db6fd2eca0939bf5468
[ "MIT" ]
null
null
null
lib/rube/erc20/events/burn.ex
icecube11/rube
5d813c5b9f7b984786ac7db6fd2eca0939bf5468
[ "MIT" ]
null
null
null
defmodule Rube.Erc20.Events.Burn do defstruct ~w(sender amount0 amount1 to)a end
20.75
42
0.795181
ff9639ea272fae2d59e1f30e65a9633a18010823
220
exs
Elixir
priv/repo/migrations/20150903145437_create_contacts.exs
cncgl/phoenix-sample
81b1c807a40e972df93ccc4063395ddf48bf4e2e
[ "MIT" ]
1
2016-01-01T12:55:25.000Z
2016-01-01T12:55:25.000Z
priv/repo/migrations/20150903145437_create_contacts.exs
cncgl/phoenix-todo
81b1c807a40e972df93ccc4063395ddf48bf4e2e
[ "MIT" ]
1
2015-09-10T13:41:51.000Z
2015-09-10T13:41:51.000Z
priv/repo/migrations/20150903145437_create_contacts.exs
cncgl/phoenix-todo
81b1c807a40e972df93ccc4063395ddf48bf4e2e
[ "MIT" ]
null
null
null
defmodule HelloPhoenix.Repo.Migrations.CreateContacts do use Ecto.Migration def change do create table(:contacts) do add :name, :string add :phone, :string timestamps end end end
16.923077
56
0.659091
ff964a6f0acd410d0e1a4bec14c06c317d30ae6c
1,037
ex
Elixir
lib/queerlink/application.ex
Queertoo/Queerlink
0a7726460cda63fc4ab342a2fe1d1155caa3d6d4
[ "MIT" ]
38
2015-11-07T23:54:26.000Z
2021-04-09T04:14:25.000Z
lib/queerlink/application.ex
Queertoo/Queerlink
0a7726460cda63fc4ab342a2fe1d1155caa3d6d4
[ "MIT" ]
2
2015-11-23T15:00:34.000Z
2015-11-26T09:59:26.000Z
lib/queerlink/application.ex
Queertoo/Queerlink
0a7726460cda63fc4ab342a2fe1d1155caa3d6d4
[ "MIT" ]
6
2015-11-26T00:25:22.000Z
2020-03-04T22:13:59.000Z
defmodule Queerlink.Application do use Application # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications def start(_type, _args) do import Supervisor.Spec # Define workers and child supervisors to be supervised children = [ # Start the Ecto repository supervisor(Queerlink.Repo, []), # Start the endpoint when the application starts supervisor(QueerlinkWeb.Endpoint, []), # Start your own worker by calling: Queerlink.Worker.start_link(arg1, arg2, arg3) # worker(Queerlink.Worker, [arg1, arg2, arg3]), ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Queerlink.Supervisor] Supervisor.start_link(children, opts) end # Tell Phoenix to update the endpoint configuration # whenever the application is updated. def config_change(changed, _new, removed) do QueerlinkWeb.Endpoint.config_change(changed, removed) :ok end end
32.40625
87
0.717454
ff96b37eb088ad1da75475b17858f01b415fe4f6
2,564
ex
Elixir
clients/cloud_run/lib/google_api/cloud_run/v1alpha1/model/service_spec_release_type.ex
jechol/elixir-google-api
0290b683dfc6491ca2ef755a80bc329378738d03
[ "Apache-2.0" ]
null
null
null
clients/cloud_run/lib/google_api/cloud_run/v1alpha1/model/service_spec_release_type.ex
jechol/elixir-google-api
0290b683dfc6491ca2ef755a80bc329378738d03
[ "Apache-2.0" ]
null
null
null
clients/cloud_run/lib/google_api/cloud_run/v1alpha1/model/service_spec_release_type.ex
jechol/elixir-google-api
0290b683dfc6491ca2ef755a80bc329378738d03
[ "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.CloudRun.V1alpha1.Model.ServiceSpecReleaseType do @moduledoc """ ServiceSpecReleaseType contains the options for slowly releasing revisions. See ServiceSpec for more details. Not currently supported by Cloud Run. ## Attributes * `configuration` (*type:* `GoogleApi.CloudRun.V1alpha1.Model.ConfigurationSpec.t`, *default:* `nil`) - The configuration for this service. All revisions from this service must come from a single configuration. * `revisions` (*type:* `list(String.t)`, *default:* `nil`) - Revisions is an ordered list of 1 or 2 revisions. The first is the current revision, and the second is the candidate revision. If a single revision is provided, traffic will be pinned at that revision. "@latest" is a shortcut for usage that refers to the latest created revision by the configuration. * `rolloutPercent` (*type:* `integer()`, *default:* `nil`) - RolloutPercent is the percent of traffic that should be sent to the candidate revision, i.e. the 2nd revision in the revisions list. Valid values are between 0 and 99 inclusive. """ use GoogleApi.Gax.ModelBase @type t :: %__MODULE__{ :configuration => GoogleApi.CloudRun.V1alpha1.Model.ConfigurationSpec.t() | nil, :revisions => list(String.t()) | nil, :rolloutPercent => integer() | nil } field(:configuration, as: GoogleApi.CloudRun.V1alpha1.Model.ConfigurationSpec) field(:revisions, type: :list) field(:rolloutPercent) end defimpl Poison.Decoder, for: GoogleApi.CloudRun.V1alpha1.Model.ServiceSpecReleaseType do def decode(value, options) do GoogleApi.CloudRun.V1alpha1.Model.ServiceSpecReleaseType.decode(value, options) end end defimpl Poison.Encoder, for: GoogleApi.CloudRun.V1alpha1.Model.ServiceSpecReleaseType do def encode(value, options) do GoogleApi.Gax.ModelBase.encode(value, options) end end
48.377358
365
0.75156