warden-github 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/config.ru CHANGED
@@ -9,7 +9,7 @@ rescue LoadError
9
9
  end
10
10
 
11
11
  Bundler.require(:runtime, :test)
12
- require "ruby-debug"
12
+ #require "debugger"
13
13
 
14
14
  $LOAD_PATH << File.dirname(__FILE__) + '/lib'
15
15
  require File.expand_path(File.join(File.dirname(__FILE__), 'lib', 'warden-github'))
@@ -32,8 +32,7 @@ module Warden
32
32
  #
33
33
  # Returns: true if the user is publicized as an org member
34
34
  def publicized_organization_member?(org_name)
35
- members = github_request("orgs/#{org_name}/public_members")
36
- members.map { |org| org["login"] }.include?(login)
35
+ github_raw_request("orgs/#{org_name}/public_members/#{login}").code == 204
37
36
  rescue RestClient::Forbidden, RestClient::Unauthorized, RestClient::ResourceNotFound => e
38
37
  false
39
38
  end
@@ -44,8 +43,7 @@ module Warden
44
43
  #
45
44
  # Returns: true if the user has access, false otherwise
46
45
  def organization_member?(org_name)
47
- orgs = github_request("orgs/#{org_name}/members")
48
- orgs.map { |org| org["login"] }.include?(login)
46
+ github_raw_request("orgs/#{org_name}/members/#{login}").code == 204
49
47
  rescue RestClient::Forbidden, RestClient::Unauthorized, RestClient::ResourceNotFound => e
50
48
  false
51
49
  end
@@ -56,8 +54,7 @@ module Warden
56
54
  #
57
55
  # Returns: true if the user has access, false otherwise
58
56
  def team_member?(team_id)
59
- members = github_request("teams/#{team_id}/members")
60
- members.map { |user| user["login"] }.include?(login)
57
+ github_raw_request("teams/#{team_id}/members/#{login}").code == 204
61
58
  rescue RestClient::Forbidden, RestClient::Unauthorized, RestClient::ResourceNotFound => e
62
59
  false
63
60
  end
@@ -1,5 +1,5 @@
1
1
  module Warden
2
2
  module Github
3
- VERSION = "0.11.0"
3
+ VERSION = "0.12.0"
4
4
  end
5
5
  end
data/spec/app.rb CHANGED
@@ -13,7 +13,7 @@ module Example
13
13
  manager[:github_client_id] = ENV['GITHUB_CLIENT_ID'] || 'ee9aa24b64d82c21535a'
14
14
  manager[:github_secret] = ENV['GITHUB_CLIENT_SECRET'] || 'ed8ff0c54067aefb808dab1ca265865405d08d6f'
15
15
 
16
- manager[:github_scopes] = ''
16
+ manager[:github_scopes] = 'repo'
17
17
  manager[:github_oauth_domain] = ENV['GITHUB_OAUTH_DOMAIN'] || 'https://github.com'
18
18
  manager[:github_callback_url] = '/auth/github/callback'
19
19
  end
@@ -34,9 +34,9 @@ module Example
34
34
  ensure_authenticated
35
35
  <<-EOS
36
36
  <h2>Hello There, #{user.name}!</h2>
37
- <h3>Rails Org Member: #{user.organization_member?('rails')}.</h3>
38
- <h3>Publicized Rails Org Member: #{user.publicized_organization_member?('rails')}.</h3>
39
- <h3>Rails Committer Team Member: #{user.team_member?(632)}.</h3>
37
+ <h3>Rails Org Member: #{user.organization_member?('github')}.</h3>
38
+ <h3>Publicized Rails Org Member: #{user.publicized_organization_member?('github')}.</h3>
39
+ <h3>Rails Committer Team Member: #{user.team_member?(135235)}.</h3>
40
40
  EOS
41
41
  end
42
42
 
@@ -18,11 +18,11 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency "json", "~>1.5"
19
19
  s.add_dependency "warden", "~>1.0"
20
20
  s.add_dependency "oauth2", "~>0.5.2"
21
- s.add_dependency "octokit", "~>1.13.0"
21
+ s.add_dependency "octokit", "~>1.19.0"
22
22
  s.add_dependency "rest-client", "~>1.6.1"
23
23
  s.add_dependency "yajl-ruby", "~>1.1"
24
24
 
25
- s.add_development_dependency "rack", "~>1.4.0"
25
+ s.add_development_dependency "rack", "~>1.4.1"
26
26
  s.add_development_dependency "rake"
27
27
  s.add_development_dependency "rspec", "~>2.8.0"
28
28
  s.add_development_dependency "webrat"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-github
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 47
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 11
8
+ - 12
9
9
  - 0
10
- version: 0.11.0
10
+ version: 0.12.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Corey Donohoe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-09-20 00:00:00 -07:00
18
+ date: 2012-11-30 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -72,12 +72,12 @@ dependencies:
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- hash: 35
75
+ hash: 91
76
76
  segments:
77
77
  - 1
78
- - 13
78
+ - 19
79
79
  - 0
80
- version: 1.13.0
80
+ version: 1.19.0
81
81
  type: :runtime
82
82
  version_requirements: *id004
83
83
  - !ruby/object:Gem::Dependency
@@ -119,12 +119,12 @@ dependencies:
119
119
  requirements:
120
120
  - - ~>
121
121
  - !ruby/object:Gem::Version
122
- hash: 7
122
+ hash: 5
123
123
  segments:
124
124
  - 1
125
125
  - 4
126
- - 0
127
- version: 1.4.0
126
+ - 1
127
+ version: 1.4.1
128
128
  type: :development
129
129
  version_requirements: *id007
130
130
  - !ruby/object:Gem::Dependency