bitbucket_rest_api2 0.9.1 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -12
  3. data/lib/bitbucket_rest_api/api.rb +1 -6
  4. data/lib/bitbucket_rest_api/api_factory.rb +0 -1
  5. data/lib/bitbucket_rest_api/configuration.rb +7 -1
  6. data/lib/bitbucket_rest_api/connection.rb +7 -4
  7. data/lib/bitbucket_rest_api/error/refresh_token.rb +12 -0
  8. data/lib/bitbucket_rest_api/error.rb +1 -0
  9. data/lib/bitbucket_rest_api/helpers/repository_helper.rb +13 -0
  10. data/lib/bitbucket_rest_api/invitations.rb +1 -1
  11. data/lib/bitbucket_rest_api/issues/comments.rb +5 -5
  12. data/lib/bitbucket_rest_api/issues/components.rb +5 -5
  13. data/lib/bitbucket_rest_api/issues/milestones.rb +5 -5
  14. data/lib/bitbucket_rest_api/issues.rb +5 -5
  15. data/lib/bitbucket_rest_api/repos/changesets.rb +2 -2
  16. data/lib/bitbucket_rest_api/repos/commits.rb +8 -2
  17. data/lib/bitbucket_rest_api/repos/following.rb +2 -2
  18. data/lib/bitbucket_rest_api/repos/forks.rb +1 -1
  19. data/lib/bitbucket_rest_api/repos/keys.rb +32 -12
  20. data/lib/bitbucket_rest_api/repos/pull_request.rb +1 -1
  21. data/lib/bitbucket_rest_api/repos/services.rb +14 -7
  22. data/lib/bitbucket_rest_api/repos/sources.rb +2 -2
  23. data/lib/bitbucket_rest_api/repos/statuses.rb +51 -0
  24. data/lib/bitbucket_rest_api/repos/webhooks.rb +35 -16
  25. data/lib/bitbucket_rest_api/repos.rb +35 -12
  26. data/lib/bitbucket_rest_api/request.rb +43 -15
  27. data/lib/bitbucket_rest_api/response/raise_error.rb +5 -0
  28. data/lib/bitbucket_rest_api/user.rb +7 -7
  29. data/lib/bitbucket_rest_api/users/account.rb +8 -8
  30. data/lib/bitbucket_rest_api/version.rb +1 -1
  31. data/lib/bitbucket_rest_api.rb +1 -25
  32. data/spec/bitbucket_rest_api/core_ext/hash_spec.rb +1 -1
  33. data/spec/bitbucket_rest_api/helpers/repository_helper_spec.rb +30 -0
  34. data/spec/bitbucket_rest_api/invitations_spec.rb +1 -1
  35. data/spec/bitbucket_rest_api/issues/comments_spec.rb +5 -5
  36. data/spec/bitbucket_rest_api/issues/components_spec.rb +5 -5
  37. data/spec/bitbucket_rest_api/issues/milestones_spec.rb +5 -5
  38. data/spec/bitbucket_rest_api/issues_spec.rb +5 -5
  39. data/spec/bitbucket_rest_api/repos/changesets_spec.rb +2 -2
  40. data/spec/bitbucket_rest_api/repos/following_spec.rb +2 -2
  41. data/spec/bitbucket_rest_api/repos/forks_spec.rb +1 -1
  42. data/spec/bitbucket_rest_api/repos/keys_spec.rb +5 -5
  43. data/spec/bitbucket_rest_api/repos/pull_request_spec.rb +1 -1
  44. data/spec/bitbucket_rest_api/repos/sources_spec.rb +3 -3
  45. data/spec/bitbucket_rest_api/repos/statuses_spec.rb +48 -0
  46. data/spec/bitbucket_rest_api/repos/webhooks_spec.rb +3 -3
  47. data/spec/bitbucket_rest_api/repos_spec.rb +7 -7
  48. data/spec/bitbucket_rest_api/request_spec.rb +11 -11
  49. data/spec/bitbucket_rest_api/user_spec.rb +8 -8
  50. metadata +11 -8
  51. data/lib/bitbucket_rest_api/response/helpers.rb +0 -21
  52. data/lib/bitbucket_rest_api/result.rb +0 -140
@@ -1,140 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module BitBucket
4
- module Result
5
- include BitBucket::Constants
6
-
7
- # TODO Add result counts method to check total items looking at result links
8
-
9
- def ratelimit_limit
10
- loaded? ? @env[:response_headers][RATELIMIT_LIMIT] : nil
11
- end
12
-
13
- def ratelimit_remaining
14
- loaded? ? @env[:response_headers][RATELIMIT_REMAINING] : nil
15
- end
16
-
17
- def cache_control
18
- loaded? ? @env[:response_headers][CACHE_CONTROL] : nil
19
- end
20
-
21
- def content_type
22
- loaded? ? @env[:response_headers][CONTENT_TYPE] : nil
23
- end
24
-
25
- def content_length
26
- loaded? ? @env[:response_headers][CONTENT_LENGTH] : nil
27
- end
28
-
29
- def etag
30
- loaded? ? @env[:response_headers][ETAG] : nil
31
- end
32
-
33
- def date
34
- loaded? ? @env[:response_headers][DATE] : nil
35
- end
36
-
37
- def location
38
- loaded? ? @env[:response_headers][LOCATION] : nil
39
- end
40
-
41
- def server
42
- loaded? ? @env[:response_headers][SERVER] : nil
43
- end
44
-
45
- def status
46
- loaded? ? @env[:status] : nil
47
- end
48
-
49
- def success?
50
- (200..299).include? status
51
- end
52
-
53
- # Returns raw body
54
- def body
55
- loaded? ? @env[:body] : nil
56
- end
57
-
58
- def loaded?
59
- !!@env
60
- end
61
-
62
- # Return page links
63
- def links
64
- @@links = BitBucket::PageLinks.new(@env[:response_headers])
65
- end
66
-
67
- # Iterator like each for response pages. If there are no pages to
68
- # iterate over this method will return nothing.
69
- def each_page
70
- yield self.body
71
- while page_iterator.has_next?
72
- yield next_page
73
- end
74
- end
75
-
76
- # Retrives the result of the first page. Returns <tt>nil</tt> if there is
77
- # no first page - either because you are already on the first page
78
- # or there are no pages at all in the result.
79
- def first_page
80
- first_request = page_iterator.first
81
- self.instance_eval { @env = first_request.env } if first_request
82
- self.body
83
- end
84
-
85
- # Retrives the result of the next page. Returns <tt>nil</tt> if there is
86
- # no next page or no pages at all.
87
- def next_page
88
- next_request = page_iterator.next
89
- self.instance_eval { @env = next_request.env } if next_request
90
- self.body
91
- end
92
-
93
- # Retrives the result of the previous page. Returns <tt>nil</tt> if there is
94
- # no previous page or no pages at all.
95
- def prev_page
96
- prev_request = page_iterator.prev
97
- self.instance_eval { @env = prev_request.env } if prev_request
98
- self.body
99
- end
100
- alias :previous_page :prev_page
101
-
102
- # Retrives the result of the last page. Returns <tt>nil</tt> if there is
103
- # no last page - either because you are already on the last page,
104
- # there is only one page or there are no pages at all in the result.
105
- def last_page
106
- last_request = page_iterator.last
107
- self.instance_eval { @env = last_request.env } if last_request
108
- self.body
109
- end
110
-
111
- # Retrives a specific result for a page given page number.
112
- # The <tt>page_number</tt> parameter is not validate, hitting a page
113
- # that does not exist will return BitBucket API error. Consequently, if
114
- # there is only one page, this method returns nil
115
- def page(page_number)
116
- request = page_iterator.get_page(page_number)
117
- self.instance_eval { @env = request.env } if request
118
- self.body
119
- end
120
-
121
- # Returns <tt>true</tt> if there is another page in the result set,
122
- # otherwise <tt>false</tt>
123
- def has_next_page?
124
- page_iterator.has_next?
125
- end
126
-
127
- # Repopulates objects for new values
128
- def reset
129
- nil
130
- end
131
-
132
- private
133
-
134
- # Internally used page iterator
135
- def page_iterator # :nodoc:
136
- @@page_iterator = BitBucket::PageIterator.new(@env)
137
- end
138
-
139
- end # Result
140
- end # BitBucket