pk-merb_sequel 1.0.4 → 1.0.5
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/Rakefile +5 -5
- data/lib/generators/templates/migration/schema/migrations/%file_name%.rb +3 -3
- data/lib/generators/templates/resource_controller/app/controllers/%file_name%.rb +11 -8
- data/lib/merb/session/sequel_session.rb +12 -6
- data/lib/merb_sequel.rb +2 -0
- data/lib/sequel_ext/model.rb +9 -5
- metadata +10 -9
data/Rakefile
CHANGED
@@ -7,17 +7,17 @@ require "spec/rake/spectask"
|
|
7
7
|
##############################################################################
|
8
8
|
# Package && release
|
9
9
|
##############################################################################
|
10
|
-
RUBY_FORGE_PROJECT = "
|
11
|
-
PROJECT_URL = "http://
|
10
|
+
RUBY_FORGE_PROJECT = "merb_sequel"
|
11
|
+
PROJECT_URL = "http://github.com/pk/merb_sequel"
|
12
12
|
PROJECT_SUMMARY = "Merb plugin that provides support for Sequel and Sequel::Model"
|
13
13
|
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
14
14
|
|
15
|
-
GEM_AUTHOR = "Wayne E. Seguin, Lance Carlson, Lori Holden"
|
16
|
-
GEM_EMAIL = "wayneeseguin@gmail.com, lancecarlson@gmail.com, email@loriholden.com"
|
15
|
+
GEM_AUTHOR = "Wayne E. Seguin, Lance Carlson, Lori Holden, Pavel Kunc"
|
16
|
+
GEM_EMAIL = "wayneeseguin@gmail.com, lancecarlson@gmail.com, email@loriholden.com, pavel.kunc@gmail.com"
|
17
17
|
|
18
18
|
GEM_NAME = "merb_sequel"
|
19
19
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
20
|
-
GEM_VERSION =
|
20
|
+
GEM_VERSION = "1.0.5" + PKG_BUILD
|
21
21
|
|
22
22
|
RELEASE_NAME = "REL #{GEM_VERSION}"
|
23
23
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# For details on Sequel migrations see
|
2
|
-
# http://sequel.rubyforge.org/
|
3
|
-
# http://sequel.rubyforge.org/rdoc/classes/Sequel/
|
1
|
+
# For details on Sequel migrations see:
|
2
|
+
# * http://sequel.rubyforge.org/
|
3
|
+
# * http://sequel.rubyforge.org/rdoc-plugins/classes/Sequel/Migration.html
|
4
4
|
|
5
5
|
class <%= class_name %> < Sequel::Migration
|
6
6
|
|
@@ -25,9 +25,10 @@ class <%= class_name %> < Application
|
|
25
25
|
# POST /<%= resource_path %>
|
26
26
|
def create
|
27
27
|
@<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
|
28
|
-
|
28
|
+
begin
|
29
|
+
@<%= singular_model %>.save
|
29
30
|
redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>, @<%= singular_model %>)
|
30
|
-
|
31
|
+
rescue Sequel::ValidationFailed
|
31
32
|
render :new
|
32
33
|
end
|
33
34
|
end
|
@@ -44,10 +45,11 @@ class <%= class_name %> < Application
|
|
44
45
|
def update
|
45
46
|
@<%= singular_model %> = <%= model_class_name %>[params[:id]]
|
46
47
|
raise NotFound unless @<%= singular_model %>
|
47
|
-
|
48
|
+
begin
|
49
|
+
@<%= singular_model %>.update(params[:<%= singular_model %>])
|
48
50
|
redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>, @<%= singular_model %>)
|
49
|
-
|
50
|
-
|
51
|
+
rescue Sequel::ValidationFailed
|
52
|
+
render :edit
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
@@ -55,12 +57,13 @@ class <%= class_name %> < Application
|
|
55
57
|
def destroy
|
56
58
|
@<%= singular_model %> = <%= model_class_name %>[params[:id]]
|
57
59
|
raise NotFound unless @<%= singular_model %>
|
58
|
-
|
60
|
+
begin
|
61
|
+
@<%= singular_model %>.destroy
|
59
62
|
redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>s)
|
60
|
-
|
63
|
+
rescue Sequel::Error
|
61
64
|
raise BadRequest
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
65
68
|
end
|
66
|
-
<% end -%>
|
69
|
+
<% end -%>
|
@@ -57,10 +57,15 @@ module Merb
|
|
57
57
|
# session_id<String>:: ID of the session to set.
|
58
58
|
# data<ContainerSession>:: The session to set.
|
59
59
|
def store_session(session_id, data)
|
60
|
-
|
61
|
-
item
|
62
|
-
|
63
|
-
|
60
|
+
begin
|
61
|
+
if item = find(:session_id => session_id)
|
62
|
+
item.update(:data => data)
|
63
|
+
else
|
64
|
+
item = self.new(:session_id => session_id, :data => data, :created_at => Time.now)
|
65
|
+
item.save
|
66
|
+
end
|
67
|
+
rescue => e
|
68
|
+
Merb.logger.error("#{e.message} when trying to save #{data}")
|
64
69
|
end
|
65
70
|
end
|
66
71
|
|
@@ -86,12 +91,13 @@ module Merb
|
|
86
91
|
|
87
92
|
# Lazy-unserialize session state.
|
88
93
|
def data
|
89
|
-
|
94
|
+
data = (@values[:data] ? Marshal.load(@values[:data]) : {}) if @data.nil?
|
95
|
+
@data
|
90
96
|
end
|
91
97
|
|
92
98
|
# Virtual attribute writer - override.
|
93
99
|
def data=(hsh)
|
94
|
-
|
100
|
+
super(hsh) if hsh.is_a?(Hash)
|
95
101
|
end
|
96
102
|
|
97
103
|
# Has the session been loaded yet?
|
data/lib/merb_sequel.rb
CHANGED
@@ -4,6 +4,8 @@ if defined?(Merb::Plugins)
|
|
4
4
|
require File.join(File.dirname(__FILE__) / "merb" / "orms" / "sequel" / "connection")
|
5
5
|
Merb::Plugins.add_rakefiles "merb_sequel" / "merbtasks"
|
6
6
|
|
7
|
+
Sequel::Model.send(:include, Merb::Orms::Sequel::ModelExtensions)
|
8
|
+
|
7
9
|
# Connects to the database and handles session
|
8
10
|
#
|
9
11
|
# Connects to the database and loads sequel sessions if we use them.
|
data/lib/sequel_ext/model.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pk-merb_sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Wayne E. Seguin, Lance Carlson, Lori Holden
|
7
|
+
- Wayne E. Seguin, Lance Carlson, Lori Holden, Pavel Kunc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-23 00:00:00 -07: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, email@loriholden.com
|
36
|
+
email: wayneeseguin@gmail.com, lancecarlson@gmail.com, email@loriholden.com, pavel.kunc@gmail.com
|
37
37
|
executables: []
|
38
38
|
|
39
39
|
extensions: []
|
@@ -90,8 +90,9 @@ files:
|
|
90
90
|
- lib/merb_sequel.rb
|
91
91
|
- lib/sequel_ext
|
92
92
|
- lib/sequel_ext/model.rb
|
93
|
-
has_rdoc:
|
94
|
-
homepage: http://
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: http://github.com/pk/merb_sequel
|
95
|
+
licenses:
|
95
96
|
post_install_message:
|
96
97
|
rdoc_options: []
|
97
98
|
|
@@ -111,10 +112,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
112
|
version:
|
112
113
|
requirements: []
|
113
114
|
|
114
|
-
rubyforge_project:
|
115
|
-
rubygems_version: 1.
|
115
|
+
rubyforge_project: merb_sequel
|
116
|
+
rubygems_version: 1.3.5
|
116
117
|
signing_key:
|
117
|
-
specification_version:
|
118
|
+
specification_version: 2
|
118
119
|
summary: Merb plugin that provides support for Sequel and Sequel::Model
|
119
120
|
test_files: []
|
120
121
|
|