Skip to content

Commit

Permalink
Fix 500, update Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed May 25, 2020
1 parent 77311dc commit fcb5e60
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.2
2.6.5
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "http://rubygems.org"

ruby "2.6.2"
ruby "2.6.5"

gem "rails", "~> 6.0"
gem "doorkeeper", "~> 5.4.0"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ DEPENDENCIES
uglifier

RUBY VERSION
ruby 2.6.2p47
ruby 2.6.5p114

BUNDLED WITH
2.0.1
2.1.4
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ namespace :api do
end
```

We namespace the API controllers to avoid name clashing and collisions between your existing application and the API. This way, you can make changes to your application without messing up with the API's behavior.
We namespace the API controllers to avoid name clashing and collisions between your existing application and the API.
This way, you can make changes to your application without messing up with the API's behavior.

You can find all controllers under `/app/controllers/api/v1` folder.

The `api_controller.rb` works as a parent class to the other controllers. It only defines a method that returns the current resource owner, based on the access token:
The `api_controller.rb` works as a parent class to the other controllers. It only defines a method that returns
the current resource owner, based on the access token:

``` ruby
def current_resource_owner
Expand All @@ -81,7 +83,8 @@ This is required if you want to return data based on the current user, like in `

### Make Access Token Required

To make your API only available for OAuth users, you need to tell doorkeeper to require an access token in your api controller, like this:
To make your API only available for OAuth users, you need to tell doorkeeper to require an access token in
your api controller, like this:

``` ruby
module Api::V1
Expand All @@ -103,4 +106,5 @@ If you attempt to access any of the protected resources without an proper access

You can manage all client applications in `/oauth/applications`.

If you want to create a client application, check out [this example using Sinatra](http://doorkeeper-sinatra.herokuapp.com) and this [another one using Rails and Devise](http://doorkeeper-devise.herokuapp.com).
If you want to create a client application, check out [this example using Sinatra](http://doorkeeper-sinatra.herokuapp.com)
and this [another one using Rails and Devise](http://doorkeeper-devise.herokuapp.com).
2 changes: 1 addition & 1 deletion app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="row">
<div class="col">
<h1 class="display-4">Doorkeeper <span class="badge badge-primary"><%= Doorkeeper.gem_version %></span></h1>
<h1 class="display-4">Doorkeeper <span class="badge badge-primary"><%= Doorkeeper::VERSION::STRING %></span></h1>

<p class="lead">
<a href="https://github.com/applicake/doorkeeper">Doorkeeper</a> is an <a href="http://oauth.net/2/">OAuth 2</a> provider for <a href="http://rubyonrails.org/">Rails</a>.
Expand Down
37 changes: 23 additions & 14 deletions bin/bundle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
require "rubygems"

m = Module.new do
module_function
module_function

def invoked_as_script?
File.expand_path($0) == File.expand_path(__FILE__)
Expand All @@ -31,7 +31,7 @@ m = Module.new do
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1 || ">= 0.a"
bundler_version = $1
update_index = i
end
bundler_version
Expand Down Expand Up @@ -61,32 +61,41 @@ m = Module.new do
end

def bundler_version
@bundler_version ||= begin
@bundler_version ||=
env_var_version || cli_arg_version ||
lockfile_version || "#{Gem::Requirement.default}.a"
end
lockfile_version
end

def bundler_requirement
return "#{Gem::Requirement.default}.a" unless bundler_version

bundler_gem_version = Gem::Version.new(bundler_version)

requirement = bundler_gem_version.approximate_recommendation

return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")

requirement += ".a" if bundler_gem_version.prerelease?

requirement
end

def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile

# must dup string for RG < 1.8 compatibility
activate_bundler(bundler_version.dup)
activate_bundler
end

def activate_bundler(bundler_version)
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
bundler_version = "< 2"
end
def activate_bundler
gem_error = activation_error_handling do
gem "bundler", bundler_version
gem "bundler", bundler_requirement
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
end
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end

Expand Down

0 comments on commit fcb5e60

Please sign in to comment.