Skip to content

Commit 5d9c586

Browse files
committed
Prep for publishing to hex.
1 parent ea48a16 commit 5d9c586

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Christopher Jon Keathley
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

lib/rollout.ex

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Rollout do
66
alias Rollout.Storage
77

88
@doc """
9-
Checks to see if a feature is active or not
9+
Checks to see if a feature is active or not.
1010
"""
1111
def active?(flag) do
1212
case Storage.percentage(flag) do
@@ -17,18 +17,29 @@ defmodule Rollout do
1717
false
1818

1919
val ->
20-
:rand.uniform(100) < val
20+
:rand.uniform(100) <= val
2121
end
2222
end
2323

24+
@doc """
25+
Fully activates a feature flag.
26+
"""
2427
def activate(flag) do
2528
Storage.set_percentage(flag, 100)
2629
end
2730

31+
@doc """
32+
Activates a feature flag for a percentage of requests. An integer between 0 and 100
33+
must be provided. Deciding whether a flag is active is done with the following
34+
calculation: `:rand.uniform(100) <= provided_percentage`
35+
"""
2836
def activate_percentage(flag, percentage) when is_integer(percentage) and 0 <= percentage and percentage <= 100 do
2937
Storage.set_percentage(flag, percentage)
3038
end
3139

40+
@doc """
41+
Disables a feature flag.
42+
"""
3243
def deactivate(flag) do
3344
Storage.set_percentage(flag, 0)
3445
end

mix.exs

+35-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
defmodule Rollout.MixProject do
22
use Mix.Project
33

4+
@version "0.1.0"
5+
46
def project do
57
[
68
app: :rollout,
7-
version: "0.1.0",
9+
version: @version,
810
elixir: "~> 1.8",
911
start_permanent: Mix.env() == :prod,
10-
deps: deps()
12+
deps: deps(),
13+
14+
description: description(),
15+
package: package(),
16+
name: "Rollout",
17+
source_url: "https://github.com/keathley/rollout",
18+
docs: docs(),
1119
]
1220
end
1321

@@ -22,7 +30,31 @@ defmodule Rollout.MixProject do
2230
# Run "mix help deps" to learn about dependencies.
2331
defp deps do
2432
[
25-
{:hlcid, path: "../hlcid"},
33+
{:hlclock, "~> 1.0"},
34+
]
35+
end
36+
37+
def description do
38+
"""
39+
Rollout allows you to flip features quickly and easily. It relies on
40+
distributed erlang and uses LWW-register CRDTs and Hybrid-logical clocks
41+
to provide maximum availability.
42+
"""
43+
end
44+
45+
def package do
46+
[
47+
name: "rollout",
48+
licenses: ["MIT"],
49+
links: %{"GitHub" => "https://github.com/keathley/rollout"},
50+
]
51+
end
52+
53+
def docs do
54+
[
55+
source_ref: "v#{@version}",
56+
source_url: "https://github.com/keathley/rollout",
57+
main: "Rollout",
2658
]
2759
end
2860
end

0 commit comments

Comments
 (0)