Skip to content

Commit

Permalink
Replace nokogiri with lighter oga
Browse files Browse the repository at this point in the history
  • Loading branch information
greeneca committed Jun 28, 2017
1 parent a3b80ee commit abe08f5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
13 changes: 9 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PATH
git (~> 1.3)
net-ping (~> 2.0)
net-telnet (~> 0.1)
nokogiri (~> 1.7)
oga (~> 2.10)
rubyzip (~> 1.2)
win32-security (~> 0.5)

Expand All @@ -16,6 +16,8 @@ GEM
specs:
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
ansi (1.5.0)
ast (2.3.0)
byebug (9.0.6)
coderay (1.1.1)
coveralls (0.8.21)
Expand Down Expand Up @@ -61,7 +63,6 @@ GEM
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
method_source (0.8.2)
mini_portile2 (2.2.0)
minitest (5.10.2)
minitest-autotest (1.0.3)
minitest-server (~> 1.0)
Expand All @@ -74,11 +75,12 @@ GEM
net-http-digest_auth (1.4.1)
net-ping (2.0.1)
net-telnet (0.1.1)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
oga (2.10)
ast
ruby-ll (~> 2.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand All @@ -88,6 +90,9 @@ GEM
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
ruby-ll (2.1.2)
ansi
ast
ruby_dep (1.5.0)
rubyzip (1.2.1)
safe_yaml (1.0.4)
Expand Down
4 changes: 3 additions & 1 deletion intergration/roku_builder/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
require "minitest/utils"
require "securerandom"

ROKU_IP = "192.168.1.114"

module Minitest
module Assertions
def wait_assert(timeout = 10, msg = nil)
Expand Down Expand Up @@ -103,7 +105,7 @@ def good_config(klass)
devices: {
default: :roku,
roku: {
ip: "192.168.1.127",
ip: ROKU_IP,
user: "rokudev",
password: "aaaa"
}
Expand Down
20 changes: 10 additions & 10 deletions intergration/roku_builder/test_profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ def test_profile_stats
`#{roku} --sideload --working`
assert_log @uuid
output = `#{roku} --profile stats`
assert output =~ /Name \| Count/
assert output =~ /Total \|\s*5/
assert output =~ /Default \|\s*1/
assert output =~ /RectangleExample \|\s*1/
assert output =~ /Poster \|\s*1/
assert output =~ /Node \|\s*1/
assert output =~ /Rectangle \|\s*1/
assert_match(/Name \| Count/, output)
assert_match(/Total \|\s*5/, output)
assert_match(/Default \|\s*1/, output)
assert_match(/RectangleExample \|\s*1/, output)
assert_match(/Poster \|\s*1/, output)
assert_match(/Node \|\s*1/, output)
assert_match(/Rectangle \|\s*1/, output)
end
def test_profile_all
`#{roku} --sideload --working`
assert_log @uuid
output = `#{roku} --profile all`
assert output =~ /RectangleExample/
assert_match(/RectangleExample/, output)
end
def test_profile_images
`#{roku} --sideload --working`
assert_log @uuid
output = `#{roku} --profile images`
assert output =~ /Available memory/
assert_match(/Available memory/, output)
end
def test_profile_textures
`#{roku} --sideload --working`
assert_log @uuid
output = `#{roku} --profile textures`
assert output =~ /System textures/
assert_match(/System textures/, output)
end
end
end
2 changes: 1 addition & 1 deletion lib/roku_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require 'pstore'
require "git"
#profiler
require 'nokogiri'
require 'oga'
#navigator
require 'io/console'
#monitor
Expand Down
7 changes: 4 additions & 3 deletions lib/roku_builder/plugins/profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def print_stats
lines = get_command_response(command: "sgnodes all", start_reg: start_reg, end_reg: end_reg)
xml_string = lines.join("\n")
stats = {"Total" => 0}
doc = Nokogiri::XML(xml_string)
handle_node(stats: stats, node: doc.root)
doc = Oga.parse_xml(xml_string)
handle_node(stats: stats, node: doc.children.first)
stats = stats.to_a
stats = stats.sort {|a, b| b[1] <=> a[1]}
printf "%30s | %5s\n", "Name", "Count"
Expand All @@ -52,7 +52,8 @@ def print_stats
end

def handle_node(stats:, node:)
node.element_children.each do |element|
node.children.each do |element|
next unless element.class == Oga::XML::Element
stats[element.name] ||= 0
stats[element.name] += 1
stats["Total"] += 1
Expand Down
2 changes: 1 addition & 1 deletion roku_builder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "git", "~> 1.3"
spec.add_dependency "net-ping", "~> 2.0"
spec.add_dependency "net-telnet", "~> 0.1"
spec.add_dependency "nokogiri", "~> 1.7"
spec.add_dependency "oga", "~> 2.10"
spec.add_dependency "win32-security", "~> 0.5" # For windows compatibility

spec.add_development_dependency "bundler", "~> 1.7"
Expand Down

0 comments on commit abe08f5

Please sign in to comment.