Permalink
Browse files

Replaced libxmljs-easy with libxmljs (libxmljs-easy isn't actively ma…

…intained). All vows are passing now.
  • Loading branch information...
Daniel Stevens
Daniel Stevens committed Aug 2, 2012
1 parent 5bab0d8 commit 6401a05c39998c5c93897432f8c5637bde4a18f4
Showing with 22 additions and 21 deletions.
  1. +4 −3 package.json
  2. +18 −18 src/client.coffee
View
@@ -10,7 +10,8 @@
"author": "3scale <support@3scale.net>",
"contributors": [
"Carlos Villuendas <carlosvillu@3scale.net>",
- "Michal Cichra <michal@3scale.net>"
+ "Michal Cichra <michal@3scale.net>",
+ "Daniel Stevens <daniel.stevens@senicolabs.com>"
],
"main": "lib/index.js",
"bugs": {
@@ -30,14 +31,14 @@
"lib": "./lib"
},
"dependencies": {
- "libxmljs-easy": "*"
+ "libxmljs": "*"
},
"devDependencies": {
"coffee-script": "1.x",
"vows": "0.5.x"
},
"engines": {
- "node": "0.6.x"
+ "node": "0.8.x"
},
"optionalDependencies": {}
}
View
@@ -1,6 +1,6 @@
http = require 'http'
querystring = require 'querystring'
-easy = require('libxmljs-easy')
+libxml = require 'libxmljs'
Response = require './response'
AuthorizeResponse = require './authorize_response'
@@ -130,36 +130,36 @@ module.exports = class Client
# privates methods
_build_success_authorize_response: (xml) ->
response = new AuthorizeResponse()
- doc = easy.parse(xml)
- authorize = doc.authorized[0].$.text()
- plan = doc.plan[0].$.text()
-
+ doc = libxml.parseXml xml
+ authorize = doc.get('//authorized').text()
+ plan = doc.get('//plan').text()
+
if authorize is 'true'
response.success()
else
- reason = doc.reason[0]
+ reason = doc.get '//reason'
response.error(reason)
- usage_reports = doc.usage_reports[0].usage_report
+ usage_reports = doc.get '//usage_reports'
- for index, usage_report of usage_reports
+ for index, usage_report of usage_reports.childNodes()
do (usage_report) ->
report =
- period: usage_report.$period
- metric: usage_report.$metric
- period_start: usage_report.period_start[0].$.text()
- period_end: usage_report.period_end[0].$.text()
- current_value: usage_report.current_value[0].$.text()
- max_value: usage_report.max_value[0].$.text()
+ period: usage_report.attr('period').value()
+ metric: usage_report.attr('metric').value()
+ period_start: usage_report.get('period_start').text()
+ period_end: usage_report.get('period_end').text()
+ current_value: usage_report.get('current_value').text()
+ max_value: usage_report.get('max_value').text()
response.add_usage_reports report
-
+
response
_build_error_response: (xml) ->
response = new AuthorizeResponse()
- doc = easy.parse xml
- error = doc[0]
+ doc = libxml.parseXml xml
+ error = doc.get '/error'
response = new Response()
- response.error error.$.text(), error.$code
+ response.error error.text(), error.attr('code').value()
response

0 comments on commit 6401a05

Please sign in to comment.