add red test
impl get_top_selling_free_apps_in_category
refactor: use custom matcher
add red tests
impl methods
refactor
impl: get apps in ranking page. close #3

Merge branch 'issues/3'
add red test
impl get_content
add red test
[from now] 2013/02/19 14:31:13

diff --git a/lib/android_market_api/android_market_application.rb b/lib/android_market_api/android_market_application.rb
index 2be7fcd..3ebbb21 100755
--- a/lib/android_market_api/android_market_application.rb
+++ b/lib/android_market_api/android_market_application.rb
@@ -74,7 +74,7 @@ class AndroidMarketApplication

     url="https://play.google.com/store/apps/details?id="+@package+"&hl="+language
     puts "Getting URL="+url if @@debug == 1
-    doc = Hpricot(open(url,'User-Agent' => 'ruby'))
+    doc = Hpricot(get_content(url,'User-Agent' => 'ruby'))
     fill_current_version(doc.root)
     fill_rating_value(doc.root)
     fill_rating_count(doc.root)
diff --git a/lib/android_market_api/util.rb b/lib/android_market_api/util.rb
index c35d4bc..aa0dd0b 100644
--- a/lib/android_market_api/util.rb
+++ b/lib/android_market_api/util.rb
@@ -3,6 +3,7 @@ require 'net/http'

 module AndroidMarketApi
   module Util
+
     # remove html tags
     # <br> -> \n
     def sanitize(str)
@@ -13,12 +14,14 @@ module AndroidMarketApi

     module_function :sanitize

-    def get_content(uri)
+    def get_content(uri, headers = {})
       url = URI.parse(uri)
-      req = Net::HTTP::Get.new(url.path)
+      req = Net::HTTP::Get.new(uri)
+      headers.each do |name, value|
+        req[name] = value
+      end
       res = Net::HTTP.start(url.host, url.port) {|http|
-        args = [Net::HTTP::Get.new(uri)]
-        http.request(*args)
+        http.request(req)
       }
       res.body
     end
apply
modify test param
add response code check
use memorize
don't use open-uri : close #1

Merge branch 'issues/1'