thecity 0.0.4 → 0.0.5

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f492df47b04ec33d8474850424bef2adca6cc4b1
4
- data.tar.gz: ff196364e87fdd1375b9fe05aef391cd2179b68c
3
+ metadata.gz: b12bfee6951905f54282a071d1cbd98df569c3be
4
+ data.tar.gz: 77ef962cbd7632893106541eff518ccc7a6b7af8
5
5
  SHA512:
6
- metadata.gz: d4360d9b2954cab54944344a065ceb8b6ea5f592722a6405a1daeab10bc6a6aa2df9710b93c64baf5aaf2245a0821cc81909d0112f48fe719fb97c87660a7dd0
7
- data.tar.gz: dcb877e2537a82a303dc300dc1ecf43ac9f0a94e0767f95b70f136a3e6719512827f3e8a50d9058124ec45c879dec8b173c1edd5105dc9860a270c7c68cb0b15
6
+ metadata.gz: 4c60f17af5476b2389430de4919456674e5a8927fba37dd71ef3e7878eb9a5b8e23dd29cdeb8d896395e5c6be875497645e2d0ff8333c7de3f1556f6f80eb6e7
7
+ data.tar.gz: 6c3613d4b345a6cabd24fba97bf5f7e897fb2f89998f83935e3f52893b1febd44a0101c8e035945ac6b6c47479dff5ee96eacdc9422484ec9f5f501d9ea10c31
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # The City Ruby Gem
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/thecity.png)](http://badge.fury.io/rb/thecity)
4
+ [![Dependency Status](https://gemnasium.com/thecity/thecity.png)](https://gemnasium.com/thecity/thecity)
5
+ [![Build Status](https://travis-ci.org/thecity/thecity.png?branch=master)](https://travis-ci.org/thecity/thecity)
4
6
 
5
7
  A Ruby interface to the The City API. For more information about The City platform, see [http://api.onthecity.org][api info]
6
8
 
@@ -45,22 +47,12 @@ Alternately, you can set the following environment variables:
45
47
  THECITY_ACCESS_TOKEN
46
48
  THECITY_SUBDOMAIN
47
49
 
48
- After configuration, requests can be made like so:
49
-
50
- ```ruby
51
- client.current_user
52
- ```
53
-
54
- or
55
-
56
- ```ruby
57
- client.my_groups
58
- ```
59
-
60
50
  ## Usage Examples
61
51
  All examples require an authenticated TheCity client with a valid access_token. See the section on <a
62
52
  href="#configuration">configuration</a>.
63
53
 
54
+ After configuration, requests can be made like so:
55
+
64
56
  **Get the authenticated user (current user)**
65
57
 
66
58
  ```ruby
@@ -33,17 +33,17 @@ module TheCity
33
33
  include TheCity::API::Prayers
34
34
  include TheCity::API::Needs
35
35
 
36
- attr_writer :bearer_token, :connection_options, :middleware
36
+ attr_writer :connection_options, :middleware
37
37
 
38
- ENDPOINT = ENV['THECITY_API_ENDPOINT'] || 'https://api.onthecity.org'
38
+ ENDPOINT = ENV['THECITY_API_ENDPOINT'] || 'https://api.stagethecity.org'
39
39
 
40
40
  def connection_options
41
41
  {
42
42
  :builder => middleware,
43
43
  :headers => {
44
44
  :accept => "application/vnd.thecity.v#{version}+json",
45
- 'X-THECITY-SUBDOMAIN' => subdomain,
46
- 'X-THECITY-ACCESS-TOKEN' => access_token,
45
+ 'X-CITY-SUBDOMAIN' => subdomain,
46
+ 'X-CITY-ACCESS-TOKEN' => access_token,
47
47
  },
48
48
  :request => {
49
49
  :open_timeout => 5,
@@ -4,7 +4,7 @@ require 'the_city/need'
4
4
 
5
5
  module TheCity
6
6
  module API
7
- module needs
7
+ module Needs
8
8
  include TheCity::API::Utils
9
9
 
10
10
  # Posts a need to The City
@@ -4,7 +4,7 @@ require 'the_city/prayer'
4
4
 
5
5
  module TheCity
6
6
  module API
7
- module prayers
7
+ module Prayers
8
8
  include TheCity::API::Utils
9
9
 
10
10
  # Posts a prayer to The City
@@ -2,7 +2,7 @@ module TheCity
2
2
  class Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 4
5
+ PATCH = 5
6
6
  PRE = nil
7
7
 
8
8
  class << self
@@ -0,0 +1 @@
1
+ {"id":6753948,"first":"Bob","last":"Smith","groups":[{"name": "my one group", "id": 333},{"name": "my two group", "id": 555}]}
data/spec/helper.rb ADDED
@@ -0,0 +1,62 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ Coveralls::SimpleCov::Formatter
8
+ ]
9
+ SimpleCov.start
10
+
11
+ require 'the_city'
12
+ require 'rspec'
13
+ require 'webmock/rspec'
14
+
15
+ WebMock.disable_net_connect!(:allow => 'coveralls.io')
16
+
17
+ RSpec.configure do |config|
18
+ config.expect_with :rspec do |c|
19
+ c.syntax = :expect
20
+ end
21
+ end
22
+
23
+ def a_delete(path)
24
+ a_request(:delete, TheCity::API::Client::ENDPOINT + path)
25
+ end
26
+
27
+ def a_get(path)
28
+ a_request(:get, TheCity::API::Client::ENDPOINT + path)
29
+ end
30
+
31
+ def a_post(path)
32
+ a_request(:post, TheCity::API::Client::ENDPOINT + path)
33
+ end
34
+
35
+ def a_put(path)
36
+ a_request(:put, TheCity::API::Client::ENDPOINT + path)
37
+ end
38
+
39
+ def stub_delete(path)
40
+ stub_request(:delete, TheCity::API::Client::ENDPOINT + path)
41
+ end
42
+
43
+ def stub_get(path)
44
+ puts TheCity::API::Client::ENDPOINT + path
45
+ stub_request(:get, TheCity::API::Client::ENDPOINT + path)
46
+ end
47
+
48
+ def stub_post(path)
49
+ stub_request(:post, TheCity::API::Client::ENDPOINT + path)
50
+ end
51
+
52
+ def stub_put(path)
53
+ stub_request(:put, TheCity::API::Client::ENDPOINT + path)
54
+ end
55
+
56
+ def fixture_path
57
+ File.expand_path("../fixtures", __FILE__)
58
+ end
59
+
60
+ def fixture(file)
61
+ File.new(fixture_path + '/' + file)
62
+ end
@@ -0,0 +1,24 @@
1
+ require 'helper'
2
+
3
+ describe TheCity::API::Users do
4
+
5
+ before do
6
+ @client = TheCity::API::Client.new(:app_id => "CK", :app_secret => "CS", :access_token => "AT")
7
+ end
8
+
9
+ describe "#me" do
10
+ before do
11
+ stub_get("/me").to_return(:body => fixture("me.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
+ end
13
+ it "requests the correct resource" do
14
+ @client.me
15
+ expect(a_get("/me")).to have_been_made
16
+ end
17
+ it "returns the requesting user" do
18
+ user = @client.me
19
+ expect(user).to be_a TheCity::User
20
+ expect(user.id).to eq(6753948)
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,43 @@
1
+ require 'helper'
2
+
3
+ describe TheCity::Base do
4
+ before do
5
+ @base = TheCity::Base.new(:name => "Jim")
6
+ end
7
+
8
+ describe "#[]" do
9
+ it "calls methods using [] with symbol" do
10
+ expect(@base[:attrs]).to be_an Hash
11
+ end
12
+ it "calls methods using [] with string" do
13
+ expect(@base["attrs"]).to be_an Hash
14
+ end
15
+ it "returns nil for missing method" do
16
+ expect(@base[:foo]).to be_nil
17
+ expect(@base["foo"]).to be_nil
18
+ end
19
+ end
20
+
21
+ describe "#attrs" do
22
+ it "returns a hash of attributes" do
23
+ expect(@base.attrs).to eq({:name => "Jim"})
24
+ end
25
+ end
26
+
27
+ describe "#delete" do
28
+ it "deletes an attribute and returns its value" do
29
+ base = TheCity::Base.new(:id => 1)
30
+ expect(base.delete(:id)).to eq(1)
31
+ expect(base.attrs[:id]).to be_nil
32
+ end
33
+ end
34
+
35
+ describe "#update" do
36
+ it "returns a hash of attributes" do
37
+ base = TheCity::Base.new(:id => 1)
38
+ base.update(:id => 2)
39
+ expect(base.attrs[:id]).to eq(2)
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,47 @@
1
+ # coding: utf-8
2
+ require 'helper'
3
+
4
+ describe TheCity::User do
5
+
6
+ describe "#groups" do
7
+ it "returns an array of TheCity::Group's when groups are set" do
8
+ groups = [
9
+ {
10
+ :id => 5432154321,
11
+ :name => "My Group",
12
+ }
13
+ ]
14
+ user = TheCity::User.new(:id => 6753948, :groups => groups)
15
+ expect(user.groups).to be_an Array
16
+ expect(user.groups.first).to be_a TheCity::Group
17
+ expect(user.groups.first.name).to eq("My Group")
18
+ end
19
+ it "is empty when not set" do
20
+ user = TheCity::User.new(:id => 6753948)
21
+ expect(user.groups).to be_empty
22
+ end
23
+ end
24
+
25
+ describe "#gender" do
26
+ it "returns the gender" do
27
+ user = TheCity::User.new(:id => 6753948, :gender => "Female")
28
+ expect(user.gender.to_s).to eq("Female")
29
+ end
30
+ it "returns nil when gender is not set" do
31
+ user = TheCity::User.new(:id => 6753948)
32
+ expect(user.gender).to be_nil
33
+ end
34
+ end
35
+
36
+ describe "#gender?" do
37
+ it "returns true when the gender is set" do
38
+ user = TheCity::User.new(:id => 6753948, :gender => "Male")
39
+ expect(user.gender?).to be_true
40
+ end
41
+ it "returns false when the url is not set" do
42
+ user = TheCity::User.new(:id => 6753948)
43
+ expect(user.gender?).to be_false
44
+ end
45
+ end
46
+
47
+ end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Leib
@@ -144,6 +144,12 @@ files:
144
144
  - lib/the_city/user.rb
145
145
  - lib/the_city/version.rb
146
146
  - lib/the_city.rb
147
+ - spec/fixtures/me.json
148
+ - spec/helper.rb
149
+ - spec/thecity/api/users_spec.rb
150
+ - spec/thecity/base_spec.rb
151
+ - spec/thecity/user_spec.rb
152
+ - spec/thecity_spec.rb
147
153
  homepage: http://github.com/thecity/thecity/
148
154
  licenses:
149
155
  - MIT
@@ -168,5 +174,11 @@ rubygems_version: 2.1.5
168
174
  signing_key:
169
175
  specification_version: 4
170
176
  summary: A Ruby interface to The City API.
171
- test_files: []
177
+ test_files:
178
+ - spec/fixtures/me.json
179
+ - spec/helper.rb
180
+ - spec/thecity/api/users_spec.rb
181
+ - spec/thecity/base_spec.rb
182
+ - spec/thecity/user_spec.rb
183
+ - spec/thecity_spec.rb
172
184
  has_rdoc: