yass-css 0.2.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cfdea80822b1a34f32b6275cbf273f27fa5480d7351973871a0b66135ce07fa
4
- data.tar.gz: c1e0b94b72410f8f9b5794be113f7c6f18842c8a73774c5807a9a1d25de32bee
3
+ metadata.gz: 964454f0c8bdcfd25f640bff134b466d111d77762345707e7c75c778a5edf224
4
+ data.tar.gz: be5c8bad69e40f961b554a65bd9faad47bde6c190bbb966ac3d2af8118981341
5
5
  SHA512:
6
- metadata.gz: 1d8a76d695194c0d501608d2118274c34274a78ad0841c279591520435683597c989029b9dfa0487c8d4f31c3e734c74b2b271c933ddaff2570944b9fac96179
7
- data.tar.gz: 85e27a49582a8be423ba87568797c0a832bdc68b410d695b840ab10a7e5ce7a028155356074f764818bffff05fc85ad9a4f2eea5086017024a1298c24397ffc1
6
+ metadata.gz: 90de862ea2b3691488983d8bfe765c40a10df87d3598b336385293e055599558b1fb6d344b90eb70270fcdfa8c6438fee44011e3b60be48ba32ad72350da2fe3
7
+ data.tar.gz: 1a466ea66b1012163c8da76c31b0c46b660ce1f51997af8324dd86c87ce3f1f66220f744fcdd61063a61d950766508f926a4bfbaa7900767ed6649a66f719bb9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2026-04-20
4
+
5
+ - Support nested rules.
6
+
7
+ ## [0.3.0] - 2026-04-19
8
+
9
+ - Upgrade to rb_sys v0.9.126.
10
+
3
11
  ## [0.2.0] - 2026-04-19
4
12
 
5
13
  - Fully support all style declarations.
data/Cargo.lock CHANGED
@@ -1357,7 +1357,7 @@ checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
1357
1357
 
1358
1358
  [[package]]
1359
1359
  name = "yass"
1360
- version = "0.2.0"
1360
+ version = "0.4.0"
1361
1361
  dependencies = [
1362
1362
  "cssparser",
1363
1363
  "magnus",
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Yass
2
2
 
3
+ Yass: Yet Another Stylesheet System
4
+
3
5
  Yass is a Ruby wrapper around the [Stylo](https://github.com/servo/stylo) CSS engine, the parser behind the Firefox and Servo browsers developed by Mozilla.
4
6
 
5
7
  ## Rationale
data/RELEASING.md ADDED
@@ -0,0 +1,15 @@
1
+ # Releasing Yass
2
+
3
+ Follow these steps to release a new version of Yass:
4
+
5
+ 1. Bump the version in lib/yass/version.rb.
6
+ 2. Bump the version in ext/yass/Cargo.toml (should be the same version from step 1).
7
+ 3. Add a heading in CHANGELOG.md with the version number and today's date.
8
+ 4. Run `bundle install` and `bundle exec rake compile` to refresh the Bundler and Cargo lockfiles.
9
+ 5. Commit the results of these changes and push them to GitHub.
10
+ 6. Wait for CI to run. This might seem unimportant but weird things can go wrong with lockfiles, etc, so it's best to wait for a clean bill of health before continuing.
11
+ 7. Create a release in the GitHub UI [here](https://github.com/camertron/yass/releases/new).
12
+ 1. Create a new tag for the release of the form vX.X.X, using the same version number you've been using this whole time.
13
+ 2. Name the release the same thing, i.e. vX.X.X.
14
+ 3. Copy the relevant section from CHANGELOG.md (including the header) and paste it into the release notes.
15
+ 8. This will kick off the GitHub action in .github/workflows/release.yml, build the native extension for all the supported ruby versions and platforms, and publish the various .gem files to rubygems.org.
data/Rakefile CHANGED
@@ -7,8 +7,6 @@ RSpec::Core::RakeTask.new(:spec)
7
7
 
8
8
  require "rb_sys/extensiontask"
9
9
 
10
- # task build: :compile
11
-
12
10
  GEMSPEC = Gem::Specification.load("yass.gemspec")
13
11
 
14
12
  RbSys::ExtensionTask.new("yass", GEMSPEC) do |ext|
data/ext/yass/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "yass"
3
- version = "0.2.0"
3
+ version = "0.4.0"
4
4
  edition = "2021"
5
5
  authors = ["Cameron Dutro <camertron@gmail.com>"]
6
6
  license = "MIT"
@@ -8,6 +8,7 @@ pub fn init(ruby: &Ruby, yass_module: &RModule) -> Result<(), Error> {
8
8
  let style_rule_class = yass_module.define_class("StyleRule", rule_class)?;
9
9
  style_rule_class.define_method("selectors", method!(YStyleRule::selectors, 0))?;
10
10
  style_rule_class.define_method("declarations", method!(YStyleRule::declarations, 0))?;
11
+ style_rule_class.define_method("rules", method!(YStyleRule::rules, 0))?;
11
12
  style_rule_class.define_method("source_location", method!(YStyleRule::source_location, 0))?;
12
13
 
13
14
  let media_rule_class = yass_module.define_class("MediaRule", rule_class)?;
@@ -1,9 +1,9 @@
1
1
  use cssparser::SourceLocation;
2
2
  use magnus::{DataTypeFunctions, Error, IntoValue, RArray, Ruby, TypedData, Value, gc, typed_data};
3
3
  use selectors::parser::Selector;
4
- use style::{properties::PropertyDeclaration, selector_parser::SelectorImpl, servo_arc::Arc, shared_lock::{Locked, SharedRwLock}, stylesheets::StyleRule};
4
+ use style::{properties::PropertyDeclaration, selector_parser::SelectorImpl, servo_arc::Arc, shared_lock::{Locked, SharedRwLock}, stylesheets::{CssRule, StyleRule}};
5
5
 
6
- use crate::{cached_value::CachedValue, cached_value_list::CachedValueList, declarations::declaration::YDeclaration, general::YSourceLocation, selectors::YSelector};
6
+ use crate::{cached_value::CachedValue, cached_value_list::CachedValueList, declarations::declaration::YDeclaration, general::YSourceLocation, rules::rule::make_rule, selectors::YSelector};
7
7
 
8
8
  #[derive(TypedData)]
9
9
  #[magnus(class = "Yass::StyleRule", mark)]
@@ -12,14 +12,15 @@ pub struct YStyleRule {
12
12
  lock: SharedRwLock,
13
13
  selectors: CachedValueList<Selector<SelectorImpl>>,
14
14
  declarations: CachedValueList<PropertyDeclaration>,
15
- source_location: CachedValue<SourceLocation>
15
+ source_location: CachedValue<SourceLocation>,
16
+ rules: CachedValueList<CssRule, SharedRwLock>,
16
17
  }
17
18
 
18
19
  impl YStyleRule {
19
20
  pub fn new(rule: Arc<Locked<StyleRule>>, lock: SharedRwLock) -> Self {
20
21
  YStyleRule {
21
22
  rule,
22
- lock,
23
+ lock: lock.clone(),
23
24
 
24
25
  selectors: CachedValueList::empty(None, |selector, _ctx, ruby| {
25
26
  YSelector::new(selector.clone()).into_value_with(ruby)
@@ -31,7 +32,11 @@ impl YStyleRule {
31
32
 
32
33
  source_location: CachedValue::empty(|source_location, ruby| {
33
34
  YSourceLocation::new(source_location.line, source_location.column).into_value_with(ruby)
34
- })
35
+ }),
36
+
37
+ rules: CachedValueList::empty(Some(lock.clone()), |rule, ctx, ruby| {
38
+ make_rule(rule, ctx.as_ref().unwrap(), ruby)
39
+ }),
35
40
  }
36
41
  }
37
42
 
@@ -62,6 +67,23 @@ impl YStyleRule {
62
67
  rb_self.declarations.to_a(ruby)
63
68
  }
64
69
 
70
+ pub fn rules(ruby: &Ruby, rb_self: typed_data::Obj<Self>) -> Result<RArray, Error> {
71
+ if rb_self.rules.is_empty() {
72
+ let guard = rb_self.lock.read();
73
+ let style_rule = rb_self.rule.read_with(&guard);
74
+
75
+ if let Some(locked_rules) = &style_rule.rules {
76
+ let rules = locked_rules.read_with(&guard);
77
+
78
+ for rule in &rules.0 {
79
+ rb_self.rules.add(rule.clone(), ruby)?;
80
+ }
81
+ }
82
+ }
83
+
84
+ rb_self.rules.to_a(ruby)
85
+ }
86
+
65
87
  pub fn source_location(ruby: &Ruby, rb_self: typed_data::Obj<Self>) -> Value {
66
88
  if rb_self.source_location.is_empty() {
67
89
  let guard = rb_self.lock.read();
@@ -77,6 +99,7 @@ impl DataTypeFunctions for YStyleRule {
77
99
  fn mark(&self, marker: &gc::Marker) {
78
100
  self.selectors.mark(marker);
79
101
  self.declarations.mark(marker);
102
+ self.rules.mark(marker);
80
103
  self.source_location.mark(marker);
81
104
  }
82
105
  }
data/lib/yass/rules.rb CHANGED
@@ -16,7 +16,7 @@ module Yass
16
16
  end
17
17
 
18
18
  class StyleRule
19
- RUBY_METHODS = %i(declarations kind selectors source_location).freeze
19
+ RUBY_METHODS = %i(declarations kind rules selectors source_location).freeze
20
20
 
21
21
  include ::Yass::Node
22
22
 
data/lib/yass/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yass
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/yass/visitor.rb CHANGED
@@ -2328,6 +2328,7 @@ module Yass
2328
2328
  def visit_style_rule(node)
2329
2329
  visit_list(node.selectors)
2330
2330
  visit_list(node.declarations)
2331
+ visit_list(node.rules)
2331
2332
  visit(node.source_location)
2332
2333
  end
2333
2334
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yass-css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.9.124
18
+ version: 0.9.126
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.9.124
25
+ version: 0.9.126
26
26
  description: The Stylo CSS parser wrapped in a Ruby embrace.
27
27
  email:
28
28
  - camertron@gmail.com
@@ -37,6 +37,7 @@ files:
37
37
  - Cargo.toml
38
38
  - LICENSE.txt
39
39
  - README.md
40
+ - RELEASING.md
40
41
  - Rakefile
41
42
  - codegen/ruby_module_tree.rb
42
43
  - codegen/rust_file_set.rb
@@ -480,7 +481,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
480
481
  - !ruby/object:Gem::Version
481
482
  version: 3.3.11
482
483
  requirements: []
483
- rubygems_version: 3.6.7
484
+ rubygems_version: 4.0.6
484
485
  specification_version: 4
485
486
  summary: A complete CSS parser for Ruby.
486
487
  test_files: []