syntax_tree-css 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4469bb6ec376d147727921b5694c3007cea2a3a7eb7168bcdde792dbe2cd40fe
4
+ data.tar.gz: fe6cf8d3f594977d5f8c0389c34678c0511b749942f2213ed839d4f71d560bac
5
+ SHA512:
6
+ metadata.gz: dbbbb55fff4fe7e367c8743f48f293ac02ef3281f9a32b0cfa2aeb0b29fc01b18b36ddfcd64d47c9fc061859d94082f401b8e25586d2966c24b30ba6b7c9b8d9
7
+ data.tar.gz: 371d2f0f95877ba1da6f2547e44dca36bd8198d5cf2acd703e0103781ffa0474a2fbd5af04fa3b86646e742130394a71e2ffb38ce135537d9f9096705d554e8c
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
@@ -0,0 +1,34 @@
1
+ name: Main
2
+ on:
3
+ - push
4
+ - pull_request_target
5
+ jobs:
6
+ ci:
7
+ name: CI
8
+ runs-on: ubuntu-latest
9
+ env:
10
+ CI: true
11
+ steps:
12
+ - uses: actions/checkout@master
13
+ with:
14
+ submodules: recursive
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ bundler-cache: true
18
+ ruby-version: '3.1'
19
+ - name: Test
20
+ run: bundle exec rake test
21
+ automerge:
22
+ name: AutoMerge
23
+ needs: ci
24
+ runs-on: ubuntu-latest
25
+ if: github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]'
26
+ steps:
27
+ - uses: actions/github-script@v3
28
+ with:
29
+ script: |
30
+ github.pulls.merge({
31
+ owner: context.payload.repository.owner.login,
32
+ repo: context.payload.repository.name,
33
+ pull_number: context.payload.pull_request.number
34
+ })
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ coverage
2
+ test.css
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "css-parsing-tests"]
2
+ path = test/css-parsing-tests
3
+ url = https://github.com/SimonSapin/css-parsing-tests.git
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ syntax_tree-css (0.1.0)
5
+ prettier_print
6
+ syntax_tree (>= 2.0.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ docile (1.4.0)
12
+ minitest (5.15.0)
13
+ prettier_print (0.1.0)
14
+ rake (13.0.6)
15
+ simplecov (0.21.2)
16
+ docile (~> 1.1)
17
+ simplecov-html (~> 0.11)
18
+ simplecov_json_formatter (~> 0.1)
19
+ simplecov-html (0.12.3)
20
+ simplecov_json_formatter (0.1.4)
21
+ syntax_tree (2.7.1)
22
+ prettier_print
23
+
24
+ PLATFORMS
25
+ x86_64-darwin-21
26
+ x86_64-linux
27
+
28
+ DEPENDENCIES
29
+ bundler
30
+ minitest
31
+ rake
32
+ simplecov
33
+ syntax_tree-css!
34
+
35
+ BUNDLED WITH
36
+ 2.3.6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022-present Kevin Newton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # SyntaxTree::CSS
2
+
3
+ [![Build Status](https://github.com/ruby-syntax-tree/syntax_tree-css/actions/workflows/main.yml/badge.svg)](https://github.com/ruby-syntax-tree/syntax_tree-css/actions/workflows/main.yml)
4
+ [![Gem Version](https://img.shields.io/gem/v/syntax_tree-css.svg)](https://rubygems.org/gems/syntax_tree-css)
5
+
6
+ [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree) support for CSS.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem "syntax_tree-css"
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle install
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install syntax_tree-css
23
+
24
+ ## Usage
25
+
26
+ From code:
27
+
28
+ ```ruby
29
+ require "syntax_tree/css"
30
+
31
+ pp SyntaxTree::CSS.parse(source) # print out the AST
32
+ puts SyntaxTree::CSS.format(source) # format the AST
33
+ ```
34
+
35
+ From the CLI:
36
+
37
+ ```sh
38
+ $ stree ast --plugins=css file.css
39
+ (css-stylesheet
40
+ (style-rule
41
+ (selectors
42
+ (type-selector (delim-token "*"))
43
+ )
44
+ (declarations
45
+ (declaration hello (ident-token "world"), (semicolon-token))
46
+ )
47
+ )
48
+ )
49
+ ```
50
+
51
+ or
52
+
53
+ ```sh
54
+ $ stree format --plugins=css file.css
55
+ * {
56
+ hello: world;
57
+ }
58
+ ```
59
+
60
+ or
61
+
62
+ ```sh
63
+ $ stree write --plugins=css file.css
64
+ file.css 1ms
65
+ ```
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-syntax-tree/syntax_tree-css.
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require "syntax_tree/rake_tasks"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.test_files = FileList["test/**/*_test.rb"]
11
+ end
12
+
13
+ SyntaxTree::Rake::CheckTask.new
14
+ SyntaxTree::Rake::WriteTask.new
15
+
16
+ task default: :test
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SyntaxTree
4
+ module CSS
5
+ # The parent class of all visitors that provides the double dispatch
6
+ # pattern. It doesn't provide any of the aliases so it can't actually be
7
+ # used to visit the tree. It's used to implement visitors that should raise
8
+ # an error if a node that's not implemented is visited.
9
+ class BasicVisitor
10
+ def visit(node)
11
+ node&.accept(self)
12
+ end
13
+
14
+ def visit_all(nodes)
15
+ nodes.map { |node| visit(node) }
16
+ end
17
+
18
+ def visit_child_nodes(node)
19
+ visit_all(node.child_nodes)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SyntaxTree
4
+ module CSS
5
+ # A formatting visitor.
6
+ class Format < BasicVisitor
7
+ attr_reader :q
8
+
9
+ def initialize(q)
10
+ @q = q
11
+ end
12
+ end
13
+ end
14
+ end