Compare commits
10 Commits
b9bcd21b2b
...
47238a8c7b
Author | SHA1 | Date |
---|---|---|
rulingcom | 47238a8c7b | |
Yorick Peterse | c4efbcec1b | |
lulalala | 0a9d6302c3 | |
lulalala | 36c11b2712 | |
Yorick Peterse | cf27b764e8 | |
Roy Zwambag | 2142243227 | |
Roy Zwambag | 5bdd0207a0 | |
Yorick Peterse | b7daee79de | |
Yorick Peterse | 6736bcaeba | |
Yorick Peterse | 7f5c0dc8b0 |
|
@ -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:
|
||||
|
|
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 | |
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
b0c3740f08d33f5b9a76c6532de749b8004fb591e3bd3b745e8c57a3bbc5b3d6be4c9a02432fc32f4ae3ca53b488dc409243af91e43646ba3f486fec4738911e
|
|
@ -0,0 +1 @@
|
|||
27f941862134b9e5fc46b33d8dd642a7c816f8b0bb6448789c5f23e9da42abdc72b19713985cf81257074931a4f51e014aa551e09bcb7858cde9987ea17aca75
|
|
@ -0,0 +1 @@
|
|||
c5521d5bc9e025fadfb4e0719c8ff0fa103dd7c184cdf4c60154a1bb5f7d71c9d807a84e76a21b13665de1bbe54f9ba23f6e479650b1bd497302f86ff2af8bbf
|
|
@ -0,0 +1 @@
|
|||
be44f4fb2f5f821306556b965a928e42753a57e489516654bdda74662058510cdc9885b50f6170f23762309f3a7c94791d8db71180272961341c917ffc3560e4
|
|
@ -0,0 +1 @@
|
|||
eef134163a86451be4a5ec72b262fec6a1dad10613e0d4002142b09e02cb444cc25ce018cdd62a870b266fc8dd390ba4fe110e07a2c41f50a3d8abdcc69b5dec
|
|
@ -0,0 +1 @@
|
|||
2ba0fdbfa3fa15b8d1ce5df4df4cfb3813f34399c93517f98ec8da1e82ff3cdc6e3543bf017b8246daa8b2521a64af92a9438a404b69da0f319272c510961314
|
|
@ -1,3 +1,3 @@
|
|||
module Oga
|
||||
VERSION = '3.1'
|
||||
VERSION = '3.4'
|
||||
end # Oga
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,6 +7,8 @@ module Oga
|
|||
def to_xml
|
||||
Generator.new(self).to_xml
|
||||
end
|
||||
|
||||
alias_method :to_s, :to_xml
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue