juju 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Gemfile.lock +1 -1
  2. data/lib/juju/version.rb +1 -1
  3. data/lib/juju.rb +12 -1
  4. metadata +1 -1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- juju (0.0.3)
4
+ juju (0.0.4)
5
5
  rest-client
6
6
 
7
7
  GEM
data/lib/juju/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Juju
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
4
4
 
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'].each {|item| item['link'].squish!}
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]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juju
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: