juju 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/juju/version.rb +1 -1
- data/lib/juju.rb +12 -1
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/lib/juju/version.rb
CHANGED
data/lib/juju.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'active_support/all'
|
2
2
|
require 'rest-client'
|
3
|
+
require 'action_view'
|
3
4
|
|
4
5
|
class Juju
|
6
|
+
include ActionView::Helpers::SanitizeHelper
|
7
|
+
|
5
8
|
URL = "http://api.juju.com/jobs"
|
6
9
|
|
7
10
|
def self.instance
|
@@ -23,11 +26,19 @@ class Juju
|
|
23
26
|
protected
|
24
27
|
def parse_xml(xml)
|
25
28
|
data = Hash.from_xml(xml)['rss']['channel']
|
26
|
-
jobs = data['item']
|
29
|
+
jobs = remove_spaces_and_tags data['item']
|
27
30
|
JujuResult.new(jobs, data['totalresults'], data['startindex'], data['itemsperpage'])
|
28
31
|
rescue REXML::ParseException
|
29
32
|
raise JujuError, 'Did not get a valid XML response from Juju'
|
30
33
|
end
|
34
|
+
|
35
|
+
def remove_spaces_and_tags(jobs)
|
36
|
+
jobs.each do |item|
|
37
|
+
item['link'].squish!
|
38
|
+
item['title'] = strip_tags(item['title']).squish!
|
39
|
+
item['description'] = strip_tags(item['description']).squish!
|
40
|
+
end
|
41
|
+
end
|
31
42
|
|
32
43
|
def check_required(params)
|
33
44
|
raise ArgumentError.new('Partner ID was not provided') unless params[:partnerid]
|