Skip to content

Commit 32caaeb

Browse files
committed
Add gem infrastructure
1 parent c34baa5 commit 32caaeb

File tree

13 files changed

+283
-6
lines changed

13 files changed

+283
-6
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
110
test.xml

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
## [0.1.0] - 2022-05-25
10+
11+
### Added
12+
13+
- 🎉 Initial release! 🎉
14+
15+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-xml/compare/v0.1.0...HEAD
16+
[0.1.0]: https://github.com/ruby-syntax-tree/syntax_tree-xml/compare/c34baa...v0.1.0

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
source "https://rubygems.org"
44

5-
gem "prettier_print"
6-
gem "syntax_tree"
5+
gemspec

Gemfile.lock

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
1+
PATH
2+
remote: .
3+
specs:
4+
syntax_tree-xml (0.1.0)
5+
prettier_print
6+
syntax_tree (>= 2.0.1)
7+
18
GEM
29
remote: https://rubygems.org/
310
specs:
11+
docile (1.4.0)
12+
minitest (5.15.0)
413
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)
521
syntax_tree (2.7.1)
622
prettier_print
723

824
PLATFORMS
925
x86_64-darwin-21
1026

1127
DEPENDENCIES
12-
prettier_print
13-
syntax_tree
28+
bundler
29+
minitest
30+
rake
31+
simplecov
32+
syntax_tree-xml!
1433

1534
BUNDLED WITH
1635
2.4.0.dev

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.

Rakefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

lib/syntax_tree/xml/format.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ def visit_prolog(node)
4343

4444
if node.attributes.any?
4545
q.indent do
46-
q.breakable("")
46+
q.breakable
4747
q.seplist(node.attributes, -> { q.breakable }) do |child_node|
4848
visit(child_node)
4949
end
5050
end
5151
end
5252

53-
q.breakable
53+
q.breakable("")
5454
visit(node.closing)
5555
end
5656
end

lib/syntax_tree/xml/version.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
module SyntaxTree
4+
module XML
5+
VERSION = "0.1.0"
6+
end
7+
end

syntax_tree-xml.gemspec

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "lib/syntax_tree/xml/version"
4+
5+
Gem::Specification.new do |spec|
6+
spec.name = "syntax_tree-xml"
7+
spec.version = SyntaxTree::XML::VERSION
8+
spec.authors = ["Kevin Newton"]
9+
spec.email = ["[email protected]"]
10+
11+
spec.summary = "Syntax Tree support for XML"
12+
spec.homepage = "https://github.com/ruby-syntax-tree/syntax_tree-xml"
13+
spec.license = "MIT"
14+
spec.metadata = { "rubygems_mfa_required" => "true" }
15+
16+
spec.files = Dir.chdir(__dir__) do
17+
`git ls-files -z`.split("\x0").reject do |f|
18+
f.match(%r{^(test|spec|features)/})
19+
end
20+
end
21+
22+
spec.bindir = "exe"
23+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24+
spec.require_paths = %w[lib]
25+
26+
spec.add_dependency "prettier_print"
27+
spec.add_dependency "syntax_tree", ">= 2.0.1"
28+
29+
spec.add_development_dependency "bundler"
30+
spec.add_development_dependency "minitest"
31+
spec.add_development_dependency "rake"
32+
spec.add_development_dependency "simplecov"
33+
end

test/fixture/formatted.xml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
3+
"https://www.puppycrawl.com/dtds/configuration_1_3.dtd">
4+
<?xml-model href="project.rnc" type="application/relax-ng-compact-syntax"?>
5+
<!-- foo -->
6+
<svg
7+
xmlns="http://www.w3.org/2000/svg"
8+
xmlns:xlink="http://www.w3.org/1999/xlink"
9+
width="200"
10+
height="100"
11+
viewBox="0 0 200 100"
12+
>
13+
<title>Style inheritance and the use element</title>
14+
<desc _attr="attr">
15+
&amp;
16+
&#12345;
17+
<![CDATA[
18+
foo
19+
]]>
20+
bar
21+
</desc>
22+
<?pagebreak?>
23+
24+
<style />
25+
<style />
26+
<style type="text/css">
27+
circle { stroke-opacity: 0.7; }
28+
.special circle { stroke: green; }
29+
use { stroke: purple;
30+
fill: orange; }
31+
</style>
32+
33+
<yaml
34+
myveryveryveryverylongattributename="myveryveryveryverylongattributevalue"
35+
>
36+
- 1
37+
- 2
38+
- 3
39+
</yaml>
40+
41+
<!-- inner comment -->
42+
43+
<?pagebreak?>
44+
<g class="special" style="fill: blue">
45+
<circle id="c" cy="50" cx="50" r="40" stroke-width="20" />
46+
</g>
47+
<use xlink:href="#c" x="100" />
48+
<ignored>
49+
<!-- prettier-ignore-start -->
50+
<ignored />
51+
<!-- prettier-ignore-end -->
52+
</ignored>
53+
<p>
54+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at est eget
55+
enim consectetur accumsan. Aliquam pretium sodales ipsum quis dignissim. Sed
56+
id sem vel diam luctus fringilla. Aliquam quis egestas magna. Curabitur
57+
molestie lorem et odio porta, et molestie libero laoreet. Morbi rhoncus
58+
sagittis cursus. Nullam vehicula pretium consequat. Praesent porta ante at
59+
posuere sollicitudin. Nullam commodo tempor arcu, at condimentum neque
60+
elementum ut.
61+
</p>
62+
<span>content</span>
63+
64+
<div>
65+
even more
66+
<content />
67+
</div>
68+
</svg>
69+
<!-- bar -->

0 commit comments

Comments
 (0)