wowecon 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ require 'wowecon/currency_helpers.rb'
4
4
  require 'wowecon/currency.rb'
5
5
 
6
6
  module Wowecon
7
- VERSION = '0.2.4'
7
+ VERSION = '0.2.5'
8
8
 
9
9
  def self.price(item_name, opts={})
10
10
  request_url = "http://data.wowecon.com/?type=price&item_name=#{uri_escape(item_name)}"
@@ -21,22 +21,17 @@ module Wowecon
21
21
  def to_s
22
22
  output = ""
23
23
  self.to_hash.each do |denom, value|
24
- if value > 0 || output.length > 0
24
+ if value > 0 || output.length > 0 || denom == :copper
25
25
  output += "#{value.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")}#{denom.to_s[0,1]} "
26
26
  end
27
27
  end
28
-
29
- if output == ""
30
- ""
31
- else
32
- output.strip
33
- end
28
+ output.strip
34
29
  end
35
30
 
36
31
  def to_html
37
32
  tags = ""
38
33
  self.to_hash.each do |denom, value|
39
- if value > 0 || tags.length > 0
34
+ if value > 0 || tags.length > 0 || denom == :copper
40
35
  tags += "<var class=\"#{denom.to_s}\">#{value.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")}</var>"
41
36
  end
42
37
  end
@@ -27,6 +27,11 @@ describe Wowecon::Currency do
27
27
  @nilcurrency.should be_nil
28
28
  end
29
29
 
30
+ it "returns a currency with a value of zero if initialised with 0" do
31
+ zero = Wowecon::Currency.new(0)
32
+ zero.class.should == Wowecon::Currency and zero.to_s.should == "0c"
33
+ end
34
+
30
35
  describe "for a given valid currency" do
31
36
  before do
32
37
  @currency = Wowecon::Currency.new({:gold => 1420, :silver => 9, :copper => 10})
@@ -24,9 +24,9 @@ describe Wowecon do
24
24
 
25
25
  # use http://data.wowecon.com/?type=price&item_name=Rock%20Furrow%20Boots to confirm
26
26
  describe "With known market data" do
27
- it "should return a value of 60000000 for this item" do
27
+ it "should return a value of 25000000 for this item" do
28
28
  price = Wowecon.price("Rock Furrow Boots")
29
- price.should == {:value => 60000000}
29
+ price.should == {:value => 25000000}
30
30
  end
31
31
  end
32
32
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wowecon
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.4
5
+ version: 0.2.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Darlow
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-16 00:00:00 +01:00
13
+ date: 2011-07-27 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency