gratitude 0.0.5 → 0.0.6
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/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/lib/gratitude/payday.rb +13 -8
- data/lib/gratitude/profile.rb +2 -1
- data/lib/gratitude/statistics.rb +103 -0
- data/lib/gratitude/version.rb +1 -1
- data/lib/gratitude.rb +4 -2
- data/spec/cassettes/statistics.json +59 -0
- data/spec/gratitude/payday_spec.rb +32 -16
- data/spec/gratitude/profile_spec.rb +14 -10
- data/spec/gratitude/statistics_spec.rb +287 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa13d9b092bbdeeac1cf25a1dbcc6721797938e6
|
4
|
+
data.tar.gz: 97d0644da849618e7248200557151cc2bb38b1db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 532b903736ce513281faba8014c2b38d83708b0bac481f295eb69fa555782e512581e2e0ffb9386eb2d09a8b687b9b6e81e1e6ee1b2acdc166a3858b8bc6d602
|
7
|
+
data.tar.gz: ccb638c89cee8bdb2a61f99cec3d27f8b9f3c2a6742b4adbfb276d68e937ca8f6bd5f4a96b166c30c50c5d50fb4667518b27ceef50cff3224dd9e1219c44a322
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
### 0.1.0 (Upcoming Stable Release)
|
2
2
|
* Implement all aspects of the Gittip API.
|
3
3
|
|
4
|
+
### 0.0.5 (9/17/2013)
|
5
|
+
* Complete Gittip's Paydays API integration.
|
6
|
+
* Add aliases for all methods to correspond to Gittip's original API documentation.
|
7
|
+
|
4
8
|
### 0.0.4 (9/14/2013)
|
5
9
|
* Improve integration with Gittip's Public User API to better account for different user settings.
|
6
10
|
|
data/README.md
CHANGED
@@ -98,6 +98,7 @@ The following will retrieve the public profile of the above user. You can then a
|
|
98
98
|
* otherwise, returns `nil`.
|
99
99
|
* `amount_giving`
|
100
100
|
* returns the amount (as a float) the user has pledged to give this week.
|
101
|
+
* if the user has decided to donately privately then this will return 0.00.
|
101
102
|
* `amount_receiving`
|
102
103
|
* returns an estimate as a float of what the given user is expected to receive this week.
|
103
104
|
* `goal`
|
data/lib/gratitude/payday.rb
CHANGED
@@ -5,28 +5,33 @@ module Gratitude
|
|
5
5
|
PAYDAYS = []
|
6
6
|
|
7
7
|
attr_reader :ach_fees_volume, :ach_volume, :charge_fees_volume,
|
8
|
-
:charge_volume, :
|
8
|
+
:charge_volume, :number_of_ach_credits, :number_of_active_users,
|
9
9
|
:number_of_failing_credit_cards, :number_of_missing_credit_cards,
|
10
10
|
:number_of_charges, :number_of_participants, :number_of_tippers,
|
11
|
-
:number_of_transfers, :transfer_volume, :
|
11
|
+
:number_of_transfers, :transfer_volume, :transfer_end_time,
|
12
|
+
:transfer_start_time
|
12
13
|
|
13
14
|
# Provide aliases so all methods can correspond to the original Gittip API names.
|
14
|
-
alias :nachs :
|
15
|
-
alias :
|
15
|
+
alias :nachs :number_of_ach_credits
|
16
|
+
alias :number_of_achs :number_of_ach_credits
|
17
|
+
alias :nactive :number_of_active_users
|
18
|
+
alias :number_active :number_of_active_users
|
16
19
|
alias :ncc_failing :number_of_failing_credit_cards
|
17
20
|
alias :ncc_missing :number_of_missing_credit_cards
|
18
21
|
alias :ncharges :number_of_charges
|
19
22
|
alias :nparticipants :number_of_participants
|
20
23
|
alias :ntippers :number_of_tippers
|
21
24
|
alias :ntransfers :number_of_transfers
|
25
|
+
alias :ts_end :transfer_end_time
|
26
|
+
alias :ts_start :transfer_start_time
|
22
27
|
|
23
28
|
def initialize(options = {})
|
24
29
|
@ach_fees_volume = options["ach_fees_volume"]
|
25
30
|
@ach_volume = options["ach_volume"]
|
26
31
|
@charge_fees_volume = options["charge_fees_volume"]
|
27
32
|
@charge_volume = options["charge_volume"]
|
28
|
-
@
|
29
|
-
@
|
33
|
+
@number_of_ach_credits = options["nachs"]
|
34
|
+
@number_of_active_users = options["nactive"]
|
30
35
|
@number_of_failing_credit_cards = options["ncc_failing"]
|
31
36
|
@number_of_missing_credit_cards = options["ncc_missing"]
|
32
37
|
@number_of_charges = options["ncharges"]
|
@@ -34,8 +39,8 @@ module Gratitude
|
|
34
39
|
@number_of_tippers = options["ntippers"]
|
35
40
|
@number_of_transfers = options["ntransfers"]
|
36
41
|
@transfer_volume = options["transfer_volume"]
|
37
|
-
@
|
38
|
-
@
|
42
|
+
@transfer_end_time = DateTime.parse(options["ts_end"])
|
43
|
+
@transfer_start_time = DateTime.parse(options["ts_start"])
|
39
44
|
PAYDAYS << self
|
40
45
|
end
|
41
46
|
|
data/lib/gratitude/profile.rb
CHANGED
@@ -0,0 +1,103 @@
|
|
1
|
+
module Gratitude
|
2
|
+
class Statistics
|
3
|
+
include HTTParty
|
4
|
+
base_uri "https://www.gittip.com/about/stats.json"
|
5
|
+
|
6
|
+
attr_reader :response
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@response = self.class.get("")
|
10
|
+
end
|
11
|
+
|
12
|
+
def average_tip_amount
|
13
|
+
response["average_tip"]
|
14
|
+
end
|
15
|
+
alias :average_tip :average_tip_amount
|
16
|
+
|
17
|
+
def average_number_of_tippees
|
18
|
+
response["average_tippees"]
|
19
|
+
end
|
20
|
+
alias :average_tippees :average_number_of_tippees
|
21
|
+
|
22
|
+
def amount_in_escrow
|
23
|
+
response["escrow"]
|
24
|
+
end
|
25
|
+
alias :escrow :amount_in_escrow
|
26
|
+
|
27
|
+
def last_thursday
|
28
|
+
response["last_thursday"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def number_of_ach_credits
|
32
|
+
response["nach"].to_i
|
33
|
+
end
|
34
|
+
alias :nach :number_of_ach_credits
|
35
|
+
alias :number_of_achs :number_of_ach_credits
|
36
|
+
|
37
|
+
def number_of_active_users
|
38
|
+
response["nactive"]
|
39
|
+
end
|
40
|
+
alias :nactive :number_of_active_users
|
41
|
+
|
42
|
+
def number_of_credit_cards
|
43
|
+
response["ncc"]
|
44
|
+
end
|
45
|
+
alias :ncc :number_of_credit_cards
|
46
|
+
|
47
|
+
def number_of_givers
|
48
|
+
response["ngivers"]
|
49
|
+
end
|
50
|
+
alias :ngivers :number_of_givers
|
51
|
+
|
52
|
+
def number_who_give_and_receive
|
53
|
+
response["noverlap"]
|
54
|
+
end
|
55
|
+
alias :noverlap :number_who_give_and_receive
|
56
|
+
|
57
|
+
def number_of_receivers
|
58
|
+
response["nreceivers"]
|
59
|
+
end
|
60
|
+
alias :nreceivers :number_of_receivers
|
61
|
+
|
62
|
+
def other_people
|
63
|
+
response["other_people"]
|
64
|
+
end
|
65
|
+
|
66
|
+
def percentage_of_users_with_credit_cards
|
67
|
+
response["pcc"].strip
|
68
|
+
end
|
69
|
+
alias :pcc :percentage_of_users_with_credit_cards
|
70
|
+
|
71
|
+
def punctuation
|
72
|
+
response["punc"]
|
73
|
+
end
|
74
|
+
alias :punc :punctuation
|
75
|
+
|
76
|
+
def statements
|
77
|
+
response["statements"]
|
78
|
+
end
|
79
|
+
|
80
|
+
def this_thursday
|
81
|
+
response["this_thursday"]
|
82
|
+
end
|
83
|
+
|
84
|
+
def tip_distribution_json
|
85
|
+
response["tip_distribution_json"]
|
86
|
+
end
|
87
|
+
|
88
|
+
def number_of_tips
|
89
|
+
response["tip_n"]
|
90
|
+
end
|
91
|
+
alias :tip_n :number_of_tips
|
92
|
+
|
93
|
+
def value_of_total_backed_tips
|
94
|
+
response["total_backed_tips"]
|
95
|
+
end
|
96
|
+
alias :total_backed_tips :value_of_total_backed_tips
|
97
|
+
|
98
|
+
def transfer_volume
|
99
|
+
response["transfer_volume"]
|
100
|
+
end
|
101
|
+
|
102
|
+
end # Statistics
|
103
|
+
end # Gratitude
|
data/lib/gratitude/version.rb
CHANGED
data/lib/gratitude.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"http_interactions": [
|
3
|
+
{
|
4
|
+
"request": {
|
5
|
+
"method": "get",
|
6
|
+
"uri": "https://www.gittip.com/about/stats.json",
|
7
|
+
"body": {
|
8
|
+
"encoding": "US-ASCII",
|
9
|
+
"string": ""
|
10
|
+
},
|
11
|
+
"headers": {
|
12
|
+
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"response": {
|
16
|
+
"status": {
|
17
|
+
"code": 200,
|
18
|
+
"message": "OK"
|
19
|
+
},
|
20
|
+
"headers": {
|
21
|
+
"Content-Type": [
|
22
|
+
"application/json"
|
23
|
+
],
|
24
|
+
"Date": [
|
25
|
+
"Tue, 17 Sep 2013 18:56:23 GMT"
|
26
|
+
],
|
27
|
+
"Server": [
|
28
|
+
"Aspen! Cheroot!"
|
29
|
+
],
|
30
|
+
"Set-Cookie": [
|
31
|
+
"csrf_token=Ucss1VG2RbUpKKnY4yYNUz8erAH6azfR; expires=Tue, 16 Sep 2014 18:56:23 GMT; Path=/"
|
32
|
+
],
|
33
|
+
"Vary": [
|
34
|
+
"Cookie"
|
35
|
+
],
|
36
|
+
"X-Frame-Options": [
|
37
|
+
"SAMEORIGIN"
|
38
|
+
],
|
39
|
+
"X-Gittip-Version": [
|
40
|
+
"10.1.21"
|
41
|
+
],
|
42
|
+
"Transfer-Encoding": [
|
43
|
+
"chunked"
|
44
|
+
],
|
45
|
+
"Connection": [
|
46
|
+
"keep-alive"
|
47
|
+
]
|
48
|
+
},
|
49
|
+
"body": {
|
50
|
+
"encoding": "UTF-8",
|
51
|
+
"string": "{\n \"average_tip\": 1.2348237280979523,\n \"average_tippees\": 3,\n \"escrow\": 50441.17,\n \"last_thursday\": \"last Thursday\",\n \"nach\": \"299\",\n \"nactive\": 1719,\n \"ncc\": 1496,\n \"ngivers\": 1113,\n \"noverlap\": 301,\n \"nreceivers\": 907,\n \"other_people\": \"three other people\",\n \"pcc\": \" 7.6\",\n \"punc\": \".\",\n \"statements\": [\n {\n \"statement\": \"hacking around and having fun building things.\",\n \"username\": \"cfontes\"\n },\n {\n \"statement\": \"making the world better by thinking.\",\n \"username\": \"inanisryoo\"\n },\n {\n \"statement\": \"working on open-source software for the web. I created the messaging library Faye, the password manager Vault and a bunch more besides.\",\n \"username\": \"jcoglan\"\n },\n {\n \"statement\": \"maintaining various Ruby open-source projects (rails_admin, twitter, omniauth, thor, multi_json, multi_xml, faraday, delayed_job, etc.)\",\n \"username\": \"sferik\"\n },\n {\n \"statement\": \"making it easier to retrieve Google Analytics data and build amazing dashboards!\",\n \"username\": \"OOcharts\"\n },\n {\n \"statement\": \"Building free WordPress plugins and themes for others to use\",\n \"username\": \"sumobi_\"\n },\n {\n \"statement\": \"writing the code :)\",\n \"username\": \"torkve\"\n },\n {\n \"statement\": \"contributing to various projects I'm interested in. I'm not a real programmer or anything, though--just going through the motions and pretending to know what I'm doing.\\n\\nYour tips are probably better spent elsewhere, but here are some projects I will commit to at different funding levels:\\n\\n- $2/week: Fix outstanding issues in my projects on Github.\\n- $5/week: Open-source a useful iOS library. \\n- $15/week: Open-source an iOS side-scrolling game and make at least 3 non-trivial pull requests on cocos2d-iphone.\\n- $25+/week: Embark on an open-source pilgrimage.\\n\",\n \"username\": \"modocache\"\n },\n {\n \"statement\": \"contributes to GitHub repos: https://github.com/lexrus\\nand create some useful open source projects.\",\n \"username\": \"Lex\"\n },\n {\n \"statement\": \"developing XBMC add-ons.\",\n \"username\": \"sphere\"\n },\n {\n \"statement\": \"writing software\",\n \"username\": \"mamby\"\n },\n {\n \"statement\": \"making sure nobody gets my username on here :P\",\n \"username\": \"clarkeash\"\n },\n {\n \"statement\": \"I write small tools and libraries. Most of them pass by unnoticed in the night but I also contribute to projects semi regularly. Check my github profile to see what I've been working on.\",\n \"username\": \"wraithan\"\n },\n {\n \"statement\": \"We made some simple CMS\\nhttps://github.com/iDenn/AVE.cms\",\n \"username\": \"iDenn\"\n },\n {\n \"statement\": \"writing, maintaining and extending the console file manager \\\"ranger\\\" which is available on a variety of operating systems. See http://ranger.nongnu.org/\",\n \"username\": \"hut\"\n },\n {\n \"statement\": \"teaching others for free! I also contribute to open-source platforms regularly.\",\n \"username\": \"TerryHarveyMe\"\n }\n ],\n \"this_thursday\": \"this Thursday\",\n \"tip_distribution_json\": {\n \"0.01\": [\n 5,\n 0.0010615711252653928\n ],\n \"0.02\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.03\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.05\": [\n 14,\n 0.0029723991507431\n ],\n \"0.08\": [\n 36,\n 0.007643312101910828\n ],\n \"0.10\": [\n 16,\n 0.003397027600849257\n ],\n \"0.11\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.12\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.15\": [\n 2,\n 0.0004246284501061571\n ],\n \"0.16\": [\n 27,\n 0.005732484076433121\n ],\n \"0.20\": [\n 6,\n 0.0012738853503184713\n ],\n \"0.21\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.25\": [\n 1970,\n 0.4182590233545648\n ],\n \"0.26\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.28\": [\n 2,\n 0.0004246284501061571\n ],\n \"0.29\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.30\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.32\": [\n 16,\n 0.003397027600849257\n ],\n \"0.40\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.42\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.45\": [\n 2,\n 0.0004246284501061571\n ],\n \"0.48\": [\n 2,\n 0.0004246284501061571\n ],\n \"0.50\": [\n 131,\n 0.02781316348195329\n ],\n \"0.52\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.57\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.64\": [\n 8,\n 0.0016985138004246285\n ],\n \"0.65\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.75\": [\n 20,\n 0.004246284501061571\n ],\n \"0.76\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.79\": [\n 1,\n 0.00021231422505307856\n ],\n \"0.95\": [\n 1,\n 0.00021231422505307856\n ],\n \"1.00\": [\n 1457,\n 0.30934182590233544\n ],\n \"1.10\": [\n 1,\n 0.00021231422505307856\n ],\n \"1.11\": [\n 2,\n 0.0004246284501061571\n ],\n \"1.12\": [\n 1,\n 0.00021231422505307856\n ],\n \"1.20\": [\n 1,\n 0.00021231422505307856\n ],\n \"1.25\": [\n 15,\n 0.0031847133757961785\n ],\n \"1.28\": [\n 11,\n 0.002335456475583864\n ],\n \"1.35\": [\n 1,\n 0.00021231422505307856\n ],\n \"1.49\": [\n 1,\n 0.00021231422505307856\n ],\n \"1.50\": [\n 23,\n 0.004883227176220807\n ],\n \"1.70\": [\n 1,\n 0.00021231422505307856\n ],\n \"1.85\": [\n 1,\n 0.00021231422505307856\n ],\n \"1.92\": [\n 1,\n 0.00021231422505307856\n ],\n \"10.00\": [\n 53,\n 0.011252653927813163\n ],\n \"10.75\": [\n 1,\n 0.00021231422505307856\n ],\n \"100.00\": [\n 9,\n 0.001910828025477707\n ],\n \"12.00\": [\n 51,\n 0.010828025477707006\n ],\n \"15.00\": [\n 3,\n 0.0006369426751592356\n ],\n \"19.00\": [\n 1,\n 0.00021231422505307856\n ],\n \"19.25\": [\n 1,\n 0.00021231422505307856\n ],\n \"2.00\": [\n 176,\n 0.037367303609341825\n ],\n \"2.22\": [\n 1,\n 0.00021231422505307856\n ],\n \"2.25\": [\n 3,\n 0.0006369426751592356\n ],\n \"2.50\": [\n 13,\n 0.002760084925690021\n ],\n \"20.00\": [\n 10,\n 0.0021231422505307855\n ],\n \"24.00\": [\n 75,\n 0.01592356687898089\n ],\n \"24.75\": [\n 1,\n 0.00021231422505307856\n ],\n \"25.00\": [\n 12,\n 0.0025477707006369425\n ],\n \"27.00\": [\n 1,\n 0.00021231422505307856\n ],\n \"3.00\": [\n 307,\n 0.06518046709129512\n ],\n \"3.33\": [\n 2,\n 0.0004246284501061571\n ],\n \"30.00\": [\n 2,\n 0.0004246284501061571\n ],\n \"35.00\": [\n 1,\n 0.00021231422505307856\n ],\n \"4.00\": [\n 18,\n 0.003821656050955414\n ],\n \"4.50\": [\n 1,\n 0.00021231422505307856\n ],\n \"4.75\": [\n 1,\n 0.00021231422505307856\n ],\n \"4.80\": [\n 1,\n 0.00021231422505307856\n ],\n \"40.00\": [\n 1,\n 0.00021231422505307856\n ],\n \"5.00\": [\n 66,\n 0.014012738853503185\n ],\n \"5.50\": [\n 3,\n 0.0006369426751592356\n ],\n \"5.75\": [\n 1,\n 0.00021231422505307856\n ],\n \"50.00\": [\n 1,\n 0.00021231422505307856\n ],\n \"51.00\": [\n 1,\n 0.00021231422505307856\n ],\n \"6.00\": [\n 85,\n 0.018046709129511677\n ],\n \"6.50\": [\n 1,\n 0.00021231422505307856\n ],\n \"65.00\": [\n 1,\n 0.00021231422505307856\n ],\n \"7.00\": [\n 2,\n 0.0004246284501061571\n ],\n \"7.25\": [\n 1,\n 0.00021231422505307856\n ],\n \"7.75\": [\n 1,\n 0.00021231422505307856\n ],\n \"75.00\": [\n 1,\n 0.00021231422505307856\n ],\n \"8.00\": [\n 6,\n 0.0012738853503184713\n ],\n \"8.50\": [\n 1,\n 0.00021231422505307856\n ],\n \"8.75\": [\n 1,\n 0.00021231422505307856\n ],\n \"9.00\": [\n 2,\n 0.0004246284501061571\n ],\n \"9.75\": [\n 1,\n 0.00021231422505307856\n ],\n \"9.99\": [\n 1,\n 0.00021231422505307856\n ]\n },\n \"tip_n\": 4710,\n \"total_backed_tips\": 5849.36,\n \"transfer_volume\": 5464.38\n}\n"
|
52
|
+
},
|
53
|
+
"http_version": null
|
54
|
+
},
|
55
|
+
"recorded_at": "Tue, 17 Sep 2013 18:56:22 GMT"
|
56
|
+
}
|
57
|
+
],
|
58
|
+
"recorded_with": "VCR 2.5.0"
|
59
|
+
}
|
@@ -141,24 +141,32 @@ describe Gratitude::Payday do
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
describe "#
|
144
|
+
describe "#number_of_ach_credits" do
|
145
145
|
it "should return the correct number of achs" do
|
146
|
-
expect(payday.
|
146
|
+
expect(payday.number_of_ach_credits).to eq(53)
|
147
147
|
end
|
148
148
|
|
149
149
|
|
150
150
|
it "should return the same value as #nachs" do
|
151
|
-
expect(payday.
|
151
|
+
expect(payday.number_of_ach_credits).to eq(payday.nachs)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should return the same value as #number_of_achs" do
|
155
|
+
expect(payday.number_of_ach_credits).to eq(payday.number_of_achs)
|
152
156
|
end
|
153
157
|
end
|
154
158
|
|
155
|
-
describe "#
|
159
|
+
describe "#number_of_active_users" do
|
156
160
|
it "should return the correct number active" do
|
157
|
-
expect(payday.
|
161
|
+
expect(payday.number_of_active_users).to eq(1719)
|
158
162
|
end
|
159
163
|
|
160
164
|
it "should return the same value as #nactive" do
|
161
|
-
expect(payday.
|
165
|
+
expect(payday.number_of_active_users).to eq(payday.nactive)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should return the same value as #number_active" do
|
169
|
+
expect(payday.number_of_active_users).to eq(payday.number_active)
|
162
170
|
end
|
163
171
|
end
|
164
172
|
|
@@ -228,39 +236,47 @@ describe Gratitude::Payday do
|
|
228
236
|
end
|
229
237
|
end
|
230
238
|
|
231
|
-
describe "#
|
239
|
+
describe "#transfer_end_time" do
|
232
240
|
it "should return a DateTime object" do
|
233
|
-
expect(payday.
|
241
|
+
expect(payday.transfer_end_time.class).to eq(DateTime)
|
234
242
|
end
|
235
243
|
|
236
244
|
it "should have the correct year" do
|
237
|
-
expect(payday.
|
245
|
+
expect(payday.transfer_end_time.year).to eq(2013)
|
238
246
|
end
|
239
247
|
|
240
248
|
it "should have the correct month" do
|
241
|
-
expect(payday.
|
249
|
+
expect(payday.transfer_end_time.month).to eq(9)
|
242
250
|
end
|
243
251
|
|
244
252
|
it "should have the correct date" do
|
245
|
-
expect(payday.
|
253
|
+
expect(payday.transfer_end_time.day).to eq(12)
|
254
|
+
end
|
255
|
+
|
256
|
+
it "should return the same value as #ts_end" do
|
257
|
+
expect(payday.transfer_end_time).to eq(payday.ts_end)
|
246
258
|
end
|
247
259
|
end
|
248
260
|
|
249
|
-
describe "#
|
261
|
+
describe "#transfer_start_time" do
|
250
262
|
it "should return a DateTime object" do
|
251
|
-
expect(payday.
|
263
|
+
expect(payday.transfer_start_time.class).to eq(DateTime)
|
252
264
|
end
|
253
265
|
|
254
266
|
it "should have the correct year" do
|
255
|
-
expect(payday.
|
267
|
+
expect(payday.transfer_start_time.year).to eq(2013)
|
256
268
|
end
|
257
269
|
|
258
270
|
it "should have the correct month" do
|
259
|
-
expect(payday.
|
271
|
+
expect(payday.transfer_start_time.month).to eq(9)
|
260
272
|
end
|
261
273
|
|
262
274
|
it "should have the correct date" do
|
263
|
-
expect(payday.
|
275
|
+
expect(payday.transfer_start_time.day).to eq(12)
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should return the same value as #ts_start" do
|
279
|
+
expect(payday.transfer_start_time).to eq(payday.ts_start)
|
264
280
|
end
|
265
281
|
end
|
266
282
|
|
@@ -47,7 +47,7 @@ describe Gratitude::Profile do
|
|
47
47
|
expect(complete_profile.avatar_url).to eq("https://www.gravatar.com/avatar/fb054b407a6461e417ee6b6ae084da37.jpg?s=128")
|
48
48
|
end
|
49
49
|
|
50
|
-
it "should return the same value as #avatar" do
|
50
|
+
it "should return the same value as its alias: #avatar" do
|
51
51
|
expect(complete_profile.avatar_url).to eq(complete_profile.avatar)
|
52
52
|
end
|
53
53
|
end
|
@@ -57,7 +57,7 @@ describe Gratitude::Profile do
|
|
57
57
|
expect(complete_profile.bitbucket_api_url).to eq("https://bitbucket.org/api/1.0/users/whit537")
|
58
58
|
end
|
59
59
|
|
60
|
-
it "should return the same value as #bitbucket" do
|
60
|
+
it "should return the same value as its alias: #bitbucket" do
|
61
61
|
expect(complete_profile.bitbucket_api_url).to eq(complete_profile.bitbucket)
|
62
62
|
end
|
63
63
|
end
|
@@ -85,7 +85,7 @@ describe Gratitude::Profile do
|
|
85
85
|
expect(complete_profile.github_api_url).to eq("https://api.github.com/users/whit537")
|
86
86
|
end
|
87
87
|
|
88
|
-
it "should return the same value as #github" do
|
88
|
+
it "should return the same value as its alias: #github" do
|
89
89
|
expect(complete_profile.github_api_url).to eq(complete_profile.github)
|
90
90
|
end
|
91
91
|
end
|
@@ -101,7 +101,7 @@ describe Gratitude::Profile do
|
|
101
101
|
expect(complete_profile.twitter_api_url).to eq("https://api.twitter.com/1.1/users/show.json?id=34175404&include_entities=1")
|
102
102
|
end
|
103
103
|
|
104
|
-
it "should return the same value as #twitter" do
|
104
|
+
it "should return the same value as its alias: #twitter" do
|
105
105
|
expect(complete_profile.twitter_api_url).to eq(complete_profile.twitter)
|
106
106
|
end
|
107
107
|
end
|
@@ -121,7 +121,7 @@ describe Gratitude::Profile do
|
|
121
121
|
expect(complete_profile.amount_giving).to eq(101.41)
|
122
122
|
end
|
123
123
|
|
124
|
-
it "should return the same value as #giving" do
|
124
|
+
it "should return the same value as its alias: #giving" do
|
125
125
|
expect(complete_profile.amount_giving).to eq(complete_profile.giving)
|
126
126
|
end
|
127
127
|
end
|
@@ -133,9 +133,9 @@ describe Gratitude::Profile do
|
|
133
133
|
|
134
134
|
it "should return the correct amount amount receiving" do
|
135
135
|
expect(complete_profile.amount_receiving).to eq(434.25)
|
136
|
-
|
136
|
+
end
|
137
137
|
|
138
|
-
|
138
|
+
it "should return the same value as its alias: #receiving" do
|
139
139
|
expect(complete_profile.amount_receiving).to eq(complete_profile.receiving)
|
140
140
|
end
|
141
141
|
end
|
@@ -146,9 +146,13 @@ describe Gratitude::Profile do
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
describe "#
|
150
|
-
it "should return the correct
|
151
|
-
expect(complete_profile.
|
149
|
+
describe "#account_type" do
|
150
|
+
it "should return the correct account_type" do
|
151
|
+
expect(complete_profile.account_type).to eq("singular")
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should return the same value as its alias: #number" do
|
155
|
+
expect(complete_profile.account_type).to eq(complete_profile.number)
|
152
156
|
end
|
153
157
|
end
|
154
158
|
|
@@ -0,0 +1,287 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Gratitude::Statistics do
|
4
|
+
|
5
|
+
describe "default attributes" do
|
6
|
+
it "should include httparty methods" do
|
7
|
+
Gratitude::Statistics.should include(HTTParty)
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
it "should have the base uri set to gittip's payday api endpoint" do
|
12
|
+
expect(Gratitude::Statistics.base_uri).to eq("https://www.gittip.com/about/stats.json")
|
13
|
+
end
|
14
|
+
end # default attributes
|
15
|
+
|
16
|
+
describe "instance methods" do
|
17
|
+
|
18
|
+
before do
|
19
|
+
VCR.insert_cassette "statistics"
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
VCR.eject_cassette
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:stats) { Gratitude::Statistics.new }
|
27
|
+
|
28
|
+
it "should respond to #repsonse" do
|
29
|
+
expect(stats).to respond_to(:response)
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#average_tip_amount" do
|
33
|
+
it "should return the correct average tip amount" do
|
34
|
+
expect(stats.average_tip_amount).to eq(1.2348237280979524)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return a float" do
|
38
|
+
expect(stats.average_tip_amount.class).to be(Float)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return the same value as its alias: #average_tip" do
|
42
|
+
expect(stats.average_tip_amount).to eq(stats.average_tip)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#average_number_of_tippees" do
|
47
|
+
it "should return the correct average number of tippees" do
|
48
|
+
expect(stats.average_number_of_tippees).to eq(3)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return a fixnum" do
|
52
|
+
expect(stats.average_number_of_tippees.class).to be(Fixnum)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return the same value as its alias: #average_tippees" do
|
56
|
+
expect(stats.average_number_of_tippees).to eq(stats.average_tippees)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#amount_in_escrow" do
|
61
|
+
it "should return the correct amount in escrow" do
|
62
|
+
expect(stats.amount_in_escrow).to eq(50441.17)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return a float" do
|
66
|
+
expect(stats.amount_in_escrow.class).to be(Float)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should return the same value as its alias: #escrow" do
|
70
|
+
expect(stats.amount_in_escrow).to eq(stats.escrow)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#last_thursday" do
|
75
|
+
it "should return the correct value for last thursday" do
|
76
|
+
expect(stats.last_thursday).to eq("last Thursday")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should be a string" do
|
80
|
+
expect(stats.last_thursday.class).to be(String)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#number_of_achs" do
|
85
|
+
it "should return the correct number of ach credits" do
|
86
|
+
expect(stats.number_of_ach_credits).to eq(299)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should be a fixnum" do
|
90
|
+
expect(stats.number_of_ach_credits.class).to be(Fixnum)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return the same value as its alias: #nach" do
|
94
|
+
expect(stats.number_of_ach_credits).to eq(stats.nach)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should return the same value as its alias: #number_of_achs" do
|
98
|
+
expect(stats.number_of_ach_credits).to eq(stats.number_of_achs)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#number_of_active_users" do
|
103
|
+
it "should return the correct number of active users" do
|
104
|
+
expect(stats.number_of_active_users).to eq(1719)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should be a fixnum" do
|
108
|
+
expect(stats.number_of_active_users.class).to be(Fixnum)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should return the same value as its alias: #nactive" do
|
112
|
+
expect(stats.number_of_active_users).to eq(stats.nactive)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#number_of_credit_cards" do
|
117
|
+
it "should return the correct number of credit cards on file" do
|
118
|
+
expect(stats.number_of_credit_cards).to eq(1496)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should be a fixnum" do
|
122
|
+
expect(stats.number_of_credit_cards.class).to be(Fixnum)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should return the same value as its alias: #ncc" do
|
126
|
+
expect(stats.number_of_credit_cards).to eq(stats.ncc)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "#number_of_givers" do
|
131
|
+
it "should return the correct number of givers" do
|
132
|
+
expect(stats.number_of_givers).to eq(1113)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should be a fixnum" do
|
136
|
+
expect(stats.number_of_givers.class).to be(Fixnum)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should return the same value as its alias: #ngivers" do
|
140
|
+
expect(stats.number_of_givers).to eq(stats.ngivers)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#number_who_give_and_receive" do
|
145
|
+
it "should return the correct number of users who both give and receive" do
|
146
|
+
expect(stats.number_who_give_and_receive).to eq(301)
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should be a fixnum" do
|
150
|
+
expect(stats.number_who_give_and_receive.class).to be(Fixnum)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should return the same value as its alias: #noverlap" do
|
154
|
+
expect(stats.number_who_give_and_receive).to eq(stats.noverlap)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "#number_of_receivers" do
|
159
|
+
it "should return the correct number of receivers" do
|
160
|
+
expect(stats.number_of_receivers).to eq(907)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should be a fixnum" do
|
164
|
+
expect(stats.number_of_receivers.class).to be(Fixnum)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should return the same value as its alias: #nreceivers" do
|
168
|
+
expect(stats.number_of_receivers).to eq(stats.nreceivers)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "#other_people" do
|
173
|
+
it "should return the correct value for #other_people" do
|
174
|
+
expect(stats.other_people).to eq("three other people")
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should be a string" do
|
178
|
+
expect(stats.other_people.class).to be(String)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "#percentage_of_users_with_credit_cards" do
|
183
|
+
it "should return the correct value for #percentage_of_users_with_credit_cards" do
|
184
|
+
expect(stats.percentage_of_users_with_credit_cards).to eq("7.6")
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should be a string" do
|
188
|
+
expect(stats.percentage_of_users_with_credit_cards.class).to be(String)
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should return the same value as its alias: #pcc" do
|
192
|
+
expect(stats.percentage_of_users_with_credit_cards).to eq(stats.pcc)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "#punctuation" do
|
197
|
+
it "should return the correct value for #punctuation" do
|
198
|
+
expect(stats.punctuation).to eq(".")
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should be a string" do
|
202
|
+
expect(stats.punctuation.class).to be(String)
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should return the same value as its alias: #pcc" do
|
206
|
+
expect(stats.punctuation).to eq(stats.punc)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe "#statements" do
|
211
|
+
it "should return an array" do
|
212
|
+
expect(stats.statements.class).to be(Array)
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should contain 16 elements in the array" do
|
216
|
+
expect(stats.statements.size).to eq(16)
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should have a hash for each element in the array" do
|
220
|
+
expect(stats.statements.first.class).to be(Hash)
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should have statement as a key in each hash element" do
|
224
|
+
expect(stats.statements.first.has_key?("statement")).to be(true)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should have username as a key in each hash element" do
|
228
|
+
expect(stats.statements.first.has_key?("username")).to be(true)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe "#this_thursday" do
|
233
|
+
it "should return the correct value for this thursday" do
|
234
|
+
expect(stats.this_thursday).to eq("this Thursday")
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should be a string" do
|
238
|
+
expect(stats.this_thursday.class).to be(String)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "#tip_distribution_json" do
|
243
|
+
it "should return a hash" do
|
244
|
+
expect(stats.tip_distribution_json.class).to be(Hash)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "#number_of_tips" do
|
249
|
+
it "should return the correct number of tips" do
|
250
|
+
expect(stats.number_of_tips).to eq(4710)
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should be a fixnum" do
|
254
|
+
expect(stats.number_of_tips.class).to be(Fixnum)
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should return the same value as its alias: #tip_n" do
|
258
|
+
expect(stats.number_of_tips).to eq(stats.tip_n)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "#value_of_total_backed_tips" do
|
263
|
+
it "should return the correct value of total backed tips" do
|
264
|
+
expect(stats.value_of_total_backed_tips).to eq(5849.36)
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should be a float" do
|
268
|
+
expect(stats.value_of_total_backed_tips.class).to be(Float)
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should return the same value as its alias: #total_backed_tips" do
|
272
|
+
expect(stats.value_of_total_backed_tips).to eq(stats.total_backed_tips)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
describe "#transfer_volume" do
|
277
|
+
it "should return the correct transfer volume" do
|
278
|
+
expect(stats.transfer_volume).to eq(5464.38)
|
279
|
+
end
|
280
|
+
|
281
|
+
it "should be a float" do
|
282
|
+
expect(stats.transfer_volume.class).to be(Float)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
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.0.
|
4
|
+
version: 0.0.6
|
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: 2013-09-
|
11
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -71,13 +71,16 @@ files:
|
|
71
71
|
- lib/gratitude.rb
|
72
72
|
- lib/gratitude/payday.rb
|
73
73
|
- lib/gratitude/profile.rb
|
74
|
+
- lib/gratitude/statistics.rb
|
74
75
|
- lib/gratitude/version.rb
|
75
76
|
- spec/cassettes/complete_profile.json
|
76
77
|
- spec/cassettes/goal_profile.json
|
77
78
|
- spec/cassettes/incomplete_profile.json
|
78
79
|
- spec/cassettes/paydays.json
|
80
|
+
- spec/cassettes/statistics.json
|
79
81
|
- spec/gratitude/payday_spec.rb
|
80
82
|
- spec/gratitude/profile_spec.rb
|
83
|
+
- spec/gratitude/statistics_spec.rb
|
81
84
|
- spec/gratitude/version_spec.rb
|
82
85
|
- spec/spec_helper.rb
|
83
86
|
homepage: https://github.com/JohnKellyFerguson/gratitude
|
@@ -109,7 +112,9 @@ test_files:
|
|
109
112
|
- spec/cassettes/goal_profile.json
|
110
113
|
- spec/cassettes/incomplete_profile.json
|
111
114
|
- spec/cassettes/paydays.json
|
115
|
+
- spec/cassettes/statistics.json
|
112
116
|
- spec/gratitude/payday_spec.rb
|
113
117
|
- spec/gratitude/profile_spec.rb
|
118
|
+
- spec/gratitude/statistics_spec.rb
|
114
119
|
- spec/gratitude/version_spec.rb
|
115
120
|
- spec/spec_helper.rb
|