Skip to content

Commit

Permalink
Allow using of Sequel 5: merge pull request #8 from nbulaj/sequel5
Browse files Browse the repository at this point in the history
Allow to use Sequel 5
  • Loading branch information
nbulaj authored Dec 13, 2017
2 parents 6b66bd6 + 945d714 commit 3772941
Show file tree
Hide file tree
Showing 26 changed files with 154 additions and 151 deletions.
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Rails:
Enabled: true
Documentation:
Enabled: false
Layout/EndOfLine:
Enabled: false
Metrics/BlockLength:
Exclude:
- lib/doorkeeper/orm/sequel/validators/*
- lib/generators/doorkeeper/sequel/templates/*
- lib/doorkeeper-sequel/generators/templates*
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ Reverse Chronological Order:

## master

https://github.com/nbulaj/doorkeeper-sequel/compare/1.2.3...master
https://github.com/nbulaj/doorkeeper-sequel/compare/1.3.0...master

...

## `1.3.0` (2017-12-13)

https://github.com/nbulaj/doorkeeper-sequel/compare/1.2.3...1.3.0

* Fix dependencies to allow using of Sequel 5
* Fix models plugins for Sequel >= 4.47
* Fix generators to allow migration generation when tables not created

## `1.2.3` (2017-08-10)

https://github.com/nbulaj/doorkeeper-sequel/compare/1.2.2...1.2.3
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
To start using the Doorkeeper Sequel ORM, add to your Gemfile:

``` ruby
gem 'doorkeeper-sequel', '~> 1.2'
gem 'doorkeeper-sequel', '~> 1.3'
```

Or you can use git `master` branch for the latest gem version:
Expand All @@ -38,9 +38,9 @@ end
Generate migrations:

```
rails generate doorkeeper:sequel:migration
rails generate doorkeeper:sequel:application_owner
rails generate doorkeeper:sequel:previous_refresh_token
rake doorkeeper_sequel:generate:migration
rake doorkeeper_sequel:generate:application_owner
rake doorkeeper_sequel:generate:previous_refresh_token
```

## Tests
Expand Down Expand Up @@ -73,7 +73,7 @@ Thanks.

Doorkeeper-sequel gem is released under the [MIT License](http://www.opensource.org/licenses/MIT).

Copyright (c) 2016-2017 Nikita Bulai (bulajnikita@gmail.com).
Copyright (c) 2016-2018 Nikita Bulai (bulajnikita@gmail.com).

---

Expand Down
5 changes: 2 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ExtensionIntegrator
base_dir = File.join(Dir.pwd, 'spec')

Dir.foreach(base_dir) do |file|
next if %w(. .. stubs).include?(file)
next if %w[. .. stubs].include?(file)

file_name = File.join(base_dir, file)

Expand All @@ -31,9 +31,8 @@ class ExtensionIntegrator
FileUtils.cp_r('spec/stubs/config/application.rb', 'spec/dummy/config/application.rb')
FileUtils.cp_r('spec/stubs/support/sequel.rb', 'spec/support/orm/sequel.rb')
FileUtils.rm('spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb')
# Generators
# Remove generators specs because we are using our own
FileUtils.rm(Dir.glob('spec/generators/*.rb'))
FileUtils.cp_r(Dir.glob('spec/stubs/generators/*.rb'), 'spec/generators/')
end
end
end
Expand Down
13 changes: 8 additions & 5 deletions doorkeeper-sequel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@ Gem::Specification.new do |gem|
gem.name = 'doorkeeper-sequel'
gem.version = DoorkeeperSequel.gem_version
gem.authors = ['Nikita Bulai']
gem.date = '2017-08-10'
gem.date = '2017-12-13'
gem.email = ['bulajnikita@gmail.com']
gem.homepage = 'http://github.com/nbulaj/doorkeeper-sequel'
gem.summary = 'Doorkeeper Sequel ORM'
gem.description = 'Provides Doorkeeper support to Sequel database toolkit.'
gem.license = 'MIT'

gem.require_paths = %w(lib config)
gem.bindir = 'bin'
gem.require_paths = %w[lib config]
gem.files = `git ls-files`.split($RS)
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
gem.test_files = Dir['spec/**/*']

gem.required_ruby_version = '>= 2.0.0'

gem.add_runtime_dependency 'doorkeeper', '~> 4.0', '>= 4.0.0'
gem.add_runtime_dependency 'sequel', '>= 4.0.0', '< 6'
gem.add_runtime_dependency 'sequel_polymorphic', '~> 0.2', '< 1.0'
gem.add_runtime_dependency 'thor', '>= 0.18', '< 6'

gem.add_development_dependency 'rspec-rails', '~> 3.5', '>= 3.5.0'
gem.add_development_dependency 'capybara', '~> 2.14', '>= 2.14.0'
gem.add_development_dependency 'generator_spec', '~> 0.9.4'
gem.add_development_dependency 'database_cleaner', '~> 1.5', '>= 1.5.0'
gem.add_development_dependency 'factory_girl', '~> 4.8', '>= 4.8.0'
gem.add_development_dependency 'generator_spec', '~> 0.9.4'
gem.add_development_dependency 'rspec-rails', '~> 3.5', '>= 3.5.0'
gem.add_development_dependency 'timecop', '~> 0.9.0'
gem.add_development_dependency 'database_cleaner', '~> 1.5', '>= 1.5.0'
end
2 changes: 1 addition & 1 deletion gemfiles/rails-4.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

gemspec path: '../'

gem 'rails', '~> 4.2'
gem 'rails', '~> 4.2', '<= 5.0'
gem 'sqlite3', '~> 1.3.5'
gem 'sequel', '>= 4.0'

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails-5.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

gemspec path: '..'

gem 'rails', '~> 5.0'
gem 'rails', '~> 5.0', '<= 5.1'
gem 'sqlite3', '~> 1.3.5'
gem 'sequel', '>= 4.0'

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails-5.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'

gemspec path: '..'

gem 'rails', '5.1.1'
gem 'rails', '~> 5.1', '<= 5.2'
gem 'sqlite3', '~> 1.3.5'
gem 'sequel', '>= 4.0'

Expand Down
12 changes: 11 additions & 1 deletion lib/doorkeeper-sequel.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
require 'doorkeeper-sequel/version'

require 'doorkeeper'
if defined?(::Rails)
require 'thor/group'

require 'doorkeeper-sequel/generators/concerns/migration_actions'
require 'doorkeeper-sequel/generators/application_owner_generator'
require 'doorkeeper-sequel/generators/migration_generator'
require 'doorkeeper-sequel/generators/previous_refresh_token_generator'

require 'doorkeeper-sequel/railtie'
end

require 'doorkeeper'
require 'doorkeeper/orm/sequel'

module DoorkeeperSequel
Expand Down
4 changes: 2 additions & 2 deletions lib/doorkeeper-sequel/gem_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def self.gem_version

module VERSION
MAJOR = 1
MINOR = 2
TINY = 3
MINOR = 3
TINY = 0

STRING = [MAJOR, MINOR, TINY].compact.join('.')
end
Expand Down
14 changes: 14 additions & 0 deletions lib/doorkeeper-sequel/generators/application_owner_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module DoorkeeperSequel
class ApplicationOwnerGenerator < ::Thor::Group
include ::Thor::Actions
include MigrationActions

source_root File.expand_path('../templates', __FILE__)

desc 'Provide support for client application ownership.'

def install
create_migration 'add_owner_to_application.rb'
end
end
end
43 changes: 43 additions & 0 deletions lib/doorkeeper-sequel/generators/concerns/migration_actions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module DoorkeeperSequel
module MigrationActions
extend ::ActiveSupport::Concern

protected

def create_migration(template_name)
copy_file template_name, migration_filename_for(template_name)
end

def migration_template
File.expand_path('../templates/migration.rb', __FILE__)
end

private

def migration_filename_for(template_name)
"db/migrate/#{new_migration_number}_#{template_name}"
end

def new_migration_number
current_number = current_migration_number('db/migrate')

# possible numeric migration
if current_number && current_number.start_with?('0')
# generate the same name as used by the developer
"%.#{current_number.length}d" % (current_number.to_i + 1)
else
Time.now.utc.strftime('%Y%m%d%H%M%S')
end
end

def current_migration_number(dirname)
migration_lookup_at(dirname).collect do |file|
File.basename(file).split('_').first
end.max
end

def migration_lookup_at(dirname)
Dir.glob("#{dirname}/[0-9]*_*.rb")
end
end
end
14 changes: 14 additions & 0 deletions lib/doorkeeper-sequel/generators/migration_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module DoorkeeperSequel
class MigrationGenerator < ::Thor::Group
include ::Thor::Actions
include MigrationActions

source_root File.expand_path('../templates', __FILE__)

desc 'Installs Doorkeeper Sequel migration file.'

def install
create_migration 'migration.rb'
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module DoorkeeperSequel
class PreviousRefreshTokenGenerator < ::Thor::Group
include ::Thor::Actions
include MigrationActions

source_root File.expand_path('../templates', __FILE__)

desc 'Support revoke refresh token on access token use'

def install
create_migration 'add_previous_refresh_token_to_access_tokens.rb'
end
end
end
7 changes: 7 additions & 0 deletions lib/doorkeeper-sequel/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module DoorkeeperSequel
class Railtie < ::Rails::Railtie
rake_tasks do
load File.expand_path('../tasks/doorkeeper-sequel.rake', __FILE__)
end
end
end
18 changes: 18 additions & 0 deletions lib/doorkeeper-sequel/tasks/doorkeeper-sequel.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace :doorkeeper_sequel do
namespace :generate do
desc 'Generate main migration file'
task :migration do
DoorkeeperSequel::MigrationGenerator.start
end

desc 'Generate migration file for Application Owner functionality'
task :application_owner do
DoorkeeperSequel::ApplicationOwnerGenerator.start
end

desc 'Generate migration file for Previous Refresh Token functionality'
task :previous_refresh_token do
DoorkeeperSequel::PreviousRefreshTokenGenerator.start
end
end
end
2 changes: 1 addition & 1 deletion lib/doorkeeper/orm/sequel/models/access_token_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def matching_token_for(application, resource_owner_or_id, scopes)
end

def scopes_match?(token_scopes, param_scopes, app_scopes)
(!token_scopes.present? && !param_scopes.present?) ||
(token_scopes.blank? && param_scopes.blank?) ||
Doorkeeper::OAuth::Helpers::ScopeChecker.match?(
token_scopes.to_s,
param_scopes,
Expand Down
23 changes: 0 additions & 23 deletions lib/generators/doorkeeper/sequel/application_owner_generator.rb

This file was deleted.

23 changes: 0 additions & 23 deletions lib/generators/doorkeeper/sequel/migration_generator.rb

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions spec/stubs/generators/application_owner_generator_spec.rb

This file was deleted.

Loading

0 comments on commit 3772941

Please sign in to comment.