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,22 +0,0 @@
1
- module Rubyoverflow
2
- class BadgeCounts
3
-
4
- attr_reader :gold
5
- attr_reader :silver
6
- attr_reader :bronze
7
-
8
- def initialize(hash, request_path = '')
9
- dash = BadgeCountsDash.new hash
10
- @gold = dash.gold
11
- @silver = dash.silver
12
- @bronze = dash.bronze
13
- end
14
-
15
- end
16
-
17
- class BadgeCountsDash < BaseDash
18
- property :gold
19
- property :silver
20
- property :bronze
21
- end
22
- end
@@ -1,59 +0,0 @@
1
- module Rubyoverflow
2
- class Badges < PagedBase
3
-
4
- attr_reader :badges
5
-
6
- def initialize(hash, request_path = '')
7
- dash = BadgesDash.new hash
8
-
9
- @badges = Array.new
10
- dash.badges.each{ |badgeHash| @badges.push(Badge.new badgeHash)}
11
-
12
- super(dash, request_path)
13
- end
14
-
15
- class <<self
16
- #Retrieves all badges in alphabetical order
17
- #
18
- #Maps to '/badges'
19
- def retrieve_all
20
- hash, url = request('badges')
21
- Badges.new hash, url
22
- end
23
-
24
- #Retrieves all standard, non-tag-based badges in alphabetical order
25
- #
26
- #Maps to '/badges/name'
27
- def retrieve_all_non_tag_based
28
- hash, url = request('badges/name')
29
- Badges.new hash, url
30
- end
31
-
32
- #Retrieves all tag-based badges in alphabetical order
33
- #
34
- #Maps to '/badges/tags'
35
- def retrieve_all_tag_based
36
- hash, url = request('badges/tags')
37
- Badges.new hash, url
38
- end
39
-
40
- #Retrieves all badges that have been awarded to a set of users by their id(s)
41
- #
42
- #id can be an int, string or an array of ints or strings
43
- #
44
- #Maps to '/users/{id}/badges'
45
- def retrieve_by_user(id)
46
- id = convert_to_id_list(id)
47
-
48
- hash, url = request('users/'+id.to_s+'/badges')
49
- Badges.new hash, url
50
- end
51
-
52
- end
53
-
54
- end
55
-
56
- class BadgesDash < PagedDash
57
- property :badges
58
- end
59
- end
@@ -1,41 +0,0 @@
1
- module Rubyoverflow
2
- class Comment
3
-
4
- attr_reader :comment_id
5
- attr_reader :creation_date
6
- attr_reader :owner
7
- attr_reader :reply_to_user
8
- attr_reader :post_id
9
- attr_reader :post_type
10
- attr_reader :score
11
- attr_reader :edit_count
12
- attr_reader :body
13
-
14
- def initialize(hash, request_path = '')
15
- dash = CommentDash.new hash
16
-
17
- @comment_id = dash.comment_id
18
- @creation_date = dash.creation_date
19
- @owner = User.new dash.owner
20
- @reply_to_user = User.new dash.reply_to_user if dash.reply_to_user
21
- @post_id = dash.post_id
22
- @post_type = dash.post_type
23
- @score = dash.score
24
- @edit_count = dash.edit_count
25
- @body = dash.body
26
- end
27
-
28
- end
29
-
30
- class CommentDash < BaseDash
31
- property :comment_id
32
- property :creation_date
33
- property :owner
34
- property :reply_to_user
35
- property :post_id
36
- property :post_type
37
- property :score
38
- property :edit_count
39
- property :body
40
- end
41
- end
@@ -1,115 +0,0 @@
1
- module Rubyoverflow
2
- class Comments < PagedBase
3
-
4
- attr_reader :comments
5
-
6
- def initialize(hash, request_path = '')
7
- dash = CommentsDash.new hash
8
-
9
- @comments = Array.new
10
- dash.comments.each{ |commentHash| @comments.push(Comment.new commentHash)}
11
-
12
- super(dash, request_path)
13
- end
14
-
15
- #Retrieves the next set of comments using the same parameters used to retrieve the current set
16
- def get_next_set
17
- hash,url = perform_next_page_request
18
- Comments.new hash,url
19
- end
20
-
21
- class << self
22
-
23
- #Retieves a set of comments by a set by their ids
24
- #
25
- #id can be an int, string, or an array of ints or strings
26
- #
27
- #Maps to 'comments/{id}
28
- def retrieve_by_id(id, parameters = {})
29
- id = convert_to_id_list(id)
30
-
31
- hash, url = request('comments/'+id.to_s, parameters)
32
- Comments.new hash, url
33
- end
34
-
35
- #Retrieves a set of comments made by a set of users by their ids
36
- #
37
- #id can be an int, string, or an array of ints or strings
38
- #
39
- #Maps to 'users/{id}/comments'
40
- def retrieve_by_user(id, parameters={})
41
- id = convert_to_id_list(id)
42
-
43
- hash, url = request('users/'+id.to_s+"/comments", parameters)
44
- Comments.new hash, url
45
- end
46
-
47
- #Retrieves a set of comments made on an answer by the answer's id
48
- #
49
- #id can be an int, string, or an array of ints or strings
50
- #
51
- #Maps to 'answers/{id}/comments'
52
- def retrieve_by_answer(id, parameters={})
53
- id = convert_to_id_list(id)
54
-
55
- hash, url = request('answers/'+id.to_s+"/comments", parameters)
56
- Comments.new hash, url
57
- end
58
-
59
- #Retrieves a set of comments made on a post by the post's id
60
- #
61
- #id can be an int, string, or an array of ints or strings
62
- #
63
- #Maps to 'posts/{id}/comments'
64
- def retrieve_by_post(id, parameters={})
65
- id = convert_to_id_list(id)
66
-
67
- hash, url = request('posts/'+id.to_s+"/comments", parameters)
68
- Comments.new hash, url
69
- end
70
-
71
- #Retrieves a set comments made on a question by the post's id
72
- #
73
- #id can be an int, string, or an array of ints or strings
74
- #
75
- #Maps to 'question/{id}/comments'
76
- def retrieve_by_question(id, parameters={})
77
- id = convert_to_id_list(id)
78
-
79
- hash, url = request('questions/'+id.to_s+"/comments", parameters)
80
- Comments.new hash, url
81
- end
82
-
83
- #Retrieves a set of comments made by a set of users to a user
84
- #
85
- #id can be an int, string, or an array of ints or strings
86
- #
87
- #toid must be an int or string
88
- #
89
- #Maps to 'users/{id}/comments/{toid}'
90
- def retrieve_from_user_to_user(id, toid, parameters={})
91
- id = convert_to_id_list(id)
92
-
93
- hash, url = request('users/'+id.to_s+"/comments/" + toid.to_s, parameters)
94
- Comments.new hash, url
95
- end
96
-
97
- #Retieves a set commments directed at a set of users by their ids
98
- #
99
- #id can be an int, string, or an array of ints or strings
100
- #
101
- #Maps to 'users/{id}/mentioned'
102
- def retrieve_to_user(id, parameters={})
103
- id = convert_to_id_list(id)
104
-
105
- hash, url = request('users/'+id.to_s+"/mentioned", parameters)
106
- Comments.new hash, url
107
- end
108
- end
109
-
110
- end
111
-
112
- class CommentsDash < PagedDash
113
- property :comments
114
- end
115
- end
@@ -1,17 +0,0 @@
1
- module Rubyoverflow
2
- class Errors < Base
3
-
4
- class << self
5
-
6
- #Retrieves errors
7
- #
8
- #Maps to 'errors/{id}'
9
- def retrieve(id)
10
- request('errors/'+id.to_s)
11
- end
12
-
13
- end
14
-
15
-
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- module Rubyoverflow
2
- class PagedBase < Base
3
- attr_reader :total, :pagesize, :page, :request_path, :query_parameters
4
-
5
- def initialize(dash, request_path)
6
- @total = dash.total
7
- @page = dash.page
8
- @pagesize = dash.pagesize
9
- @request_path,@query_parameters = find_parse_querystring(request_path)
10
- end
11
-
12
- def next_page_parameters()
13
- temp = @query_parameters
14
- if @page.respond_to?(:to_int)
15
- temp['page'] = @page.to_i + 1
16
- else
17
- temp["page"] = 2
18
- end
19
- return temp
20
- end
21
-
22
- def perform_next_page_request()
23
- request(@request_path,next_page_parameters)
24
- end
25
-
26
- end
27
- end
@@ -1,7 +0,0 @@
1
- module Rubyoverflow
2
- class PagedDash < BaseDash
3
- property :total
4
- property :pagesize
5
- property :page
6
- end
7
- end
@@ -1,93 +0,0 @@
1
- module Rubyoverflow
2
- class PostTimelineEvent < Base
3
- attr_reader :timeline_type
4
- attr_reader :question_id
5
- attr_reader :post_id
6
- attr_reader :comment_id
7
- attr_reader :revision_guid
8
- attr_reader :creation_date
9
- attr_reader :user
10
- attr_reader :owner
11
- attr_reader :action
12
- attr_reader :post_revision_url
13
- attr_reader :post_url
14
- attr_reader :post_comment_url
15
-
16
- def initialize(hash, request_path = '')
17
- dash = PostTimelineEventDash.new hash
18
-
19
- @timeline_type = dash.timeline_type
20
- @post_id = dash.post_id
21
- @comment_id = dash.comment_id
22
- @question_id = dash.question_id
23
- @revision_guid = dash.revision_guid
24
- @creation_date = dash.creation_date
25
- @user = User.new dash.user if dash.user
26
- @owner = User.new dash.owner if dash.owner
27
- @action = dash.action
28
- @post_revision_url = dash.post_revision_url
29
- @post_url = dash.post_url
30
- @post_comment_url = dash.post_comment_url
31
- end
32
-
33
- #Gets the post associated with this postTimelineEvent
34
- def get_post(parameters={})
35
- if @post_url
36
- hash,url = request(@post_url, parameters)
37
- if @post_url.include? 'question'
38
- Questions.new hash, url
39
- elsif @post_url.include? 'answer'
40
- Answers.new hash, url
41
- end
42
- else
43
- nil
44
- end
45
- end
46
-
47
- #Gets the question that this postTimleineEvent belongs to
48
- def get_parent_question(parameters={})
49
- if @question_id
50
- Questions.retrieve_by_id @question_id
51
- else
52
- nil
53
- end
54
- end
55
-
56
-
57
- #Gets the revision associated with this postTimelineEvent
58
- def get_post_revision(parameters={})
59
- if @post_revision_url
60
- hash,url = request(@post_revision_url, parameters)
61
- Revisions.new hash, url
62
- else
63
- nil
64
- end
65
- end
66
-
67
- #Gets the comment associated with this postTimelineEvent
68
- def get_post_comment(parameters={})
69
- if @post_comment_url
70
- hash,url = request(@post_comment_url, parameters)
71
- Comments.new hash, url
72
- else
73
- nil
74
- end
75
- end
76
-
77
- end
78
-
79
- class PostTimelineEventDash < BaseDash
80
- property :timeline_type
81
- property :post_id
82
- property :question_id
83
- property :comment_id
84
- property :revision_guid
85
- property :creation_date
86
- property :user
87
- property :owner
88
- property :action
89
- property :post_revision_url
90
- property :post_url
91
- property :post_comment_url
92
- end
93
- end
@@ -1,39 +0,0 @@
1
- module Rubyoverflow
2
- class PostTimelineEvents < PagedBase
3
- attr_reader :post_timelines
4
-
5
- def initialize(hash, request_path = '')
6
- dash = PostTimelineEventsDash.new hash
7
- super(dash, request_path)
8
-
9
- @post_timelines = Array.new
10
- dash.post_timelines.each {|postTimeHash| @post_timelines.push(PostTimelineEvent.new postTimeHash)}
11
- end
12
-
13
- #Retrieves the next set of PostTimelineEvents using the same parameters used to retrieve the current set
14
- def get_next_set
15
- hash,url = perform_next_page_request
16
- PostTimelineEvents.new hash,url
17
- end
18
-
19
- class << self
20
-
21
- #Retrieve a set of PostTimelineEvent for a set of question(s) by their id(s)
22
- #
23
- #id can be an int, string, or an array of ints or strings
24
- #
25
- #Maps to 'questions/{id}/timeline'
26
- def retrieve_by_question(id, parameters = {})
27
- id = convert_to_id_list(id)
28
-
29
- hash, url = request('questions/' + id.to_s + '/timeline', parameters)
30
- PostTimelineEvents.new hash, url
31
- end
32
- end
33
-
34
- end
35
-
36
- class PostTimelineEventsDash < PagedDash
37
- property :post_timelines
38
- end
39
- end
@@ -1,110 +0,0 @@
1
- module Rubyoverflow
2
- class Question < Base
3
- attr_reader :tags, :answer_count, :answers, :accepted_answer_id, :favorite_count, :bounty_closes_date,
4
- :bounty_amount, :closed_date, :closed_reason, :question_timeline_url, :question_comments_url,
5
- :question_answers_url, :question_id, :locked_date, :owner, :creation_date, :last_edit_date,
6
- :last_activity_date, :up_vote_count, :down_vote_count, :view_count, :score, :community_owned,
7
- :title, :body, :comments, :migrated, :protected_date
8
-
9
- def initialize(hash, request_path = '')
10
- dash = QuestionDash.new hash
11
-
12
- @tags = Array.new
13
- @comments = Array.new
14
- @answers = Array.new
15
-
16
- dash.tags.each {|tag| @tags.push(tag)} if dash.tags
17
- dash.comments.each {|commentHash| @comment.push(Comment.new commentHash)} if dash.comments
18
- dash.answers.each {|answerHash| @comment.push(Answer.new answerHash)} if dash.answers
19
-
20
- @migrated = dash.migrated
21
- @answer_count = dash.answer_count
22
- @accepted_answer_id = dash.accepted_answer_id
23
- @favorite_count = dash.favorite_count
24
- @bounty_closes_date = dash.bounty_closes_date
25
- @bounty_amount = dash.bounty_amount
26
- @closed_date = dash.closed_date
27
- @closed_reason = dash.closed_reason
28
- @question_timeline_url = dash.question_timeline_url
29
- @question_comments_url = dash.question_comments_url
30
- @question_answers_url = dash.question_answers_url
31
- @question_id = dash.question_id
32
- @locked_date = dash.locked_date
33
- @owner = User.new dash.owner if dash.owner
34
- @creation_date = dash.creation_date
35
- @last_edit_date = dash.last_edit_date
36
- @last_activity_date = dash.last_activity_date
37
- @up_vote_count = dash.up_vote_count
38
- @down_vote_count = dash.down_vote_count
39
- @view_count = dash.view_count
40
- @score = dash.score
41
- @community_owned = dash.community_owned
42
- @title = dash.title
43
- @body = dash.body
44
- @protected_date = dash.protected_date
45
- end
46
-
47
- #Gets the comments made on the question
48
- def get_comments(parameters = {})
49
- if @question_comments_url
50
- hash,url =request(@question_comments_url, parameters)
51
- Comments.new hash, url
52
- else
53
- nil
54
- end
55
- end
56
-
57
- #Gets the answers posted to the question
58
- def get_answers(parameters = {})
59
- if @question_answers_url
60
- hash,url =request(@question_answers_url, parameters)
61
- Answers.new hash, url
62
- else
63
- nil
64
- end
65
- end
66
-
67
- #Gets the timeline for the question
68
- def get_timeline(parameters = {})
69
- if @question_timeline_url
70
- hash,url =request(@question_timeline_url, parameters)
71
- PostTimelineEvents.new hash, url
72
- else
73
- nil
74
- end
75
- end
76
-
77
-
78
- end
79
-
80
- class QuestionDash < BaseDash
81
- property :tags
82
- property :answer_count
83
- property :answers
84
- property :accepted_answer_id
85
- property :favorite_count
86
- property :bounty_closes_date
87
- property :bounty_amount
88
- property :closed_date
89
- property :closed_reason
90
- property :question_timeline_url
91
- property :question_comments_url
92
- property :question_answers_url
93
- property :question_id
94
- property :locked_date
95
- property :owner
96
- property :creation_date
97
- property :last_edit_date
98
- property :last_activity_date
99
- property :up_vote_count
100
- property :down_vote_count
101
- property :view_count
102
- property :score
103
- property :community_owned
104
- property :title
105
- property :body
106
- property :comments
107
- property :migrated
108
- property :protected_date
109
- end
110
- end