selma 0.0.7-x86_64-darwin → 0.1.0-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c33b48a18adeaa939bca2bc674c8337bc77a82cee7b70fdf97852550769c9a2
4
- data.tar.gz: 8cc95c08378813afe5e7d4f0be6749e7092858676324f6ec4a20ade3546c19a4
3
+ metadata.gz: c15121f043689705a08e614e162664dc6585995805146ad1f19d70d01c0fbc7b
4
+ data.tar.gz: e2ec76537eb841d4d6d2c197861a7b130b154790e46ffbdb93347a3c17abfef5
5
5
  SHA512:
6
- metadata.gz: d2c10fb6a52dc5628bffb044664f4009f159c8929168988d3e46b30becdef33ea6e2600a0682ce3161941fb2e58ddb0b0b991b8dd78c2de17eefd499ccc28184
7
- data.tar.gz: da2d1092c87a3a0b2c4df4546ad917d8eec015b55e77d8fd67a6a813b09b364b49784ab213c14bb63f233631af7aee148075ca3c6896ddf76c4fdb119db95c4a
6
+ metadata.gz: 2a30cbd05781873c259991563c319d3e58cccd42dca93366394ff83e37e723bca270bc8bce1e3106dab5a7cb451a56d640c0c54f2821782fb5940a03b4868cd1
7
+ data.tar.gz: e30b53fe6ec347bf033a855014e524ac534c5832e5046a8264989175c835529936fe1c3e052d313dc03ac065f07834f650a803819ab905230aa7d212bfd61d76
data/README.md CHANGED
@@ -29,7 +29,7 @@ Selma can perform two different actions, either independently or together:
29
29
  - Sanitize HTML, through a [Sanitize](https://github.com/rgrove/sanitize)-like allowlist syntax; and
30
30
  - Select HTML using CSS rules, and manipulate elements and text nodes along the way.
31
31
 
32
- It does this through two kwargsL `sanitizer` and `handlers`. The basic API for Selma looks like this:
32
+ It does this through two kwargs: `sanitizer` and `handlers`. The basic API for Selma looks like this:
33
33
 
34
34
  ```ruby
35
35
  sanitizer_config = {
Binary file
Binary file
data/lib/selma/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Selma
4
- VERSION = "0.0.7"
4
+ VERSION = "0.1.0"
5
5
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-09 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rb_sys
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.9'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.9'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +38,6 @@ dependencies:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
40
  version: '1.2'
55
- - !ruby/object:Gem::Dependency
56
- name: rake-compiler-dock
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.2'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.2'
69
41
  description:
70
42
  email:
71
43
  - gjtorikian@gmail.com
@@ -75,20 +47,6 @@ extra_rdoc_files: []
75
47
  files:
76
48
  - LICENSE.txt
77
49
  - README.md
78
- - ext/selma/Cargo.toml
79
- - ext/selma/_util.rb
80
- - ext/selma/extconf.rb
81
- - ext/selma/src/html.rs
82
- - ext/selma/src/html/element.rs
83
- - ext/selma/src/html/end_tag.rs
84
- - ext/selma/src/html/text_chunk.rs
85
- - ext/selma/src/lib.rs
86
- - ext/selma/src/native_ref_wrap.rs
87
- - ext/selma/src/rewriter.rs
88
- - ext/selma/src/sanitizer.rs
89
- - ext/selma/src/selector.rs
90
- - ext/selma/src/tags.rs
91
- - ext/selma/src/wrapped_struct.rs
92
50
  - lib/selma.rb
93
51
  - lib/selma/3.1/selma.bundle
94
52
  - lib/selma/3.2/selma.bundle
@@ -103,7 +61,6 @@ files:
103
61
  - lib/selma/sanitizer/config/restricted.rb
104
62
  - lib/selma/selector.rb
105
63
  - lib/selma/version.rb
106
- - selma.gemspec
107
64
  homepage:
108
65
  licenses:
109
66
  - MIT
@@ -130,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
87
  - !ruby/object:Gem::Version
131
88
  version: 3.3.22
132
89
  requirements: []
133
- rubygems_version: 3.4.3
90
+ rubygems_version: 3.4.4
134
91
  signing_key:
135
92
  specification_version: 4
136
93
  summary: Selma selects and matches HTML nodes using CSS rules. Backed by Rust's lol_html
data/ext/selma/Cargo.toml DELETED
@@ -1,14 +0,0 @@
1
- [package]
2
- name = "selma"
3
- version = "1.0.0"
4
- edition = "2021"
5
-
6
- [dependencies]
7
- enum-iterator = "1.2"
8
- escapist = "0.0.2"
9
- magnus = { git = "https://github.com/matsadler/magnus", rev = "23160f7229ac74c42da1b5096a65ccbc40962697" }
10
- lol_html = "0.3"
11
-
12
- [lib]
13
- name = "selma"
14
- crate-type = ["cdylib"]
data/ext/selma/_util.rb DELETED
@@ -1,102 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RUBY_MAJOR, RUBY_MINOR = RUBY_VERSION.split(".").collect(&:to_i)
4
-
5
- PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
6
- PACKAGE_EXT_DIR = File.join(PACKAGE_ROOT_DIR, "ext", "selma")
7
-
8
- OS = case os = RbConfig::CONFIG["host_os"].downcase
9
- when /linux/
10
- # The official ruby-alpine Docker containers pre-build Ruby. As a result,
11
- # Ruby doesn't know that it's on a musl-based platform. `ldd` is the
12
- # a more reliable way to detect musl.
13
- # See https://github.com/skylightio/skylight-ruby/issues/92
14
- if ENV["SKYLIGHT_MUSL"] || %x(ldd --version 2>&1).include?("musl")
15
- "linux-musl"
16
- else
17
- "linux"
18
- end
19
- when /darwin/
20
- "darwin"
21
- when /freebsd/
22
- "freebsd"
23
- when /netbsd/
24
- "netbsd"
25
- when /openbsd/
26
- "openbsd"
27
- when /sunos|solaris/
28
- "solaris"
29
- when /mingw|mswin/
30
- "windows"
31
- else
32
- os
33
- end
34
-
35
- # Normalize the platform CPU
36
- ARCH = case cpu = RbConfig::CONFIG["host_cpu"].downcase
37
- when /amd64|x86_64|x64/
38
- "x86_64"
39
- when /i?86|x86|i86pc/
40
- "x86"
41
- when /ppc|powerpc/
42
- "powerpc"
43
- when /^aarch/
44
- "aarch"
45
- when /^arm/
46
- "arm"
47
- else
48
- cpu
49
- end
50
-
51
- def windows?
52
- OS == "windows"
53
- end
54
-
55
- def solaris?
56
- OS == solaries
57
- end
58
-
59
- def darwin?
60
- OS == "darwin"
61
- end
62
-
63
- def macos?
64
- darwin? || OS == "macos"
65
- end
66
-
67
- def openbsd?
68
- OS == "openbsd"
69
- end
70
-
71
- def aix?
72
- OS == "aix"
73
- end
74
-
75
- def nix?
76
- !(windows? || solaris? || darwin?)
77
- end
78
-
79
- def x86_64?
80
- ARCH == "x86_64"
81
- end
82
-
83
- def x86?
84
- ARCH == "x86"
85
- end
86
-
87
- def abs_path(path)
88
- File.join(PACKAGE_EXT_DIR, path)
89
- end
90
-
91
- def find_header_or_abort(header, *paths)
92
- find_header(header, *paths) || abort("#{header} was expected in `#{paths.join(", ")}`, but it is missing.")
93
- end
94
-
95
- def find_library_or_abort(lib, func, *paths)
96
- find_library(lib, func, *paths) || abort("#{lib} was expected in `#{paths.join(", ")}`, but it is missing.")
97
- end
98
-
99
- def concat_flags(*args)
100
- args.compact.join(" ")
101
- end
102
-
data/ext/selma/extconf.rb DELETED
@@ -1,6 +0,0 @@
1
- require "mkmf"
2
- require "rb_sys/mkmf"
3
-
4
- require_relative "_util"
5
-
6
- create_rust_makefile("selma/selma")
@@ -1,254 +0,0 @@
1
- use crate::native_ref_wrap::NativeRefWrap;
2
- use lol_html::html_content::Element;
3
- use magnus::{exception, method, Error, Module, RArray, RClass, RHash, RString, Value};
4
-
5
- struct HTMLElement {
6
- element: NativeRefWrap<Element<'static, 'static>>,
7
- ancestors: Vec<String>,
8
- }
9
-
10
- #[magnus::wrap(class = "Selma::HTML::Element")]
11
- pub struct SelmaHTMLElement(std::cell::RefCell<HTMLElement>);
12
-
13
- /// SAFETY: This is safe because we only access this data when the GVL is held.
14
- unsafe impl Send for SelmaHTMLElement {}
15
-
16
- impl SelmaHTMLElement {
17
- pub fn new(element: &mut Element, ancestors: &[String]) -> Self {
18
- let (ref_wrap, _anchor) = NativeRefWrap::wrap_mut(element);
19
-
20
- Self(std::cell::RefCell::new(HTMLElement {
21
- element: ref_wrap,
22
- ancestors: ancestors.to_owned(),
23
- }))
24
- }
25
-
26
- fn tag_name(&self) -> Result<String, Error> {
27
- let binding = self.0.borrow();
28
-
29
- if let Ok(e) = binding.element.get() {
30
- Ok(e.tag_name())
31
- } else {
32
- Err(Error::new(
33
- exception::runtime_error(),
34
- "`tag_name` is not available",
35
- ))
36
- }
37
- }
38
-
39
- fn set_tag_name(&self, name: String) -> Result<(), Error> {
40
- let mut binding = self.0.borrow_mut();
41
-
42
- if let Ok(element) = binding.element.get_mut() {
43
- match element.set_tag_name(&name) {
44
- Ok(_) => Ok(()),
45
- Err(err) => Err(Error::new(exception::runtime_error(), format!("{err:?}"))),
46
- }
47
- } else {
48
- Err(Error::new(
49
- exception::runtime_error(),
50
- "`set_tag_name` is not available",
51
- ))
52
- }
53
- }
54
-
55
- fn is_self_closing(&self) -> Result<bool, Error> {
56
- let binding = self.0.borrow();
57
-
58
- if let Ok(e) = binding.element.get() {
59
- Ok(e.is_self_closing())
60
- } else {
61
- Err(Error::new(
62
- exception::runtime_error(),
63
- "`is_self_closing` is not available",
64
- ))
65
- }
66
- }
67
-
68
- fn has_attribute(&self, attr: String) -> Result<bool, Error> {
69
- let binding = self.0.borrow();
70
-
71
- if let Ok(e) = binding.element.get() {
72
- Ok(e.has_attribute(&attr))
73
- } else {
74
- Err(Error::new(
75
- exception::runtime_error(),
76
- "`is_self_closing` is not available",
77
- ))
78
- }
79
- }
80
-
81
- fn get_attribute(&self, attr: String) -> Option<String> {
82
- let binding = self.0.borrow();
83
- let element = binding.element.get();
84
- element.unwrap().get_attribute(&attr)
85
- }
86
-
87
- fn set_attribute(&self, attr: String, value: String) -> Result<String, Error> {
88
- let mut binding = self.0.borrow_mut();
89
- if let Ok(element) = binding.element.get_mut() {
90
- match element.set_attribute(&attr, &value) {
91
- Ok(_) => Ok(value),
92
- Err(err) => Err(Error::new(
93
- exception::runtime_error(),
94
- format!("AttributeNameError: {err:?}"),
95
- )),
96
- }
97
- } else {
98
- Err(Error::new(
99
- exception::runtime_error(),
100
- "`tag_name` is not available",
101
- ))
102
- }
103
- }
104
-
105
- fn remove_attribute(&self, attr: String) {
106
- let mut binding = self.0.borrow_mut();
107
-
108
- if let Ok(e) = binding.element.get_mut() {
109
- e.remove_attribute(&attr)
110
- }
111
- }
112
-
113
- fn get_attributes(&self) -> Result<RHash, Error> {
114
- let binding = self.0.borrow();
115
- let hash = RHash::new();
116
-
117
- if let Ok(e) = binding.element.get() {
118
- e.attributes()
119
- .iter()
120
- .for_each(|attr| match hash.aset(attr.name(), attr.value()) {
121
- Ok(_) => {}
122
- Err(err) => Err(Error::new(
123
- exception::runtime_error(),
124
- format!("AttributeNameError: {err:?}"),
125
- ))
126
- .unwrap(),
127
- });
128
- }
129
- Ok(hash)
130
- }
131
-
132
- fn get_ancestors(&self) -> Result<RArray, Error> {
133
- let binding = self.0.borrow();
134
- let array = RArray::new();
135
-
136
- binding
137
- .ancestors
138
- .iter()
139
- .for_each(|ancestor| match array.push(RString::new(ancestor)) {
140
- Ok(_) => {}
141
- Err(err) => {
142
- Err(Error::new(exception::runtime_error(), format!("{err:?}"))).unwrap()
143
- }
144
- });
145
-
146
- Ok(array)
147
- }
148
-
149
- fn before(&self, args: &[Value]) -> Result<(), Error> {
150
- let mut binding = self.0.borrow_mut();
151
- let element = binding.element.get_mut().unwrap();
152
-
153
- let (text_str, content_type) = match crate::scan_text_args(args) {
154
- Ok((text_str, content_type)) => (text_str, content_type),
155
- Err(err) => return Err(err),
156
- };
157
-
158
- element.before(&text_str, content_type);
159
-
160
- Ok(())
161
- }
162
-
163
- fn after(&self, args: &[Value]) -> Result<(), Error> {
164
- let mut binding = self.0.borrow_mut();
165
- let element = binding.element.get_mut().unwrap();
166
-
167
- let (text_str, content_type) = match crate::scan_text_args(args) {
168
- Ok((text_str, content_type)) => (text_str, content_type),
169
- Err(err) => return Err(err),
170
- };
171
-
172
- element.after(&text_str, content_type);
173
-
174
- Ok(())
175
- }
176
-
177
- fn prepend(&self, args: &[Value]) -> Result<(), Error> {
178
- let mut binding = self.0.borrow_mut();
179
- let element = binding.element.get_mut().unwrap();
180
-
181
- let (text_str, content_type) = match crate::scan_text_args(args) {
182
- Ok((text_str, content_type)) => (text_str, content_type),
183
- Err(err) => return Err(err),
184
- };
185
-
186
- element.prepend(&text_str, content_type);
187
-
188
- Ok(())
189
- }
190
-
191
- fn append(&self, args: &[Value]) -> Result<(), Error> {
192
- let mut binding = self.0.borrow_mut();
193
- let element = binding.element.get_mut().unwrap();
194
-
195
- let (text_str, content_type) = match crate::scan_text_args(args) {
196
- Ok((text_str, content_type)) => (text_str, content_type),
197
- Err(err) => return Err(err),
198
- };
199
-
200
- element.append(&text_str, content_type);
201
-
202
- Ok(())
203
- }
204
-
205
- fn set_inner_content(&self, args: &[Value]) -> Result<(), Error> {
206
- let mut binding = self.0.borrow_mut();
207
- let element = binding.element.get_mut().unwrap();
208
-
209
- let (inner_content, content_type) = match crate::scan_text_args(args) {
210
- Ok((inner_content, content_type)) => (inner_content, content_type),
211
- Err(err) => return Err(err),
212
- };
213
-
214
- element.set_inner_content(&inner_content, content_type);
215
-
216
- Ok(())
217
- }
218
- }
219
-
220
- pub fn init(c_html: RClass) -> Result<(), Error> {
221
- let c_element = c_html
222
- .define_class("Element", Default::default())
223
- .expect("cannot find class Selma::HTML::Element");
224
-
225
- c_element.define_method("tag_name", method!(SelmaHTMLElement::tag_name, 0))?;
226
- c_element.define_method("tag_name=", method!(SelmaHTMLElement::set_tag_name, 1))?;
227
- c_element.define_method(
228
- "self_closing?",
229
- method!(SelmaHTMLElement::is_self_closing, 0),
230
- )?;
231
- c_element.define_method("[]", method!(SelmaHTMLElement::get_attribute, 1))?;
232
- c_element.define_method("[]=", method!(SelmaHTMLElement::set_attribute, 2))?;
233
- c_element.define_method(
234
- "remove_attribute",
235
- method!(SelmaHTMLElement::remove_attribute, 1),
236
- )?;
237
- c_element.define_method(
238
- "has_attribute?",
239
- method!(SelmaHTMLElement::has_attribute, 1),
240
- )?;
241
- c_element.define_method("attributes", method!(SelmaHTMLElement::get_attributes, 0))?;
242
- c_element.define_method("ancestors", method!(SelmaHTMLElement::get_ancestors, 0))?;
243
-
244
- c_element.define_method("before", method!(SelmaHTMLElement::before, -1))?;
245
- c_element.define_method("after", method!(SelmaHTMLElement::after, -1))?;
246
- c_element.define_method("prepend", method!(SelmaHTMLElement::prepend, -1))?;
247
- c_element.define_method("append", method!(SelmaHTMLElement::append, -1))?;
248
- c_element.define_method(
249
- "set_inner_content",
250
- method!(SelmaHTMLElement::set_inner_content, -1),
251
- )?;
252
-
253
- Ok(())
254
- }
@@ -1,35 +0,0 @@
1
- use crate::native_ref_wrap::NativeRefWrap;
2
- use lol_html::html_content::EndTag;
3
- use magnus::{method, Error, Module, RClass};
4
-
5
- struct HTMLEndTag {
6
- end_tag: NativeRefWrap<EndTag<'static>>,
7
- }
8
-
9
- #[magnus::wrap(class = "Selma::HTML::EndTag")]
10
- pub struct SelmaHTMLEndTag(std::cell::RefCell<HTMLEndTag>);
11
-
12
- /// SAFETY: This is safe because we only access this data when the GVL is held.
13
- unsafe impl Send for SelmaHTMLEndTag {}
14
-
15
- impl SelmaHTMLEndTag {
16
- pub fn new(end_tag: &mut EndTag) -> Self {
17
- let (ref_wrap, _anchor) = NativeRefWrap::wrap(end_tag);
18
-
19
- Self(std::cell::RefCell::new(HTMLEndTag { end_tag: ref_wrap }))
20
- }
21
-
22
- fn tag_name(&self) -> String {
23
- self.0.borrow().end_tag.get().unwrap().name()
24
- }
25
- }
26
-
27
- pub fn init(c_html: RClass) -> Result<(), Error> {
28
- let c_end_tag = c_html
29
- .define_class("EndTag", Default::default())
30
- .expect("cannot find class Selma::HTML::EndTag");
31
-
32
- c_end_tag.define_method("tag_name", method!(SelmaHTMLEndTag::tag_name, 0))?;
33
-
34
- Ok(())
35
- }
@@ -1,113 +0,0 @@
1
- use crate::native_ref_wrap::NativeRefWrap;
2
- use lol_html::html_content::{TextChunk, TextType};
3
- use magnus::{exception, method, Error, Module, RClass, Symbol, Value};
4
-
5
- struct HTMLTextChunk {
6
- text_chunk: NativeRefWrap<TextChunk<'static>>,
7
- }
8
-
9
- #[magnus::wrap(class = "Selma::HTML::TextChunk")]
10
- pub struct SelmaHTMLTextChunk(std::cell::RefCell<HTMLTextChunk>);
11
-
12
- /// SAFETY: This is safe because we only access this data when the GVL is held.
13
- unsafe impl Send for SelmaHTMLTextChunk {}
14
-
15
- impl SelmaHTMLTextChunk {
16
- pub fn new(text_chunk: &mut TextChunk) -> Self {
17
- let (ref_wrap, _anchor) = NativeRefWrap::wrap_mut(text_chunk);
18
-
19
- Self(std::cell::RefCell::new(HTMLTextChunk {
20
- text_chunk: ref_wrap,
21
- }))
22
- }
23
-
24
- fn to_s(&self) -> Result<String, Error> {
25
- let binding = self.0.borrow();
26
-
27
- if let Ok(tc) = binding.text_chunk.get() {
28
- Ok(tc.as_str().to_string())
29
- } else {
30
- Err(Error::new(
31
- exception::runtime_error(),
32
- "`to_s` is not available",
33
- ))
34
- }
35
- }
36
-
37
- fn text_type(&self) -> Result<Symbol, Error> {
38
- let binding = self.0.borrow();
39
-
40
- if let Ok(tc) = binding.text_chunk.get() {
41
- match tc.text_type() {
42
- TextType::Data => Ok(Symbol::from("data")),
43
- TextType::PlainText => Ok(Symbol::from("plain_text")),
44
- TextType::RawText => Ok(Symbol::from("raw_text")),
45
- TextType::ScriptData => Ok(Symbol::from("script")),
46
- TextType::RCData => Ok(Symbol::from("rc_data")),
47
- TextType::CDataSection => Ok(Symbol::from("cdata_section")),
48
- }
49
- } else {
50
- Err(Error::new(
51
- exception::runtime_error(),
52
- "`text_type` is not available",
53
- ))
54
- }
55
- }
56
-
57
- fn before(&self, args: &[Value]) -> Result<(), Error> {
58
- let mut binding = self.0.borrow_mut();
59
- let text_chunk = binding.text_chunk.get_mut().unwrap();
60
-
61
- let (text_str, content_type) = match crate::scan_text_args(args) {
62
- Ok((text_str, content_type)) => (text_str, content_type),
63
- Err(err) => return Err(err),
64
- };
65
-
66
- text_chunk.before(&text_str, content_type);
67
-
68
- Ok(())
69
- }
70
-
71
- fn after(&self, args: &[Value]) -> Result<(), Error> {
72
- let mut binding = self.0.borrow_mut();
73
- let text_chunk = binding.text_chunk.get_mut().unwrap();
74
-
75
- let (text_str, content_type) = match crate::scan_text_args(args) {
76
- Ok((text_str, content_type)) => (text_str, content_type),
77
- Err(err) => return Err(err),
78
- };
79
-
80
- text_chunk.after(&text_str, content_type);
81
-
82
- Ok(())
83
- }
84
-
85
- fn replace(&self, args: &[Value]) -> Result<(), Error> {
86
- let mut binding = self.0.borrow_mut();
87
- let text_chunk = binding.text_chunk.get_mut().unwrap();
88
-
89
- let (text_str, content_type) = match crate::scan_text_args(args) {
90
- Ok((text_str, content_type)) => (text_str, content_type),
91
- Err(err) => return Err(err),
92
- };
93
-
94
- text_chunk.replace(&text_str, content_type);
95
-
96
- Ok(())
97
- }
98
- }
99
-
100
- pub fn init(c_html: RClass) -> Result<(), Error> {
101
- let c_text_chunk = c_html
102
- .define_class("TextChunk", Default::default())
103
- .expect("cannot find class Selma::HTML::TextChunk");
104
-
105
- c_text_chunk.define_method("to_s", method!(SelmaHTMLTextChunk::to_s, 0))?;
106
- c_text_chunk.define_method("content", method!(SelmaHTMLTextChunk::to_s, 0))?;
107
- c_text_chunk.define_method("text_type", method!(SelmaHTMLTextChunk::text_type, 0))?;
108
- c_text_chunk.define_method("before", method!(SelmaHTMLTextChunk::before, -1))?;
109
- c_text_chunk.define_method("after", method!(SelmaHTMLTextChunk::after, -1))?;
110
- c_text_chunk.define_method("replace", method!(SelmaHTMLTextChunk::replace, -1))?;
111
-
112
- Ok(())
113
- }
@@ -1,19 +0,0 @@
1
- use magnus::{Error, Module, RModule};
2
-
3
- #[derive(Clone, Debug)]
4
- #[magnus::wrap(class = "Selma::HTML")]
5
- pub(crate) struct SelmaHTML {}
6
-
7
- pub fn init(m_selma: RModule) -> Result<(), Error> {
8
- let c_html = m_selma.define_class("HTML", Default::default()).unwrap();
9
-
10
- element::init(c_html).expect("cannot define Selma::HTML::Element class");
11
- end_tag::init(c_html).expect("cannot define Selma::HTML::EndTag class");
12
- text_chunk::init(c_html).expect("cannot define Selma::HTML::TextChunk class");
13
-
14
- Ok(())
15
- }
16
-
17
- pub mod element;
18
- pub mod end_tag;
19
- pub mod text_chunk;