Skip to content

Commit 677dcb8

Browse files
committed
Update documentation visibility of private methods
Now that we're allowing yard to document private methods, we need to be explicit about what we do not wish to be public api by tagging it.
1 parent 029784b commit 677dcb8

15 files changed

+64
-11
lines changed

.yardopts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
--protected
12
--private
23
--hide-api private
34
--exclude templates

lib/clearance/authentication.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def handle_unverified_request
105105

106106
protected
107107

108-
# @private
108+
# @api private
109109
def clearance_session
110110
request.env[:clearance]
111111
end

lib/clearance/authorization.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def deny_access(flash_message = nil)
5858

5959
protected
6060

61-
# @private
61+
# @api private
6262
def redirect_request(flash_message)
6363
store_location
6464

@@ -73,46 +73,48 @@ def redirect_request(flash_message)
7373
end
7474
end
7575

76-
# @private
76+
# @api private
7777
def clear_return_to
7878
session[:return_to] = nil
7979
end
8080

81-
# @private
81+
# @api private
8282
def store_location
8383
if request.get?
8484
session[:return_to] = request.original_fullpath
8585
end
8686
end
8787

88-
# @private
88+
# @api private
8989
def redirect_back_or(default)
9090
redirect_to(return_to || default)
9191
clear_return_to
9292
end
9393

94-
# @private
94+
# @api private
9595
def return_to
9696
if return_to_url
9797
uri = URI.parse(return_to_url)
9898
"#{uri.path}?#{uri.query}".chomp('?')
9999
end
100100
end
101101

102-
# @private
102+
# @api private
103103
def return_to_url
104104
session[:return_to]
105105
end
106106

107107
# Used as the redirect location when {#deny_access} is called and there is a
108108
# currently signed in user.
109+
#
109110
# @return [String]
110111
def url_after_denied_access_when_signed_in
111112
Clearance.configuration.redirect_url
112113
end
113114

114115
# Used as the redirect location when {#deny_access} is called and there is
115116
# no currently signed in user.
117+
#
116118
# @return [String]
117119
def url_after_denied_access_when_signed_out
118120
sign_in_url

lib/clearance/back_door.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def call(env)
2929

3030
private
3131

32+
# @api private
3233
def sign_in_through_the_back_door(env)
3334
params = Rack::Utils.parse_query(env['QUERY_STRING'])
3435
user_id = params['as']

lib/clearance/configuration.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ def routes_enabled?
138138
# This is called from the Clearance engine to reload the configured
139139
# user class during each request while in development mode, but only once
140140
# in production.
141-
# @private
141+
#
142+
# @api private
142143
def reload_user_model
143144
if @user_model.present?
144145
@user_model = @user_model.to_s.constantize

lib/clearance/constraints/signed_in.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@ def matches?(request)
2929

3030
private
3131

32+
# @api private
3233
def clearance_session
3334
@request.env[:clearance]
3435
end
3536

37+
# @api private
3638
def current_user
3739
clearance_session.current_user
3840
end
3941

42+
# @api private
4043
def current_user_fulfills_additional_requirements?
4144
@block.call current_user
4245
end
4346

47+
# @api private
4448
def signed_in?
4549
clearance_session.present? && clearance_session.signed_in?
4650
end

lib/clearance/constraints/signed_out.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ def matches?(request)
1818

1919
private
2020

21+
# @api private
2122
def clearance_session
2223
@request.env[:clearance]
2324
end
2425

26+
# @api private
2527
def missing_session?
2628
clearance_session.nil?
2729
end

lib/clearance/password_strategies/bcrypt.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ def password=(new_password)
2525

2626
private
2727

28+
# @api private
2829
def encrypt(password)
2930
::BCrypt::Password.create(password, cost: cost)
3031
end
3132

33+
# @api private
3234
def cost
3335
if test_environment?
3436
::BCrypt::Engine::MIN_COST
@@ -37,6 +39,7 @@ def cost
3739
end
3840
end
3941

42+
# @api private
4043
def test_environment?
4144
defined?(::Rails) && ::Rails.env.test?
4245
end

lib/clearance/password_strategies/bcrypt_migration_from_sha1.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module BCryptMigrationFromSHA1
99
"strategy, add clearance-deprecated_password_strategies to your " \
1010
"Gemfile."
1111

12+
# @api private
1213
class BCryptUser
1314
include Clearance::PasswordStrategies::BCrypt
1415

@@ -19,6 +20,7 @@ def initialize(user)
1920
delegate :encrypted_password, :encrypted_password=, to: :@user
2021
end
2122

23+
# @api private
2224
class SHA1User
2325
include Clearance::PasswordStrategies::SHA1
2426

@@ -29,11 +31,15 @@ def initialize(user)
2931
delegate :salt, :salt=, :encrypted_password, :encrypted_password=, to: :@user
3032
end
3133

34+
# @deprecated Use {BCrypt} or `clearance-deprecated_password_strategies`
35+
# gem
3236
def authenticated?(password)
3337
warn "#{Kernel.caller.first}: #{DEPRECATION_MESSAGE}"
3438
authenticated_with_sha1?(password) || authenticated_with_bcrypt?(password)
3539
end
3640

41+
# @deprecated Use {BCrypt} or `clearance-deprecated_password_strategies`
42+
# gem
3743
def password=(new_password)
3844
warn "#{Kernel.caller.first}: #{DEPRECATION_MESSAGE}"
3945
@password = new_password
@@ -42,6 +48,7 @@ def password=(new_password)
4248

4349
private
4450

51+
# @api private
4552
def authenticated_with_bcrypt?(password)
4653
begin
4754
BCryptUser.new(self).authenticated? password
@@ -50,6 +57,7 @@ def authenticated_with_bcrypt?(password)
5057
end
5158
end
5259

60+
# @api private
5361
def authenticated_with_sha1?(password)
5462
if sha1_password?
5563
if SHA1User.new(self).authenticated? password
@@ -60,6 +68,7 @@ def authenticated_with_sha1?(password)
6068
end
6169
end
6270

71+
# @api private
6372
def sha1_password?
6473
self.encrypted_password =~ /^[a-f0-9]{40}$/
6574
end

lib/clearance/password_strategies/blowfish.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ module Blowfish
1111
"provide your own. To continue using this strategy add " \
1212
"clearance-deprecated_password_strategies to your Gemfile."
1313

14+
# @deprecated Use {BCrypt} or `clearance-deprecated_password_strategies`
15+
# gem
1416
def authenticated?(password)
1517
warn "#{Kernel.caller.first}: #{DEPRECATION_MESSAGE}"
1618
encrypted_password == encrypt(password)
1719
end
1820

21+
# @deprecated Use {BCrypt} or `clearance-deprecated_password_strategies`
22+
# gem
1923
def password=(new_password)
2024
warn "#{Kernel.caller.first}: #{DEPRECATION_MESSAGE}"
2125
@password = new_password
@@ -28,23 +32,27 @@ def password=(new_password)
2832

2933
protected
3034

35+
# @api private
3136
def encrypt(string)
3237
generate_hash("--#{salt}--#{string}--")
3338
end
3439

40+
# @api private
3541
def generate_hash(string)
3642
cipher = OpenSSL::Cipher::Cipher.new('bf-cbc').encrypt
3743
cipher.key = Digest::SHA256.digest(salt)
3844
hash = cipher.update(string) << cipher.final
3945
Base64.encode64(hash).encode('utf-8')
4046
end
4147

48+
# @api private
4249
def initialize_salt_if_necessary
4350
if salt.blank?
4451
self.salt = generate_salt
4552
end
4653
end
4754

55+
# @api private
4856
def generate_salt
4957
Base64.encode64(SecureRandom.hex(20)).encode('utf-8')
5058
end

0 commit comments

Comments
 (0)