Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support version normalizations #1426

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [unreleased]

## Added
- `LiveViewNative.SwiftUI.normalize_os_version/1`
- `LiveViewNative.SwiftUI.normalize_app_version/1`

## Changed

## Fixed

## [0.3.0] 2024-08-21

### Added
Expand Down
15 changes: 15 additions & 0 deletions lib/live_view_native/swiftui.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,19 @@ defmodule LiveViewNative.SwiftUI do
module_suffix: :SwiftUI,
template_engine: LiveViewNative.Engine,
stylesheet_rules_parser: LiveViewNative.SwiftUI.RulesParser

def normalize_os_version(os_version),
do: normalize_version(os_version)

def normalize_app_version(app_version),
do: normalize_version(app_version)

defp normalize_version(version) do
version
|> String.split(".")
|> Enum.map(fn(number) ->
{number, _rem} = Integer.parse(number)
number
end)
end
end
15 changes: 15 additions & 0 deletions test/live_view_native/swiftui/swiftui_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defmodule LiveViewNative.SwiftUITest do
use ExUnit.Case

alias LiveViewNative.SwiftUI

describe "version normalization" do
test "normalize_os_version" do
assert [1, 2, 3] = SwiftUI.normalize_os_version("1.2.3")
end

test "normalize_app_version" do
assert [1, 2, 3] = SwiftUI.normalize_app_version("1.2.3")
end
end
end
Loading