gratitude 0.1.0 → 0.2.0
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/.hound.yml +4 -0
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +5 -4
- data/Guardfile +10 -8
- data/README.md +37 -37
- data/gratitude.gemspec +2 -2
- data/lib/gratitude/chart.rb +6 -5
- data/lib/gratitude/connection.rb +1 -1
- data/lib/gratitude/error.rb +2 -2
- data/lib/gratitude/payday.rb +7 -6
- data/lib/gratitude/profile.rb +36 -75
- data/lib/gratitude/statistics.rb +45 -89
- data/lib/gratitude/tips.rb +16 -24
- data/lib/gratitude/user_chart.rb +8 -4
- data/lib/gratitude/version.rb +1 -1
- data/spec/cassettes/charts.json +11 -11
- data/spec/cassettes/current_tips.json +23 -25
- data/spec/cassettes/current_tips_not_authenticated.json +14 -17
- data/spec/cassettes/paydays.json +11 -11
- data/spec/cassettes/profiles.json +1 -265
- data/spec/cassettes/prune_tips_not_authenticated.json +15 -18
- data/spec/cassettes/statistics.json +11 -11
- data/spec/cassettes/update_and_prune.json +33 -36
- data/spec/cassettes/update_and_prune_bad_request.json +12 -13
- data/spec/cassettes/update_bad_request.json +13 -14
- data/spec/cassettes/update_tips.json +13 -14
- data/spec/cassettes/update_tips_not_authenticated.json +15 -18
- data/spec/cassettes/user_chart_not_found.json +10 -10
- data/spec/cassettes/user_charts.json +22 -22
- data/spec/gratitude/chart_spec.rb +3 -10
- data/spec/gratitude/connection_spec.rb +2 -2
- data/spec/gratitude/payday_spec.rb +3 -10
- data/spec/gratitude/profile_spec.rb +47 -47
- data/spec/gratitude/statistics_spec.rb +27 -23
- data/spec/gratitude/tips_spec.rb +18 -18
- data/spec/gratitude/user_chart_spec.rb +17 -21
- metadata +4 -4
@@ -35,18 +35,18 @@ describe Gratitude::Statistics do
|
|
35
35
|
punc
|
36
36
|
statements
|
37
37
|
this_thursday
|
38
|
-
|
38
|
+
tip_distribution
|
39
39
|
tip_n
|
40
40
|
total_backed_tips
|
41
41
|
transfer_volume
|
42
|
-
|
42
|
+
)
|
43
43
|
)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "#average_tip_amount" do
|
48
48
|
it "returns a float" do
|
49
|
-
expect(stats.average_tip_amount
|
49
|
+
expect(stats.average_tip_amount).to be_a(Float)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "returns the same value as its alias: #average_tip" do
|
@@ -56,7 +56,7 @@ describe Gratitude::Statistics do
|
|
56
56
|
|
57
57
|
describe "#average_number_of_tippees" do
|
58
58
|
it "returns a fixnum" do
|
59
|
-
expect(stats.average_number_of_tippees
|
59
|
+
expect(stats.average_number_of_tippees).to be_a(Fixnum)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "returns the same value as its alias: #average_tippees" do
|
@@ -66,7 +66,7 @@ describe Gratitude::Statistics do
|
|
66
66
|
|
67
67
|
describe "#amount_in_escrow" do
|
68
68
|
it "returns a float" do
|
69
|
-
expect(stats.amount_in_escrow
|
69
|
+
expect(stats.amount_in_escrow).to be_a(Float)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "returns the same value as its alias: #escrow" do
|
@@ -76,13 +76,13 @@ describe Gratitude::Statistics do
|
|
76
76
|
|
77
77
|
describe "#last_thursday" do
|
78
78
|
it "returns a string" do
|
79
|
-
expect(stats.last_thursday
|
79
|
+
expect(stats.last_thursday).to be_a(String)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
describe "#number_of_achs" do
|
84
84
|
it "returns a fixnum" do
|
85
|
-
expect(stats.number_of_ach_credits
|
85
|
+
expect(stats.number_of_ach_credits).to be_a(Fixnum)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "returns the same value as its alias: #nach" do
|
@@ -96,7 +96,7 @@ describe Gratitude::Statistics do
|
|
96
96
|
|
97
97
|
describe "#number_of_active_users" do
|
98
98
|
it "returns a fixnum" do
|
99
|
-
expect(stats.number_of_active_users
|
99
|
+
expect(stats.number_of_active_users).to be_a(Fixnum)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "returns the same value as its alias: #nactive" do
|
@@ -106,7 +106,7 @@ describe Gratitude::Statistics do
|
|
106
106
|
|
107
107
|
describe "#number_of_credit_cards" do
|
108
108
|
it "returns a fixnum" do
|
109
|
-
expect(stats.number_of_credit_cards
|
109
|
+
expect(stats.number_of_credit_cards).to be_a(Fixnum)
|
110
110
|
end
|
111
111
|
|
112
112
|
it "returns the same value as its alias: #ncc" do
|
@@ -116,7 +116,7 @@ describe Gratitude::Statistics do
|
|
116
116
|
|
117
117
|
describe "#number_of_givers" do
|
118
118
|
it "returns a fixnum" do
|
119
|
-
expect(stats.number_of_givers
|
119
|
+
expect(stats.number_of_givers).to be_a(Fixnum)
|
120
120
|
end
|
121
121
|
|
122
122
|
it "returns the same value as its alias: #ngivers" do
|
@@ -126,7 +126,7 @@ describe Gratitude::Statistics do
|
|
126
126
|
|
127
127
|
describe "#number_who_give_and_receive" do
|
128
128
|
it "returns a fixnum" do
|
129
|
-
expect(stats.number_who_give_and_receive
|
129
|
+
expect(stats.number_who_give_and_receive).to be_a(Fixnum)
|
130
130
|
end
|
131
131
|
|
132
132
|
it "returns the same value as its alias: #noverlap" do
|
@@ -136,7 +136,7 @@ describe Gratitude::Statistics do
|
|
136
136
|
|
137
137
|
describe "#number_of_receivers" do
|
138
138
|
it "returns a fixnum" do
|
139
|
-
expect(stats.number_of_receivers
|
139
|
+
expect(stats.number_of_receivers).to be_a(Fixnum)
|
140
140
|
end
|
141
141
|
|
142
142
|
it "returns the same value as its alias: #nreceivers" do
|
@@ -146,13 +146,13 @@ describe Gratitude::Statistics do
|
|
146
146
|
|
147
147
|
describe "#other_people" do
|
148
148
|
it "returns a string" do
|
149
|
-
expect(stats.other_people
|
149
|
+
expect(stats.other_people).to be_a(String)
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
153
|
describe "#percentage_of_users_with_credit_cards" do
|
154
154
|
it "returns a string" do
|
155
|
-
expect(stats.percentage_of_users_with_credit_cards
|
155
|
+
expect(stats.percentage_of_users_with_credit_cards).to be_a(String)
|
156
156
|
end
|
157
157
|
|
158
158
|
it "returns the same value as its alias: #pcc" do
|
@@ -162,7 +162,7 @@ describe Gratitude::Statistics do
|
|
162
162
|
|
163
163
|
describe "#punctuation" do
|
164
164
|
it "returns a string" do
|
165
|
-
expect(stats.punctuation
|
165
|
+
expect(stats.punctuation).to be_a(String)
|
166
166
|
end
|
167
167
|
|
168
168
|
it "returns the same value as its alias: #pcc" do
|
@@ -172,7 +172,7 @@ describe Gratitude::Statistics do
|
|
172
172
|
|
173
173
|
describe "#statements" do
|
174
174
|
it "returns an array" do
|
175
|
-
expect(stats.statements
|
175
|
+
expect(stats.statements).to be_a(Array)
|
176
176
|
end
|
177
177
|
|
178
178
|
it "contain the currect number of elements in the array" do
|
@@ -180,7 +180,7 @@ describe Gratitude::Statistics do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
it "has a hash for each element in the array" do
|
183
|
-
expect(stats.statements.first
|
183
|
+
expect(stats.statements.first).to be_a(Hash)
|
184
184
|
end
|
185
185
|
|
186
186
|
it "has statement as a key in each hash element" do
|
@@ -198,19 +198,23 @@ describe Gratitude::Statistics do
|
|
198
198
|
|
199
199
|
describe "#this_thursday" do
|
200
200
|
it "returns a string" do
|
201
|
-
expect(stats.this_thursday
|
201
|
+
expect(stats.this_thursday).to be_a(String)
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
describe "#
|
205
|
+
describe "#tip_distribution" do
|
206
206
|
it "returns a hash" do
|
207
|
-
expect(stats.
|
207
|
+
expect(stats.tip_distribution).to be_a(Hash)
|
208
|
+
end
|
209
|
+
|
210
|
+
it "returns the same value as its alias: #tip_distribution_json" do
|
211
|
+
expect(stats.tip_distribution).to eq(stats.tip_distribution_json)
|
208
212
|
end
|
209
213
|
end
|
210
214
|
|
211
215
|
describe "#number_of_tips" do
|
212
216
|
it "returns a fixnum" do
|
213
|
-
expect(stats.number_of_tips
|
217
|
+
expect(stats.number_of_tips).to be_a(Fixnum)
|
214
218
|
end
|
215
219
|
|
216
220
|
it "returns the same value as its alias: #tip_n" do
|
@@ -220,7 +224,7 @@ describe Gratitude::Statistics do
|
|
220
224
|
|
221
225
|
describe "#value_of_total_backed_tips" do
|
222
226
|
it "returns a float" do
|
223
|
-
expect(stats.value_of_total_backed_tips
|
227
|
+
expect(stats.value_of_total_backed_tips).to be_a(Float)
|
224
228
|
end
|
225
229
|
|
226
230
|
it "returns the same value as its alias: #total_backed_tips" do
|
@@ -230,7 +234,7 @@ describe Gratitude::Statistics do
|
|
230
234
|
|
231
235
|
describe "#transfer_volume" do
|
232
236
|
it "returns a float" do
|
233
|
-
expect(stats.transfer_volume
|
237
|
+
expect(stats.transfer_volume).to be_a(Float)
|
234
238
|
end
|
235
239
|
end
|
236
240
|
end
|
data/spec/gratitude/tips_spec.rb
CHANGED
@@ -14,11 +14,11 @@ describe Gratitude::Client::Tips do
|
|
14
14
|
let(:current_tips) do
|
15
15
|
[
|
16
16
|
{ "amount" => "1.00",
|
17
|
-
"platform" => "
|
17
|
+
"platform" => "gratipay",
|
18
18
|
"username" => "whit537"
|
19
19
|
},
|
20
20
|
{ "amount" => "0.25",
|
21
|
-
"platform" => "
|
21
|
+
"platform" => "gratipay",
|
22
22
|
"username" => "JohnKellyFerguson"
|
23
23
|
}
|
24
24
|
]
|
@@ -61,17 +61,17 @@ describe Gratitude::Client::Tips do
|
|
61
61
|
let(:multiple_tips) do
|
62
62
|
[
|
63
63
|
{ "amount" => "1.00",
|
64
|
-
"platform" => "
|
64
|
+
"platform" => "gratipay",
|
65
65
|
"username" => "whit537"
|
66
66
|
},
|
67
67
|
{ "amount" => "0.25",
|
68
|
-
"platform" => "
|
68
|
+
"platform" => "gratipay",
|
69
69
|
"username" => "JohnKellyFerguson"
|
70
70
|
},
|
71
71
|
{
|
72
72
|
"amount" => "1.00",
|
73
|
-
"platform" => "
|
74
|
-
"username" => "
|
73
|
+
"platform" => "gratipay",
|
74
|
+
"username" => "Gratipay"
|
75
75
|
}
|
76
76
|
]
|
77
77
|
end
|
@@ -93,22 +93,22 @@ describe Gratitude::Client::Tips do
|
|
93
93
|
[
|
94
94
|
{
|
95
95
|
"amount" => "1.00",
|
96
|
-
"platform" => "
|
96
|
+
"platform" => "gratipay",
|
97
97
|
"username" => "not_a_user_so_fake"
|
98
98
|
},
|
99
99
|
{
|
100
100
|
"amount" => "0.25",
|
101
|
-
"platform" => "
|
101
|
+
"platform" => "gratipay",
|
102
102
|
"username" => "lol_this_will_be_an_error"
|
103
103
|
},
|
104
104
|
{
|
105
105
|
"amount" => "1.00",
|
106
|
-
"platform" => "
|
106
|
+
"platform" => "gratipay",
|
107
107
|
"username" => "whit537"
|
108
108
|
},
|
109
109
|
{
|
110
110
|
"amount" => "0.25",
|
111
|
-
"platform" => "
|
111
|
+
"platform" => "gratipay",
|
112
112
|
"username" => "JohnKellyFerguson"
|
113
113
|
}
|
114
114
|
]
|
@@ -135,12 +135,12 @@ describe Gratitude::Client::Tips do
|
|
135
135
|
[
|
136
136
|
{
|
137
137
|
"amount" => "1.00",
|
138
|
-
"platform" => "
|
138
|
+
"platform" => "gratipay",
|
139
139
|
"username" => "whit537"
|
140
140
|
},
|
141
141
|
{
|
142
142
|
"amount" => "0.25",
|
143
|
-
"platform" => "
|
143
|
+
"platform" => "gratipay",
|
144
144
|
"username" => "JohnKellyFerguson"
|
145
145
|
}
|
146
146
|
]
|
@@ -153,17 +153,17 @@ describe Gratitude::Client::Tips do
|
|
153
153
|
[
|
154
154
|
{
|
155
155
|
"amount" => "1.00",
|
156
|
-
"platform" => "
|
157
|
-
"username" => "
|
156
|
+
"platform" => "gratipay",
|
157
|
+
"username" => "Gratipay"
|
158
158
|
},
|
159
159
|
{
|
160
160
|
"amount" => "1.00",
|
161
|
-
"platform" => "
|
161
|
+
"platform" => "gratipay",
|
162
162
|
"username" => "whit537"
|
163
163
|
},
|
164
164
|
{
|
165
165
|
"amount" => "0.25",
|
166
|
-
"platform" => "
|
166
|
+
"platform" => "gratipay",
|
167
167
|
"username" => "JohnKellyFerguson"
|
168
168
|
}
|
169
169
|
]
|
@@ -183,12 +183,12 @@ describe Gratitude::Client::Tips do
|
|
183
183
|
let(:incorrect_tips) do
|
184
184
|
[
|
185
185
|
{ "amount" => "1.00",
|
186
|
-
"platform" => "
|
186
|
+
"platform" => "gratipay",
|
187
187
|
"username" => "not_a_user_so_fake"
|
188
188
|
},
|
189
189
|
{
|
190
190
|
"amount" => "0.25",
|
191
|
-
"platform" => "
|
191
|
+
"platform" => "gratipay",
|
192
192
|
"username" => "will_be_an_error"
|
193
193
|
}
|
194
194
|
]
|
@@ -20,31 +20,31 @@ describe Gratitude::UserChart do
|
|
20
20
|
before(:each) { Gratitude::UserChart::USER_CHARTS = [] }
|
21
21
|
describe "#all_for_user" do
|
22
22
|
it "returns an array" do
|
23
|
-
expect(Gratitude::UserChart.all_for_user("
|
23
|
+
expect(Gratitude::UserChart.all_for_user("Gratipay").class)
|
24
24
|
.to be(Array)
|
25
25
|
end
|
26
26
|
|
27
|
-
context "when the requested
|
27
|
+
context "when the requested Gratipay user exists" do
|
28
28
|
it "updates the USER_CHARTS constant when it is empty" do
|
29
|
-
expect { Gratitude::UserChart.all_for_user("
|
29
|
+
expect { Gratitude::UserChart.all_for_user("Gratipay") }
|
30
30
|
.to change { Gratitude::UserChart::USER_CHARTS.size }.from(0)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "its array should be comprised of User_Chart objects" do
|
34
|
-
Gratitude::UserChart.all_for_user("
|
34
|
+
Gratitude::UserChart.all_for_user("Gratipay").each do |user_chart|
|
35
35
|
expect(user_chart.class).to eq(Gratitude::UserChart)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
it "only includes charts for a given username" do
|
40
40
|
Gratitude::UserChart.all_for_user("whit537")
|
41
|
-
Gratitude::UserChart.all_for_user("
|
42
|
-
expect(user_chart.username).to eq("
|
41
|
+
Gratitude::UserChart.all_for_user("Gratipay").each do |user_chart|
|
42
|
+
expect(user_chart.username).to eq("Gratipay")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
context "when the requested
|
47
|
+
context "when the requested Gratipay user does not exist" do
|
48
48
|
before { VCR.insert_cassette "user_chart_not_found" }
|
49
49
|
after { VCR.eject_cassette }
|
50
50
|
|
@@ -55,25 +55,21 @@ describe Gratitude::UserChart do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
describe "#sort_by_date_for_user" do
|
59
|
-
it "places the newest user chart before the oldest user chart" do
|
60
|
-
expect(Gratitude::UserChart.sort_by_date_for_user("Gittip").first.date)
|
61
|
-
.to be >
|
62
|
-
(Gratitude::UserChart.sort_by_date_for_user("Gittip").last.date)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
58
|
describe "#newest_for" do
|
67
59
|
it "returns the most recent payday" do
|
68
|
-
expect(Gratitude::UserChart.newest_for("
|
69
|
-
.to eq(
|
60
|
+
expect(Gratitude::UserChart.newest_for("Gratipay"))
|
61
|
+
.to eq(
|
62
|
+
Gratitude::UserChart.send(:sort_by_date_for_user, "Gratipay").first
|
63
|
+
)
|
70
64
|
end
|
71
65
|
end
|
72
66
|
|
73
67
|
describe "#oldest" do
|
74
68
|
it "returns the oldest payday" do
|
75
|
-
expect(Gratitude::UserChart.oldest_for("
|
76
|
-
.to eq(
|
69
|
+
expect(Gratitude::UserChart.oldest_for("Gratipay"))
|
70
|
+
.to eq(
|
71
|
+
Gratitude::UserChart.send(:sort_by_date_for_user, "Gratipay").last
|
72
|
+
)
|
77
73
|
end
|
78
74
|
end
|
79
75
|
end
|
@@ -87,7 +83,7 @@ describe Gratitude::UserChart do
|
|
87
83
|
|
88
84
|
let(:user_chart) do
|
89
85
|
Gratitude::UserChart.new(
|
90
|
-
"username" => "
|
86
|
+
"username" => "Gratipay",
|
91
87
|
"date" => "2014-03-27",
|
92
88
|
"npatrons" => 137,
|
93
89
|
"receipts" => 416.94
|
@@ -96,7 +92,7 @@ describe Gratitude::UserChart do
|
|
96
92
|
|
97
93
|
describe "#username" do
|
98
94
|
it "sets the correct username" do
|
99
|
-
expect(user_chart.username).to eq("
|
95
|
+
expect(user_chart.username).to eq("Gratipay")
|
100
96
|
end
|
101
97
|
end
|
102
98
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gratitude
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Kelly Ferguson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description: A simple Ruby wrapper for the
|
83
|
+
description: A simple Ruby wrapper for the Gratipay API.
|
84
84
|
email:
|
85
85
|
- hello@johnkellyferguson.com
|
86
86
|
executables: []
|
@@ -159,7 +159,7 @@ rubyforge_project:
|
|
159
159
|
rubygems_version: 2.2.2
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
|
-
summary: A simple Ruby wrapper for the
|
162
|
+
summary: A simple Ruby wrapper for the Gratipay API.
|
163
163
|
test_files:
|
164
164
|
- spec/cassettes/charts.json
|
165
165
|
- spec/cassettes/current_tips.json
|