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,34 +0,0 @@
1
- module Rubyoverflow
2
- class RepChange
3
- attr_reader :user_id
4
- attr_reader :post_id
5
- attr_reader :post_type
6
- attr_reader :title
7
- attr_reader :positive_rep
8
- attr_reader :negative_rep
9
- attr_reader :on_date
10
-
11
- def initialize(hash, request_path = '')
12
- dash = RepChangeDash.new hash
13
-
14
- @user_id = dash.user_id
15
- @post_id = dash.post_id
16
- @post_type = dash.post_type
17
- @title = dash.title
18
- @positive_rep = dash.positive_rep
19
- @negative_rep = dash.negative_rep
20
- @on_date = dash.on_date
21
- end
22
-
23
- end
24
-
25
- class RepChangeDash <BaseDash
26
- property :user_id
27
- property :post_id
28
- property :post_type
29
- property :title
30
- property :positive_rep
31
- property :negative_rep
32
- property :on_date
33
- end
34
- end
@@ -1,41 +0,0 @@
1
- module Rubyoverflow
2
- class RepChanges < PagedBase
3
-
4
- attr_reader :rep_changes
5
-
6
- def initialize(hash, request_path = '')
7
- dash = RepChangesDash.new hash
8
- super(dash, request_path)
9
-
10
- @rep_changes = Array.new
11
- dash.rep_changes.each{|repHash| @rep_changes.push(RepChange.new repHash)}
12
- end
13
-
14
- #Retrieves the next set of RepChanges using the same parameters used to retrieve the current set
15
- def get_next_set
16
- hash,url = perform_next_page_request
17
- RepChanges.new hash,url
18
- end
19
-
20
- class << self
21
-
22
- #Retrieves all the rep_changes for a set of user(s) by their id(s)
23
- #
24
- #id can be an int, string, or an array of ints or strings
25
- #
26
- #Maps to '/users{id}/reputation'
27
- def retrieve_by_user(id, parameters={})
28
- id = convert_to_id_list(id)
29
- hash, url = request('/users/' + id.to_s + '/reputation', parameters)
30
- RepChanges.new hash, url
31
- end
32
-
33
- end
34
-
35
- end
36
-
37
- class RepChangesDash < PagedDash
38
- property :rep_changes
39
-
40
- end
41
- end
@@ -1,62 +0,0 @@
1
- module Rubyoverflow
2
- class Revision
3
- attr_reader :body
4
- attr_reader :comment
5
- attr_reader :creation_date
6
- attr_reader :is_question
7
- attr_reader :is_rollback
8
- attr_reader :last_body
9
- attr_reader :last_title
10
- attr_reader :last_tags
11
- attr_reader :revision_guid
12
- attr_reader :revision_number
13
- attr_reader :tags
14
- attr_reader :title
15
- attr_reader :revision_type
16
- attr_reader :set_community_wiki
17
- attr_reader :user
18
- attr_reader :post_id
19
-
20
- def initialize(hash, request_path = '')
21
- dash = RevisionDash.new hash
22
-
23
- @body = dash.body
24
- @comment = dash.comment
25
- @creation_date = dash.creation_date
26
- @is_question = dash.is_question
27
- @is_rollback = dash.is_rollback
28
- @last_body = dash.last_body
29
- @last_title = dash.last_title
30
- @last_tags = dash.last_tags
31
- @revision_guid = dash.revision_guid
32
- @revision_number = dash.revision_number
33
- @tags = dash.tags
34
- @title = dash.title
35
- @revision_type = dash.revision_type
36
- @set_community_wiki = dash.set_community_wiki
37
- @user = User.new dash.user if dash.user
38
- @post_id = dash.post_id
39
- end
40
-
41
-
42
- end
43
-
44
- class RevisionDash < BaseDash
45
- property :body
46
- property :comment
47
- property :creation_date
48
- property :is_question
49
- property :is_rollback
50
- property :last_body
51
- property :last_title
52
- property :last_tags
53
- property :revision_guid
54
- property :revision_number
55
- property :tags
56
- property :title
57
- property :revision_type
58
- property :set_community_wiki
59
- property :user
60
- property :post_id
61
- end
62
- end
@@ -1,52 +0,0 @@
1
- module Rubyoverflow
2
- class Revisions < PagedBase
3
- attr_reader :revisions
4
-
5
- def initialize(hash, request_path = '')
6
- dash = RevisionsDash.new hash
7
- super(dash, request_path)
8
-
9
- @revisions = Array.new
10
- dash.revisions.each{|revisionHash| @revisions.push(Revision.new revisionHash)}
11
- end
12
-
13
- #Retrieves the next set of revisions using the same parameters used to retrieve the current set
14
- def get_next_set
15
- hash,url = perform_next_page_request
16
- Revisions.new hash,url
17
- end
18
-
19
- class << self
20
-
21
- #Retrieves the post history of a set of post(s) by their id(s)
22
- #
23
- #id can be an int, string or an array of ints or strings
24
- #
25
- #Maps to 'revisions/{id}'
26
- def retrieve_by_post(id, parameters = {})
27
- id = convert_to_id_list(id)
28
- hash, url = request('/revisions/'+id.to_s, parameters)
29
- Revisions.new hash, url
30
- end
31
-
32
- #Retrieves a specific post revision by post id and revision guid
33
- #
34
- #id can be an int, string or an array of ints or strings
35
- #
36
- #revisionguid must be a string in 8-4-4-4-12 format
37
- #
38
- #Maps to 'revisions/{id}'
39
- def retrieve_post_revision(id, revisionguid, parameters = {})
40
- id = convert_to_id_list(id)
41
- hash, url = request('/revisions/'+id.to_s + '/' + revisionguid, parameters)
42
- Revisions.new hash, url
43
- end
44
-
45
- end
46
-
47
- end
48
-
49
- class RevisionsDash < PagedDash
50
- property :revisions
51
- end
52
- end
@@ -1,57 +0,0 @@
1
- module Rubyoverflow
2
- class Statistics < Base
3
-
4
- attr_reader :total_questions, :total_badges, :total_unanswered, :total_votes, :total_comments, :total_answers, :site,
5
- :total_users, :questions_per_minute, :answers_per_minute, :badges_per_minute, :views_per_day, :api_version, :total_accepted
6
-
7
- def initialize(hash, request_path = '')
8
- dash = StatisticsDash.new hash
9
-
10
- @total_questions = dash.total_questions
11
- @total_accepted = dash.total_accepted
12
- @total_badges = dash.total_badges
13
- @total_unanswered = dash.total_unanswered
14
- @total_votes = dash.total_votes
15
- @total_comments = dash.total_comments
16
- @total_answers = dash.total_answers
17
- @total_users = dash.total_users
18
- @questions_per_minute = dash.questions_per_minute
19
- @answers_per_minute = dash.answers_per_minute
20
- @badges_per_minute = dash.badges_per_minute
21
- @views_per_day = dash.views_per_day
22
- @site = ApiSite.new dash.site
23
- @api_version = ApiVersion.new dash.api_version
24
- end
25
-
26
-
27
- class << self
28
-
29
- #Retrieves the stats for the domain
30
- #
31
- #Maps to 'stats'
32
- def retrieve
33
- hash, url = request('stats')
34
- Statistics.new hash['statistics'].first, url
35
- end
36
- end
37
-
38
-
39
- end
40
-
41
- class StatisticsDash < BaseDash
42
- property :total_questions
43
- property :total_badges
44
- property :total_unanswered
45
- property :total_votes
46
- property :total_comments
47
- property :total_answers
48
- property :total_users
49
- property :total_accepted
50
- property :questions_per_minute
51
- property :answers_per_minute
52
- property :badges_per_minute
53
- property :views_per_day
54
- property :api_version
55
- property :site
56
- end
57
- end
@@ -1,19 +0,0 @@
1
- module Rubyoverflow
2
- class Styling
3
- attr_reader :link_color, :tag_foreground_color ,:tag_background_color
4
-
5
- def initialize(hash)
6
- dash = StylingDash.new hash
7
- @link_color = dash.link_color
8
- @tag_background_color = dash.tag_background_color
9
- @tag_foreground_color = dash.tag_foreground_color
10
- end
11
-
12
- end
13
-
14
- class StylingDash < BaseDash
15
- property :link_color
16
- property :tag_foreground_color
17
- property :tag_background_color
18
- end
19
- end
@@ -1,27 +0,0 @@
1
- module Rubyoverflow
2
- class Tag
3
- attr_reader :name
4
- attr_reader :count
5
- attr_reader :restricted_to
6
- attr_reader :fulfills_required
7
- attr_reader :user_id
8
-
9
- def initialize(hash, request_path = '')
10
- dash = TagDash.new hash
11
- @name = dash.name
12
- @count = dash.count
13
- @restricted_to = dash.restricted_to
14
- @fulfills_required = dash.fulfills_required
15
- @user_id = dash.user_id
16
- end
17
-
18
- end
19
-
20
- class TagDash < BaseDash
21
- property :name
22
- property :count
23
- property :restricted_to
24
- property :fulfills_required
25
- property :user_id
26
- end
27
- end
@@ -1,46 +0,0 @@
1
- module Rubyoverflow
2
- class Tags < PagedBase
3
-
4
- attr_reader :tags
5
-
6
- def initialize(hash, request_path = '')
7
- dash = TagsDash.new hash
8
- @tags = Array.new
9
- dash.tags.each{ |tagHash| @tags.push(Tag.new tagHash)}
10
-
11
- super(dash, request_path)
12
- end
13
-
14
- #Retrieves the next set of tags using the same parameters used to retrieve the current set
15
- def get_next_set
16
- hash,url = perform_next_page_request
17
- Tags.new hash,url
18
- end
19
-
20
- class << self
21
- #Retrieves all of the tags
22
- #
23
- #Maps to '/tags/
24
- def retrieve_all(parameters = {})
25
- hash, url = request('tags', parameters)
26
- Tags.new hash, url
27
- end
28
-
29
- #Retieves all of the tags assign to a set of users by their ids
30
- #
31
- #id can be an int, string, or an array of ints or strings
32
- #
33
- #Maps to 'users/{id}/tags'
34
- def retrieve_by_user(id, parameters = {})
35
- id = convert_to_id_list(id)
36
- hash, url = request('users/'+id.to_s+'/tags',parameters)
37
- Tags.new hash, url
38
- end
39
- end
40
- end
41
-
42
- class TagsDash < PagedDash
43
- property :tags
44
-
45
- end
46
- end
@@ -1,181 +0,0 @@
1
- module Rubyoverflow
2
- class User < Base
3
-
4
- attr_reader :user_id, :user_type, :creation_date, :display_name, :reputation, :email_hash, :age,
5
- :last_access_date, :website_url, :location, :about_me, :question_count, :answer_count, :view_count,
6
- :up_vote_count, :down_vote_count, :accept_rate, :user_questions_url, :user_answers_url, :user_favorites_url,
7
- :user_tags_url, :user_badges_url, :user_timeline_url, :user_mentioned_url, :user_comments_url,
8
- :user_reputation_url, :badge_counts, :timed_penalty_date, :association_id, :on_site
9
-
10
- def initialize(hash, request_path = '')
11
- dash = UserDash.new hash
12
-
13
- @user_id = dash.user_id
14
- @user_type = dash.user_type
15
- @creation_date = dash.creation_date
16
- @display_name = dash.display_name
17
- @reputation = dash.reputation
18
- @email_hash = dash.email_hash
19
- @age = dash.age
20
- @last_access_date = dash.last_access_date
21
- @website_url = dash.website_url
22
- @location = dash.location
23
- @about_me = dash.about_me
24
- @question_count = dash.question_count
25
- @answer_count = dash.answer_count
26
- @view_count = dash.view_count
27
- @up_vote_count = dash.up_vote_count
28
- @down_vote_count = dash.down_vote_count
29
- @accept_rate = dash.accept_rate
30
- @user_questions_url = dash.user_questions_url
31
- @user_answers_url = dash.user_answers_url
32
- @user_favorites_url = dash.user_favorites_url
33
- @user_tags_url = dash.user_tags_url
34
- @user_badges_url = dash.user_badges_url
35
- @user_timeline_url = dash.user_timeline_url
36
- @user_mentioned_url = dash.user_mentioned_url
37
- @user_comments_url = dash.user_comments_url
38
- @user_reputation_url = dash.user_reputation_url
39
- @badge_counts = BadgeCounts.new dash.badge_counts if dash.badge_counts
40
- @timed_penalty_date = dash.timed_penalty_date
41
- @association_id = dash.association_id
42
- @on_site = ApiSite.new dash.on_site if dash.on_site
43
- end
44
-
45
- def item_id
46
- @user_id
47
- end
48
-
49
- #Gets the questions by the user
50
- def get_questions(parameters = {})
51
- if @user_questions_url
52
- hash,url =request(@user_questions_url, parameters)
53
- Questions.new hash, url
54
- else
55
- nil
56
- end
57
- end
58
-
59
- #Gets the answers from the user
60
- def get_answers(parameters = {})
61
- if @user_answers_url
62
- hash,url =request(@user_answers_url, parameters)
63
- Answers.new hash, url
64
- else
65
- nil
66
- end
67
- end
68
-
69
- #Gets the questions favorited by the user
70
- def get_favorites(parameters = {})
71
- if @user_favorites_url
72
- hash,url =request(@user_favorites_url, parameters)
73
- Questions.new hash, url
74
- else
75
- nil
76
- end
77
- end
78
-
79
- #Gets the tags the user has participated in
80
- def get_tags(parameters = {})
81
- if @user_tags_url
82
- hash,url =request(@user_tags_url, parameters)
83
- Tags.new hash, url
84
- else
85
- nil
86
- end
87
- end
88
-
89
- #Gets the badges awared to the user
90
- def get_badges
91
- if @user_badges_url
92
- hash,url =request(@user_badges_url,{})
93
- Badges.new hash, url
94
- else
95
- nil
96
- end
97
- end
98
-
99
- #Gets the user's timeline
100
- def get_timeline(parameters = {})
101
- if @user_timeline_url
102
- hash,url =request(@user_timeline_url, parameters)
103
- UserTimelineEvents.new hash, url
104
- else
105
- nil
106
- end
107
- end
108
-
109
- #Gets the comments that mention the user
110
- def get_mentioned(parameters = {})
111
- if @user_mentioned_url
112
- hash,url =request(@user_mentioned_url, parameters)
113
- Comments.new hash, url
114
- else
115
- nil
116
- end
117
- end
118
-
119
- #Gets the comments by the user
120
- def get_comments(parameters = {})
121
- if @user_comments_url
122
- hash,url =request(@user_comments_url, parameters)
123
- Comments.new hash, url
124
- else
125
- nil
126
- end
127
- end
128
-
129
- #Gets the user's reputation
130
- def get_reputation(parameters = {})
131
- if @user_reputation_url
132
- hash,url =request(@user_reputation_url, parameters)
133
- RepChanges.new hash, url
134
- else
135
- nil
136
- end
137
- end
138
-
139
- #Gets the user's other accounts
140
- def retrieve_associated_accounts
141
- if @association_id
142
- Users.retrieve_associated_accounts @association_id
143
- else
144
- nil
145
- end
146
- end
147
- end
148
-
149
- class UserDash < BaseDash
150
- property :user_id
151
- property :user_type
152
- property :creation_date
153
- property :display_name
154
- property :reputation
155
- property :email_hash
156
- property :age
157
- property :last_access_date
158
- property :website_url
159
- property :location
160
- property :about_me
161
- property :question_count
162
- property :answer_count
163
- property :view_count
164
- property :up_vote_count
165
- property :down_vote_count
166
- property :accept_rate
167
- property :user_questions_url
168
- property :user_answers_url
169
- property :user_favorites_url
170
- property :user_tags_url
171
- property :user_badges_url
172
- property :user_timeline_url
173
- property :user_mentioned_url
174
- property :user_comments_url
175
- property :user_reputation_url
176
- property :badge_counts
177
- property :timed_penalty_date
178
- property :association_id
179
- property :on_site
180
- end
181
- end