merb_sequel 0.9.14 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,12 +13,12 @@ PROJECT_URL = "http://merbivore.com"
13
13
  PROJECT_SUMMARY = "Merb plugin that provides support for Sequel and Sequel::Model"
14
14
  PROJECT_DESCRIPTION = PROJECT_SUMMARY
15
15
 
16
- GEM_AUTHOR = "Wayne E. Seguin, Lance Carlson"
17
- GEM_EMAIL = "wayneeseguin@gmail.com, lancecarlson@gmail.com"
16
+ GEM_AUTHOR = "Wayne E. Seguin, Lance Carlson, Lori Holden"
17
+ GEM_EMAIL = "wayneeseguin@gmail.com, lancecarlson@gmail.com, email@loriholden.com"
18
18
 
19
19
  GEM_NAME = "merb_sequel"
20
20
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
21
- GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.14") + PKG_BUILD
21
+ GEM_VERSION = (Merb::MORE_VERSION rescue "1.0.0") + PKG_BUILD
22
22
 
23
23
  RELEASE_NAME = "REL #{GEM_VERSION}"
24
24
 
data/TODO CHANGED
@@ -1,2 +1,2 @@
1
1
  TODO:
2
- * More meaningful messages for cases with misconfigured database.yml.
2
+ * Figure out why using a sqlite3 memory store for the session bombs with stream errors.
@@ -1,6 +1,6 @@
1
1
  # For details on Sequel migrations see
2
2
  # http://sequel.rubyforge.org/
3
- # http://code.google.com/p/ruby-sequel/wiki/Migrations
3
+ # http://sequel.rubyforge.org/rdoc/classes/Sequel/Database.html#M000607
4
4
 
5
5
  class <%= class_name %> < Sequel::Migration
6
6
 
@@ -7,8 +7,8 @@ module Merb
7
7
 
8
8
  class << self
9
9
 
10
- def config_file() Merb.root / "config" / "database.yml" end
11
- def sample_dest() Merb.root / "config" / "database.yml.sample" end
10
+ def config_file() Merb.dir_for(:config) / "database.yml" end
11
+ def sample_dest() Merb.dir_for(:config) / "database.yml.sample" end
12
12
  def sample_source() File.dirname(__FILE__) / "database.yml.sample" end
13
13
 
14
14
  def copy_sample_config
@@ -32,13 +32,18 @@ module Merb
32
32
  if File.exists?(config_file)
33
33
  Merb.logger.info!("Connecting to the '#{config[:database]}' database on '#{config[:host]}' using '#{config[:adapter]}' ...")
34
34
  connection = ::Sequel.connect(config_options(config))
35
- Merb.logger.error!("Connection Error: #{e}") unless connection
35
+ begin
36
+ connection.test_connection
37
+ rescue => e
38
+ Merb.logger.error!("Connection Error: #{e}")
39
+ exit(1)
40
+ end
36
41
  connection
37
42
  else
38
43
  copy_sample_config
39
44
  Merb.logger.set_log(STDERR)
40
- Merb.logger.error! "No database.yml file found in #{Merb.root}/config."
41
- Merb.logger.error! "A sample file was created called config/database.yml.sample for you to copy and edit."
45
+ Merb.logger.error! "No database.yml file found at #{config_file}."
46
+ Merb.logger.error! "A sample file was created called #{sample_dest} for you to copy and edit."
42
47
  exit(1)
43
48
  end
44
49
  end
@@ -7,6 +7,7 @@
7
7
  :password: secrets
8
8
  :host: localhost
9
9
  :socket: /tmp/mysql.sock
10
+ :encoding: utf8
10
11
 
11
12
  :test:
12
13
  <<: *defaults
@@ -4,7 +4,32 @@ require 'base64'
4
4
 
5
5
  module Merb
6
6
 
7
- table_name = (Merb::Plugins.config[:merb_sequel][:session_table_name] || "sessions")
7
+ Merb::Plugins.config[:merb_sequel][:session_table_name] ||= "sessions"
8
+
9
+ # Default session migration run if a sessions table does not yet exist.
10
+ #
11
+ # Will create a table with a name of 'sessions' by default, or as
12
+ # set by Merb::Plugins.config[:merb_sequel][:session_table_name]
13
+
14
+ class CreateSessionMigration < Sequel::Migration
15
+ def up
16
+ table_name = Merb::Plugins.config[:merb_sequel][:session_table_name].to_sym
17
+ unless table_exists?(table_name)
18
+ puts "Warning: The database did not contain a '#{table_name}' table for sessions."
19
+
20
+ create_table table_name do
21
+ primary_key :id
22
+ varchar :session_id
23
+ text :data
24
+ timestamp :created_at
25
+ end
26
+
27
+ puts "Created '#{table_name}' session table."
28
+ end
29
+ end
30
+ end
31
+
32
+ CreateSessionMigration.apply(Sequel::Model.db, :up)
8
33
 
9
34
  # Sessions stored in Sequel model.
10
35
  #
@@ -12,14 +37,7 @@ module Merb
12
37
  #
13
38
  # Merb::Config[:session_store] = 'sequel'
14
39
 
15
- class SequelSessionStore < Sequel::Model(table_name.to_sym)
16
-
17
- set_schema do
18
- primary_key :id
19
- varchar :session_id
20
- text :data
21
- timestamp :created_at
22
- end
40
+ class SequelSessionStore < Sequel::Model(Merb::Plugins.config[:merb_sequel][:session_table_name].to_sym)
23
41
 
24
42
  class << self
25
43
 
@@ -86,12 +104,6 @@ module Merb
86
104
  end
87
105
 
88
106
  end
89
-
90
- unless Sequel::Model.db.table_exists?(table_name.to_sym)
91
- puts "Warning: The database did not contain a '#{table_name}' table for sessions."
92
- SequelSessionStore.class_eval { create_table unless table_exists? }
93
- puts "Created sessions table."
94
- end
95
107
 
96
108
  class SequelSession < SessionStoreContainer
97
109
 
@@ -15,7 +15,7 @@ if defined?(Merb::Plugins)
15
15
  require File.join(File.dirname(__FILE__) / "merb" / "session" / "sequel_session")
16
16
  end
17
17
 
18
- Merb::Router.root_behavior = Merb::Router.root_behavior.identify(Sequel::Model => :id)
18
+ Merb::Router.root_behavior = Merb::Router.root_behavior.identify(Sequel::Model => :pk)
19
19
  end
20
20
 
21
21
  end
@@ -24,7 +24,7 @@ namespace :sequel do
24
24
  if migration_exists
25
25
  puts "\nThe Session Migration File already exists\n\n"
26
26
  else
27
- sh %{merb-gen database_sessions_migration}
27
+ sh %{merb-gen session_migration}
28
28
  end
29
29
  end
30
30
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb_sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.14
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Wayne E. Seguin, Lance Carlson
7
+ - Wayne E. Seguin, Lance Carlson, Lori Holden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-12 00:00:00 -08:00
12
+ date: 2009-01-02 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 1.4.0
34
34
  version:
35
35
  description: Merb plugin that provides support for Sequel and Sequel::Model
36
- email: wayneeseguin@gmail.com, lancecarlson@gmail.com
36
+ email: wayneeseguin@gmail.com, lancecarlson@gmail.com, email@loriholden.com
37
37
  executables: []
38
38
 
39
39
  extensions: []