gratitude 0.0.1 → 0.0.3

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTczYmJjYjU1YTUwZDRmZjhlNzU5YmYwNTZiNmFlNDEwMzU4MjM0Yw==
4
+ ZmIwZmUzM2U3YWY2MDQzMzc0NmFiNmIzNzZiZTU3NTE5OGZiNDQyOA==
5
5
  data.tar.gz: !binary |-
6
- OGM5NjcwMDYxODhiNGFjMWVlYzNjMjhmMGNlYWI1NzU3MTVhYjc2ZQ==
6
+ ZTAxNGRhMWEzNWJkYjBkNjkxZTM3OWZlNWE1YzYwZDk2NDQwOTI1Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTg3NzJmNTE4OWQ1OTczY2JiYjdhZWRhZWRmMmRjZDI1NDA4N2JlODJhYzUx
10
- MWU0ZGQzNDg5MDg0ZDFiMjUzMGEwOGNjMTg2ZWYyZTAyN2I2Mjk3NzhjNWE3
11
- NGVhNzViOTY3NGZjN2QwZjRkZTQzMzEwMjFiNGMwM2VlMmU3MDE=
9
+ YTE0MDJkYzAwZmI0MzZkZmZmYTVjZGYxNWNjMzEyODRiOGUzMWRiNDhkNzli
10
+ OWFlNGEwNzQzODE1OTM4YjkwN2U2OTQ5OGI5NGYzNmU2NDYzNDZiM2ZkZmU4
11
+ NzJlNTIzNjdjYjg0Mjg0NTMwMDIyMGNlYmM0MjU1MjlkNTE5Njg=
12
12
  data.tar.gz: !binary |-
13
- NTFiNmE3NDFiYWJkNjA0ODdjYWZiZjBmYTBkYzM4MjJkYTA4Nzg2NGFjOWVi
14
- ZDI0YzQ5YzQ3YTA5ZDk5M2ZmNWRiZmZiMTMxMjUxM2NmOWY3ODZjNmU2MGNl
15
- YTA0NGM2ODYyYTg3ZmRkZWEwZGJiZjdjMmIyNzQ4ZWNmMmVhNjM=
13
+ YWEzY2M5ZTNmZWUzNTM4MzhlMzBkMmNhNDk4MDk0YTVkNjc1ZjZhYzY5OTMw
14
+ OWEzMWYxYTY5ZmM3ZjQxMWU2NDcwZjI2MDg0NWJiOTE3OWJlMWI0MWNiZjRk
15
+ YTY5NTQ4YmRhY2UyNGI4MDZlNzcwODI2YjlkNzNlZDlmZDhmOWM=
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ ### 0.1.0 (Upcoming Stable Release)
2
+ * Implement all aspects of the Gittip API.
3
+
4
+ ### 0.0.4 (Next Release)
5
+ * Improve integration with Gittip's Public User API to account for any edgecases.
6
+
7
+ ### 0.0.3 (9/11/2013)
8
+ * Fix release version.
9
+
10
+ ### O.0.2 (9/11/2013)
11
+ * Add ability to get a Gittip user's public information.
12
+
13
+ ### 0.0.1 (9/10/2013)
14
+ * Initial release.
data/Gemfile CHANGED
@@ -4,4 +4,8 @@ gemspec
4
4
 
5
5
  group :development, :test do
6
6
  gem "rspec"
7
+ gem "webmock"
8
+ gem "vcr"
9
+ gem "pry"
10
+ gem "awesome_print"
7
11
  end
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  gratitude
2
2
  =========
3
+ [![Build Status](https://travis-ci.org/JohnKellyFerguson/gratitude.png?branch=master)](https://travis-ci.org/JohnKellyFerguson/gratitude)
3
4
 
4
5
  A simple Ruby wrapper for the Gittip API.
5
6
 
7
+ **Note**: This gem is currently under development and is not ready for use in a production environment. A stable version is planned for v0.1.0. Please follow the [Changelog](CHANGELOG.md) to check the status of the project.
8
+
6
9
  #### Copyright and License
7
10
 
8
11
  Copyright John Kelly Ferguson and Contributors, 2013
data/gratitude.gemspec CHANGED
@@ -18,6 +18,7 @@ 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 "httparty", "~> 0.11"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
23
  spec.add_development_dependency "rake"
23
24
  end
@@ -0,0 +1,71 @@
1
+ module Gratitude
2
+ class Profile
3
+ include HTTParty
4
+ base_uri "https://www.gittip.com"
5
+ URI_SUFFIX = "/public.json"
6
+
7
+ attr_reader :username, :response
8
+
9
+ def initialize(username)
10
+ @username = username
11
+ @response = self.class.get("/#{username}#{URI_SUFFIX}")
12
+ end
13
+
14
+ def avatar_url
15
+ response["avatar"]
16
+ end
17
+
18
+ def bitbucket_api_url
19
+ response["elsewhere"]["bitbucket"]
20
+ end
21
+
22
+ def bitbucket_username
23
+ bitbucket_api_url.gsub("https://bitbucket.org/api/1.0/users/", "")
24
+ end
25
+
26
+ def bountysource_api_url
27
+ response["elsewhere"]["bountysource"]
28
+ end
29
+
30
+ def bountysource_username
31
+ bountysource_api_url.gsub("https://api.bountysource.com/users/", "")
32
+ end
33
+
34
+ def github_api_url
35
+ response["elsewhere"]["github"]
36
+ end
37
+
38
+ def github_username
39
+ github_api_url.gsub("https://api.github.com/users/", "")
40
+ end
41
+
42
+ def twitter_api_url
43
+ response["elsewhere"]["twitter"]
44
+ end
45
+
46
+ def twitter_username
47
+ nil
48
+ end
49
+
50
+ def amount_giving
51
+ response["giving"].to_f
52
+ end
53
+
54
+ def amount_receiving
55
+ response["receiving"].to_f
56
+ end
57
+
58
+ def goal
59
+ response["goal"]
60
+ end
61
+
62
+ def number
63
+ response["number"]
64
+ end
65
+
66
+ def id
67
+ response["id"]
68
+ end
69
+
70
+ end # Profile
71
+ end # Gratitude
@@ -1,3 +1,3 @@
1
1
  module Gratitude
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/gratitude.rb CHANGED
@@ -1,4 +1,7 @@
1
+ require "httparty"
2
+
1
3
  require "gratitude/version"
4
+ require "gratitude/profile"
2
5
 
3
6
  module Gratitude
4
7
  # Your code goes here...
@@ -0,0 +1,62 @@
1
+ {
2
+ "http_interactions": [
3
+ {
4
+ "request": {
5
+ "method": "get",
6
+ "uri": "https://www.gittip.com/whit537/public.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
+ "Access-Control-Allow-Origin": [
22
+ "*"
23
+ ],
24
+ "Content-Type": [
25
+ "application/json"
26
+ ],
27
+ "Date": [
28
+ "Wed, 11 Sep 2013 15:34:11 GMT"
29
+ ],
30
+ "Server": [
31
+ "Aspen! Cheroot!"
32
+ ],
33
+ "Set-Cookie": [
34
+ "csrf_token=QNlOmd9PC1eiKAaO71X7xFDsjp44mPYo; expires=Wed, 10 Sep 2014 15:34:11 GMT; Path=/"
35
+ ],
36
+ "Vary": [
37
+ "Cookie"
38
+ ],
39
+ "X-Frame-Options": [
40
+ "SAMEORIGIN"
41
+ ],
42
+ "X-Gittip-Version": [
43
+ "10.1.14"
44
+ ],
45
+ "Content-Length": [
46
+ "550"
47
+ ],
48
+ "Connection": [
49
+ "keep-alive"
50
+ ]
51
+ },
52
+ "body": {
53
+ "encoding": "US-ASCII",
54
+ "string": "{\n \"avatar\": \"https://www.gravatar.com/avatar/fb054b407a6461e417ee6b6ae084da37.jpg?s=128\",\n \"elsewhere\": {\n \"bitbucket\": \"https://bitbucket.org/api/1.0/users/whit537\",\n \"bountysource\": \"https://api.bountysource.com/users/whit537\",\n \"github\": \"https://api.github.com/users/whit537\",\n \"twitter\": \"https://api.twitter.com/1.1/users/show.json?id=34175404&include_entities=1\"\n },\n \"giving\": \"101.41\",\n \"goal\": null,\n \"id\": 1451,\n \"number\": \"singular\",\n \"receiving\": \"433.00\",\n \"username\": \"whit537\"\n}"
55
+ },
56
+ "http_version": null
57
+ },
58
+ "recorded_at": "Wed, 11 Sep 2013 15:34:11 GMT"
59
+ }
60
+ ],
61
+ "recorded_with": "VCR 2.5.0"
62
+ }
@@ -0,0 +1,144 @@
1
+ require "spec_helper"
2
+
3
+ describe Gratitude::Profile do
4
+
5
+ describe "default attributes" do
6
+
7
+ it "should include httparty methods" do
8
+ Gratitude::Profile.should include(HTTParty)
9
+ end
10
+
11
+ it "should have the base url set to the API endpoint" do
12
+ expect(Gratitude::Profile.base_uri).to eq("https://www.gittip.com")
13
+ end
14
+
15
+ it "should have the correct uri suffix" do
16
+ expect(Gratitude::Profile::URI_SUFFIX).to eq("/public.json")
17
+ end
18
+
19
+ end
20
+
21
+ describe "instance methods" do
22
+ before do
23
+ VCR.insert_cassette "profile"
24
+ end
25
+
26
+ after do
27
+ VCR.eject_cassette
28
+ end
29
+
30
+ let(:profile) { Gratitude::Profile.new("whit537") }
31
+
32
+ it "should set the correct username" do
33
+ expect(profile.username).to eq("whit537")
34
+ end
35
+
36
+ it "should respond to #response" do
37
+ expect(profile).to respond_to(:response)
38
+ end
39
+
40
+ describe "#avatar_url" do
41
+ it "should return the correct avatar url" do
42
+ expect(profile.avatar_url).to eq("https://www.gravatar.com/avatar/fb054b407a6461e417ee6b6ae084da37.jpg?s=128")
43
+ end
44
+ end
45
+
46
+ describe "#bitbucket_api_url" do
47
+ it "should return the correct bitbucket api url" do
48
+ expect(profile.bitbucket_api_url).to eq("https://bitbucket.org/api/1.0/users/whit537")
49
+ end
50
+ end
51
+
52
+ describe "#bitbucket_username" do
53
+ it "should return the correct bitbucket username" do
54
+ expect(profile.bitbucket_username).to eq("whit537")
55
+ end
56
+ end
57
+
58
+ describe "#bountysource_api_url" do
59
+ it "should return the correct the bountysource api url" do
60
+ expect(profile.bountysource_api_url).to eq("https://api.bountysource.com/users/whit537")
61
+ end
62
+ end
63
+
64
+ describe "#bountysource_username" do
65
+ it "should return the correct bountysource username" do
66
+ expect(profile.bountysource_username).to eq("whit537")
67
+ end
68
+ end
69
+
70
+ describe "#github_api_url" do
71
+ it "should return the correct github api url" do
72
+ expect(profile.github_api_url).to eq("https://api.github.com/users/whit537")
73
+ end
74
+ end
75
+
76
+ describe "#github_username" do
77
+ it "should return the correct github username" do
78
+ expect(profile.github_username).to eq("whit537")
79
+ end
80
+ end
81
+
82
+ describe "#twitter_api_url" do
83
+ it "should return the correct twitter api url" do
84
+ expect(profile.twitter_api_url).to eq("https://api.twitter.com/1.1/users/show.json?id=34175404&include_entities=1")
85
+ end
86
+ end
87
+
88
+ describe "#twitter_username" do
89
+ it "should return nil" do
90
+ expect(profile.twitter_username).to be(nil)
91
+ end
92
+ end
93
+
94
+ describe "#amount_giving" do
95
+
96
+ it "should be a float" do
97
+ expect(profile.amount_giving.class).to be(Float)
98
+ end
99
+
100
+ it "should return the correct amount giving" do
101
+ expect(profile.amount_giving).to eq(101.41)
102
+ end
103
+
104
+ end
105
+
106
+ describe "#amount_receiving" do
107
+
108
+ it "should be a float" do
109
+ expect(profile.amount_receiving.class).to be(Float)
110
+ end
111
+
112
+ it "should return the correct amount amount receiving" do
113
+ expect(profile.amount_receiving).to eq(433.00)
114
+ end
115
+
116
+ end
117
+
118
+ describe "#goal" do
119
+ it "should return the correct goal" do
120
+ expect(profile.goal).to be(nil)
121
+ end
122
+ end
123
+
124
+ describe "#number" do
125
+ it "should return the correct number" do
126
+ expect(profile.number).to eq("singular")
127
+ end
128
+ end
129
+
130
+ describe "#id" do
131
+
132
+ it "should be a fixnum" do
133
+ expect(profile.id.class).to be(Fixnum)
134
+ end
135
+
136
+ it "should return the correct id number" do
137
+ expect(profile.id).to eq(1451)
138
+ end
139
+ end
140
+
141
+
142
+ end
143
+
144
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,15 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
 
3
+ # dependencies
3
4
  require "rubygems"
4
5
  require "rspec"
5
- require "gratitude"
6
+ require "gratitude"
7
+ require "vcr"
8
+ require "webmock"
9
+
10
+ # VCR config
11
+ VCR.configure do |c|
12
+ c.cassette_library_dir = 'spec/cassettes'
13
+ c.hook_into :webmock
14
+ c.default_cassette_options = { record: :new_episodes, serialize_with: :json }
15
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gratitude
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
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-10 00:00:00.000000000 Z
11
+ date: 2013-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.11'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -48,13 +62,17 @@ files:
48
62
  - .gitignore
49
63
  - .rspec
50
64
  - .travis.yml
65
+ - CHANGELOG.md
51
66
  - Gemfile
52
67
  - LICENSE.txt
53
68
  - README.md
54
69
  - Rakefile
55
70
  - gratitude.gemspec
56
71
  - lib/gratitude.rb
72
+ - lib/gratitude/profile.rb
57
73
  - lib/gratitude/version.rb
74
+ - spec/cassettes/profile.json
75
+ - spec/gratitude/profile_spec.rb
58
76
  - spec/gratitude/version_spec.rb
59
77
  - spec/spec_helper.rb
60
78
  homepage: https://github.com/JohnKellyFerguson/gratitude
@@ -82,5 +100,7 @@ signing_key:
82
100
  specification_version: 4
83
101
  summary: A simple Ruby wrapper for the Gittip API.
84
102
  test_files:
103
+ - spec/cassettes/profile.json
104
+ - spec/gratitude/profile_spec.rb
85
105
  - spec/gratitude/version_spec.rb
86
106
  - spec/spec_helper.rb