Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removing code and adding README.md pointing to new official fork.

  • Loading branch information...
commit edfa16462249ad09330903aebc64cb72e69c47ed 1 parent b2897ba
@brasten authored
Showing with 6 additions and 1,398 deletions.
  1. +0 −5 .document
  2. +0 −29 .gitignore
  3. +0 −15 CHANGELOG
  4. +0 −21 Gemfile
  5. +0 −20 LICENSE
  6. +6 −0 README.md
  7. +0 −86 README.rdoc
  8. +0 −33 Rakefile
  9. +0 −1  VERSION
  10. +0 −1  autotest/discover.rb
  11. +0 −83 lib/generators/sequel.rb
  12. +0 −30 lib/generators/sequel/migration/migration_generator.rb
  13. +0 −16 lib/generators/sequel/migration/templates/migration.rb
  14. +0 −23 lib/generators/sequel/model/model_generator.rb
  15. +0 −3  lib/generators/sequel/model/templates/model.rb
  16. +0 −19 lib/generators/sequel/observer/observer_generator.rb
  17. +0 −7 lib/generators/sequel/observer/templates/observer.rb
  18. +0 −1  lib/sequel-rails.rb
  19. +0 −61 lib/sequel-rails/configuration.rb
  20. +0 −30 lib/sequel-rails/migrations.rb
  21. +0 −90 lib/sequel-rails/railtie.rb
  22. +0 −23 lib/sequel-rails/railties/benchmarking_mixin.rb
  23. +0 −43 lib/sequel-rails/railties/controller_runtime.rb
  24. +0 −148 lib/sequel-rails/railties/database.rake
  25. +0 −12 lib/sequel-rails/railties/i18n_support.rb
  26. +0 −31 lib/sequel-rails/railties/log_subscriber.rb
  27. +0 −14 lib/sequel-rails/runtime.rb
  28. +0 −82 lib/sequel-rails/session_store.rb
  29. +0 −19 lib/sequel-rails/setup.rb
  30. +0 −210 lib/sequel-rails/storage.rb
  31. +0 −93 sequel-rails.gemspec
  32. +0 −6 spec/rcov.opts
  33. +0 −7 spec/setup_spec.rb
  34. +0 −4 spec/spec.opts
  35. +0 −21 spec/spec_helper.rb
  36. +0 −1  tasks/ci.rake
  37. +0 −6 tasks/clean.rake
  38. +0 −37 tasks/metrics.rake
  39. +0 −38 tasks/spec.rake
  40. +0 −9 tasks/yard.rake
  41. +0 −20 tasks/yardstick.rake
View
5 .document
@@ -1,5 +0,0 @@
-README.rdoc
-lib/**/*.rb
-bin/*
-features/**/*.feature
-LICENSE
View
29 .gitignore
@@ -1,29 +0,0 @@
-## MAC OS
-.DS_Store
-
-## TEXTMATE
-*.tmproj
-tmtags
-
-## EMACS
-*~
-\#*
-.\#*
-
-## VIM
-*.swp
-
-## PROJECT::GENERAL
-coverage
-rdoc
-doc
-pkg
-tmp
-log
-.yardoc
-
-## PROJECT::SPECIFIC
-vendor
-.bundle
-.rvmrc
-*.gem
View
15 CHANGELOG
@@ -1,15 +0,0 @@
-== 0.1.4
-* Merged in changes to rake tasks and timestamp migrations
-
-== 0.1.3
-* update sequel dependency, configuration change
-
-== 0.1.2
-* fixed log_subscriber bug that 0.1.1 was -supposed- to fix.
-* fixed controller_runtime bug
-
-== 0.1.1
-* bug fixes, no additional functionality
-
-== 0.1.0
-* initial release
View
21 Gemfile
@@ -1,21 +0,0 @@
-source 'http://rubygems.org'
-
-gem 'rake', '~> 0.8.7'
-gem 'jeweler', '~> 1.4'
-gem 'yard', '~> 0.5'
-
-git 'git://github.com/rails/rails.git' do
-
- gem 'activesupport', '~> 3.0.0.beta3', :require => 'active_support'
- gem 'actionpack', '~> 3.0.0.beta3', :require => 'action_pack'
- gem 'railties', '~> 3.0.0.beta3', :require => 'rails'
-
-end
-
-gem 'sequel', '~> 3.11.0'
-
-group :test do
- gem 'rspec'
- gem 'autotest'
- gem 'rcov'
-end
View
20 LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2009-2010 The sequel-rails team
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
6 README.md
@@ -0,0 +1,6 @@
+sequel-rails
+============
+
+THIS FORK IS NO LONGER MAINTAINED.
+
+The official sequel-rails gem is now maintained at (https://github.com/TalentBox/sequel-rails).
View
86 README.rdoc
@@ -1,86 +0,0 @@
-= sequel-rails
-
-This gem provides the railtie that allows {sequel}[http://github.com/jeremyevans/sequel] to hook into {rails3}[http://github.com/rails/rails] and thus behave like a rails framework component. Just like activerecord does in rails, {sequel-rails}[http://github.com/brasten/sequel-rails] uses the railtie API to hook into rails. The two are actually hooked into rails almost identically.
-
-The code for this gem was initially taken from the excellent {dm-rails}[http://github.com/datamapper/dm-rails] project.
-
-== Using sequel-rails
-
-Using sequel with rails3 requires a couple minor changes.
-
-First, add the following to your Gemfile:
-
- gem 'sequel-rails'
-
-... be sure to run "bundle install" if needed!
-
-Secondly, you'll need to require "sequel-rails/railtie" in your config/application.rb file, and not require activerecord. The top of your config/application.rb will probably look something like:
-
- # require 'rails/all'
-
- # Instead of 'rails/all', require these:
- require "action_controller/railtie"
- require "sequel-rails/railtie"
- require "action_mailer/railtie"
-
-
-After those changes, you should be good to go!
-
-
-== Available sequel specific rake tasks
-
-To get a list of all available rake tasks in your rails3 app, issue the usual
-
- vendor/bin/rake -T
-
-Once you do that, you will see the following rake tasks among others. These are the ones that sequel-rails added for us.
-
- ...
- vendor/bin/rake db:create # Create the database(s) defined in config/database.yml for the current Rails.env - also creates the test database(s) if Rails.env.development?
- vendor/bin/rake db:create:all # Create all the local databases defined in config/database.yml
- vendor/bin/rake db:drop # Drops the database(s) for the current Rails.env - also drops the test database(s) if Rails.env.development?
- vendor/bin/rake db:drop:all # Drop all the local databases defined in config/database.yml
- vendor/bin/rake db:migrate # Migrate the database to the latest version
- vendor/bin/rake db:migrate:down[version] # Migrate down using migrations
- vendor/bin/rake db:migrate:up[version] # Migrate up using migrations
- vendor/bin/rake db:seed # Load the seed data from db/seeds.rb
- vendor/bin/rake db:sessions:clear # Clear the sessions table for SequelStore
- vendor/bin/rake db:sessions:create # Creates the sessions table for SequelStore
- vendor/bin/rake db:setup # Create the database, load the schema, and initialize with the seed data
- ...
-
-
-== Current Issues
-
-* There are bound to be a lot, but I'm not yet sure what they are
-
-== TODO (not necessarily in that order)
-
-* SPECS
-* README changes
-* Publish SQL issued by sequel to rails subscribers
-
-== Credits
-
-The {dm-rails}[http://github.com/datamapper/dm-rails] team wrote most of this code, I just sequel-ized it.
-
-
-
-== Note on Patches/Pull Requests
-
-* Fork the project.
-* Make your feature addition or bug fix.
-* Add tests for it. This is important so I don't break it in a
- future version unintentionally.
-* Commit, do not mess with rakefile, version, or history.
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-* Send me a pull request. Bonus points for topic branches.
-
-
-== The sequel-rails team
-
-* Brasten Sager (brasten)
-
-== Copyright
-
-Copyright (c) 2010 The sequel-rails team. See {LICENSE}[http://github.com/brasten/sequel-rails/blob/master/LICENSE] for details.
View
33 Rakefile
@@ -1,33 +0,0 @@
-require 'rubygems'
-require 'rake'
-
-begin
-
- require 'jeweler'
-
- Jeweler::Tasks.new do |gem|
-
- gem.name = 'sequel-rails'
- gem.summary = 'Use Sequel with Rails 3'
- gem.description = 'Integrate Sequel with Rails 3'
- gem.email = 'brasten@gmail.com'
- gem.homepage = 'http://github.com/brasten/sequel-rails'
- gem.authors = [ 'Brasten Sager (brasten)' ]
-
- gem.add_dependency 'sequel', '~> 3.13'
-
- gem.add_dependency 'activesupport', '~> 3.0.0.rc'
- gem.add_dependency 'actionpack', '~> 3.0.0.rc'
- gem.add_dependency 'railties', '~> 3.0.0.rc'
-
- # gem.add_development_dependency 'yard', '~> 0.5'
-
- end
-
- Jeweler::GemcutterTasks.new
-
- FileList['tasks/**/*.rake'].each { |task| import task }
-
-rescue LoadError
- puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
-end
View
1  VERSION
@@ -1 +0,0 @@
-0.1.5
View
1  autotest/discover.rb
@@ -1 +0,0 @@
-Autotest.add_discovery { "rspec" }
View
83 lib/generators/sequel.rb
@@ -1,83 +0,0 @@
-require 'rails/generators/named_base'
-require 'rails/generators/migration'
-require 'rails/generators/active_model'
-
-module Sequel
- module Generators
-
- class Base < ::Rails::Generators::NamedBase #:nodoc:
-
- include ::Rails::Generators::Migration
-
- def self.source_root
- @_sequel_source_root ||=
- File.expand_path("../#{base_name}/#{generator_name}/templates", __FILE__)
- end
-
- protected
-
- # Sequel does not care if migrations have the same name as long as
- # they have different ids.
- #
- def migration_exists?(dirname, file_name) #:nodoc:
- false
- end
-
- # Implement the required interface for Rails::Generators::Migration.
- #
- def self.next_migration_number(dirname) #:nodoc:
- next_migration_number = current_migration_number(dirname) + 1
- [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
- end
-
- end
-
- class ActiveModel < ::Rails::Generators::ActiveModel #:nodoc:
- def self.all(klass)
- "#{klass}.all"
- end
-
- def self.find(klass, params=nil)
- "#{klass}.get(#{params})"
- end
-
- def self.build(klass, params=nil)
- if params
- "#{klass}.new(#{params})"
- else
- "#{klass}.new"
- end
- end
-
- def save
- "#{name}.save"
- end
-
- def update_attributes(params=nil)
- "#{name}.update(#{params})"
- end
-
- def errors
- "#{name}.errors"
- end
-
- def destroy
- "#{name}.destroy"
- end
- end
-
- end
-end
-
-module Rails
-
- module Generators
- class GeneratedAttribute #:nodoc:
- def type_class
- return 'DateTime' if type.to_s == 'datetime'
- return type.to_s.camelcase
- end
- end
- end
-
-end
View
30 lib/generators/sequel/migration/migration_generator.rb
@@ -1,30 +0,0 @@
-require 'generators/sequel'
-
-module Sequel
- module Generators
-
- class MigrationGenerator < Base
-
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
- class_option :id, :type => :numeric, :desc => "The id to be used in this migration"
-
- def create_migration_file
- set_local_assigns!
- migration_template "migration.rb", "db/migrate/#{file_name}.rb"
- end
-
- protected
-
- attr_reader :migration_action
-
- def set_local_assigns!
- if file_name =~ /^(add|remove|drop)_.*_(?:to|from)_(.*)/
- @migration_action = $1 == 'add' ? 'add' : 'drop'
- @table_name = $2.pluralize
- end
- end
-
- end
-
- end
-end
View
16 lib/generators/sequel/migration/templates/migration.rb
@@ -1,16 +0,0 @@
-class <%= migration_file_name.camelize %>Migration < Sequel::Migration
-
- def up
- create_table :<%= table_name %> do
- primary_key :id
-<% attributes.each do |attribute| -%>
- <%= attribute.type_class %> :<%= attribute.name %>
-<% end -%>
- end
- end
-
- def down
- drop_table :<%= table_name %>
- end
-
-end
View
23 lib/generators/sequel/model/model_generator.rb
@@ -1,23 +0,0 @@
-require 'generators/sequel'
-
-module Sequel
- module Generators
-
- class ModelGenerator < Base
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
-
- check_class_collision
-
- class_option :timestamps, :type => :boolean
- class_option :parent, :type => :string, :desc => "The parent class for the generated model"
-
- def create_model_file
- template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
- end
-
- hook_for :test_framework
-
- end
-
- end
-end
View
3  lib/generators/sequel/model/templates/model.rb
@@ -1,3 +0,0 @@
-class <%= class_name %><%= options[:parent] ? " < #{options[:parent].classify}" : " < Sequel::Model" %>
-
-end
View
19 lib/generators/sequel/observer/observer_generator.rb
@@ -1,19 +0,0 @@
-require 'generators/sequel'
-
-module Sequel
- module Generators
-
- class ObserverGenerator < Base
-
- check_class_collision :suffix => "Observer"
-
- def create_observer_file
- template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
- end
-
- hook_for :test_framework
-
- end
-
- end
-end
View
7 lib/generators/sequel/observer/templates/observer.rb
@@ -1,7 +0,0 @@
-class <%= class_name %>Observer
-
- include Sequel::Observer
-
- observe <%= class_name %>
-
-end
View
1  lib/sequel-rails.rb
@@ -1 +0,0 @@
-require 'sequel-rails/railtie'
View
61 lib/sequel-rails/configuration.rb
@@ -1,61 +0,0 @@
-require 'active_support/core_ext/hash/except'
-require 'active_support/core_ext/class/attribute_accessors'
-
-module Rails
- module Sequel
-
- mattr_accessor :configuration
-
- class Configuration
-
- def self.for(root, database_yml_hash)
- Rails::Sequel.configuration ||= new(root, database_yml_hash)
- end
-
- attr_reader :root, :raw
- attr_accessor :logger
- attr_accessor :migration_dir
-
- def environment_for(name)
- environments[name.to_s] || environments[name.to_sym]
- end
-
- def environments
- @environments ||= @raw.inject({}) do |normalized, environment|
- name, config = environment.first, environment.last
- normalized[name] = normalize_repository_config(config)
- normalized
- end
- end
-
- private
-
- def initialize(root, database_yml_hash)
- @root, @raw = root, database_yml_hash
- end
-
- def normalize_repository_config(hash)
- config = {}
- hash.each do |key, value|
- config[key.to_s] =
- if key.to_s == 'port'
- value.to_i
- elsif key.to_s == 'adapter' && value == 'sqlite3'
- 'sqlite'
- elsif key.to_s == 'database' && (hash['adapter'] == 'sqlite3' ||
- hash['adapter'] == 'sqlite' ||
- hash[:adapter] == 'sqlite3' ||
- hash[:adapter] == 'sqlite')
- value == ':memory:' ? value : File.expand_path((hash['database'] || hash[:database]), root)
- else
- value
- end
- end
-
- config
- end
-
- end
-
- end
-end
View
30 lib/sequel-rails/migrations.rb
@@ -1,30 +0,0 @@
-require 'sequel/extensions/migration'
-
-module Rails
- module Sequel
- class Migrations
-
- class << self
-
- def migrate_up!(version=nil)
- opts = {}
- opts[:target] = version.to_i if version
-
-
-
- ::Sequel::Migrator.run(::Sequel::Model.db, "db/migrate", opts)
- end
-
- def migrate_down!(version=nil)
- opts = {}
- opts[:target] = version.to_i if version
-
- ::Sequel::Migrator.run(::Sequel::Model.db, "db/migrate", opts)
- end
-
- end
-
-
- end
- end
-end
View
90 lib/sequel-rails/railtie.rb
@@ -1,90 +0,0 @@
-require 'sequel'
-
-require 'rails'
-require 'active_model/railtie'
-
-# Comment taken from active_record/railtie.rb
-#
-# For now, action_controller must always be present with
-# rails, so let's make sure that it gets required before
-# here. This is needed for correctly setting up the middleware.
-# In the future, this might become an optional require.
-require 'action_controller/railtie'
-
-require 'sequel-rails/setup'
-require "sequel-rails/railties/log_subscriber"
-require "sequel-rails/railties/i18n_support"
-
-
-module Rails
- module Sequel
-
- class Railtie < Rails::Railtie
-
- ::Sequel::Railties::LogSubscriber.attach_to :sequel
-
- config.generators.orm :sequel, :migration => true
- config.rails_fancy_pants_logging = true
-
- rake_tasks do
- load 'sequel-rails/railties/database.rake'
- end
-
- initializer 'sequel.configuration' do |app|
- configure_sequel(app)
- end
-
- initializer 'sequel.logger' do |app|
- setup_logger(app, Rails.logger)
- end
-
- initializer 'sequel.i18n_support' do |app|
- setup_i18n_support(app)
- end
-
- # Expose database runtime to controller for logging.
- initializer "sequel.log_runtime" do |app|
- setup_controller_runtime(app)
- end
-
- initializer "sequel.connect" do |app|
- Rails::Sequel.setup(Rails.env)
- end
-
- # Run setup code after_initialize to make sure all config/initializers
- # are in effect once we setup the connection. This is especially necessary
- # for the cascaded adapter wrappers that need to be declared before setup.
-
- config.after_initialize do |app|
- ::Sequel::Model.plugin :active_model
- ::Sequel::Model.plugin :validation_helpers
-
- ::Sequel::Model.raise_on_save_failure = false
- end
-
-
- # Support overwriting crucial steps in subclasses
-
- def configure_sequel(app)
- app.config.sequel = Rails::Sequel::Configuration.for(
- Rails.root, app.config.database_configuration
- )
- end
-
- def setup_i18n_support(app)
- ::Sequel::Model.send :include, Rails::Sequel::I18nSupport
- end
-
- def setup_controller_runtime(app)
- require "sequel-rails/railties/controller_runtime"
- ActionController::Base.send :include, Rails::Sequel::Railties::ControllerRuntime
- end
-
- def setup_logger(app, logger)
- app.config.sequel.logger=logger
- end
-
- end
-
- end
-end
View
23 lib/sequel-rails/railties/benchmarking_mixin.rb
@@ -1,23 +0,0 @@
-module Sequel
- module Adapters
- module Benchmarking
-
- %w[ create read update delete ].each do |method|
- class_eval <<-RUBY, __FILE__, __LINE__
- def #{method}(*args, &block)
- result = nil
- @runtime ||= 0
- @runtime += Benchmark.ms { result = super(*args, &block) }
- result
- end
- RUBY
- end
-
- def reset_runtime
- rt, @runtime = @runtime, 0
- rt.to_f
- end
-
- end
- end
-end
View
43 lib/sequel-rails/railties/controller_runtime.rb
@@ -1,43 +0,0 @@
-require 'active_support/core_ext/module/attr_internal'
-
-module Rails
- module Sequel
- module Railties
-
- module ControllerRuntime
-
- extend ActiveSupport::Concern
-
- protected
-
- attr_internal :db_runtime
-
- def cleanup_view_runtime
- db_rt_before_render = ::Rails::Sequel.reset_runtime
- runtime = super
- db_rt_after_render = ::Rails::Sequel.reset_runtime
- self.db_runtime = db_rt_before_render + db_rt_after_render
- runtime - db_rt_after_render
- end
-
- def append_info_to_payload(payload)
- super
- payload[:db_runtime] = db_runtime
- end
-
-
- module ClassMethods
-
- def log_process_action(payload)
- messages, db_runtime = super, payload[:db_runtime]
- messages << ("Models: %.1fms" % db_runtime.to_f) if db_runtime
- messages
- end
-
- end
-
- end
-
- end
- end
-end
View
148 lib/sequel-rails/railties/database.rake
@@ -1,148 +0,0 @@
-# TODO: DRY these up
-namespace :db do
- namespace :schema do
- desc "Create a db/schema.rb file that can be portably used against any DB supported by Sequel"
- task :dump do
- Sequel.extension :schema_dumper
- db = Sequel.connect(Rails.configuration.database_configuration[Rails.env])
- File.open(ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb", "w") do |file|
- file.write(db.dump_schema_migration)
- end
- Rake::Task["db:schema:dump"].reenable
- end
-
- desc "Load a schema.rb file into the database"
- task :load, :needs => :environment do
- require 'sequel-rails/storage'
- Rails::Sequel::Storage.new(Rails.env).create
-
- file = ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb"
- if File.exists?(file)
- load(file)
- else
- abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/boot.rb to limit the frameworks that will be loaded}
- end
- end
- end
-
- namespace :create do
- desc 'Create all the local databases defined in config/database.yml'
- task :all, :needs => :environment do
- require 'sequel-rails/storage'
- Rails::Sequel::Storage.create_all
- end
- end
-
- desc "Create the database defined in config/database.yml for the current Rails.env - also creates the test database if Rails.env.development?"
- task :create, :env, :needs => :environment do |t, args|
- args.with_defaults(:env => Rails.env)
-
- require 'sequel-rails/storage'
- Rails::Sequel::Storage.new(args.env).create
-
- if Rails.env.development? && Rails.configuration.database_configuration['test']
- Rails::Sequel::Storage.new('test').create
- end
- end
-
- namespace :drop do
- desc 'Drops all the local databases defined in config/database.yml'
- task :all, :needs => :environment do
- require 'sequel-rails/storage'
- Rails::Sequel::Storage.drop_all
- end
- end
-
- desc "Create the database defined in config/database.yml for the current Rails.env - also creates the test database if Rails.env.development?"
- task :drop, :env, :needs => :environment do |t, args|
- args.with_defaults(:env => Rails.env)
-
- require 'sequel-rails/storage'
- Rails::Sequel::Storage.new(args.env).drop
-
- if Rails.env.development? && Rails.configuration.database_configuration['test']
- Rails::Sequel::Storage.new('test').drop
- end
- end
-
- namespace :migrate do
- task :load => :environment do
- require 'sequel-rails/migrations'
- end
-
- desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
- task :redo => :load do
- if ENV["VERSION"]
- Rake::Task["db:migrate:down"].invoke
- Rake::Task["db:migrate:up"].invoke
- else
- Rake::Task["db:rollback"].invoke
- Rake::Task["db:migrate"].invoke
- end
- end
-
-
- desc 'Resets your database using your migrations for the current environment'
- task :reset => ["db:drop", "db:create", "db:migrate"]
-
- desc 'Runs the "up" for a given migration VERSION.'
- task :up => :load do
- version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
- raise "VERSION is required" unless version
- Rails::Sequel::Migrations.migrate_up!(version)
- Rake::Task["db:schema:dump"].invoke if Rails.env != 'test'
- end
-
- desc 'Runs the "down" for a given migration VERSION.'
- task :down => :load do
- version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
- raise "VERSION is required" unless version
- Rails::Sequel::Migrations.migrate_down!(version)
- Rake::Task["db:schema:dump"].invoke if Rails.env != 'test'
- end
- end
-
- desc 'Migrate the database to the latest version'
- task :migrate => :'migrate:load' do
- Rails::Sequel::Migrations.migrate_up!(ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
- Rake::Task["db:schema:dump"].invoke if Rails.env != 'test'
- end
-
- desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
- task :rollback => :'migrate:load' do
- step = ENV['STEP'] ? ENV['STEP'].to_i : 1
- Sequel::Migrator.rollback('db/migrate/', step)
- Rake::Task["db:schema:dump"].invoke if Rails.env != 'test'
- end
-
- desc 'Pushes the schema to the next version. Specify the number of steps with STEP=n'
- task :forward => :'migrate:load' do
- step = ENV['STEP'] ? ENV['STEP'].to_i : 1
- Sequel::Migrator.forward('db/migrate/', step)
- Rake::Task["db:schema:dump"].invoke if Rails.env != 'test'
- end
-
- desc 'Load the seed data from db/seeds.rb'
- task :seed => :environment do
- seed_file = File.join(Rails.root, 'db', 'seeds.rb')
- load(seed_file) if File.exist?(seed_file)
- end
-
- desc 'Create the database, load the schema, and initialize with the seed data'
- task :setup => [ 'db:create', 'db:migrate', 'db:seed' ]
-
- desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.'
- task :reset => [ 'db:drop', 'db:setup' ]
-
- namespace :test do
- task :prepare do
- Rails.env = 'test'
- Rake::Task['db:reset'].invoke()
- Sequel::DATABASES.each do |db|
- db.disconnect
- end
- end
- end
-end
-
-task 'test:prepare' => 'db:test:prepare'
View
12 lib/sequel-rails/railties/i18n_support.rb
@@ -1,12 +0,0 @@
-module Rails
- module Sequel
-
- module I18nSupport
- # Set the i18n scope to overwrite ActiveModel.
- def i18n_scope #:nodoc:
- :sequel
- end
- end
-
- end
-end
View
31 lib/sequel-rails/railties/log_subscriber.rb
@@ -1,31 +0,0 @@
-module Sequel
- module Railties
-
- class LogSubscriber < ActiveSupport::LogSubscriber
-
- def sql(event)
- name = '%s (%.1fms)' % [event.payload[:name], event.duration]
- sql = event.payload[:sql].squeeze(' ')
-
- if odd?
- name = color(name, :cyan, true)
- sql = color(sql, nil, true)
- else
- name = color(name, :magenta, true)
- end
-
- debug " #{name} #{sql}"
- end
-
- def odd?
- @odd_or_even = !@odd_or_even
- end
-
- def logger
- ::Rails::Sequel.configuration.logger
- end
-
- end
-
- end
-end
View
14 lib/sequel-rails/runtime.rb
@@ -1,14 +0,0 @@
-module Rails
- module Sequel
-
- class << self
- def reset_runtime
- @runtime ||= 0
-
- rt, @runtime = @runtime, 0
- rt
- end
- end
-
- end
-end
View
82 lib/sequel-rails/session_store.rb
@@ -1,82 +0,0 @@
-require 'sequel'
-
-# Implements Sequel-specific session store.
-
-module Rails
- module Sequel
-
- class SessionStore < ActionDispatch::Session::AbstractStore
-
- class Session < ::Sequel::Model
-
- # property :id, Serial
- # property :session_id, String, :required => true, :unique => true, :unique_index => true
- # property :data, Object, :required => true, :default => ActiveSupport::Base64.encode64(Marshal.dump({}))
- # property :updated_at, DateTime, :required => false, :index => true
-
- class << self
-
- def auto_migrate!
- self.db.create_table :sessions do
- primary_key :id
- column :session_id, String,
- :null => false,
- :unique => true,
- :index => true
-
- column :data, :text,
- :null => false
-
- column :updated_at, DateTime,
- :null => true,
- :index => true
- end
- end
-
- end
-
- def self.name
- 'session'
- end
-
- end
-
- SESSION_RECORD_KEY = 'rack.session.record'.freeze
-
- cattr_accessor :session_class
- self.session_class = Session
-
- private
-
- def get_session(env, sid)
- sid ||= generate_sid
- session = find_session(sid)
- env[SESSION_RECORD_KEY] = session
- [ sid, session.data ]
- end
-
- def set_session(env, sid, session_data)
- session = get_session_resource(env, sid)
- session.data = session_data
- session.updated_at = Time.now if session.dirty?
- session.save
- end
-
- def get_session_resource(env, sid)
- if env[ENV_SESSION_OPTIONS_KEY][:id].nil?
- env[SESSION_RECORD_KEY] = find_session(sid)
- else
- env[SESSION_RECORD_KEY] ||= find_session(sid)
- end
- end
-
- def find_session(sid)
- klass = self.class.session_class
-
- klass.where(:session_id => sid).first || klass.new(:session_id => sid)
- end
-
- end
-
- end
-end
View
19 lib/sequel-rails/setup.rb
@@ -1,19 +0,0 @@
-require 'active_support/core_ext/hash/except'
-
-require 'sequel/extensions/migration'
-
-require 'sequel-rails/configuration'
-require 'sequel-rails/runtime'
-require 'sequel-rails/railties/benchmarking_mixin'
-
-module Rails
- module Sequel
-
- def self.setup(environment)
- puts "[sequel] Setting up the #{environment.inspect} environment:"
-
- ::Sequel.connect({:logger => configuration.logger}.merge(::Rails::Sequel.configuration.environment_for(environment.to_s)))
- end
-
- end
-end
View
210 lib/sequel-rails/storage.rb
@@ -1,210 +0,0 @@
-module Rails
- module Sequel
-
- def self.storage
- Storage
- end
-
- class Storage
- attr_reader :config
-
- def self.create_all
- with_local_repositories { |config| create_environment(config) }
- end
-
- def self.drop_all
- with_local_repositories { |config| drop_environment(config) }
- end
-
- def self.create_environment(config)
- new(config).create
- end
-
- def self.drop_environment(config)
- new(config).drop
- end
-
- def self.new(config)
- config = Rails::Sequel.configuration.environments[config.to_s] unless config.kind_of?(Hash)
-
- klass = lookup_class(config['adapter'])
- if klass.equal?(self)
- super(config)
- else
- klass.new(config)
- end
- end
-
- class << self
- private
-
- def with_local_repositories
- Rails::Sequel.configuration.environments.each_value do |config|
- if config['host'].blank? || %w[ 127.0.0.1 localhost ].include?(config['host'])
- yield(config)
- else
- puts "This task only modifies local databases. #{config['database']} is on a remote host."
- end
- end
- end
-
- def lookup_class(adapter)
- klass_name = adapter.camelize.to_sym
-
- unless Storage.const_defined?(klass_name)
- raise "Adapter #{adapter} not supported (#{klass_name.inspect})"
- end
-
- const_get(klass_name)
- end
-
- end
-
- def initialize(config)
- @config = config
- end
-
- def create
- _create
- puts "[sequel] Created database '#{database}'"
- end
-
- def drop
- _drop
- puts "[sequel] Dropped database '#{database}'"
- end
-
- def database
- @database ||= config['database'] || config['path']
- end
-
- def username
- @username ||= config['username'] || ''
- end
-
- def password
- @password ||= config['password'] || ''
- end
-
- def charset
- @charset ||= config['charset'] || ENV['CHARSET'] || 'utf8'
- end
-
- class Sqlite < Storage
- def _create
- return if in_memory?
- ::Sequel.connect(config.merge('database' => path))
- end
-
- def _drop
- return if in_memory?
- path.unlink if path.file?
- end
-
- private
-
- def in_memory?
- database == ':memory:'
- end
-
- def path
- @path ||= Pathname(File.expand_path(database, Rails.root))
- end
-
- end
-
- class Mysql < Storage
- def _create
- execute("CREATE DATABASE IF NOT EXISTS `#{database}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}")
- end
-
- def _drop
- execute("DROP DATABASE IF EXISTS `#{database}`")
- end
-
- private
-
- def execute(statement)
- system(
- 'mysql',
- (username.blank? ? '' : "--user=#{username}"),
- (password.blank? ? '' : "--password=#{password}"),
- '-e',
- statement
- )
- end
-
- def collation
- @collation ||= config['collation'] || ENV['COLLATION'] || 'utf8_unicode_ci'
- end
-
- end
-
- class Postgres < Storage
- def _create
- system(
- 'createdb',
- '-E',
- charset,
- '-U',
- username,
- database
- )
- end
-
- def _drop
- system(
- 'dropdb',
- '-U',
- username,
- database
- )
- end
- end
-
- class Jdbc < Storage
-
- def _is_mysql?
- database.match(/^jdbc:mysql/)
- end
-
- def _root_url
- database.scan /^jdbc:mysql:\/\/\w*:?\d*/
- end
-
- def db_name
- database.scan(/^jdbc:mysql:\/\/\w+:?\d*\/(\w+)/).flatten.first
- end
-
- def _params
- database.scan /\?.*$/
- end
-
- def _create
- if _is_mysql?
- ::Sequel.connect("#{_root_url}#{_params}") do |db|
- db.execute("CREATE DATABASE IF NOT EXISTS `#{db_name}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}")
- end
- end
- end
-
- def _drop
- if _is_mysql?
- ::Sequel.connect("#{_root_url}#{_params}") do |db|
- db.execute("DROP DATABASE IF EXISTS `#{db_name}`")
- end
- end
- end
-
- private
-
- def collation
- @collation ||= config['collation'] || ENV['COLLATION'] || 'utf8_unicode_ci'
- end
-
-
- end
-
- end
- end
-end
View
93 sequel-rails.gemspec
@@ -1,93 +0,0 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{sequel-rails}
- s.version = "0.1.7"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Brasten Sager (brasten)"]
- s.date = %q{2010-08-11}
- s.description = %q{Integrate Sequel with Rails 3}
- s.email = %q{brasten@gmail.com}
- s.extra_rdoc_files = [
- "LICENSE",
- "README.rdoc"
- ]
- s.files = [
- ".document",
- ".gitignore",
- "CHANGELOG",
- "Gemfile",
- "LICENSE",
- "README.rdoc",
- "Rakefile",
- "VERSION",
- "autotest/discover.rb",
- "lib/generators/sequel.rb",
- "lib/generators/sequel/migration/migration_generator.rb",
- "lib/generators/sequel/migration/templates/migration.rb",
- "lib/generators/sequel/model/model_generator.rb",
- "lib/generators/sequel/model/templates/model.rb",
- "lib/generators/sequel/observer/observer_generator.rb",
- "lib/generators/sequel/observer/templates/observer.rb",
- "lib/sequel-rails.rb",
- "lib/sequel-rails/configuration.rb",
- "lib/sequel-rails/migrations.rb",
- "lib/sequel-rails/railtie.rb",
- "lib/sequel-rails/railties/benchmarking_mixin.rb",
- "lib/sequel-rails/railties/controller_runtime.rb",
- "lib/sequel-rails/railties/database.rake",
- "lib/sequel-rails/railties/i18n_support.rb",
- "lib/sequel-rails/railties/log_subscriber.rb",
- "lib/sequel-rails/runtime.rb",
- "lib/sequel-rails/session_store.rb",
- "lib/sequel-rails/setup.rb",
- "lib/sequel-rails/storage.rb",
- "sequel-rails.gemspec",
- "spec/rcov.opts",
- "spec/setup_spec.rb",
- "spec/spec.opts",
- "spec/spec_helper.rb",
- "tasks/ci.rake",
- "tasks/clean.rake",
- "tasks/metrics.rake",
- "tasks/spec.rake",
- "tasks/yard.rake",
- "tasks/yardstick.rake"
- ]
- s.homepage = %q{http://github.com/brasten/sequel-rails}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.6}
- s.summary = %q{Use Sequel with Rails 3}
- s.test_files = [
- "spec/setup_spec.rb",
- "spec/spec_helper.rb"
- ]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<sequel>, ["~> 3.13"])
- s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0.rc"])
- s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0.rc"])
- s.add_runtime_dependency(%q<railties>, ["~> 3.0.0.rc"])
- else
- s.add_dependency(%q<sequel>, ["~> 3.13"])
- s.add_dependency(%q<activesupport>, ["~> 3.0.0.rc"])
- s.add_dependency(%q<actionpack>, ["~> 3.0.0.rc"])
- s.add_dependency(%q<railties>, ["~> 3.0.0.rc"])
- end
- else
- s.add_dependency(%q<sequel>, ["~> 3.13"])
- s.add_dependency(%q<activesupport>, ["~> 3.0.0.rc"])
- s.add_dependency(%q<actionpack>, ["~> 3.0.0.rc"])
- s.add_dependency(%q<railties>, ["~> 3.0.0.rc"])
- end
-end
-
View
6 spec/rcov.opts
@@ -1,6 +0,0 @@
---exclude-only "spec\/,^\/"
---sort coverage
---callsites
---xrefs
---profile
---text-summary
View
7 spec/setup_spec.rb
@@ -1,7 +0,0 @@
-require 'spec_helper'
-
-describe "Rails::Sequel::Setup" do
- it "fails" do
- # fail "hey buddy, you should probably rename this file and start specing for real"
- end
-end
View
4 spec/spec.opts
@@ -1,4 +0,0 @@
---color
---loadby random
---format profile
---backtrace
View
21 spec/spec_helper.rb
@@ -1,21 +0,0 @@
-begin
- # Just in case the bundle was locked
- # This shouldn't happen in a dev environment but lets be safe
- require File.expand_path('../../.bundle/environment', __FILE__)
-rescue LoadError
- require 'rubygems'
- require 'bundler'
- Bundler.setup
-end
-Bundler.require(:default, :test)
-
-$LOAD_PATH.unshift(File.expand_path('../', __FILE__))
-$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
-
-require 'sequel-rails'
-
-require 'spec'
-require 'spec/autorun'
-
-Spec::Runner.configure do |config|
-end
View
1  tasks/ci.rake
@@ -1 +0,0 @@
-task :ci => [ 'metrics:all' ]
View
6 tasks/clean.rake
@@ -1,6 +0,0 @@
-require 'rake/clean'
-
-File.foreach('.gitignore') do |line|
- line.strip!
- CLOBBER << line unless line.empty? || line[0, 1] == '#'
-end
View
37 tasks/metrics.rake
@@ -1,37 +0,0 @@
-begin
- require 'metric_fu'
-rescue LoadError
- namespace :metrics do
- task :all do
- abort 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
- end
- end
-end
-
-begin
- require 'reek/adapters/rake_task'
-
- Reek::RakeTask.new do |t|
- t.fail_on_error = true
- t.verbose = false
- t.source_files = 'lib/**/*.rb'
- end
-rescue LoadError
- task :reek do
- abort 'Reek is not available. In order to run reek, you must: gem install reek'
- end
-end
-
-begin
- require 'roodi'
- require 'rake/tasklib'
- require 'roodi_task'
-
- RoodiTask.new do |t|
- t.verbose = false
- end
-rescue LoadError
- task :roodi do
- abort 'Roodi is not available. In order to run roodi, you must: gem install roodi'
- end
-end
View
38 tasks/spec.rake
@@ -1,38 +0,0 @@
-spec_defaults = lambda do |spec|
- spec.pattern = 'spec/**/*_spec.rb'
- spec.libs << 'lib' << 'spec'
- spec.spec_opts << '--options' << 'spec/spec.opts'
-end
-
-begin
- require 'spec/rake/spectask'
-
- Spec::Rake::SpecTask.new(:spec, &spec_defaults)
-rescue LoadError
- task :spec do
- abort 'rspec is not available. In order to run spec, you must: gem install rspec'
- end
-end
-
-begin
- require 'rcov'
- require 'spec/rake/verify_rcov'
-
- Spec::Rake::SpecTask.new(:rcov) do |rcov|
- spec_defaults.call(rcov)
- rcov.rcov = true
- rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
- end
-
- RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
- rcov.threshold = 100
- end
-rescue LoadError
- %w[ rcov verify_rcov ].each do |name|
- task name do
- abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
- end
- end
-end
-
-task :default => :spec
View
9 tasks/yard.rake
@@ -1,9 +0,0 @@
-begin
- require 'yard'
-
- YARD::Rake::YardocTask.new
-rescue LoadError
- task :yard do
- abort 'YARD is not available. In order to run yard, you must: gem install yard'
- end
-end
View
20 tasks/yardstick.rake
@@ -1,20 +0,0 @@
-begin
- require 'pathname'
- require 'yardstick'
- require 'yardstick/rake/measurement'
- require 'yardstick/rake/verify'
-
- # yardstick_measure task
- Yardstick::Rake::Measurement.new
-
- # verify_measurements task
- Yardstick::Rake::Verify.new do |verify|
- verify.threshold = 100
- end
-rescue LoadError
- %w[ yardstick_measure verify_measurements ].each do |name|
- task name.to_s do
- abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.