-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 03a099a
Showing
18 changed files
with
683 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] | ||
] |
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,31 @@ | ||
name: Elixir CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
test: | ||
|
||
name: Build and test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Elixir | ||
uses: erlef/setup-beam@988e02bfe678367a02564f65ca2e37726dc0268f | ||
with: | ||
elixir-version: '1.13.4' # Define the elixir version [required] | ||
otp-version: '24.3.4.2' # Define the OTP version [required] | ||
- name: Restore dependencies cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | ||
restore-keys: ${{ runner.os }}-mix- | ||
- name: Install dependencies | ||
run: mix deps.get | ||
- name: Run tests | ||
run: mix test |
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,26 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where third-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
|
||
# Ignore .fetch files in case you like to edit your project deps locally. | ||
/.fetch | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
*.ez | ||
|
||
# Ignore package tarball (built via "mix hex.build"). | ||
fast_syndication-*.tar | ||
|
||
# Temporary files, for example, from tests. | ||
/tmp/ |
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,2 @@ | ||
elixir 1.13.4 | ||
erlang 24.3.4.2 |
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,10 @@ | ||
# Changelog | ||
|
||
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.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.0] - 2022-08-17 | ||
### Added | ||
- Initial release for parsing RSS and Atom feeds |
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,10 @@ | ||
# FastSyndication | ||
|
||
Minimal wrapper around Rust NIFs for fast RSS and Atom feed parsing | ||
|
||
## Usage | ||
|
||
```elixir | ||
iex(1)> {:ok, map_of_rss} = FastRSS.parse(%{rss_string: "...rss_feed_string..."}) | ||
iex(2)> {:ok, map_of_atom} = FastRSS.parse(%{atom_string: "...rss_feed_string..."}) | ||
``` |
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,29 @@ | ||
defmodule FastSyndication do | ||
defmodule Native do | ||
use Rustler, otp_app: :fast_syndication, crate: "fastsyndication" | ||
|
||
def parse_atom(_a), do: :erlang.nif_error(:nif_not_loaded) | ||
def parse_rss(_a), do: :erlang.nif_error(:nif_not_loaded) | ||
end | ||
|
||
def parse(""), do: {:error, "Cannot parse blank string"} | ||
|
||
def parse(%{atom_string: atom_string}) when is_binary(atom_string) do | ||
atom_string | ||
|> Native.parse_atom() | ||
|> map_to_tuple() | ||
end | ||
|
||
def parse(%{rss_string: rss_string}) when is_binary(rss_string) do | ||
rss_string | ||
|> Native.parse_rss() | ||
|> map_to_tuple() | ||
end | ||
|
||
def parse(_somethig_else), do: {:error, "RSS feed must be passed in as a string"} | ||
|
||
defp map_to_tuple(%{"Ok" => map}), do: {:ok, map} | ||
defp map_to_tuple({:ok, map}), do: {:ok, map} | ||
defp map_to_tuple(%{"Err" => msg}), do: {:error, msg} | ||
defp map_to_tuple({:error, msg}), do: {:error, msg} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
defmodule FastSyndication.MixProject do | ||
use Mix.Project | ||
|
||
@source_url "https://github.com/mikhailbot/fast_syndication" | ||
@version "0.1.0" | ||
|
||
def project do | ||
[ | ||
app: :fast_syndication, | ||
version: @version, | ||
elixir: "~> 1.13", | ||
start_permanent: Mix.env() == :prod, | ||
deps: deps(), | ||
|
||
# hex | ||
description: "Fast Elixir RSS and Atom feed parser", | ||
package: package() | ||
] | ||
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 | ||
[ | ||
{:rustler, "~> 0.25.0"} | ||
] | ||
end | ||
|
||
defp package() do | ||
[ | ||
files: [ | ||
"lib", | ||
"native/fastsyndication/.cargo", | ||
"native/fastsyndication/src", | ||
"native/fastsyndication/Cargo.toml", | ||
"native/fastsyndication/Cargo.lock", | ||
"mix.exs", | ||
"README.md", | ||
"LICENSE" | ||
], | ||
maintainers: ["Mikhail Delport"], | ||
licenses: ["Apache-2.0"], | ||
links: %{ | ||
"Changelog" => "#{@source_url}/blob/master/CHANGELOG.md", | ||
"GitHub" => @source_url | ||
} | ||
] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
%{ | ||
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, | ||
"rustler": {:hex, :rustler, "0.25.0", "32526b51af7e58a740f61941bf923486ce6415a91c3934cc16c281aa201a2240", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "6b43a11a37fe79c6234d88c4102ab5dfede7a6a764dc5c7b539956cfa02f3cf4"}, | ||
"toml": {:hex, :toml, "0.6.2", "38f445df384a17e5d382befe30e3489112a48d3ba4c459e543f748c2f25dd4d1", [:mix], [], "hexpm", "d013e45126d74c0c26a38d31f5e8e9b83ea19fc752470feb9a86071ca5a672fa"}, | ||
} |
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,5 @@ | ||
[target.'cfg(target_os = "macos")'] | ||
rustflags = [ | ||
"-C", "link-arg=-undefined", | ||
"-C", "link-arg=dynamic_lookup", | ||
] |
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 @@ | ||
/target |
Oops, something went wrong.