vacuum 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2010 Hakan Ensari
3
+ Copyright (c) 2012 Hakan Ensari
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Vacuum
2
2
 
3
- [![travis] [2]] [3]
3
+ [![travis] [1]] [2]
4
4
 
5
- ![vacuum] [1]
5
+ ![vacuum] [3]
6
6
 
7
7
  Vacuum is a minimal Ruby wrapper to the [Amazon Product Advertising API] [4].
8
8
 
@@ -36,8 +36,8 @@ end
36
36
 
37
37
  Read further [here] [5].
38
38
 
39
- [1]: https://github.com/hakanensari/vacuum/blob/master/vacuum.png?raw=true
40
- [2]: https://secure.travis-ci.org/hakanensari/vacuum.png
41
- [3]: http://travis-ci.org/hakanensari/vacuum
39
+ [1]: https://secure.travis-ci.org/hakanensari/vacuum.png
40
+ [2]: http://travis-ci.org/hakanensari/vacuum
41
+ [3]: http://f.cl.ly/items/2k2X0e2u0G3k1c260D2u/vacuum.png
42
42
  [4]: https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html
43
43
  [5]: https://github.com/hakanensari/vacuum/blob/master/examples/
data/lib/vacuum.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require 'forwardable'
2
2
  require 'net/http'
3
- require 'nokogiri'
4
3
  require 'openssl'
5
4
  require 'time'
6
5
 
7
- %w{hash_builder request response}.each do |f|
6
+ require 'knack'
7
+ require 'nokogiri'
8
+
9
+ %w{request response}.each do |f|
8
10
  require "vacuum/#{f}"
9
11
  end
10
12
 
@@ -35,7 +35,7 @@ module Vacuum
35
35
  #
36
36
  def find(query)
37
37
  xml.xpath("//xmlns:#{query}").map do |node|
38
- hsh = HashBuilder.from_xml node
38
+ hsh = Knack.from_xml node
39
39
  block_given? ? yield(hsh) : hsh
40
40
  end
41
41
  end
@@ -47,7 +47,7 @@ module Vacuum
47
47
 
48
48
  # @return [Hash] A hash representation of the entire response.
49
49
  def to_hash
50
- HashBuilder.from_xml xml
50
+ Knack.from_xml xml
51
51
  end
52
52
 
53
53
  # @return [true, false] Whether the HTTP response is OK
@@ -1,3 +1,3 @@
1
1
  module Vacuum
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vacuum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,9 +11,20 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: knack
16
+ requirement: &70284811596620 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70284811596620
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: nokogiri
16
- requirement: &70211676691980 !ruby/object:Gem::Requirement
27
+ requirement: &70284811596020 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
@@ -21,7 +32,7 @@ dependencies:
21
32
  version: '1.4'
22
33
  type: :runtime
23
34
  prerelease: false
24
- version_requirements: *70211676691980
35
+ version_requirements: *70284811596020
25
36
  description: Vacuum is a Ruby wrapper to the Amazon Product Advertising API.
26
37
  email:
27
38
  - hakan.ensari@papercavalier.com
@@ -30,7 +41,6 @@ extensions: []
30
41
  extra_rdoc_files: []
31
42
  files:
32
43
  - lib/vacuum/em.rb
33
- - lib/vacuum/hash_builder.rb
34
44
  - lib/vacuum/request.rb
35
45
  - lib/vacuum/response.rb
36
46
  - lib/vacuum/version.rb
@@ -39,7 +49,6 @@ files:
39
49
  - README.md
40
50
  - spec/fixtures/http_response
41
51
  - spec/spec_helper.rb
42
- - spec/vacuum/hash_builder_spec.rb
43
52
  - spec/vacuum/request_spec.rb
44
53
  - spec/vacuum/response_spec.rb
45
54
  homepage: http://github.com/hakanensari/vacuum
@@ -69,6 +78,6 @@ summary: A Ruby wrapper to the Amazon Product Advertising API
69
78
  test_files:
70
79
  - spec/fixtures/http_response
71
80
  - spec/spec_helper.rb
72
- - spec/vacuum/hash_builder_spec.rb
73
81
  - spec/vacuum/request_spec.rb
74
82
  - spec/vacuum/response_spec.rb
83
+ has_rdoc:
@@ -1,45 +0,0 @@
1
- module Vacuum
2
- module HashBuilder
3
- # Builds a hash from a Nokogiri XML document.
4
- #
5
- # @param [Nokogiri::XML::Document] xml An XML document
6
- # @return [Hash]
7
- def self.from_xml(xml)
8
- case xml
9
- when Nokogiri::XML::Document
10
- from_xml(xml.root)
11
- when Nokogiri::XML::Element
12
- hsh = {}
13
-
14
- xml.attributes.each_pair do |key, attribute|
15
- hsh[key] = attribute.value
16
- end
17
-
18
- xml.children.each do |child|
19
- result = from_xml(child)
20
-
21
- if child.name == 'text'
22
- if hsh.empty?
23
- return result
24
- else
25
- hsh['__content__'] = result
26
- end
27
- elsif hsh[child.name]
28
- case hsh[child.name]
29
- when Array
30
- hsh[child.name] << result
31
- else
32
- hsh[child.name] = [hsh[child.name]] << result
33
- end
34
- else
35
- hsh[child.name] = result
36
- end
37
- end
38
-
39
- hsh
40
- else
41
- xml.content.to_s
42
- end
43
- end
44
- end
45
- end
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Vacuum
4
- describe HashBuilder do
5
- let(:xml) do
6
- xml = <<-XML.gsub!(/>\s+</, '><').strip!
7
- <?xml version=\"1.0\" ?>
8
- <ItemAttributes>
9
- <Title>Anti-Oedipus</Title>
10
- <Author>Gilles Deleuze</Author>
11
- <Author>Felix Guattari</Author>
12
- <Creator Role="Translator">Robert Hurley</Creator>
13
- </ItemAttributes>
14
- XML
15
- Nokogiri::XML(xml)
16
- end
17
-
18
- describe '.from_xml' do
19
- it 'returns a hash' do
20
- HashBuilder.from_xml(xml).should be_an_instance_of Hash
21
- end
22
-
23
- it 'handles only childs' do
24
- HashBuilder.from_xml(xml)['Title'].should eql 'Anti-Oedipus'
25
- end
26
-
27
- it 'handles arrays' do
28
- HashBuilder.from_xml(xml)['Author'].should be_a Array
29
- end
30
-
31
- it 'handles attributes' do
32
- node = HashBuilder.from_xml(xml)['Creator']
33
- node['Role'].should eql 'Translator'
34
- node['__content__'].should eql 'Robert Hurley'
35
- end
36
- end
37
- end
38
- end