chunky_projects 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +1464 -154
- data/ext/chunky_projects/Cargo.toml +2 -1
- data/ext/chunky_projects/extconf.rb +1 -1
- data/ext/chunky_projects/src/lib.rs +10 -5
- data/lib/chunky_projects/error.rb +7 -0
- data/lib/chunky_projects/public.rb +12 -0
- data/lib/chunky_projects/version.rb +1 -1
- data/lib/chunky_projects.rb +10 -4
- metadata +3 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
[package]
|
2
|
-
name = "
|
2
|
+
name = "internal"
|
3
3
|
version = "0.0.0"
|
4
4
|
edition = "2021"
|
5
5
|
authors = ["Zach Ahn <engineering@zachahn.com>"]
|
@@ -11,3 +11,4 @@ crate-type = ["cdylib"]
|
|
11
11
|
|
12
12
|
[dependencies]
|
13
13
|
magnus = { version = "0.6.2" }
|
14
|
+
rustextile = "1"
|
@@ -1,12 +1,17 @@
|
|
1
|
-
use magnus::{function, prelude::*, Error, Ruby};
|
1
|
+
use magnus::{class, function, prelude::*, Error, Ruby};
|
2
|
+
use rustextile::{HtmlKind, Textile};
|
2
3
|
|
3
|
-
fn
|
4
|
-
|
4
|
+
fn to_html(textile: String) -> String {
|
5
|
+
let parser = Textile::default().set_html_kind(HtmlKind::HTML5);
|
6
|
+
let html = parser.parse(textile.as_str());
|
7
|
+
|
8
|
+
return html;
|
5
9
|
}
|
6
10
|
|
7
11
|
#[magnus::init]
|
8
12
|
fn init(ruby: &Ruby) -> Result<(), Error> {
|
9
|
-
let
|
10
|
-
|
13
|
+
let namespace = ruby.define_module("ChunkyProjects")?;
|
14
|
+
let internal = namespace.define_class("Internal", class::object())?;
|
15
|
+
internal.define_singleton_method("to_html", function!(to_html, 1))?;
|
11
16
|
Ok(())
|
12
17
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ChunkyProjects
|
2
|
+
def self.to_html(textile)
|
3
|
+
if textile.encoding.name != "UTF-8"
|
4
|
+
raise ChunkyProjects::EncodingError, "Textile encoding must be UTF-8"
|
5
|
+
end
|
6
|
+
if !textile.valid_encoding?
|
7
|
+
raise ChunkyProjects::EncodingError, "Textile encoding must be valid UTF-8"
|
8
|
+
end
|
9
|
+
|
10
|
+
Internal.to_html(textile)
|
11
|
+
end
|
12
|
+
end
|
data/lib/chunky_projects.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module ChunkyProjects
|
4
|
+
end
|
5
|
+
|
6
|
+
require_relative "chunky_projects/error"
|
3
7
|
require_relative "chunky_projects/version"
|
4
|
-
require_relative "chunky_projects/
|
8
|
+
require_relative "chunky_projects/public"
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
begin
|
11
|
+
ruby_version = RUBY_VERSION[/^\d+\.\d+/]
|
12
|
+
require_relative "chunky_projects/#{ruby_version}/internal"
|
13
|
+
rescue LoadError
|
14
|
+
require "chunky_projects/internal"
|
9
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chunky_projects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Ahn
|
@@ -25,6 +25,8 @@ files:
|
|
25
25
|
- ext/chunky_projects/extconf.rb
|
26
26
|
- ext/chunky_projects/src/lib.rs
|
27
27
|
- lib/chunky_projects.rb
|
28
|
+
- lib/chunky_projects/error.rb
|
29
|
+
- lib/chunky_projects/public.rb
|
28
30
|
- lib/chunky_projects/version.rb
|
29
31
|
homepage: https://github.com/zachahn/chunky_projects
|
30
32
|
licenses:
|