pusewicz-rails_sequel 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +37 -0
- data/init.rb +1 -0
- data/lib/rails_sequel/rails_sequel.rb +46 -0
- data/lib/rails_sequel/sequel_ext.rb +12 -0
- data/lib/rails_sequel/version.rb +15 -0
- data/lib/rails_sequel.rb +8 -0
- metadata +66 -0
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Sequel for Rails
|
2
|
+
================
|
3
|
+
|
4
|
+
Installation
|
5
|
+
------------
|
6
|
+
|
7
|
+
### Using Rails plugin script:
|
8
|
+
|
9
|
+
script/plugin install git://github.com/pusewicz/rails_sequel.git
|
10
|
+
|
11
|
+
### Using Rails 2.1 Gem dependencies
|
12
|
+
|
13
|
+
Install the gem
|
14
|
+
|
15
|
+
gem sources -a http://gems.github.com
|
16
|
+
gem install pusewicz-rails_sequel
|
17
|
+
|
18
|
+
Load the gem in `environment.rb`
|
19
|
+
|
20
|
+
Rails::Initializer.run do |config|
|
21
|
+
config.gem 'pusewicz-rails_sequel', :version => '~> 0.0.2', :lib => 'rails_sequel', :source => 'http://gems.github.com'
|
22
|
+
end
|
23
|
+
|
24
|
+
Optional
|
25
|
+
--------
|
26
|
+
|
27
|
+
Remove ActiveRecord framework in `environment.rb` file:
|
28
|
+
|
29
|
+
config.frameworks -= [ :active_record ]
|
30
|
+
|
31
|
+
Community
|
32
|
+
=========
|
33
|
+
|
34
|
+
IRC Channel
|
35
|
+
-----------
|
36
|
+
|
37
|
+
You can find us on #sequel channel ([irc://irc.freenode.net/#sequel](irc://irc.freenode.net/#sequel))
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rails_sequel'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Rails
|
2
|
+
module SequelConnection
|
3
|
+
# Load configuration for current environment
|
4
|
+
CONFIG = YAML::load(ERB.new(IO.read(Rails.root + "/config/database.yml")).result)[Rails.env].with_indifferent_access unless defined?(CONFIG)
|
5
|
+
|
6
|
+
# Connects to database using constructed Database Connection URI
|
7
|
+
def self.connect
|
8
|
+
options = self.prepare_options
|
9
|
+
connection = Sequel.connect(options)
|
10
|
+
if options[:adapter] == 'mysql'
|
11
|
+
connection.execute("SET SQL_AUTO_IS_NULL=0")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns loaded database.yml configuration for current environment
|
16
|
+
def self.config
|
17
|
+
CONFIG
|
18
|
+
end
|
19
|
+
|
20
|
+
# Constructs Database Connection URI
|
21
|
+
def self.prepare_options
|
22
|
+
options = {}
|
23
|
+
|
24
|
+
# Use SQLite by default
|
25
|
+
options[:adapter] = (config[:adapter] || "sqlite")
|
26
|
+
# Use localhost as default host
|
27
|
+
options[:host] = (config[:host] || "localhost")
|
28
|
+
# Default user is an empty string. Both username and user keys are supported.
|
29
|
+
options[:user] = (config[:username] || config[:user] || "")
|
30
|
+
|
31
|
+
options[:password] = config[:password] || ""
|
32
|
+
|
33
|
+
# Both encoding and charset options are supported, default is utf8
|
34
|
+
options[:encoding] = (config[:encoding] || config[:charset] || "utf8")
|
35
|
+
# Default database is hey_dude_configure_your_database
|
36
|
+
options[:database] = config[:database] || "hey_dude_configure_your_database"
|
37
|
+
# MSSQL support
|
38
|
+
options[:db_type] = config[:db_type] if config[:db_type]
|
39
|
+
options[:socket] = config[:socket] if config[:socket]
|
40
|
+
options[:charset] = config[:charset] if config[:charset]
|
41
|
+
options[:encoding] = config[:encoding] if config[:encoding]
|
42
|
+
options[:loggers] = [Rails.logger]
|
43
|
+
options
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/rails_sequel.rb
ADDED
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pusewicz-rails_sequel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Piotr Usewicz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-14 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sequel
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.8.0
|
23
|
+
version:
|
24
|
+
description: rails_sequel allows you to quickly use Sequel Toolkit as your ORM in Ruby on Rails
|
25
|
+
email: piotr@layer22.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- lib/rails_sequel/rails_sequel.rb
|
34
|
+
- lib/rails_sequel/sequel_ext.rb
|
35
|
+
- lib/rails_sequel/version.rb
|
36
|
+
- lib/rails_sequel.rb
|
37
|
+
- init.rb
|
38
|
+
- README.md
|
39
|
+
has_rdoc: false
|
40
|
+
homepage: http://github.com/pusewicz/rails_sequel/wikis
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.2.0
|
62
|
+
signing_key:
|
63
|
+
specification_version: 2
|
64
|
+
summary: Sequel plugin for Ruby on Rails
|
65
|
+
test_files: []
|
66
|
+
|