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.
@@ -1,92 +0,0 @@
1
- use magnus::{error::Error, exception, gc, value::Value, RTypedData, TryConvert, TypedData};
2
- use std::{marker::PhantomData, ops::Deref};
3
-
4
- // NOTE: My Rust isn't good enough to know what any of this does,
5
- // but it was taken from https://cs.github.com/bytecodealliance/wasmtime-rb/blob/a843e4b4582a945f2c881b8bd3e2b87688ab5509/ext/src/helpers/wrapped_struct.rs#L4
6
-
7
- /// A small wrapper for `RTypedData` that keeps track of the concrete struct
8
- /// type, and the underlying [`Value`] for GC purposes.
9
- #[derive(Debug)]
10
- #[repr(transparent)]
11
- pub struct WrappedStruct<T: TypedData> {
12
- inner: RTypedData,
13
- phantom: PhantomData<T>,
14
- }
15
-
16
- impl<T: TypedData> Clone for WrappedStruct<T> {
17
- fn clone(&self) -> Self {
18
- Self {
19
- inner: self.inner,
20
- phantom: PhantomData,
21
- }
22
- }
23
- }
24
- impl<T: TypedData> Copy for WrappedStruct<T> {}
25
-
26
- impl<T: TypedData> WrappedStruct<T> {
27
- /// Gets the underlying struct.
28
- pub fn get(&self) -> Result<&T, Error> {
29
- self.inner.try_convert()
30
- }
31
-
32
- /// Gets the underlying struct with a `'static` lifetime.
33
- pub fn get_static(&self) -> Result<&'static T, Error> {
34
- self.inner.try_convert()
35
- }
36
-
37
- /// Get the Ruby [`Value`] for this struct.
38
- pub fn to_value(self) -> Value {
39
- self.inner.into()
40
- }
41
-
42
- /// Marks the Ruby [`Value`] for GC.
43
- pub fn mark(&self) {
44
- gc::mark(&self.inner.into());
45
- }
46
- }
47
-
48
- impl<T: TypedData> From<WrappedStruct<T>> for Value {
49
- fn from(wrapped_struct: WrappedStruct<T>) -> Self {
50
- wrapped_struct.to_value()
51
- }
52
- }
53
-
54
- impl<T: TypedData> Deref for WrappedStruct<T> {
55
- type Target = RTypedData;
56
-
57
- fn deref(&self) -> &Self::Target {
58
- &self.inner
59
- }
60
- }
61
-
62
- impl<T: TypedData> From<T> for WrappedStruct<T> {
63
- fn from(t: T) -> Self {
64
- Self {
65
- inner: RTypedData::wrap(t),
66
- phantom: PhantomData,
67
- }
68
- }
69
- }
70
-
71
- impl<T> TryConvert for WrappedStruct<T>
72
- where
73
- T: TypedData,
74
- {
75
- fn try_convert(val: Value) -> Result<Self, Error> {
76
- let inner = RTypedData::from_value(val).ok_or_else(|| {
77
- Error::new(
78
- exception::type_error(),
79
- format!(
80
- "no implicit conversion of {} into {}",
81
- unsafe { val.classname() },
82
- T::class()
83
- ),
84
- )
85
- })?;
86
-
87
- Ok(Self {
88
- inner,
89
- phantom: PhantomData,
90
- })
91
- }
92
- }
data/selma.gemspec DELETED
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "selma/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "selma"
9
- spec.version = Selma::VERSION
10
- spec.authors = ["Garen J. Torikian"]
11
- spec.email = ["gjtorikian@gmail.com"]
12
-
13
- spec.summary = "Selma selects and matches HTML nodes using CSS rules. Backed by Rust's lol_html parser."
14
- spec.license = "MIT"
15
-
16
- spec.required_ruby_version = "~> 3.1"
17
- # https://github.com/rubygems/rubygems/pull/5852#issuecomment-1231118509
18
- spec.required_rubygems_version = ">= 3.3.22"
19
-
20
- spec.files = ["LICENSE.txt", "README.md", "selma.gemspec"]
21
- spec.files += Dir.glob("lib/**/*.rb")
22
- spec.files += Dir.glob("ext/**/*.{rs,toml,lock,rb}")
23
- spec.bindir = "exe"
24
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
-
26
- spec.require_paths = ["lib"]
27
- spec.extensions = ["ext/selma/extconf.rb"]
28
-
29
- spec.metadata = {
30
- "allowed_push_host" => "https://rubygems.org",
31
- "funding_uri" => "https://github.com/sponsors/gjtorikian/",
32
- "source_code_uri" => "https://github.com/gjtorikian/selma",
33
- "rubygems_mfa_required" => "true",
34
- }
35
-
36
- spec.add_dependency("rb_sys", "~> 0.9")
37
-
38
- spec.add_development_dependency("rake", "~> 13.0")
39
- spec.add_development_dependency("rake-compiler", "~> 1.2")
40
- spec.add_development_dependency("rake-compiler-dock", "~> 1.2")
41
- end