gratitude 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/CHANGELOG.md +14 -10
- data/Gemfile +7 -5
- data/Guardfile +6 -0
- data/README.md +36 -11
- data/gratitude.gemspec +3 -2
- data/lib/gratitude.rb +3 -1
- data/lib/gratitude/client.rb +4 -2
- data/lib/gratitude/connection.rb +10 -0
- data/lib/gratitude/payday.rb +23 -17
- data/lib/gratitude/profile.rb +63 -32
- data/lib/gratitude/statistics.rb +30 -28
- data/lib/gratitude/tips.rb +12 -23
- data/lib/gratitude/version.rb +1 -1
- data/spec/cassettes/current_tips.json +74 -0
- data/spec/cassettes/paydays.json +18 -7
- data/spec/cassettes/profiles.json +209 -0
- data/spec/cassettes/statistics.json +132 -110
- data/spec/cassettes/update_and_prune.json +208 -189
- data/spec/cassettes/update_tips.json +74 -0
- data/spec/gratitude/client_spec.rb +2 -2
- data/spec/gratitude/connection_spec.rb +20 -0
- data/spec/gratitude/payday_spec.rb +56 -79
- data/spec/gratitude/profile_spec.rb +195 -127
- data/spec/gratitude/statistics_spec.rb +36 -80
- data/spec/gratitude/tips_spec.rb +23 -41
- data/spec/spec_helper.rb +1 -0
- metadata +31 -21
- data/spec/cassettes/complete_profile.json +0 -119
- data/spec/cassettes/get_tips.json +0 -63
- data/spec/cassettes/goal_profile.json +0 -121
- data/spec/cassettes/incomplete_profile.json +0 -62
- data/spec/cassettes/post_multiple_tips.json +0 -68
- data/spec/cassettes/post_single_tip.json +0 -68
- data/spec/cassettes/post_tip_error.json +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7549b619bcc85a81bc995ca6a09f0363b52548e0
|
4
|
+
data.tar.gz: 704297b6b8f5f6b69dfed8b40b3ac73a7b8a179d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb95f6be06a1f320b7066e338eb84ac6f2a59fe984100fdaf6a6833bf08931c041bc46678164aa70266ee938e6e1f5f9bd5fa6c4153de3ea812763705af5c5a
|
7
|
+
data.tar.gz: 8d51cb9fcbf942090fc7299b8de17338e850035853da7ee6c6738c20fd699a1e81442a45eaf13e4eed150064f75cf08e4ca7ab07e46cbdac8d83952a5d1d9808
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
--format documentation
|
2
|
-
--color
|
2
|
+
--color
|
data/CHANGELOG.md
CHANGED
@@ -1,37 +1,41 @@
|
|
1
1
|
### 0.1.0 (Upcoming Stable Release)
|
2
2
|
* Implement all aspects of the Gittip API.
|
3
3
|
|
4
|
-
### 0.0.
|
4
|
+
### 0.0.11 (March 29, 2014)
|
5
|
+
* Change to Faraday instead of HTTParty
|
6
|
+
* Update api methods to match current Gittip api implementation
|
7
|
+
|
8
|
+
### 0.0.10 (March 27, 2014)
|
5
9
|
* Add rake console task to enter an IRB session with Gratitude required
|
6
10
|
* Simplify Tip's public interface
|
7
11
|
|
8
|
-
### 0.0.9 (
|
12
|
+
### 0.0.9 (October 19, 2013)
|
9
13
|
* Add ability to update a user's current tips.
|
10
14
|
|
11
|
-
### 0.0.8 (
|
15
|
+
### 0.0.8 (October 18, 2013)
|
12
16
|
* Add client authentication.
|
13
17
|
* Add ability to retrieve a user's current tips.
|
14
18
|
|
15
|
-
### 0.0.7 (
|
19
|
+
### 0.0.7 (October 13, 2013)
|
16
20
|
* Update documentation.
|
17
21
|
* Alias new to current in Statistics class.
|
18
22
|
|
19
|
-
### 0.0.6 (
|
23
|
+
### 0.0.6 (October 19, 2013)
|
20
24
|
* Complete Gittip's Statistics API integration.
|
21
25
|
* Add more aliases and improve method clarity to signify method intent.
|
22
26
|
|
23
|
-
### 0.0.5 (
|
27
|
+
### 0.0.5 (September 17, 2013)
|
24
28
|
* Complete Gittip's Paydays API integration.
|
25
29
|
* Add aliases for all methods to correspond to Gittip's original API documentation.
|
26
30
|
|
27
|
-
### 0.0.4 (
|
31
|
+
### 0.0.4 (September 14, 2013)
|
28
32
|
* Improve integration with Gittip's Public User API to better account for different user settings.
|
29
33
|
|
30
|
-
### 0.0.3 (
|
34
|
+
### 0.0.3 (September 11, 2013)
|
31
35
|
* Fix release version.
|
32
36
|
|
33
|
-
### 0.0.2 (
|
37
|
+
### 0.0.2 (September 11, 2013)
|
34
38
|
* Add ability to get a Gittip user's public information.
|
35
39
|
|
36
|
-
### 0.0.1 (
|
40
|
+
### 0.0.1 (September 10, 2013)
|
37
41
|
* Initial release.
|
data/Gemfile
CHANGED
@@ -2,14 +2,16 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
group :development
|
6
|
-
gem "rspec", '~> 3.0.0.beta2'
|
7
|
-
gem "webmock"
|
8
|
-
gem "vcr"
|
5
|
+
group :development do
|
9
6
|
gem "pry"
|
10
7
|
gem "awesome_print"
|
8
|
+
gem "guard-rspec"
|
9
|
+
gem "terminal-notifier-guard", require: false
|
11
10
|
end
|
12
11
|
|
13
12
|
group :test do
|
13
|
+
gem "rspec", '~> 3.0.0.beta2'
|
14
|
+
gem "webmock"
|
15
|
+
gem "vcr"
|
14
16
|
gem 'coveralls', require: false
|
15
|
-
end
|
17
|
+
end
|
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -21,9 +21,9 @@ A simple Ruby wrapper for the [Gittip API](https://github.com/gittip/www.gittip.
|
|
21
21
|
The gratitude gem has four different components that interact with different aspects of the Gittip API. They are as follows:
|
22
22
|
|
23
23
|
* [Paydays](#paydays-source-code)
|
24
|
-
* [Statistics](#statistics)
|
24
|
+
* [Statistics](#statistics-source-code)
|
25
25
|
* [Profile](#profile-source-code)
|
26
|
-
* [Tips](#tips)
|
26
|
+
* [Tips](#tips-client-authentication-source-code-tips-source-code)
|
27
27
|
|
28
28
|
When using gratitude to retrieve data from the Gittip API, please note that many of the JSON key names have been wrapped in more naturally sounding method names. However, all of the original JSON key names have also been maintained as aliases so as to maitain consistency with the original [Gittip API documentation](https://github.com/gittip/www.gittip.com#api).
|
29
29
|
|
@@ -63,6 +63,11 @@ paydays.each do |payday|
|
|
63
63
|
end
|
64
64
|
```
|
65
65
|
|
66
|
+
If you want to get the oldest payday:
|
67
|
+
```ruby
|
68
|
+
Gratitude::Payday.oldest_payday
|
69
|
+
```
|
70
|
+
|
66
71
|
Finally, if you just want to get the most recent payday, you can do so by using:
|
67
72
|
|
68
73
|
```ruby
|
@@ -125,32 +130,53 @@ Gratitude::Profile.new("johnkellyferguson")
|
|
125
130
|
The above will retrieve the public profile of the above user. You can then access all of the different information with the following methods:
|
126
131
|
|
127
132
|
* `avatar_url` (alias: `avatar`)
|
128
|
-
* `
|
129
|
-
|
133
|
+
* `bitcoin`
|
134
|
+
* returns a link to the user's bitcoin address
|
135
|
+
* `bitbucket`
|
136
|
+
* returns a hash containing their bitbucket username, id, and user id if the user has connected their bitbucket account.
|
130
137
|
* otherwise, returns `nil`.
|
131
138
|
* `bitbucket_username`
|
132
139
|
* returns the user's bitbucket username if they have connected a bitbucket account.
|
133
140
|
* otherwise, returns `nil`.
|
134
|
-
* `
|
135
|
-
* returns
|
141
|
+
* `bountysource`
|
142
|
+
* returns a hash containing their bountysource username, id, and user id if the user has connected their bountysource account.
|
136
143
|
* otherwise, returns `nil`.
|
137
144
|
* `bountysource_username`
|
138
145
|
* returns the user's bountysource username if they have connected a bountysource account.
|
139
146
|
* otherwise, returns `nil`.
|
140
|
-
* `
|
141
|
-
* returns
|
147
|
+
* `github`
|
148
|
+
* returns a hash containing their github username, id, and user id if the user has connected their github account.
|
142
149
|
* otherwise, returns `nil`.
|
143
150
|
* `github_username`
|
144
151
|
* returns the user's github username if they have connected a github account.
|
145
152
|
* otherwise, returns `nil`.
|
146
|
-
* `
|
147
|
-
* returns
|
153
|
+
* `openstreetmap`
|
154
|
+
* returns a hash containing their openstreetmap username, id, and user id if the user has connected their openstreetmap account.
|
155
|
+
* otherwise, returns `nil`.
|
156
|
+
* `openstreetmap_username`
|
157
|
+
* returns the user's openstreetmap username if they have connected a openstreetmap account.
|
158
|
+
* otherwise, returns `nil`.
|
159
|
+
* `twitter`
|
160
|
+
* returns a hash containing their twitter username, id, and user id if the user has connected their twitter account.
|
161
|
+
* otherwise, returns `nil`.
|
162
|
+
* `twitter_username`
|
163
|
+
* returns the user's twitter username if they have connected a twitter account.
|
164
|
+
* otherwise, returns `nil`.
|
165
|
+
* `venmo`
|
166
|
+
* returns a hash containing their venmo username, id, and user id if the user has connected their venmo account.
|
148
167
|
* otherwise, returns `nil`.
|
168
|
+
* `venmo_username`
|
169
|
+
* returns the user's venmo username if they have connected a venmo account.
|
170
|
+
* otherwise, returns `nil`.
|
149
171
|
* `amount_giving` (alias: `giving`)
|
150
172
|
* returns the amount (as a float) the user has pledged to give this week.
|
151
173
|
* if the user has decided to donately privately then this will return 0.00.
|
152
174
|
* `amount_receiving` (alias: `receiving`)
|
153
175
|
* returns an estimate as a float of what the given user is expected to receive this week.
|
176
|
+
* `number_of_patrons` (alias: `npatrons`)
|
177
|
+
* returns the number of other gittipers that donate to the user being queried.
|
178
|
+
* `on`
|
179
|
+
* returns the platform name: "gittip"
|
154
180
|
* `goal`
|
155
181
|
* returns the amount (as a float) that the user would like to receive weekly if the user set such a goal.
|
156
182
|
* returns `nil` if the user has defined themselves as a patron or has not set a specific monetary goal.
|
@@ -159,7 +185,6 @@ The above will retrieve the public profile of the above user. You can then acces
|
|
159
185
|
* `id`
|
160
186
|
* the id of the user.
|
161
187
|
|
162
|
-
**TODO:** Implement the `my_tip` method into the Profile section once client authentication is finished.
|
163
188
|
|
164
189
|
##Tips ([client authentication source code](https://github.com/JohnKellyFerguson/gratitude/blob/master/lib/gratitude/client.rb), [tips source code](https://github.com/JohnKellyFerguson/gratitude/blob/master/lib/gratitude/tips.rb))
|
165
190
|
The Tips aspect of the Gittip API allows you to retrieve and update the current tips of an authenticated user. In order to interact with this aspect of the API, you will need your username and API_KEY. To find out your API Key, log into your Gittip account, go to your profile and at the bottom of the page you will find your API_KEY.
|
data/gratitude.gemspec
CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "
|
21
|
+
spec.add_dependency "faraday", "~> 0.8"
|
22
|
+
spec.add_dependency "faraday_middleware", "~> 0.9"
|
22
23
|
spec.add_dependency "json"
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
25
|
spec.add_development_dependency "rake"
|
25
26
|
end
|
data/lib/gratitude.rb
CHANGED
data/lib/gratitude/client.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
require "gratitude/connection"
|
1
2
|
require "gratitude/tips"
|
2
3
|
|
3
4
|
module Gratitude
|
4
5
|
class Client
|
5
|
-
include
|
6
|
+
include Gratitude::Connection
|
6
7
|
include Gratitude::Client::Tips
|
7
8
|
|
8
9
|
attr_reader :username, :api_key
|
@@ -10,7 +11,8 @@ module Gratitude
|
|
10
11
|
def initialize(options = {})
|
11
12
|
@username = options[:username]
|
12
13
|
@api_key = options[:api_key]
|
14
|
+
faraday.basic_auth(api_key, "")
|
13
15
|
end
|
14
16
|
|
15
17
|
end # Payday
|
16
|
-
end # Gratitude
|
18
|
+
end # Gratitude
|
data/lib/gratitude/payday.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Gratitude
|
2
2
|
class Payday
|
3
|
-
|
4
|
-
base_uri "https://www.gittip.com/about/paydays.json"
|
3
|
+
extend Connection
|
5
4
|
PAYDAYS = []
|
6
5
|
|
7
6
|
attr_reader :ach_fees_volume, :ach_volume, :charge_fees_volume,
|
@@ -11,19 +10,20 @@ module Gratitude
|
|
11
10
|
:number_of_transfers, :transfer_volume, :transfer_end_time,
|
12
11
|
:transfer_start_time
|
13
12
|
|
14
|
-
# Provide aliases so all methods can correspond to the original
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
# Provide aliases so all methods can correspond to the original
|
14
|
+
# Gittip API names.
|
15
|
+
alias_method :nachs, :number_of_ach_credits
|
16
|
+
alias_method :number_of_achs, :number_of_ach_credits
|
17
|
+
alias_method :nactive, :number_of_active_users
|
18
|
+
alias_method :number_active, :number_of_active_users
|
19
|
+
alias_method :ncc_failing, :number_of_failing_credit_cards
|
20
|
+
alias_method :ncc_missing, :number_of_missing_credit_cards
|
21
|
+
alias_method :ncharges, :number_of_charges
|
22
|
+
alias_method :nparticipants, :number_of_participants
|
23
|
+
alias_method :ntippers, :number_of_tippers
|
24
|
+
alias_method :ntransfers, :number_of_transfers
|
25
|
+
alias_method :ts_end, :transfer_end_time
|
26
|
+
alias_method :ts_start, :transfer_start_time
|
27
27
|
|
28
28
|
def initialize(options = {})
|
29
29
|
@ach_fees_volume = options["ach_fees_volume"]
|
@@ -54,12 +54,18 @@ module Gratitude
|
|
54
54
|
sort_by_ts_end.first
|
55
55
|
end
|
56
56
|
|
57
|
+
def self.oldest_payday
|
58
|
+
sort_by_ts_end.last
|
59
|
+
end
|
60
|
+
|
57
61
|
def self.sort_by_ts_end
|
58
62
|
all.sort_by { |p| p.ts_end }.reverse
|
59
63
|
end
|
60
64
|
|
65
|
+
private
|
66
|
+
|
61
67
|
def self.get_paydays_from_gittip
|
62
|
-
get(
|
68
|
+
faraday.get('/about/paydays.json').body.to_a
|
63
69
|
end
|
64
70
|
|
65
71
|
def self.collect_paydays
|
@@ -69,4 +75,4 @@ module Gratitude
|
|
69
75
|
end
|
70
76
|
|
71
77
|
end # Payday
|
72
|
-
end # Gratitude
|
78
|
+
end # Gratitude
|
data/lib/gratitude/profile.rb
CHANGED
@@ -1,78 +1,109 @@
|
|
1
1
|
module Gratitude
|
2
2
|
class Profile
|
3
|
-
include
|
4
|
-
|
5
|
-
URI_SUFFIX = "/public.json"
|
6
|
-
|
7
|
-
attr_reader :username, :response
|
3
|
+
include Connection
|
4
|
+
attr_reader :username
|
8
5
|
|
9
6
|
def initialize(username)
|
10
7
|
@username = username
|
11
|
-
@response = self.class.get("/#{username}#{URI_SUFFIX}")
|
12
8
|
end
|
13
9
|
|
14
10
|
def avatar_url
|
15
|
-
|
11
|
+
response_body["avatar"]
|
12
|
+
end
|
13
|
+
alias_method :avatar, :avatar_url
|
14
|
+
|
15
|
+
def bitcoin
|
16
|
+
response_body["bitcoin"]
|
16
17
|
end
|
17
|
-
alias :avatar :avatar_url
|
18
18
|
|
19
|
-
def
|
20
|
-
|
19
|
+
def bitbucket
|
20
|
+
response_body["elsewhere"]["bitbucket"]
|
21
21
|
end
|
22
|
-
alias :bitbucket :bitbucket_api_url
|
23
22
|
|
24
23
|
def bitbucket_username
|
25
|
-
|
24
|
+
bitbucket["user_name"] if bitbucket
|
26
25
|
end
|
27
26
|
|
28
|
-
def
|
29
|
-
|
27
|
+
def bountysource
|
28
|
+
response_body["elsewhere"]["bountysource"]
|
30
29
|
end
|
31
|
-
alias :bountysource :bountysource_api_url
|
32
30
|
|
33
31
|
def bountysource_username
|
34
|
-
|
32
|
+
bountysource["user_name"] if bountysource
|
35
33
|
end
|
36
34
|
|
37
|
-
def
|
38
|
-
|
35
|
+
def github
|
36
|
+
response_body["elsewhere"]["bountysource"]
|
39
37
|
end
|
40
|
-
alias :github :github_api_url
|
41
38
|
|
42
39
|
def github_username
|
43
|
-
|
40
|
+
github["user_name"] if github
|
41
|
+
end
|
42
|
+
|
43
|
+
def openstreetmap
|
44
|
+
response_body["elsewhere"]["openstreetmap"]
|
44
45
|
end
|
45
46
|
|
46
|
-
def
|
47
|
-
|
47
|
+
def openstreetmap_username
|
48
|
+
openstreetmap["user_name"] if openstreetmap
|
49
|
+
end
|
50
|
+
|
51
|
+
def twitter
|
52
|
+
response_body["elsewhere"]["twitter"]
|
48
53
|
end
|
49
|
-
alias :twitter :twitter_api_url
|
50
54
|
|
51
55
|
def twitter_username
|
52
|
-
|
56
|
+
twitter["user_name"] if twitter
|
57
|
+
end
|
58
|
+
|
59
|
+
def venmo
|
60
|
+
response_body["elsewhere"]["venmo"]
|
61
|
+
end
|
62
|
+
|
63
|
+
def venmo_username
|
64
|
+
venmo["user_name"] if venmo
|
53
65
|
end
|
54
66
|
|
55
67
|
def amount_giving
|
56
|
-
|
68
|
+
response_body["giving"].to_f
|
57
69
|
end
|
58
|
-
|
70
|
+
alias_method :giving, :amount_giving
|
59
71
|
|
60
72
|
def amount_receiving
|
61
|
-
|
73
|
+
response_body["receiving"].to_f
|
62
74
|
end
|
63
|
-
|
75
|
+
alias_method :receiving, :amount_receiving
|
64
76
|
|
65
77
|
def goal
|
66
|
-
|
78
|
+
response_body["goal"].to_f if response_body["goal"]
|
67
79
|
end
|
68
80
|
|
69
81
|
def account_type
|
70
|
-
|
82
|
+
response_body["number"]
|
71
83
|
end
|
72
|
-
|
84
|
+
alias_method :number, :account_type
|
73
85
|
|
74
86
|
def id
|
75
|
-
|
87
|
+
response_body["id"]
|
88
|
+
end
|
89
|
+
|
90
|
+
def number_of_patrons
|
91
|
+
response_body["npatrons"]
|
92
|
+
end
|
93
|
+
alias_method :npatrons, :number_of_patrons
|
94
|
+
|
95
|
+
def on
|
96
|
+
response_body["on"]
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def response
|
102
|
+
@response ||= faraday.get("/#{username}/public.json")
|
103
|
+
end
|
104
|
+
|
105
|
+
def response_body
|
106
|
+
@response_body ||= response.body
|
76
107
|
end
|
77
108
|
|
78
109
|
end # Profile
|