rbwowhead 0.0.1 → 0.0.2

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.
@@ -0,0 +1,18 @@
1
+ module Rbwowhead
2
+ class Item
3
+ attr_reader :name, :ilevel, :gear_score
4
+ def initialize(data)
5
+ @data = data
6
+ @name = value_for_node('name')
7
+ @ilevel = value_for_node('level')
8
+ @gear_score = value_for_node('gearScore')
9
+ end
10
+
11
+ private
12
+ def value_for_node(node_name)
13
+ @data.xpath("//#{node_name}")[0].children[0].content
14
+ end
15
+
16
+
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Rbwowhead
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/rbwowhead.rb CHANGED
@@ -1,3 +1,35 @@
1
+ require 'net/http'
2
+ require 'nokogiri'
3
+
4
+ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+
7
+ require 'rbwowhead/item.rb'
8
+
1
9
  module Rbwowhead
2
- # Your code goes here...
10
+ class WowheadApi
11
+
12
+ def get_item(item_id)
13
+ item_url = "http://www.wowhead.com/item=#{item_id}&xml"
14
+ xml = Nokogiri::XML(http_request(item_url))
15
+
16
+ # Initialize a new Item with the XML Data
17
+ Rbwowhead::Item.new(xml)
18
+ end
19
+
20
+ def http_request(url)
21
+ req = Net::HTTP::Get.new(url)
22
+ req["user-agent"] = 'Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.2'
23
+
24
+ uri = URI.parse(URI.escape(url))
25
+
26
+ http = Net::HTTP.new(uri.host, uri.port)
27
+
28
+ http.start do
29
+ res = http.request req
30
+ res.body
31
+ end
32
+ end
33
+ end
3
34
  end
35
+
data/rbwowhead.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Francesco Ceccon"]
9
9
  s.email = ["francesco.cek@me.com"]
10
10
  s.homepage = "http://rubygems.org/gems/rbwowhead"
11
- s.summary = "Wowhead gem"
12
- s.description = "You can search items on Wowhead"
11
+ s.summary = "Gem to search items on Wowhead"
12
+ s.description = "Gem to search items on Wowhead"
13
13
 
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
  s.rubyforge_project = "rbwowhead"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbwowhead
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Francesco Ceccon
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: 1.0.0
35
35
  type: :development
36
36
  version_requirements: *id001
37
- description: You can search items on Wowhead
37
+ description: Gem to search items on Wowhead
38
38
  email:
39
39
  - francesco.cek@me.com
40
40
  executables: []
@@ -49,6 +49,7 @@ files:
49
49
  - README.mdown
50
50
  - Rakefile
51
51
  - lib/rbwowhead.rb
52
+ - lib/rbwowhead/item.rb
52
53
  - lib/rbwowhead/version.rb
53
54
  - rbwowhead.gemspec
54
55
  has_rdoc: true
@@ -86,6 +87,6 @@ rubyforge_project: rbwowhead
86
87
  rubygems_version: 1.3.7
87
88
  signing_key:
88
89
  specification_version: 3
89
- summary: Wowhead gem
90
+ summary: Gem to search items on Wowhead
90
91
  test_files: []
91
92