Skip to content

Commit

Permalink
added support for /tags
Browse files Browse the repository at this point in the history
  • Loading branch information
dalto curvelano jr committed Jun 3, 2010
1 parent b5f3454 commit c55e25f
Show file tree
Hide file tree
Showing 7 changed files with 690 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/pilha.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require 'forwardable'

require 'pilha/stack_overflow/base'
require 'pilha/stack_overflow/tag'
require 'pilha/stack_overflow/user'
require 'pilha/stack_overflow/badge'
require 'pilha/stack_overflow/answer'
Expand Down Expand Up @@ -49,7 +50,7 @@ def initialize(options = OpenStruct.new)

def api_method_path(pattern, options = {})
pattern = normalize(pattern)
parts = pattern.split('/').select { |part| part =~ /^:/ }
parts = pattern.split('/').select { |part| part =~ /^:/ }

parts.each do |part|
key = part.sub(':', '').intern
Expand Down
25 changes: 25 additions & 0 deletions lib/pilha/stack_overflow/tag.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module StackExchange
module StackOverflow
class Tag < Base
extend Forwardable

def_delegators :@struct, :name, :count

class << self
def all(options = {})
request('/tags', nil, options)
end


def parse(response)
parse_with_class(response, 'tags', Tag)
OpenStruct.new response
end
end

def initialize(hash)
@struct = OpenStruct.new hash
end
end
end
end
287 changes: 287 additions & 0 deletions spec/fixtures/all_tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
{
"total": 29199,
"page": 1,
"pagesize": 70,
"tags": [
{
"name": "c#",
"count": 84875
},
{
"name": "java",
"count": 50661
},
{
"name": ".net",
"count": 42982
},
{
"name": "php",
"count": 42359
},
{
"name": "asp.net",
"count": 38560
},
{
"name": "javascript",
"count": 37024
},
{
"name": "c++",
"count": 31709
},
{
"name": "jquery",
"count": 29607
},
{
"name": "iphone",
"count": 26442
},
{
"name": "python",
"count": 25583
},
{
"name": "sql",
"count": 20885
},
{
"name": "mysql",
"count": 18581
},
{
"name": "html",
"count": 17460
},
{
"name": "sql-server",
"count": 15911
},
{
"name": "ruby-on-rails",
"count": 14369
},
{
"name": "c",
"count": 13986
},
{
"name": "asp.net-mvc",
"count": 13154
},
{
"name": "css",
"count": 13126
},
{
"name": "wpf",
"count": 13074
},
{
"name": "objective-c",
"count": 12652
},
{
"name": "windows",
"count": 10966
},
{
"name": "xml",
"count": 10172
},
{
"name": "ruby",
"count": 10157
},
{
"name": "database",
"count": 9314
},
{
"name": "best-practices",
"count": 9280
},
{
"name": "android",
"count": 9129
},
{
"name": "vb.net",
"count": 8826
},
{
"name": "visual-studio",
"count": 8564
},
{
"name": "ajax",
"count": 8168
},
{
"name": "winforms",
"count": 8154
},
{
"name": "regex",
"count": 8120
},
{
"name": "linux",
"count": 8031
},
{
"name": "django",
"count": 7724
},
{
"name": "iphone-sdk",
"count": 7322
},
{
"name": "visual-studio-2008",
"count": 6996
},
{
"name": "beginner",
"count": 6687
},
{
"name": "web-development",
"count": 6485
},
{
"name": "flex",
"count": 6404
},
{
"name": "subjective",
"count": 6229
},
{
"name": "flash",
"count": 6086
},
{
"name": "linq",
"count": 5998
},
{
"name": "wcf",
"count": 5865
},
{
"name": "silverlight",
"count": 5761
},
{
"name": "cocoa",
"count": 5659
},
{
"name": "actionscript-3",
"count": 5359
},
{
"name": "sql-server-2005",
"count": 5329
},
{
"name": "cocoa-touch",
"count": 5257
},
{
"name": "performance",
"count": 5236
},
{
"name": "algorithm",
"count": 5142
},
{
"name": "perl",
"count": 5081
},
{
"name": "eclipse",
"count": 5072
},
{
"name": "oracle",
"count": 5045
},
{
"name": "web-services",
"count": 4859
},
{
"name": "security",
"count": 4848
},
{
"name": "svn",
"count": 4837
},
{
"name": "delphi",
"count": 4778
},
{
"name": "multithreading",
"count": 4762
},
{
"name": "sharepoint",
"count": 4760
},
{
"name": "arrays",
"count": 4395
},
{
"name": "unit-testing",
"count": 4292
},
{
"name": "nhibernate",
"count": 4216
},
{
"name": "linq-to-sql",
"count": 4171
},
{
"name": "tsql",
"count": 4031
},
{
"name": "apache",
"count": 3882
},
{
"name": "string",
"count": 3790
},
{
"name": "homework",
"count": 3664
},
{
"name": "excel",
"count": 3629
},
{
"name": "design",
"count": 3506
},
{
"name": "xcode",
"count": 3472
},
{
"name": "mvc",
"count": 3427
}
]
}
Binary file added spec/fixtures/all_tags.json.gz
Binary file not shown.
Loading

0 comments on commit c55e25f

Please sign in to comment.