Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Switch from Nokogiri to Oga for XML parsing
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
colindean committed Sep 14, 2014
1 parent 3edda48 commit d52ff29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source "http://rubygems.org"

gem "nokogiri", "~> 1.6.3.0"
gem 'oga', '~> 0.1.1'

group :development do
gem "rdoc", "~> 3.12"
Expand Down
12 changes: 6 additions & 6 deletions lib/kismet-gpsxml.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'nokogiri'
require 'oga'
require 'set'

module Kismet
Expand All @@ -14,7 +14,7 @@ class Kismet::GPSXML::Reader
attr_accessor :rounding

def self.from_io io
new Nokogiri::XML::Reader.from_io(io)
new ::Oga::XML::PullParser.new(io)
end

def initialize xml_reader
Expand All @@ -24,7 +24,7 @@ def initialize xml_reader

def points
points = {}
reader.each do |node|
reader.parse do |node|
next unless interesting_node? node
point = point_info node
lat, lon, bssid = point.values
Expand All @@ -38,14 +38,14 @@ def points
private

def interesting_node? node
node.class == ::Oga::XML::Element &&
node.name == "gps-point" &&
node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT &&
node.attribute("bssid") != "00:00:00:00:00:00"
end

def point_info node
{lat: node.attribute("lat").to_f.round(rounding),
lon: node.attribute("lon").to_f.round(rounding),
{lat: node.attribute("lat").value.to_f.round(rounding),
lon: node.attribute("lon").value.to_f.round(rounding),
bssid: node.attribute("bssid")}
end
end

0 comments on commit d52ff29

Please sign in to comment.