Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rearranged files, added gemspec

  • Loading branch information...
commit b527bd7001ce00eb44dc17095216d9edcf17088b 1 parent 3e58e66
@pusewicz authored
View
32 README.md
@@ -4,4 +4,34 @@ Sequel for Rails
Installation
------------
- script/plugin install git://github.com/pusewicz/rails_sequel.git
+### Using Rails plugin script:
+
+ script/plugin install git://github.com/pusewicz/rails_sequel.git
+
+### Using Rails 2.1 Gem dependencies
+
+ Install the gem
+
+ gem sources -a http://gems.github.com
+ gem install pusewicz-rails_sequel
+
+ Load the gem in `environment.rb`
+
+ Rails::Initializer.run do |config|
+ config.gem 'pusewicz-rails_sequel', :version => '~> 0.0.2', :lib => 'rails_sequel', :source => 'http://gems.github.com'
+ end
+
+Optional
+--------
+
+ Remove ActiveRecord framework in `environment.rb` file:
+
+ config.frameworks -= [ :active_record ]
+
+Community
+=========
+
+IRC Channel
+-----------
+
+ You can find us on #sequel channel ([irc://irc.freenode.net/#sequel](irc://irc.freenode.net/#sequel))
View
2  Rakefile
@@ -0,0 +1,2 @@
+require 'rubygems'
+require 'rake'
View
6 init.rb
@@ -1,5 +1 @@
-gem 'sequel'
-require 'sequel'
-require File.expand_path(File.dirname(__FILE__) + '/lib/rails_sequel')
-require File.expand_path(File.dirname(__FILE__) + '/lib/sequel_ext')
-Rails::SequelConnection.connect
+require File.expand_path(File.dirname(__FILE__) + '/lib/rails_sequel')
View
31 lib/rails_sequel.rb
@@ -1,23 +1,8 @@
-module Rails
- module SequelConnection
- CONFIG = YAML::load(ERB.new(IO.read(Rails.root + "/config/database.yml")).result)[Rails.env].with_indifferent_access
-
- def self.connect
- Sequel.connect uri, :loggers => [Rails.logger]
- end
-
- def self.config
- CONFIG
- end
-
- def self.uri
- uri = config[:adapter] << "://"
- uri << config[:username] if config[:username]
- uri << ':' << config[:password] if config[:password]
- uri << '@' if config[:username] || config[:password]
- uri << ':' << config[:port] if config[:port]
- uri << config[:host]
- uri << '/' << config[:database]
- end
- end
-end
+gem 'sequel'
+require 'sequel'
+
+require File.expand_path(File.dirname(__FILE__) + '/rails_sequel/rails_sequel')
+require File.expand_path(File.dirname(__FILE__) + '/rails_sequel/version')
+require File.expand_path(File.dirname(__FILE__) + '/rails_sequel/sequel_ext')
+
+Rails::SequelConnection.connect
View
27 lib/rails_sequel/rails_sequel.rb
@@ -0,0 +1,27 @@
+module Rails
+ module SequelConnection
+ # Load configuration for current environment
+ CONFIG = YAML::load(ERB.new(IO.read(Rails.root + "/config/database.yml")).result)[Rails.env].with_indifferent_access unless defined?(CONFIG)
+
+ # Connects to database using constructed Database Connection URI
+ def self.connect
+ Sequel.connect uri, :loggers => [Rails.logger]
+ end
+
+ # Returns loaded database.yml configuration for current environment
+ def self.config
+ CONFIG
+ end
+
+ # Constructs Database Connection URI
+ def self.uri
+ uri = config[:adapter] << "://"
+ uri << config[:username] if config[:username]
+ uri << ':' << config[:password] if config[:password]
+ uri << '@' if config[:username] || config[:password]
+ uri << ':' << config[:port] if config[:port]
+ uri << (config[:host] || 'localhost')
+ uri << '/' << config[:database]
+ end
+ end
+end
View
12 lib/rails_sequel/sequel_ext.rb
@@ -0,0 +1,12 @@
+class Sequel::Model
+
+ # Allows Rails resource path helpers to work correctly
+ def to_param
+ pk.to_s
+ end
+
+ # Make new? play nice with Rails
+ def new_record?
+ new?
+ end
+end
View
15 lib/rails_sequel/version.rb
@@ -0,0 +1,15 @@
+module Rails
+ module SequelConnection
+ module Version
+ MAJOR = 0
+ MINOR = 0
+ TINY = 2
+
+ STRING = [MAJOR, MINOR, TINY].join('.')
+ end
+
+ def self.version
+ Version::STRING
+ end
+ end
+end
View
9 lib/sequel_ext.rb
@@ -1,9 +0,0 @@
-class Sequel::Model
- def to_param
- pk.to_s
- end
-
- def new_record?
- new?
- end
-end
View
21 rails_sequel.gemspec
@@ -0,0 +1,21 @@
+require File.expand_path(File.dirname(__FILE__) + '/lib/rails_sequel/version')
+
+Gem::Specification.new do |s|
+ s.name = 'rails_sequel'
+ s.version = "0.0.2"
+ s.date = '2009-01-10'
+
+ s.summary = "Sequel plugin for Ruby on Rails"
+ s.description = "rails_sequel allows you to quickly use Sequel Toolkit as your ORM in Ruby on Rails"
+
+ s.authors = ['Piotr Usewicz']
+ s.email = 'piotr@layer22.com'
+ s.homepage = 'http://github.com/pusewicz/rails_sequel/wikis'
+
+ s.has_rdoc = false
+ # s.rdoc_options = ['--main', 'README.rdoc']
+ # s.rdoc_options << '--inline-source' << '--charset=UTF-8'
+ # s.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'CHANGELOG.rdoc']
+
+ s.files = Dir['lib/**/*.rb'] + Dir['init.rb'] + Dir['README.md']
+end
Please sign in to comment.
Something went wrong with that request. Please try again.