rubyoverflow 1.0.2 → 2.0.2.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.gitignore +5 -0
  2. data/.rvmrc +47 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +2 -0
  5. data/LICENSE +1 -1
  6. data/README.rdoc +14 -20
  7. data/RELEASENOTES +1 -97
  8. data/Rakefile +7 -49
  9. data/lib/rubyoverflow.rb +46 -108
  10. data/lib/rubyoverflow/answers.rb +5 -57
  11. data/lib/rubyoverflow/base.rb +21 -68
  12. data/lib/rubyoverflow/questions.rb +5 -101
  13. data/lib/rubyoverflow/sites.rb +18 -0
  14. data/lib/rubyoverflow/stats.rb +8 -0
  15. data/lib/rubyoverflow/users.rb +5 -70
  16. data/lib/rubyoverflow/version.rb +3 -0
  17. data/rubyoverflow.gemspec +26 -0
  18. data/spec/answers_spec.rb +13 -0
  19. data/spec/questions_spec.rb +13 -0
  20. data/spec/sites_spec.rb +18 -0
  21. data/spec/spec_helper.rb +3 -0
  22. data/spec/stats_spec.rb +12 -0
  23. data/spec/users_spec.rb +23 -0
  24. metadata +94 -121
  25. data/VERSION +0 -1
  26. data/lib/rubyoverflow/answer.rb +0 -61
  27. data/lib/rubyoverflow/apiSite.rb +0 -32
  28. data/lib/rubyoverflow/apiSites.rb +0 -25
  29. data/lib/rubyoverflow/apiVersion.rb +0 -6
  30. data/lib/rubyoverflow/badge.rb +0 -44
  31. data/lib/rubyoverflow/badgeCounts.rb +0 -22
  32. data/lib/rubyoverflow/badges.rb +0 -59
  33. data/lib/rubyoverflow/comment.rb +0 -41
  34. data/lib/rubyoverflow/comments.rb +0 -115
  35. data/lib/rubyoverflow/errors.rb +0 -17
  36. data/lib/rubyoverflow/pagedBase.rb +0 -27
  37. data/lib/rubyoverflow/pagedDash.rb +0 -7
  38. data/lib/rubyoverflow/postTimelineEvent.rb +0 -93
  39. data/lib/rubyoverflow/postTimelineEvents.rb +0 -39
  40. data/lib/rubyoverflow/question.rb +0 -110
  41. data/lib/rubyoverflow/repChange.rb +0 -34
  42. data/lib/rubyoverflow/repChanges.rb +0 -41
  43. data/lib/rubyoverflow/revision.rb +0 -62
  44. data/lib/rubyoverflow/revisions.rb +0 -52
  45. data/lib/rubyoverflow/statistics.rb +0 -57
  46. data/lib/rubyoverflow/styling.rb +0 -19
  47. data/lib/rubyoverflow/tag.rb +0 -27
  48. data/lib/rubyoverflow/tags.rb +0 -46
  49. data/lib/rubyoverflow/user.rb +0 -181
  50. data/lib/rubyoverflow/userTimelineEvent.rb +0 -43
  51. data/lib/rubyoverflow/userTimelineEvents.rb +0 -35
  52. data/test/apiKey.rb +0 -5
  53. data/test/helper.rb +0 -159
  54. data/test/test_answer.rb +0 -20
  55. data/test/test_answers.rb +0 -32
  56. data/test/test_badge.rb +0 -18
  57. data/test/test_badges.rb +0 -30
  58. data/test/test_base.rb +0 -63
  59. data/test/test_statistics.rb +0 -26
  60. data/test/test_user.rb +0 -56
  61. data/test/test_users.rb +0 -37
@@ -1,43 +0,0 @@
1
- module Rubyoverflow
2
- class UserTimelineEvent
3
- attr_reader :user_id
4
- attr_reader :timeline_type
5
- attr_reader :post_id
6
- attr_reader :post_type
7
- attr_reader :comment_id
8
- attr_reader :action
9
- attr_reader :creation_date
10
- attr_reader :description
11
- attr_reader :detail
12
-
13
- def initialize(hash, request_path = '')
14
- dash = UserTimelineEventDash.new hash
15
-
16
- @user_id = dash.user_id
17
- @timeline_type = dash.timeline_type
18
- @post_id = dash.post_id
19
- @post_type = dash.post_type
20
- @comment_id = dash.comment_id
21
- @action = dash.action
22
- @creation_date = dash.creation_date
23
- @description = dash.description
24
- @detail = dash.detail
25
- end
26
-
27
-
28
- end
29
-
30
- class UserTimelineEventDash < BaseDash
31
-
32
- property :user_id
33
- property :timeline_type
34
- property :post_id
35
- property :post_type
36
- property :comment_id
37
- property :action
38
- property :creation_date
39
- property :description
40
- property :detail
41
-
42
- end
43
- end
@@ -1,35 +0,0 @@
1
- module Rubyoverflow
2
- class UserTimelineEvents < PagedBase
3
- attr_reader :user_timelines
4
- def initialize(hash, request_path = '')
5
- dash = UserTimelineEventsDash.new hash
6
- super(dash, request_path)
7
- @user_timelines = Array.new
8
- dash.user_timelines.each{|timelineHash| @user_timelines.push(UserTimelineEvent.new timelineHash)}
9
- end
10
-
11
- #Retrieves the next set of UserTimelineEvents using the same parameters used to retrieve the current set
12
- def get_next_set
13
- hash,url = perform_next_page_request
14
- UserTimelineEvents.new hash,url
15
- end
16
-
17
- class << self
18
- #Retrieves a set of timeline events for a set of user(s) by their id(s)
19
- #
20
- #id can be an int, string or an array of ints or strings
21
- #
22
- #Maps to 'users/{id}/timeline
23
- def retrieve_by_user(id, parameters = {})
24
- id = convert_to_id_list(id)
25
- hash, url = request('users/' + id.to_s + '/timeline',parameters)
26
- UserTimelineEvents.new hash, url
27
- end
28
-
29
- end
30
- end
31
-
32
- class UserTimelineEventsDash < PagedDash
33
- property :user_timelines
34
- end
35
- end
@@ -1,5 +0,0 @@
1
- class ApiKey
2
- def self.api_key
3
- 'WiNylIPGTkm4DrBH2yYZ3g'
4
- end
5
- end
@@ -1,159 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'spec'
4
- require 'apikey'
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'rubyoverflow'
8
- include Rubyoverflow
9
-
10
- class Test::Unit::TestCase
11
- end
12
- def set_api_key
13
- Rubyoverflow::Client.config do |options|
14
- options.api_key = ApiKey.api_key
15
- end
16
- end
17
- def check_paged_class(paged_class, page_size)
18
- paged_class.should respond_to(:total)
19
- paged_class.should respond_to(:pagesize)
20
- paged_class.should respond_to(:page)
21
- paged_class.should respond_to(:request_path)
22
- paged_class.should respond_to(:query_parameters)
23
- paged_class.pagesize.should == page_size
24
- end
25
-
26
- def single_item_set
27
- {:pagesize => 1}
28
- end
29
-
30
- def check_user_set(users, page_size = 1)
31
- check_paged_class(users, page_size)
32
- users.should respond_to(:users)
33
- check_user users.users.first
34
- end
35
-
36
- def check_answer_set(answers, page_size = 1)
37
- check_paged_class(answers, page_size)
38
- answers.should respond_to(:answers)
39
- check_answer answers.answers.first
40
- end
41
-
42
- def check_api_site_set(api_sites, page_size = 1)
43
- check_paged_class(api_sites, page_size)
44
- api_sites.should respond_to(:api_sites)
45
- #check_api_site api_sites.api_sites.first
46
- end
47
-
48
- def check_badge_set(badges)
49
- badges.should respond_to(:badges)
50
- check_badge badges.badges.first
51
- end
52
-
53
- def check_comment_set(comments, page_size = 1)
54
- check_paged_class(comments, page_size)
55
- comments.should respond_to(:comments)
56
- #check_comment comments.comments.first
57
- end
58
-
59
- def check_post_timeline_event_set(post_timeline_events, page_size = 1)
60
- check_paged_class(post_timeline_events, page_size)
61
- post_timeline_events.should respond_to(:post_timelines)
62
- #check_post_timeline_event post_timeline_events.post_timelines.first
63
- end
64
-
65
- def check_rep_change_set(rep_changes, page_size = 1)
66
- check_paged_class(rep_changes, page_size)
67
- rep_changes.should respond_to(:rep_changes)
68
- #check_rep_change rep_changes.rep_changes.first
69
- end
70
-
71
- def check_revision_set(revisions, page_size = 1)
72
- check_paged_class(revisions, page_size)
73
- revisions.should respond_to(:revisions)
74
- #check_revision revisions.revisions.first
75
- end
76
-
77
- def check_tag_set(tags, page_size = 1)
78
- check_paged_class(tags, page_size)
79
- tags.should respond_to(:tags)
80
- #check_tag tags.tags.first
81
- end
82
-
83
- def check_user_timeline_event_set(user_timeline_events, page_size = 1)
84
- check_paged_class(user_timeline_events, page_size)
85
- user_timeline_events.should respond_to(:user_timelines)
86
- #check_user_timeline_event user_timeline_events.user_timelines.first
87
- end
88
-
89
- def check_question_set(questions, page_size = 1)
90
- check_paged_class(questions, page_size)
91
- questions.should respond_to(:questions)
92
- #check_question questions.questions.first
93
- end
94
-
95
- def check_answer(answer)
96
- answer.should respond_to(:answer_id)
97
- answer.should respond_to(:accepted)
98
- answer.should respond_to(:answer_comments_url)
99
- answer.should respond_to(:question_id)
100
- answer.should respond_to(:locked_date)
101
- answer.should respond_to(:owner)
102
- answer.should respond_to(:creation_date)
103
- answer.should respond_to(:last_edit_date)
104
- answer.should respond_to(:last_activity_date)
105
- answer.should respond_to(:up_vote_count)
106
- answer.should respond_to(:down_vote_count)
107
- answer.should respond_to(:view_count)
108
- answer.should respond_to(:score)
109
- answer.should respond_to(:community_owned)
110
- answer.should respond_to(:title)
111
- answer.should respond_to(:body)
112
- answer.should respond_to(:comments)
113
- end
114
-
115
-
116
- def check_badge(badge)
117
- badge.should respond_to(:badge_id)
118
- badge.should respond_to(:rank)
119
- badge.should respond_to(:name)
120
- badge.should respond_to(:description)
121
- badge.should respond_to(:award_count)
122
- badge.should respond_to(:tag_based)
123
- badge.should respond_to(:user)
124
- badge.should respond_to(:badges_recipients_url)
125
- end
126
-
127
-
128
- def check_user(user)
129
- user.should respond_to(:user_id)
130
- user.should respond_to(:user_type)
131
- user.should respond_to(:creation_date)
132
- user.should respond_to(:display_name)
133
- user.should respond_to(:reputation)
134
- user.should respond_to(:email_hash)
135
- user.should respond_to(:age)
136
- user.should respond_to(:last_access_date)
137
- user.should respond_to(:website_url)
138
- user.should respond_to(:location)
139
- user.should respond_to(:about_me)
140
- user.should respond_to(:question_count)
141
- user.should respond_to(:answer_count)
142
- user.should respond_to(:view_count)
143
- user.should respond_to(:up_vote_count)
144
- user.should respond_to(:down_vote_count)
145
- user.should respond_to(:accept_rate)
146
- user.should respond_to(:user_questions_url)
147
- user.should respond_to(:user_answers_url)
148
- user.should respond_to(:user_favorites_url)
149
- user.should respond_to(:user_tags_url)
150
- user.should respond_to(:user_badges_url)
151
- user.should respond_to(:user_timeline_url)
152
- user.should respond_to(:user_mentioned_url)
153
- user.should respond_to(:user_comments_url)
154
- user.should respond_to(:user_reputation_url)
155
- user.should respond_to(:badge_counts)
156
- user.should respond_to(:timed_penalty_date)
157
- user.should respond_to(:association_id)
158
- user.should respond_to(:on_site)
159
- end
@@ -1,20 +0,0 @@
1
- require 'helper'
2
-
3
- class TestAnswer < Test::Unit::TestCase
4
- describe Answer do
5
- before(:all) do
6
- #@user = Users.retrieve_by_id(53587, single_item_set).users.first
7
- @answer = Answers.retrieve_by_id(952594, single_item_set).answers.first
8
- set_api_key
9
- end
10
-
11
- it "check answer" do
12
- check_answer @answer
13
- end
14
-
15
- it "get_comments" do
16
- check_comment_set @answer.get_comments single_item_set
17
- end
18
-
19
- end
20
- end
@@ -1,32 +0,0 @@
1
- require 'helper'
2
-
3
- class TestAnswers < Test::Unit::TestCase
4
- describe Answers do
5
- before(:all) do
6
- set_api_key
7
- end
8
-
9
- it "retrieve_by_id" do
10
- answers = Answers.retrieve_by_id 952594, single_item_set
11
- check_answer_set answers
12
- end
13
-
14
- it "retrieve_by_user" do
15
- answers = Answers.retrieve_by_user 53587, single_item_set
16
- check_answer_set answers
17
- end
18
-
19
- it "retrieve_by_question" do
20
- answers = Answers.retrieve_by_question 1104543, single_item_set
21
- check_answer_set answers
22
- end
23
-
24
- it "get_next_set" do
25
- answers = Answers.retrieve_by_question 1104543, single_item_set
26
- answers = answers.get_next_set
27
- check_answer_set answers
28
- answers.page.should == 2
29
- end
30
-
31
- end
32
- end
@@ -1,18 +0,0 @@
1
- require 'helper'
2
-
3
- class TestBadge < Test::Unit::TestCase
4
- describe Badge do
5
- before(:all) do
6
- @badge = Badges.retrieve_all.badges.first
7
- set_api_key
8
- end
9
-
10
- it 'check badge' do
11
- check_badge @badge
12
- end
13
-
14
- it 'get_recipients' do
15
- check_user_set @badge.get_recipients(single_item_set)
16
- end
17
- end
18
- end
@@ -1,30 +0,0 @@
1
- require 'helper'
2
-
3
- class TestBadges < Test::Unit::TestCase
4
- describe Badges do
5
- before(:all) do
6
- @users = Users.retrieve_all
7
- set_api_key
8
- end
9
-
10
- it 'retrieve_all' do
11
- badges = Badges.retrieve_all
12
- check_badge_set badges
13
- end
14
-
15
- it 'retrieve_all_non_tag_based' do
16
- badges = Badges.retrieve_all_non_tag_based
17
- check_badge_set badges
18
- end
19
-
20
- it 'retrieve_all_tag_based' do
21
- badges = Badges.retrieve_all_tag_based
22
- check_badge_set badges
23
- end
24
-
25
- it 'retrieve_by_user' do
26
- badges = Badges.retrieve_by_user @users.users.first.user_id
27
- check_badge_set badges
28
- end
29
- end
30
- end
@@ -1,63 +0,0 @@
1
- require 'helper'
2
-
3
- class TestBase < Test::Unit::TestCase
4
- describe Base do
5
-
6
- it 'find_parse_querystring' do
7
- base = Base.new
8
- testVal = 'http://api.stackoverflow.com/1.0/users/?order=asc&page=2'
9
- url,queryHash = base.find_parse_querystring testVal
10
- url.should == 'users/'
11
- queryHash.should == {'order'=>'asc','page'=>'2'}
12
- end
13
-
14
- it 'convert_to_id_list int' do
15
- Base.convert_to_id_list(1).should == '1'
16
- end
17
-
18
- it 'convert_to_id_list string' do
19
- Base.convert_to_id_list('1').should == '1'
20
- end
21
-
22
- it 'convert_to_id_list item' do
23
- item = Item.new 1
24
-
25
- Base.convert_to_id_list(item).should == '1'
26
- end
27
-
28
- it 'convert_to_id_list int[]' do
29
- Base.convert_to_id_list([1,2,3]).should == '1;2;3'
30
- end
31
-
32
- it 'convert_to_id_list string[]' do
33
- Base.convert_to_id_list(['1','2','3']).should == '1;2;3'
34
- end
35
-
36
- it 'convert_to_id_list item[]' do
37
- item1 = Item.new 1
38
- item2 = Item.new 2
39
- item3 = Item.new 3
40
-
41
- Base.convert_to_id_list([item1,item2,item3]).should == '1;2;3'
42
- end
43
-
44
- it 'convert_to_id_list mixed[]' do
45
- item3 = Item.new 3
46
- Base.convert_to_id_list([1,'2',item3]).should == '1;2;3'
47
- end
48
-
49
- end
50
- end
51
-
52
- class Item
53
- attr_reader :val
54
-
55
- def initialize(id)
56
- @val = id
57
- end
58
-
59
- def item_id
60
- @val
61
- end
62
-
63
- end
@@ -1,26 +0,0 @@
1
- require 'helper'
2
-
3
- class TestStatistics < Test::Unit::TestCase
4
- describe "Statistics" do
5
- before(:all) do
6
- set_api_key
7
- end
8
- it "retrieve stats" do
9
- stats = Statistics.retrieve
10
- stats.should respond_to(:total_badges)
11
- stats.should respond_to(:total_unanswered)
12
- stats.should respond_to(:total_votes)
13
- stats.should respond_to(:total_comments)
14
- stats.should respond_to(:total_answers)
15
- stats.should respond_to(:site)
16
- stats.should respond_to(:total_users)
17
- stats.should respond_to(:questions_per_minute)
18
- stats.should respond_to(:answers_per_minute)
19
- stats.should respond_to(:badges_per_minute)
20
- stats.should respond_to(:views_per_day)
21
- stats.should respond_to(:api_version)
22
- stats.should respond_to(:total_accepted)
23
- end
24
-
25
- end
26
- end
@@ -1,56 +0,0 @@
1
- require 'helper'
2
-
3
- class TestUser < Test::Unit::TestCase
4
- describe User do
5
- before(:all) do
6
- @user = Users.retrieve_by_id(53587, single_item_set).users.first
7
- set_api_key
8
- end
9
-
10
- it 'check user' do
11
- check_user @user
12
- end
13
-
14
- it 'get_questions' do
15
- check_question_set @user.get_questions(single_item_set)
16
- end
17
-
18
- it 'get_answers' do
19
- check_answer_set @user.get_answers(single_item_set)
20
- end
21
-
22
- it 'get_favorites' do
23
- check_question_set @user.get_favorites(single_item_set)
24
- end
25
-
26
- it 'get_tags' do
27
- check_tag_set @user.get_tags(single_item_set)
28
- end
29
-
30
- it 'get_badges' do
31
- check_badge_set @user.get_badges
32
- end
33
-
34
- it 'get_timeline' do
35
- check_user_timeline_event_set @user.get_timeline(single_item_set)
36
- end
37
-
38
- it 'get_mentioned' do
39
- check_comment_set @user.get_mentioned(single_item_set)
40
- end
41
-
42
- it 'get_comments' do
43
- check_comment_set @user.get_comments(single_item_set)
44
- end
45
-
46
- it 'get_reputation' do
47
- check_rep_change_set @user.get_reputation(single_item_set)
48
- end
49
-
50
- it 'retrieve_associated_accounts' do
51
- #users = @user.retrieve_associated_accounts
52
- #users.should respond_to(:users)
53
- #check_user users.users.first
54
- end
55
- end
56
- end