Skip to content

Commit

Permalink
XML: Revert Oga -> Nokogiri
Browse files Browse the repository at this point in the history
There are 2 main reasons for this:

1. Nokogiri actually renders XML into the complete HTML string, which makes it INCREDIBLY useful for debugging tests (a common use-case when creating components with jekyll-spark).
2. We experienced a gem dependency issue with Oga re: ruby-ll (2.1.2)
  • Loading branch information
ItsJonQ committed Jul 20, 2017
1 parent 976de37 commit f3c2fb1
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/api/find.md
Expand Up @@ -11,7 +11,7 @@

| Type | Description |
| --- | --- |
| instance | A [Oga](https://github.com/YorickPeterse/oga) element instance. |
| instance | A [Nokogiri](https://github.com/sparklemotion/nokogiri) element instance. |


## Usage
Expand Down Expand Up @@ -45,7 +45,7 @@ el["class"] # quote

### Chaining

Joule has enhanced Oga's `XML::Element` class by allowing you to find elements within elements.
Joule has enhanced Nokogiri's `XML::Element` class by allowing you to find elements within elements.

In the example below, we're able to find the inner `.pika` selector within the outer `.pikachu` selector.
```rb
Expand Down
2 changes: 1 addition & 1 deletion docs/api/find_all.md
Expand Up @@ -11,7 +11,7 @@

| Type | Description |
| --- | --- |
| array | An array of [Oga](https://github.com/YorickPeterse/oga) element instances. |
| array | An array of [Nokogiri](https://github.com/sparklemotion/nokogiri) element instances. |


## Usage
Expand Down
2 changes: 1 addition & 1 deletion docs/api/prop.md
Expand Up @@ -8,7 +8,7 @@

#### Aliases

**[.get()](http://code.yorickpeterse.com/oga/latest/Oga/XML/Element.html#get-instance_method)**
**[.attr()](http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Attr)**


#### Returns
Expand Down
2 changes: 1 addition & 1 deletion jekyll-joule.gemspec
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_runtime_dependency "jekyll", ">= 3.1.2"
spec.add_runtime_dependency "oga", "~> 2.10"
spec.add_runtime_dependency "nokogiri", "~> 1.8"

spec.add_development_dependency "bundler", "~> 1.13"
spec.add_development_dependency "rake", "~> 10.0"
Expand Down
@@ -1,4 +1,4 @@
module Oga
module Nokogiri
module XML
class Element
def find_all *args
Expand All @@ -10,7 +10,7 @@ def find *args
end

def prop *args
self.get *args
self.attr *args
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/joule.rb
@@ -1,3 +1,3 @@
require "jekyll/joule/version"
require "jekyll/joule/site"
require "jekyll/extensions/oga_element"
require "jekyll/extensions/xml_element"
4 changes: 2 additions & 2 deletions lib/jekyll/joule/site.rb
@@ -1,6 +1,6 @@
require "jekyll"
require "jekyll/joule/page"
require "oga"
require "nokogiri"

module Jekyll
module Joule
Expand Down Expand Up @@ -37,7 +37,7 @@ def render(content)
page = Jekyll::Joule::Page.new(@site, @site.source, "/", @test_page_name)
page.reparse(content)
@data = generate(page)
@html = Oga.parse_html(@data.content)
@html = Nokogiri::HTML(@data.content)

return self
end
Expand Down
8 changes: 4 additions & 4 deletions test/test_joule_nokogiri_ext.rb
@@ -1,7 +1,7 @@
require "helper"

class JouleOgaExtTest < JekyllUnitTest
should "extend Oga's Element class with find method" do
class JouleNokogiriExtTest < JekyllUnitTest
should "extend Nokogiri's Element class with find method" do
html = %Q[
<div class="hello">
<h1>Yes</h1>
Expand All @@ -19,7 +19,7 @@ class JouleOgaExtTest < JekyllUnitTest
assert(h2.text.include?("No"))
end

should "extend Oga's Element class with find_all method" do
should "extend Nokogiri's Element class with find_all method" do
html = %Q[
<div class="hello">
<h2>Yes</h2>
Expand All @@ -37,7 +37,7 @@ class JouleOgaExtTest < JekyllUnitTest
assert(h2.first.text.include?("Yes"))
end

should "extend Oga's Element class with prop method" do
should "extend Nokogiri's Element class with prop method" do
html = %Q[
<div class="hello" style="display: block;">
<h2>Yes</h2>
Expand Down

0 comments on commit f3c2fb1

Please sign in to comment.