Compare commits

...

10 Commits

Author SHA1 Message Date
rulingcom 47238a8c7b Support older ruby 2.1. 2024-02-15 13:07:07 +08:00
Yorick Peterse c4efbcec1b
Release 3.4 2022-08-02 16:18:22 +02:00
lulalala 0a9d6302c3 Take ownership when children nodes are assigned 2022-08-02 21:17:33 +08:00
lulalala 36c11b2712 Update owner when assign children 2022-07-13 21:34:08 +08:00
Yorick Peterse cf27b764e8
Release 3.3 2020-07-27 02:20:04 +02:00
Roy Zwambag 2142243227 Add to_s as an alias to the to_xml method 2020-07-27 00:14:36 +00:00
Roy Zwambag 5bdd0207a0 Small fixes in CONTRIBUTING.md
- Change the links to to working links.
- Rename "pull request" to "merge request".
2020-07-25 21:41:28 +02:00
Yorick Peterse b7daee79de
Updated outdated parts of the CONTRIBUTING guide 2020-02-20 17:33:43 +01:00
Yorick Peterse 6736bcaeba
Release 3.2 2020-01-10 16:03:15 +01:00
Yorick Peterse 7f5c0dc8b0
Add CI config for Ruby 2.7 2020-01-10 15:41:37 +01:00
19 changed files with 83 additions and 26 deletions

View File

@ -30,6 +30,10 @@ Ruby 2.6:
image: "ruby:2.6-alpine"
<<: *defaults
Ruby 2.7:
image: "ruby:2.7-alpine"
<<: *defaults
JRuby 9.1:
image: "jruby:9.1-alpine"
variables:

View File

@ -3,6 +3,24 @@
This document contains details of the various releases and their release dates.
Dates are in the format `yyyy-mm-dd`.
## 3.4 - 2022-08-02
This release includes a change that when setting the child nodes of a node A,
node A takes ownership over the entire new child tree. See merge request
https://gitlab.com/yorickpeterse/oga/-/merge_requests/194 for more details.
## 3.3 - 2020-07-27
This release adds `to_s` as an alias for `to_xml`, thanks to Roy Zwambag. See
merge request https://gitlab.com/yorickpeterse/oga/-/merge_requests/192 for more
information.
## 3.2 - 2020-01-10
This release fixes a few warnings that would show up when using Oga on Ruby
2.7.0. See https://gitlab.com/yorickpeterse/oga/merge_requests/190 for more
information.
## 3.1 - 2020-01-08
This release fixes a bug in the XML lexer that prevented the parsing of doctypes

View File

@ -28,7 +28,7 @@ When making changes please stick to the existing style and patterns as this
keeps the codebase consistent. If a certain pattern or style is getting in your
way please open a separate issue about this so it can be discussed.
Every commit and every pull request made is carefully reviewed. Chances are I'll
Every commit and every merge request made is carefully reviewed. Chances are I'll
spend more time reviewing it than the time an author spent on their changes.
This should ensure that Oga's codebase is stable, of high quality and easy to
maintain. As such _please_ take my feedback into consideration (or discuss it in
@ -36,18 +36,18 @@ a civilized manner) instead of just dismissing it with comments such as "But I
fixed the problem so your feedback is irrelevant" or "This is my way of doing
things".
Finally, and this will sound harsh: I will _not_ merge pull requests if the
Finally, and this will sound harsh: I will _not_ merge merge requests if the
author(s) simply disregard the feedback I've given them or if there are other
problems with the pull request. Do not expect me to just blindly accept whatever
problems with the merge request. Do not expect me to just blindly accept whatever
changes are submitted.
Some examples of good pull request:
Some examples of good merge requests:
* https://gitlab.com/yorickpeterse/oga/pull/96
* https://gitlab.com/yorickpeterse/oga/pull/67
* https://gitlab.com/yorickpeterse/ffi-aspell/pull/21
* https://gitlab.com/yorickpeterse/ffi-aspell/pull/20
* https://gitlab.com/yorickpeterse/ruby-ll/pull/16
* https://gitlab.com/yorickpeterse/oga/-/merge_requests/96
* https://gitlab.com/yorickpeterse/oga/-/merge_requests/67
* https://gitlab.com/yorickpeterse/ffi-aspell/-/merge_requests/21
* https://gitlab.com/yorickpeterse/ffi-aspell/-/merge_requests/20
* https://gitlab.com/yorickpeterse/ruby-ll/-/merge_requests/16
## Git
@ -140,19 +140,14 @@ such a case use `describe 'foo'` for class methods and `describe '#foo'` for
instance methods.
Whenever adding new specifications please keep them in the existing style. If
the style is problematic you can open a separate pull request to address it. If
the style is problematic you can open a separate merge request to address it. If
you expect this to be a lot of work you should open an issue first to discuss
things.
## Continuous Integration
Two continuous integration services are used to ensure the tests of Oga pass
at all times:
* Travis CI: <https://gitlab.com/yorickpeterse/oga/pipelines>
* AppVeyor (Windows): <https://ci.appveyor.com/project/yorickpeterse/oga>
Pull requests won't be merged if any of the builds fail unless stated otherwise.
Oga is tested using GitLab CI. Merge requests require that all tests pass before
they can be merged.
## Extension Setup
@ -219,7 +214,7 @@ modify `$LOAD_PATH`, instead run any scripts using `ruby -I lib`.
In case you have any further questions or would like to receive feedback before
submitting a change, feel free to contact me. You can either open an issue,
send a tweet to [@yorickpeterse][twitter] or send an Email to
<yorickpeterse@gmail.com>.
<yorick@yorickpeterse.com>.
[editorconfig]:http://editorconfig.org/
[twitter]: https://twitter.com/yorickpeterse

View File

@ -172,7 +172,7 @@ Querying a document using a namespace:
| Ruby | Required | Recommended |
|:---------|:--------------|:------------|
| MRI | >= 2.3.0 | >= 2.6.0 |
| MRI | >= 1.9.3 | >= 2.1.2 |
| JRuby | >= 1.7 | >= 1.7.12 |
| Rubinius | Not supported | |
| Maglev | Not supported | |

View File

@ -0,0 +1 @@
b0c3740f08d33f5b9a76c6532de749b8004fb591e3bd3b745e8c57a3bbc5b3d6be4c9a02432fc32f4ae3ca53b488dc409243af91e43646ba3f486fec4738911e

View File

@ -0,0 +1 @@
27f941862134b9e5fc46b33d8dd642a7c816f8b0bb6448789c5f23e9da42abdc72b19713985cf81257074931a4f51e014aa551e09bcb7858cde9987ea17aca75

View File

@ -0,0 +1 @@
c5521d5bc9e025fadfb4e0719c8ff0fa103dd7c184cdf4c60154a1bb5f7d71c9d807a84e76a21b13665de1bbe54f9ba23f6e479650b1bd497302f86ff2af8bbf

View File

@ -0,0 +1 @@
be44f4fb2f5f821306556b965a928e42753a57e489516654bdda74662058510cdc9885b50f6170f23762309f3a7c94791d8db71180272961341c917ffc3560e4

View File

@ -0,0 +1 @@
eef134163a86451be4a5ec72b262fec6a1dad10613e0d4002142b09e02cb444cc25ce018cdd62a870b266fc8dd390ba4fe110e07a2c41f50a3d8abdcc69b5dec

View File

@ -0,0 +1 @@
2ba0fdbfa3fa15b8d1ce5df4df4cfb3813f34399c93517f98ec8da1e82ff3cdc6e3543bf017b8246daa8b2521a64af92a9438a404b69da0f319272c510961314

View File

@ -1,3 +1,3 @@
module Oga
VERSION = '3.1'
VERSION = '3.4'
end # Oga

View File

@ -46,6 +46,8 @@ module Oga
# @param [Oga::XML::NodeSet|Array] nodes
def children=(nodes)
if nodes.is_a?(NodeSet)
nodes.owner = self
nodes.take_ownership_on_nodes
@children = nodes
else
@children = NodeSet.new(nodes, self)

View File

@ -49,6 +49,8 @@ module Oga
# @param [Oga::XML::NodeSet|Array] nodes
def children=(nodes)
if nodes.is_a?(NodeSet)
nodes.owner = self
nodes.take_ownership_on_nodes
@children = nodes
else
@children = NodeSet.new(nodes, self)

View File

@ -42,11 +42,7 @@ module Oga
@owner = owner
@existing = {}
@nodes.each_with_index do |node, index|
mark_existing(node)
take_ownership(node, index) if @owner
end
take_ownership_on_nodes
end
# Yields the supplied block for every node.
@ -289,6 +285,14 @@ module Oga
"NodeSet(#{values})"
end
def take_ownership_on_nodes
@nodes.each_with_index do |node, index|
mark_existing(node)
take_ownership(node, index) if @owner
end
end
private
# Takes ownership of the given node. This only occurs when the current

View File

@ -7,6 +7,8 @@ module Oga
def to_xml
Generator.new(self).to_xml
end
alias_method :to_s, :to_xml
end
end
end

View File

@ -29,7 +29,7 @@ Gem::Specification.new do |s|
s.extensions = ['ext/c/extconf.rb']
end
s.required_ruby_version = '>= 2.3.0'
s.required_ruby_version = '>= 1.9.3'
s.add_dependency 'ast'
s.add_dependency 'ruby-ll', '~> 2.1'

View File

@ -22,6 +22,7 @@ describe Oga::XML::Document do
document.children = [child]
expect(document.children[0]).to eq(child)
expect(document.children[0].parent).to eq(document)
end
it 'sets the child nodes using a NodeSet' do
@ -31,6 +32,7 @@ describe Oga::XML::Document do
document.children = Oga::XML::NodeSet.new([child])
expect(document.children[0]).to eq(child)
expect(document.children[0].parent).to eq(document)
end
end

View File

@ -168,5 +168,16 @@ describe Oga::XML::Generator do
end
end
end
describe 'using an Element with replaced children' do
it 'returns a string' do
element = Oga::XML::Element.new(name: 'foo')
element.children = Oga::XML::Parser.new('<bar></bar>').parse.children
output = described_class.new(element).to_xml
expect(output).to eq('<foo><bar /></foo>')
end
end
end
end

View File

@ -0,0 +1,11 @@
require 'spec_helper'
describe Oga::XML::ToXML do
describe '#to_s' do
it 'is an alias of to_xml' do
node = Oga::XML::Element.new(name: 'foo')
expect(node.method(:to_s)).to eq(node.method(:to_xml))
end
end
end