-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version number comparison & fix chained version renames (#134)
* Prepare possibility to get version as tuple * Compare bitstyles versions numerically * Add dummy example of chained class renames * Chain class renames * Mix credo warnings * Create two separate 'version' functions * Credo warnings * Add Changelog entry * Extract Bitstyles.Version * Do not skip versions with noop downgrades * Do not include version test classes in prod * I forgot version 3.1.0 * Update lib/bitstyles_phoenix/bitstyles.ex Co-authored-by: Andreas Knöpfle <[email protected]> * Fix format --------- Co-authored-by: Andreas Knöpfle <[email protected]>
- Loading branch information
1 parent
2859e4c
commit c101a50
Showing
11 changed files
with
338 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
defmodule BitstylesPhoenix.Bitstyles.Version do | ||
@moduledoc false | ||
|
||
@default_version "5.0.1" | ||
|
||
def version do | ||
to_tuple(version_string()) | ||
end | ||
|
||
def version_string do | ||
bitstyles_version_override = Process.get(:bitstyles_phoenix_bistyles_version) | ||
|
||
bitstyles_version_override || | ||
Application.get_env(:bitstyles_phoenix, :bitstyles_version, @default_version) | ||
end | ||
|
||
def default_version do | ||
to_tuple(@default_version) | ||
end | ||
|
||
def default_version_string, do: @default_version | ||
|
||
def to_tuple(version) when is_tuple(version), do: version | ||
|
||
def to_tuple(version) when is_binary(version) do | ||
version | ||
|> String.split(".") | ||
|> Enum.map(&String.to_integer/1) | ||
|> List.to_tuple() | ||
end | ||
|
||
def to_string(version) when is_binary(version), do: version | ||
|
||
def to_string(version) when is_tuple(version) do | ||
version | ||
|> Tuple.to_list() | ||
|> Enum.map_join(".", &Kernel.to_string/1) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.