Skip to content

Commit c2256cb

Browse files
committed
chore: renamed rrule_parser -> rrule_codec
1 parent be9cb1b commit c2256cb

18 files changed

Lines changed: 107 additions & 103 deletions

File tree

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ jobs:
5252
id: build-crate
5353
uses: philss/rustler-precompiled-action@v1.0.1
5454
with:
55-
project-name: rrule_parser_rs
55+
project-name: rrule_codec_rs
5656
project-version: ${{ env.PROJECT_VERSION }}
5757
target: ${{ matrix.job.target }}
5858
nif-version: ${{ matrix.nif }}
5959
use-cross: ${{ matrix.job.use-cross }}
60-
project-dir: "native/rrule_parser_rs"
60+
project-dir: "native/rrule_codec_rs"
6161

6262
- name: Artifact upload
6363
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ erl_crash.dump
2020
*.ez
2121

2222
# Ignore package tarball (built via "mix hex.build").
23-
RruleParser-*.tar
23+
rrule_codec-*.tar
2424

2525
# Temporary files, for example, from tests.
2626
/tmp/
2727

2828
/.elixir_ls
2929

30-
checksum-Elixir.RruleParser.Rrule.Api.exs
30+
checksum-Elixir.RruleCodec.Rrule.Api.exs
31+
32+
priv/native/*.so
33+
priv/native/*.dll
34+
priv/native/*.dylib
3135

3236
.envrc

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# RruleParser
1+
# RruleCodec
22

33
**Description**
44
Rrule parsing and utils based on rust nif
55

66
- https://docs.rs/rrule/latest/rrule/index.html
77
- https://github.com/fmeringdal/rust-rrule
88

9-
Only does this for now: RruleParser.Rrule.next("DTSTART;TZID=Etc/UTC:20191220T020000\nRRULE:FREQ=MONTHLY;BYMONTHDAY=28,29,30,31;BYSETPOS=-1", 10)
9+
Only does this for now: RruleCodec.Rrule.next("DTSTART;TZID=Etc/UTC:20191220T020000\nRRULE:FREQ=MONTHLY;BYMONTHDAY=28,29,30,31;BYSETPOS=-1", 10)
1010
## Installation
1111

1212
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
13-
by adding `RruleParser` to your list of dependencies in `mix.exs`:
13+
by adding `rrule_codec` to your list of dependencies in `mix.exs`:
1414

1515
```elixir
1616
def deps do
1717
[
18-
{:rrule_parser, "~> 0.1.0"}
18+
{:rrule_codec, "~> 0.1.0"}
1919
]
2020
end
2121
```
2222

2323
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
2424
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
25-
be found at <https://hexdocs.pm/RruleParser>.
25+
be found at <https://hexdocs.pm/rrule_codec>.
2626

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule RruleParser.Rrule.Api do
1+
defmodule RruleCodec.Rrule.Api do
22
@moduledoc """
33
Rrule parsing and utility functions using precompiled Rust NIF from https://github.com/fmeringdal/rust-rrule
44
@@ -13,7 +13,7 @@ defmodule RruleParser.Rrule.Api do
1313
## Examples
1414
1515
# Parse an RRULE string into a structured Elixir type
16-
iex> rrule = RruleParser.Rrule.Api.string_to_rrule("FREQ=DAILY;INTERVAL=2;COUNT=10")
16+
iex> rrule = RruleCodec.Rrule.Api.string_to_rrule("FREQ=DAILY;INTERVAL=2;COUNT=10")
1717
iex> rrule.freq
1818
:daily
1919
iex> rrule.interval
@@ -22,17 +22,17 @@ defmodule RruleParser.Rrule.Api do
2222
10
2323
2424
# Convert an Elixir struct back to an RRULE string
25-
iex> rrule = %RruleParser.Rrule{freq: :weekly, interval: 1, by_weekday: ["MO", "WE", "FR"]}
26-
iex> RruleParser.Rrule.Api.rrule_to_string(rrule)
25+
iex> rrule = %RruleCodec.Rrule{freq: :weekly, interval: 1, by_weekday: ["MO", "WE", "FR"]}
26+
iex> RruleCodec.Rrule.Api.rrule_to_string(rrule)
2727
"FREQ=WEEKLY;BYDAY=MO,WE,FR"
2828
2929
# Validate an RRULE against a start date
30-
iex> rrule = %RruleParser.Rrule{freq: :monthly, interval: 1, by_month_day: [24]}
31-
iex> RruleParser.Rrule.Api.validate_rrule(rrule, "2023-04-01T00:00:00Z")
30+
iex> rrule = %RruleCodec.Rrule{freq: :monthly, interval: 1, by_month_day: [24]}
31+
iex> RruleCodec.Rrule.Api.validate_rrule(rrule, "2023-04-01T00:00:00Z")
3232
:ok
3333
34-
iex> rrule = %RruleParser.Rrule{freq: :monthly, interval: 1, by_month_day: [32]}
35-
iex> RruleParser.Rrule.Api.validate_rrule(rrule, "2023-02-01T00:00:00Z")
34+
iex> rrule = %RruleCodec.Rrule{freq: :monthly, interval: 1, by_month_day: [32]}
35+
iex> RruleCodec.Rrule.Api.validate_rrule(rrule, "2023-02-01T00:00:00Z")
3636
{:error, "Error validating rrule: February doesn't have 32 days"}
3737
"""
3838

@@ -50,15 +50,15 @@ defmodule RruleParser.Rrule.Api do
5050
)
5151

5252
use RustlerPrecompiled,
53-
otp_app: :rrule_parser,
54-
crate: "rrule_parser_rs",
53+
otp_app: :rrule_codec,
54+
crate: "rrule_codec_rs",
5555
base_url: "#{github_url}/releases/download/v#{version}",
5656
force_build: System.get_env("RRULE_BUILD") in ["1", "true"],
5757
version: version,
5858
targets: targets
5959

6060
@doc """
61-
Parses an RFC 5545 RRULE string into a structured `RruleParser.Rrule` struct.
61+
Parses an RFC 5545 RRULE string into a structured `RruleCodec.Rrule` struct.
6262
6363
This function takes a string representation of a recurrence rule (RRULE) as defined in RFC 5545
6464
and converts it into a structured Elixir struct that can be used in your application.
@@ -69,31 +69,31 @@ defmodule RruleParser.Rrule.Api do
6969
7070
## Returns
7171
72-
* `{:ok, %RruleParser.Rrule{}}` - A structured representation of the RRULE if parsing succeeds
72+
* `{:ok, %RruleCodec.Rrule{}}` - A structured representation of the RRULE if parsing succeeds
7373
* `{:error, reason}` - An error if the RRULE string is malformed or contains invalid values
7474
7575
## Examples
7676
77-
iex> RruleParser.Rrule.Api.string_to_rrule("FREQ=DAILY;INTERVAL=2;COUNT=10")
78-
{:ok, %RruleParser.Rrule{freq: "Daily", interval: 2, count: 10}}
77+
iex> RruleCodec.Rrule.Api.string_to_rrule("FREQ=DAILY;INTERVAL=2;COUNT=10")
78+
{:ok, %RruleCodec.Rrule{freq: "Daily", interval: 2, count: 10}}
7979
80-
iex> RruleParser.Rrule.Api.string_to_rrule("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR")
81-
{:ok, %RruleParser.Rrule{freq: "Weekly", interval: 1, by_weekday: ["MO", "WE", "FR"]}}
80+
iex> RruleCodec.Rrule.Api.string_to_rrule("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR")
81+
{:ok, %RruleCodec.Rrule{freq: "Weekly", interval: 1, by_weekday: ["MO", "WE", "FR"]}}
8282
83-
iex> RruleParser.Rrule.Api.string_to_rrule("INVALID")
83+
iex> RruleCodec.Rrule.Api.string_to_rrule("INVALID")
8484
{:error, "Error parsing rrule: Invalid format"}
8585
"""
8686
def string_to_rrule(_rrule_string), do: error()
8787

8888
@doc """
89-
Converts an `RruleParser.Rrule` struct back into an RFC 5545 RRULE string.
89+
Converts an `RruleCodec.Rrule` struct back into an RFC 5545 RRULE string.
9090
9191
This function takes an Elixir struct that represents a recurrence rule and
9292
converts it back into a string representation that follows the RFC 5545 RRULE format.
9393
9494
## Parameters
9595
96-
* `rrule_struct` - An `RruleParser.Rrule` struct containing the RRULE parameters
96+
* `rrule_struct` - An `RruleCodec.Rrule` struct containing the RRULE parameters
9797
9898
## Returns
9999
@@ -102,30 +102,30 @@ defmodule RruleParser.Rrule.Api do
102102
103103
## Examples
104104
105-
iex> rrule = %RruleParser.Rrule{freq: "Daily", interval: 2, count: 10}
106-
iex> RruleParser.Rrule.Api.rrule_to_string(rrule)
105+
iex> rrule = %RruleCodec.Rrule{freq: "Daily", interval: 2, count: 10}
106+
iex> RruleCodec.Rrule.Api.rrule_to_string(rrule)
107107
{:ok, "FREQ=DAILY;INTERVAL=2;COUNT=10"}
108108
109-
iex> rrule = %RruleParser.Rrule{freq: "Weekly", interval: 1, by_weekday: ["MO", "WE", "FR"]}
110-
iex> RruleParser.Rrule.Api.rrule_to_string(rrule)
109+
iex> rrule = %RruleCodec.Rrule{freq: "Weekly", interval: 1, by_weekday: ["MO", "WE", "FR"]}
110+
iex> RruleCodec.Rrule.Api.rrule_to_string(rrule)
111111
{:ok, "FREQ=WEEKLY;BYDAY=MO,WE,FR"}
112112
113-
iex> rrule = %RruleParser.Rrule{freq: "InvalidFreq", interval: 1}
114-
iex> RruleParser.Rrule.Api.rrule_to_string(rrule)
113+
iex> rrule = %RruleCodec.Rrule{freq: "InvalidFreq", interval: 1}
114+
iex> RruleCodec.Rrule.Api.rrule_to_string(rrule)
115115
{:error, "Error converting properties to rrule: Invalid frequency: InvalidFreq"}
116116
"""
117117
def rrule_to_string(_rrule_struct), do: error()
118118

119119
@doc """
120120
Validates if a recurrence rule is properly formed with respect to a start date.
121121
122-
This function checks if the given `RruleParser.Rrule` struct represents a valid recurrence rule
122+
This function checks if the given `RruleCodec.Rrule` struct represents a valid recurrence rule
123123
when combined with the provided start date. The validation includes checking if all
124124
rule components are consistent with each other and with the start date.
125125
126126
## Parameters
127127
128-
* `rrule_struct` - An `RruleParser.Rrule` struct containing the RRULE parameters
128+
* `rrule_struct` - An `RruleCodec.Rrule` struct containing the RRULE parameters
129129
* `dt_start` - A string containing an RFC 3339 formatted date-time for the rule's start date
130130
131131
## Returns
@@ -135,16 +135,16 @@ defmodule RruleParser.Rrule.Api do
135135
136136
## Examples
137137
138-
iex> rrule = %RruleParser.Rrule{freq: "Monthly", interval: 1, by_month_day: [22]}
139-
iex> RruleParser.Rrule.Api.validate_rrule(rrule, "2023-04-01T00:00:00Z")
138+
iex> rrule = %RruleCodec.Rrule{freq: "Monthly", interval: 1, by_month_day: [22]}
139+
iex> RruleCodec.Rrule.Api.validate_rrule(rrule, "2023-04-01T00:00:00Z")
140140
:ok
141141
142-
iex> rrule = %RruleParser.Rrule{freq: "Monthly", interval: 1, by_month_day: [-1]}
143-
iex> RruleParser.Rrule.Api.validate_rrule(rrule, "2023-02-01T00:00:00Z")
142+
iex> rrule = %RruleCodec.Rrule{freq: "Monthly", interval: 1, by_month_day: [-1]}
143+
iex> RruleCodec.Rrule.Api.validate_rrule(rrule, "2023-02-01T00:00:00Z")
144144
{:error, "Error validating rrule: February doesn't have -1 days"}
145145
146-
iex> rrule = %RruleParser.Rrule{freq: "Monthly", interval: 1}
147-
iex> RruleParser.Rrule.Api.validate_rrule(rrule, "invalid-date")
146+
iex> rrule = %RruleCodec.Rrule{freq: "Monthly", interval: 1}
147+
iex> RruleCodec.Rrule.Api.validate_rrule(rrule, "invalid-date")
148148
{:error, "Invalid datetime: invalid-date"}
149149
"""
150150
def validate_rrule(_rrule_struct, _dt_start), do: error()

0 commit comments

Comments
 (0)