merb_datamapper 0.9.8 → 0.9.9
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/Generators +4 -0
- data/Rakefile +67 -41
- data/lib/generators/data_mapper_model.rb +5 -0
- data/lib/generators/templates/migration.rb +1 -1
- data/lib/generators/templates/model.rb +3 -1
- data/lib/generators/templates/resource_controller.rb +17 -17
- data/lib/generators/templates/views/edit.html.erb +1 -16
- data/lib/generators/templates/views/index.html.erb +1 -21
- data/lib/generators/templates/views/new.html.erb +1 -15
- data/lib/generators/templates/views/show.html.erb +1 -12
- data/lib/merb_datamapper/merbtasks.rb +72 -73
- data/lib/merb_datamapper/version.rb +1 -1
- data/lib/merb_datamapper.rb +6 -6
- metadata +18 -43
- data/History.txt +0 -1
- data/Manifest.txt +0 -31
- data/README.txt +0 -13
- data/spec/connection_spec.rb +0 -67
- data/spec/generators/data_mapper_migration_spec.rb +0 -31
- data/spec/generators/data_mapper_model_spec.rb +0 -38
- data/spec/generators/data_mapper_resource_controller_spec.rb +0 -24
- data/spec/generators/spec_helper.rb +0 -280
- data/spec/session_store_spec.rb +0 -125
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -8
data/Generators
ADDED
data/Rakefile
CHANGED
@@ -1,58 +1,84 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
3
|
-
require
|
4
|
-
require '
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require "extlib"
|
4
|
+
require 'merb-core/tasks/merb_rake_helper'
|
5
|
+
require "spec/rake/spectask"
|
5
6
|
|
6
|
-
|
7
|
-
require ROOT + 'lib/merb_datamapper/version'
|
7
|
+
require File.join(File.dirname(__FILE__), "../merb-core/lib/merb-core/version.rb")
|
8
8
|
|
9
|
-
AUTHOR = "Jason Toy"
|
10
|
-
EMAIL = "jtoy@rubynow.com"
|
11
|
-
GEM_NAME = "merb_datamapper"
|
12
|
-
GEM_VERSION = DataMapper::MerbDataMapper::VERSION
|
13
|
-
GEM_DEPENDENCIES = [["dm-core", ">=0.9.5"], ["dm-migrations", ">=0.9.5"], ["merb-core", ">=0.9.6"], ['templater', ">=0.2.0"]]
|
14
|
-
GEM_CLEAN = ["log", "pkg", "coverage"]
|
15
|
-
GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
##############################################################################
|
11
|
+
# Package && release
|
12
|
+
##############################################################################
|
13
|
+
RUBY_FORGE_PROJECT = "merb"
|
14
|
+
PROJECT_URL = "http://merbivore.com"
|
15
|
+
PROJECT_SUMMARY = "DataMapper plugin providing DataMapper support for Merb"
|
16
|
+
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
20
17
|
|
21
|
-
|
18
|
+
GEM_AUTHOR = "Jason Toy"
|
19
|
+
GEM_EMAIL = "jtoy@rubynow.com"
|
22
20
|
|
23
|
-
|
21
|
+
GEM_NAME = "merb_datamapper"
|
22
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
23
|
+
GEM_VERSION = (Merb::VERSION rescue "0.9.9") + PKG_BUILD
|
24
24
|
|
25
|
-
|
26
|
-
SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
|
25
|
+
RELEASE_NAME = "REL #{GEM_VERSION}"
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
GEM_DEPENDENCIES = [["dm-core", ">=0.9.5"], ["dm-migrations", ">=0.9.5"], ["merb-core", "~> #{GEM_VERSION}"]]
|
28
|
+
|
29
|
+
require "extlib/tasks/release"
|
30
|
+
|
31
|
+
spec = Gem::Specification.new do |s|
|
32
|
+
s.rubyforge_project = RUBY_FORGE_PROJECT
|
33
|
+
s.name = GEM_NAME
|
34
|
+
s.version = GEM_VERSION
|
35
|
+
s.platform = Gem::Platform::RUBY
|
36
|
+
s.has_rdoc = true
|
37
|
+
s.extra_rdoc_files = ["LICENSE", 'TODO']
|
38
|
+
s.summary = PROJECT_SUMMARY
|
39
|
+
s.description = PROJECT_DESCRIPTION
|
40
|
+
s.author = GEM_AUTHOR
|
41
|
+
s.email = GEM_EMAIL
|
42
|
+
s.homepage = PROJECT_URL
|
43
|
+
GEM_DEPENDENCIES.each do |gem, version|
|
44
|
+
s.add_dependency gem, version
|
45
|
+
end
|
46
|
+
s.require_path = 'lib'
|
47
|
+
s.files = %w(LICENSE Rakefile TODO Generators) + Dir.glob("{lib}/**/*")
|
48
|
+
end
|
49
|
+
|
50
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
51
|
+
pkg.gem_spec = spec
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Install the gem"
|
55
|
+
task :install do
|
56
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
31
57
|
end
|
32
58
|
|
33
|
-
desc "Uninstall
|
34
|
-
task :uninstall
|
35
|
-
|
59
|
+
desc "Uninstall the gem"
|
60
|
+
task :uninstall do
|
61
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
36
62
|
end
|
37
63
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
64
|
+
desc "Create a gemspec file"
|
65
|
+
task :gemspec do
|
66
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
67
|
+
file.puts spec.to_ruby
|
42
68
|
end
|
43
69
|
end
|
44
70
|
|
45
|
-
desc
|
46
|
-
Spec::Rake::SpecTask.new(
|
47
|
-
t.spec_opts
|
48
|
-
t.spec_files =
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
55
|
-
rescue Exception
|
56
|
-
# rcov not installed
|
71
|
+
desc "Run all examples (or a specific spec with TASK=xxxx)"
|
72
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
73
|
+
t.spec_opts = ["-cfs"]
|
74
|
+
t.spec_files = begin
|
75
|
+
if ENV["TASK"]
|
76
|
+
ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
|
77
|
+
else
|
78
|
+
FileList['spec/**/*_spec.rb']
|
79
|
+
end
|
57
80
|
end
|
58
81
|
end
|
82
|
+
|
83
|
+
desc 'Default: run spec examples'
|
84
|
+
task :default => 'spec'
|
@@ -7,6 +7,11 @@ class Merb::Generators::ModelGenerator
|
|
7
7
|
return 'DateTime' if type == 'datetime'
|
8
8
|
return type.camel_case
|
9
9
|
end
|
10
|
+
|
11
|
+
def after_generation
|
12
|
+
STDOUT << message("Don't forget to define the model schema in your #{file_name.capitalize} class")
|
13
|
+
end
|
14
|
+
|
10
15
|
end
|
11
16
|
|
12
17
|
Merb::Generators::ModelGenerator.template :model_datamapper, :orm => :datamapper do |t|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
<% with_modules(modules) do -%>
|
2
2
|
class <%= class_name %>
|
3
3
|
include DataMapper::Resource
|
4
|
-
|
4
|
+
|
5
|
+
property :id, Serial
|
6
|
+
<% attributes.each do |name, type| -%>
|
5
7
|
property :<%= name -%>, <%= datamapper_type(type) -%>
|
6
8
|
<% end %>
|
7
9
|
|
@@ -7,8 +7,8 @@ class <%= class_name %> < Application
|
|
7
7
|
display @<%= plural_model %>
|
8
8
|
end
|
9
9
|
|
10
|
-
def show
|
11
|
-
@<%= singular_model %> = <%= model_class_name %>.get(
|
10
|
+
def show(id)
|
11
|
+
@<%= singular_model %> = <%= model_class_name %>.get(id)
|
12
12
|
raise NotFound unless @<%= singular_model %>
|
13
13
|
display @<%= singular_model %>
|
14
14
|
end
|
@@ -16,42 +16,42 @@ class <%= class_name %> < Application
|
|
16
16
|
def new
|
17
17
|
only_provides :html
|
18
18
|
@<%= singular_model %> = <%= model_class_name %>.new
|
19
|
-
|
19
|
+
display <%= model_class_name %>
|
20
20
|
end
|
21
21
|
|
22
|
-
def edit
|
22
|
+
def edit(id)
|
23
23
|
only_provides :html
|
24
|
-
@<%= singular_model %> = <%= model_class_name %>.get(
|
24
|
+
@<%= singular_model %> = <%= model_class_name %>.get(id)
|
25
25
|
raise NotFound unless @<%= singular_model %>
|
26
|
-
|
26
|
+
display @<%= singular_model %>
|
27
27
|
end
|
28
28
|
|
29
|
-
def create
|
29
|
+
def create(<%= singular_model %>)
|
30
30
|
@<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
|
31
31
|
if @<%= singular_model %>.save
|
32
|
-
redirect
|
32
|
+
redirect resource(@<%= singular_model %>), :message => {:notice => "<%= model_class_name %> was successfully created"}
|
33
33
|
else
|
34
34
|
render :new
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def update
|
39
|
-
@<%= singular_model %> = <%= model_class_name %>.get(<%=
|
38
|
+
def update(<%= singular_model %>)
|
39
|
+
@<%= singular_model %> = <%= model_class_name %>.get(<%= singular_model %>[:id] )
|
40
40
|
raise NotFound unless @<%= singular_model %>
|
41
|
-
if @<%= singular_model %>.update_attributes(
|
42
|
-
|
41
|
+
if @<%= singular_model %>.update_attributes(<%= singular_model %>)
|
42
|
+
redirect resource(@<%= singular_model %>)
|
43
43
|
else
|
44
|
-
|
44
|
+
display @<%= singular_model %>, :edit
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
def destroy
|
49
|
-
@<%= singular_model %> = <%= model_class_name %>.get(
|
48
|
+
def destroy(id)
|
49
|
+
@<%= singular_model %> = <%= model_class_name %>.get(id)
|
50
50
|
raise NotFound unless @<%= singular_model %>
|
51
51
|
if @<%= singular_model %>.destroy
|
52
|
-
redirect
|
52
|
+
redirect resource(@<%= plural_model %>)
|
53
53
|
else
|
54
|
-
raise
|
54
|
+
raise InternalServerError
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -1,18 +1,3 @@
|
|
1
1
|
<h1><%= class_name %> controller, edit action</h1>
|
2
2
|
|
3
|
-
<p>Edit this file in <tt>app/views/<%= file_name %>/edit.html.erb</tt></p>
|
4
|
-
|
5
|
-
<%%= form_for(@<%= singular_model %>, :action => url(:<%= singular_model %>, @<%= singular_model %>)) do %>
|
6
|
-
<% for property in properties.select{|p| !p.key?} -%>
|
7
|
-
<p>
|
8
|
-
<%%= text_field :<%= property %>, :label => "<%= Extlib::Inflection.humanize(property) %>" %>
|
9
|
-
</p>
|
10
|
-
|
11
|
-
<% end -%>
|
12
|
-
<p>
|
13
|
-
<%%= submit "Update" %>
|
14
|
-
</p>
|
15
|
-
<%% end =%>
|
16
|
-
|
17
|
-
<%%= link_to 'Show', url(:<%= singular_model %>, @<%= singular_model %>) %> |
|
18
|
-
<%%= link_to 'Back', url(:<%= plural_model %>) %>
|
3
|
+
<p>Edit this file in <tt>app/views/<%= file_name %>/edit.html.erb</tt></p>
|
@@ -1,23 +1,3 @@
|
|
1
1
|
<h1><%= class_name %> controller, index action</h1>
|
2
2
|
|
3
|
-
<p>Edit this file in <tt>app/views/<%= file_name %>/index.html.erb</tt></p>
|
4
|
-
|
5
|
-
<table>
|
6
|
-
<tr>
|
7
|
-
<% for property in properties.reject{|p| p.lazy?} -%>
|
8
|
-
<th><%= Extlib::Inflection.humanize(property.field) %></th>
|
9
|
-
<% end -%>
|
10
|
-
</tr>
|
11
|
-
|
12
|
-
<%% for <%= singular_model %> in @<%= plural_model %> %>
|
13
|
-
<tr>
|
14
|
-
<% for property in properties.reject{|p| p.lazy?} -%>
|
15
|
-
<td><%%=h <%= singular_model %>.<%= property.getter %> %></td>
|
16
|
-
<% end -%>
|
17
|
-
<td><%%= link_to 'Show', url(:<%= singular_model %>, <%= singular_model %>) %></td>
|
18
|
-
<td><%%= link_to 'Edit', url(:edit_<%= singular_model %>, <%= singular_model %>) %></td>
|
19
|
-
</tr>
|
20
|
-
<%% end %>
|
21
|
-
</table>
|
22
|
-
|
23
|
-
<%%= link_to 'New', url(:new_<%= singular_model %>) %>
|
3
|
+
<p>Edit this file in <tt>app/views/<%= file_name %>/index.html.erb</tt></p>
|
@@ -1,17 +1,3 @@
|
|
1
1
|
<h1><%= class_name %> controller, new action</h1>
|
2
2
|
|
3
|
-
<p>Edit this file in <tt>app/views/<%= file_name %>/new.html.erb</tt></p>
|
4
|
-
|
5
|
-
<%%= form_for(@<%= singular_model %>, :action => url(:<%= plural_model %>) ) do %>
|
6
|
-
<% for property in properties.select{|p| !p.key?} -%>
|
7
|
-
<p>
|
8
|
-
<%%= text_field :<%= property %>, :label => "<%= Extlib::Inflection.humanize(property) %>" %>
|
9
|
-
</p>
|
10
|
-
|
11
|
-
<% end -%>
|
12
|
-
<p>
|
13
|
-
<%%= submit "Create" %>
|
14
|
-
</p>
|
15
|
-
<%% end =%>
|
16
|
-
|
17
|
-
<%%= link_to 'Back', url(:<%= plural_model %>) %>
|
3
|
+
<p>Edit this file in <tt>app/views/<%= file_name %>/new.html.erb</tt></p>
|
@@ -1,14 +1,3 @@
|
|
1
1
|
<h1><%= class_name %> controller, show action</h1>
|
2
2
|
|
3
|
-
<p>Edit this file in <tt>app/views/<%= file_name %>/show.html.erb</tt></p>
|
4
|
-
|
5
|
-
<% for property in properties -%>
|
6
|
-
<p>
|
7
|
-
<b><%= Extlib::Inflection.humanize(property.field) %>:</b>
|
8
|
-
<%%=h @<%= singular_model %>.<%= property.getter %> %>
|
9
|
-
</p>
|
10
|
-
|
11
|
-
<% end -%>
|
12
|
-
|
13
|
-
<%%= link_to 'Edit', url(:edit_<%= singular_model %>, @<%= singular_model %>) %> |
|
14
|
-
<%%= link_to 'Back', url(:<%= plural_model %>) %>
|
3
|
+
<p>Edit this file in <tt>app/views/<%= file_name %>/show.html.erb</tt></p>
|
@@ -1,94 +1,93 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'merb/orms/data_mapper/connection'
|
3
3
|
|
4
|
-
namespace :
|
5
|
-
|
4
|
+
namespace :db do
|
5
|
+
|
6
6
|
task :merb_start do
|
7
7
|
Merb.start_environment :adapter => 'runner',
|
8
|
-
|
8
|
+
:environment => ENV['MERB_ENV'] || 'development'
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Create a sample database.yml file"
|
12
|
+
task :database_yaml => :merb_start do
|
13
|
+
sample_location = File.join(File.dirname(__FILE__), "..", "merb", "orms", "data_mapper", "database.yml.sample")
|
14
|
+
target_location = Merb.dir_for(:config)
|
15
|
+
FileUtils.cp sample_location, target_location
|
16
|
+
end
|
17
|
+
desc "Perform automigration"
|
18
|
+
task :automigrate => :merb_start do
|
19
|
+
::DataMapper::AutoMigrator.auto_migrate
|
20
|
+
end
|
21
|
+
desc "Perform non destructive automigration"
|
22
|
+
task :autoupgrade => :merb_start do
|
23
|
+
::DataMapper::AutoMigrator.auto_upgrade
|
9
24
|
end
|
10
25
|
|
11
|
-
namespace :
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
26
|
+
namespace :migrate do
|
27
|
+
task :load => :merb_start do
|
28
|
+
gem 'dm-migrations'
|
29
|
+
require 'migration_runner'
|
30
|
+
FileList["schema/migrations/*.rb"].each do |migration|
|
31
|
+
load migration
|
32
|
+
end
|
17
33
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
34
|
+
|
35
|
+
desc "Migrate up using migrations"
|
36
|
+
task :up, :version, :needs => :load do |t, args|
|
37
|
+
version = args[:version] || ENV['VERSION']
|
38
|
+
migrate_up!(version)
|
21
39
|
end
|
22
|
-
desc "
|
23
|
-
task :
|
24
|
-
|
40
|
+
desc "Migrate down using migrations"
|
41
|
+
task :down, :version, :needs => :load do |t, args|
|
42
|
+
version = args[:version] || ENV['VERSION']
|
43
|
+
migrate_down!(version)
|
25
44
|
end
|
45
|
+
end
|
26
46
|
|
27
|
-
|
28
|
-
|
29
|
-
gem 'dm-migrations'
|
30
|
-
require 'migration_runner'
|
31
|
-
FileList["schema/migrations/*.rb"].each do |migration|
|
32
|
-
load migration
|
33
|
-
end
|
34
|
-
end
|
47
|
+
desc "Migrate the database to the latest version"
|
48
|
+
task :migrate => 'db:migrate:up'
|
35
49
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
50
|
+
desc "Create the database"
|
51
|
+
task :create do
|
52
|
+
config = Merb::Orms::DataMapper.config
|
53
|
+
puts "Creating database '#{config[:database]}'"
|
54
|
+
case config[:adapter]
|
55
|
+
when 'postgres'
|
56
|
+
`createdb -U #{config[:username]} #{config[:database]}`
|
57
|
+
when 'mysql'
|
58
|
+
`mysqladmin -u #{config[:username]} #{config[:password] ? "-p'#{config[:password]}'" : ''} create #{config[:database]}`
|
59
|
+
when 'sqlite3'
|
60
|
+
Rake::Task['rake:db:automigrate'].invoke
|
61
|
+
else
|
62
|
+
raise "Adapter #{config[:adapter]} not supported for creating databases yet."
|
46
63
|
end
|
64
|
+
end
|
47
65
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
`createdb -U #{config[:username]} #{config[:database]}`
|
58
|
-
when 'mysql'
|
59
|
-
`mysqladmin -u #{config[:username]} #{config[:password] ? "-p'#{config[:password]}'" : ''} create #{config[:database]}`
|
60
|
-
when 'sqlite3'
|
61
|
-
Rake::Task['rake:dm:db:automigrate'].invoke
|
62
|
-
else
|
63
|
-
raise "Adapter #{config[:adapter]} not supported for creating databases yet."
|
64
|
-
end
|
66
|
+
desc "Drop the database (postgres only)"
|
67
|
+
task :drop do
|
68
|
+
config = Merb::Orms::DataMapper.config
|
69
|
+
puts "Droping database '#{config[:database]}'"
|
70
|
+
case config[:adapter]
|
71
|
+
when 'postgres'
|
72
|
+
`dropdb -U #{config[:username]} #{config[:database]}`
|
73
|
+
else
|
74
|
+
raise "Adapter #{config[:adapter]} not supported for dropping databases yet.\ntry db:automigrate"
|
65
75
|
end
|
76
|
+
end
|
66
77
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
puts "Droping database '#{config[:database]}'"
|
71
|
-
case config[:adapter]
|
72
|
-
when 'postgres'
|
73
|
-
`dropdb -U #{config[:username]} #{config[:database]}`
|
74
|
-
else
|
75
|
-
raise "Adapter #{config[:adapter]} not supported for dropping databases yet.\ntry dm:db:automigrate"
|
76
|
-
end
|
77
|
-
end
|
78
|
+
desc "Drop the database, and migrate from scratch"
|
79
|
+
task :reset => [:drop, :create, :migrate]
|
80
|
+
end
|
78
81
|
|
79
|
-
|
80
|
-
|
82
|
+
namespace :sessions do
|
83
|
+
desc "Perform automigration for sessions"
|
84
|
+
task :create => :merb_start do
|
85
|
+
Merb::DataMapperSessionStore.auto_migrate!
|
81
86
|
end
|
82
87
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
Merb::DataMapperSessionStore.auto_migrate!
|
87
|
-
end
|
88
|
-
|
89
|
-
desc "Clears sessions"
|
90
|
-
task :clear => :merb_start do
|
91
|
-
Merb::DataMapperSessionStore.all.destroy!
|
92
|
-
end
|
88
|
+
desc "Clears sessions"
|
89
|
+
task :clear => :merb_start do
|
90
|
+
Merb::DataMapperSessionStore.all.destroy!
|
93
91
|
end
|
94
92
|
end
|
93
|
+
|
data/lib/merb_datamapper.rb
CHANGED
@@ -8,7 +8,7 @@ if defined?(Merb::Plugins)
|
|
8
8
|
after BeforeAppLoads
|
9
9
|
|
10
10
|
def self.run
|
11
|
-
Merb.logger.
|
11
|
+
Merb.logger.verbose! "Merb::Orms::DataMapper::Connect block."
|
12
12
|
|
13
13
|
# check for the presence of database.yml
|
14
14
|
if File.file?(Merb.dir_for(:config) / "database.yml")
|
@@ -20,16 +20,16 @@ if defined?(Merb::Plugins)
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# if we use a datamapper session store, require it.
|
23
|
-
Merb.logger.
|
23
|
+
Merb.logger.verbose! "Checking if we need to use DataMapper sessions"
|
24
24
|
if Merb::Config.session_stores.include?(:datamapper)
|
25
|
-
Merb.logger.
|
25
|
+
Merb.logger.verbose! "Using DataMapper sessions"
|
26
26
|
require File.dirname(__FILE__) / "merb" / "session" / "data_mapper_session"
|
27
27
|
end
|
28
28
|
|
29
29
|
# take advantage of the fact #id returns the key of the model, unless #id is a property
|
30
30
|
Merb::Router.root_behavior = Merb::Router.root_behavior.identify(DataMapper::Resource => :id)
|
31
31
|
|
32
|
-
Merb.logger.
|
32
|
+
Merb.logger.verbose! "Merb::Orms::DataMapper::Connect complete"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -37,7 +37,7 @@ if defined?(Merb::Plugins)
|
|
37
37
|
after LoadClasses
|
38
38
|
|
39
39
|
def self.run
|
40
|
-
Merb.logger.
|
40
|
+
Merb.logger.verbose! 'Merb::Orms::DataMapper::Associations block'
|
41
41
|
|
42
42
|
# make sure all relationships are initialized after loading
|
43
43
|
descendants = DataMapper::Resource.descendants.dup
|
@@ -48,7 +48,7 @@ if defined?(Merb::Plugins)
|
|
48
48
|
model.relationships.each_value { |r| r.child_key }
|
49
49
|
end
|
50
50
|
|
51
|
-
Merb.logger.
|
51
|
+
Merb.logger.verbose! 'Merb::Orms::DataMapper::Associations complete'
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb_datamapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Toy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-10-
|
12
|
+
date: 2008-10-14 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -38,79 +38,54 @@ dependencies:
|
|
38
38
|
version_requirement:
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 0.9.6
|
44
|
-
version:
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: templater
|
47
|
-
type: :runtime
|
48
|
-
version_requirement:
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
41
|
+
- - ~>
|
52
42
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
54
|
-
version:
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: hoe
|
57
|
-
type: :development
|
58
|
-
version_requirement:
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: 1.7.0
|
43
|
+
version: 0.9.9
|
64
44
|
version:
|
65
45
|
description: DataMapper plugin providing DataMapper support for Merb
|
66
|
-
email:
|
67
|
-
- jtoy@rubynow.com
|
46
|
+
email: jtoy@rubynow.com
|
68
47
|
executables: []
|
69
48
|
|
70
49
|
extensions: []
|
71
50
|
|
72
51
|
extra_rdoc_files:
|
73
|
-
- README.txt
|
74
52
|
- LICENSE
|
75
53
|
- TODO
|
76
54
|
files:
|
77
|
-
- History.txt
|
78
55
|
- LICENSE
|
79
|
-
- Manifest.txt
|
80
|
-
- README.txt
|
81
56
|
- Rakefile
|
82
57
|
- TODO
|
58
|
+
- Generators
|
59
|
+
- lib/generators
|
83
60
|
- lib/generators/data_mapper_migration.rb
|
84
61
|
- lib/generators/data_mapper_model.rb
|
85
62
|
- lib/generators/data_mapper_resource_controller.rb
|
63
|
+
- lib/generators/templates
|
86
64
|
- lib/generators/templates/migration.rb
|
87
65
|
- lib/generators/templates/model.rb
|
88
66
|
- lib/generators/templates/model_migration.rb
|
89
67
|
- lib/generators/templates/resource_controller.rb
|
68
|
+
- lib/generators/templates/views
|
90
69
|
- lib/generators/templates/views/edit.html.erb
|
91
70
|
- lib/generators/templates/views/index.html.erb
|
92
71
|
- lib/generators/templates/views/new.html.erb
|
93
72
|
- lib/generators/templates/views/show.html.erb
|
73
|
+
- lib/merb
|
74
|
+
- lib/merb/orms
|
75
|
+
- lib/merb/orms/data_mapper
|
94
76
|
- lib/merb/orms/data_mapper/connection.rb
|
95
77
|
- lib/merb/orms/data_mapper/database.yml.sample
|
78
|
+
- lib/merb/session
|
96
79
|
- lib/merb/session/data_mapper_session.rb
|
97
|
-
- lib/merb_datamapper
|
80
|
+
- lib/merb_datamapper
|
98
81
|
- lib/merb_datamapper/merbtasks.rb
|
99
82
|
- lib/merb_datamapper/version.rb
|
100
|
-
-
|
101
|
-
- spec/session_store_spec.rb
|
102
|
-
- spec/generators/data_mapper_migration_spec.rb
|
103
|
-
- spec/generators/data_mapper_model_spec.rb
|
104
|
-
- spec/generators/data_mapper_resource_controller_spec.rb
|
105
|
-
- spec/generators/spec_helper.rb
|
106
|
-
- spec/spec.opts
|
107
|
-
- spec/spec_helper.rb
|
83
|
+
- lib/merb_datamapper.rb
|
108
84
|
has_rdoc: true
|
109
|
-
homepage: http://
|
85
|
+
homepage: http://merbivore.com
|
110
86
|
post_install_message:
|
111
|
-
rdoc_options:
|
112
|
-
|
113
|
-
- README.txt
|
87
|
+
rdoc_options: []
|
88
|
+
|
114
89
|
require_paths:
|
115
90
|
- lib
|
116
91
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/History.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
|
data/Manifest.txt
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
LICENSE
|
3
|
-
Manifest.txt
|
4
|
-
README.txt
|
5
|
-
Rakefile
|
6
|
-
TODO
|
7
|
-
lib/generators/data_mapper_migration.rb
|
8
|
-
lib/generators/data_mapper_model.rb
|
9
|
-
lib/generators/data_mapper_resource_controller.rb
|
10
|
-
lib/generators/templates/migration.rb
|
11
|
-
lib/generators/templates/model.rb
|
12
|
-
lib/generators/templates/model_migration.rb
|
13
|
-
lib/generators/templates/resource_controller.rb
|
14
|
-
lib/generators/templates/views/edit.html.erb
|
15
|
-
lib/generators/templates/views/index.html.erb
|
16
|
-
lib/generators/templates/views/new.html.erb
|
17
|
-
lib/generators/templates/views/show.html.erb
|
18
|
-
lib/merb/orms/data_mapper/connection.rb
|
19
|
-
lib/merb/orms/data_mapper/database.yml.sample
|
20
|
-
lib/merb/session/data_mapper_session.rb
|
21
|
-
lib/merb_datamapper.rb
|
22
|
-
lib/merb_datamapper/merbtasks.rb
|
23
|
-
lib/merb_datamapper/version.rb
|
24
|
-
spec/connection_spec.rb
|
25
|
-
spec/session_store_spec.rb
|
26
|
-
spec/generators/data_mapper_migration_spec.rb
|
27
|
-
spec/generators/data_mapper_model_spec.rb
|
28
|
-
spec/generators/data_mapper_resource_controller_spec.rb
|
29
|
-
spec/generators/spec_helper.rb
|
30
|
-
spec/spec.opts
|
31
|
-
spec/spec_helper.rb
|
data/README.txt
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
= merb_datamapper
|
2
|
-
|
3
|
-
A plugin for the Merb framework that provides DataMapper access
|
4
|
-
|
5
|
-
To use sessions:
|
6
|
-
|
7
|
-
1. set the session store to datamapper in init.rb:
|
8
|
-
Merb::Config.use { |c|
|
9
|
-
c[:session_store] = 'datamapper'
|
10
|
-
}
|
11
|
-
|
12
|
-
2. add the dependency in init.rb:
|
13
|
-
use_orm :datamapper
|
data/spec/connection_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'merb', 'orms', 'data_mapper', 'connection')
|
3
|
-
|
4
|
-
describe 'Merb datamapper' do
|
5
|
-
it "should read the configuration file" do
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should return an option hash with symbol keys' do
|
10
|
-
Merb.should_receive(:environment).once.and_return('development')
|
11
|
-
|
12
|
-
config = {
|
13
|
-
'development' => {
|
14
|
-
'adapter' => 'myadapter',
|
15
|
-
'more_stuff' => 'more_stuff',
|
16
|
-
'repositories' => {
|
17
|
-
'repo1' => {
|
18
|
-
'adapter' => 'mysql',
|
19
|
-
},
|
20
|
-
},
|
21
|
-
},
|
22
|
-
}
|
23
|
-
|
24
|
-
Merb::Orms::DataMapper.should_receive(:full_config).once.and_return(config)
|
25
|
-
Merb::Orms::DataMapper.config.should have_key(:adapter)
|
26
|
-
Merb::Orms::DataMapper.config[:adapter].should == 'myadapter'
|
27
|
-
Merb::Orms::DataMapper.config.should have_key(:repositories)
|
28
|
-
Merb::Orms::DataMapper.config[:repositories].should have_key(:repo1)
|
29
|
-
Merb::Orms::DataMapper.config[:repositories][:repo1].should have_key(:adapter)
|
30
|
-
Merb::Orms::DataMapper.config[:repositories][:repo1][:adapter].should == 'mysql'
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should create a default repository" do
|
34
|
-
config = {
|
35
|
-
:adapter => 'mysql',
|
36
|
-
:database => 'mydb'
|
37
|
-
}
|
38
|
-
|
39
|
-
Merb::Orms::DataMapper.should_receive(:config).and_return(config)
|
40
|
-
DataMapper.should_receive(:setup).with(:default, config)
|
41
|
-
|
42
|
-
Merb::Orms::DataMapper.setup_connections
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should create additional repositories" do
|
46
|
-
conf_mysql = {
|
47
|
-
:adapter => "mysql",
|
48
|
-
:database => "db"
|
49
|
-
}
|
50
|
-
conf_postgres = {
|
51
|
-
:adapter => "postgres",
|
52
|
-
:database => "dbp"
|
53
|
-
}
|
54
|
-
config = {
|
55
|
-
:repositories => {
|
56
|
-
:repo1 => conf_mysql,
|
57
|
-
:repo2 => conf_postgres
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
Merb::Orms::DataMapper.should_receive(:config).and_return(config)
|
62
|
-
DataMapper.should_receive(:setup).with(:repo1, conf_mysql)
|
63
|
-
DataMapper.should_receive(:setup).with(:repo2, conf_postgres)
|
64
|
-
|
65
|
-
Merb::Orms::DataMapper.setup_connections
|
66
|
-
end
|
67
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
# many specs copied from merb-gen master branch
|
3
|
-
describe "Merb::Generators::MigrationGenerator for DataMapper" do
|
4
|
-
it "should complain if no name is specified" do
|
5
|
-
lambda {
|
6
|
-
@generator = Merb::Generators::MigrationGenerator.new('/tmp', {:orm => :datamapper})
|
7
|
-
}.should raise_error(::Templater::TooFewArgumentsError)
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
describe "with no options" do
|
12
|
-
before(:each) do
|
13
|
-
@base_dir = "/tmp/migrations"
|
14
|
-
FileUtils.mkdir_p @base_dir
|
15
|
-
@generator = Merb::Generators::MigrationGenerator.new(@base_dir, {:orm => :datamapper}, 'SomeMoreStuff')
|
16
|
-
end
|
17
|
-
|
18
|
-
after(:each) do
|
19
|
-
FileUtils.rm_r @base_dir
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should render successfully" do
|
23
|
-
lambda { @generator.render! }.should_not raise_error
|
24
|
-
end
|
25
|
-
|
26
|
-
it "creates the file correctly" do
|
27
|
-
@generator.should create('/tmp/migrations/schema/migrations/001_some_more_stuff_migration.rb')
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
describe "Merb::Generators::ModelGenerator for DataMapper" do
|
3
|
-
it "complains if no name is specified" do
|
4
|
-
lambda {
|
5
|
-
@generator = Merb::Generators::ModelGenerator.new('/tmp', {:orm => :datamapper})
|
6
|
-
}.should raise_error(::Templater::TooFewArgumentsError)
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
before do
|
11
|
-
@generator = Merb::Generators::ModelGenerator.new('/tmp',{:orm => :datamapper}, 'Stuff')
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like "namespaced generator"
|
15
|
-
|
16
|
-
it "should create a model" do
|
17
|
-
@generator.should create('/tmp/app/models/stuff.rb')
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should render successfully" do
|
21
|
-
lambda { @generator.render! }.should_not raise_error
|
22
|
-
end
|
23
|
-
|
24
|
-
it "generates a resource" do
|
25
|
-
model_file = @generator.render!.detect { |file| file =~ /class/ }
|
26
|
-
model_file.should match(/include DataMapper::Resource/)
|
27
|
-
end
|
28
|
-
it "generates a resource with appropriate properties" do
|
29
|
-
@generator = Merb::Generators::ModelGenerator.new('/tmp',{:orm => :datamapper}, 'Stuff', 'id' => 'serial')
|
30
|
-
model_file = @generator.template(:model_datamapper).render
|
31
|
-
model_file.should match(/property :id, Serial/)
|
32
|
-
end
|
33
|
-
it "generates a resource with DateTime properties in the correct case when called with the common argument of datetime" do
|
34
|
-
@generator = Merb::Generators::ModelGenerator.new('/tmp',{:orm => :datamapper}, 'Stuff', 'created_at' => 'datetime')
|
35
|
-
model_file = @generator.template(:model_datamapper).render
|
36
|
-
model_file.should match(/property :created_at, DateTime/)
|
37
|
-
end
|
38
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
describe "Merb::Generators::ResourceControllerGenerator for DataMapper" do
|
3
|
-
it "complains if no name is specified" do
|
4
|
-
lambda {
|
5
|
-
@generator = Merb::Generators::ResourceControllerGenerator.new('/tmp', {:orm => :datamapper })
|
6
|
-
}.should raise_error(::Templater::TooFewArgumentsError)
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
before do
|
11
|
-
@generator = Merb::Generators::ResourceControllerGenerator.new('/tmp', { :orm => :datamapper }, 'Stuff')
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like "namespaced generator"
|
15
|
-
|
16
|
-
it "should create a model" do
|
17
|
-
@generator.should create('/tmp/app/controllers/stuff.rb')
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should render successfully" do
|
21
|
-
lambda { @generator.render! }.should_not raise_error
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,280 +0,0 @@
|
|
1
|
-
# require our other spec helpers
|
2
|
-
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
3
|
-
|
4
|
-
# require merb-gen and the spec helpers
|
5
|
-
require 'merb-gen'
|
6
|
-
require 'templater/spec/helpers'
|
7
|
-
|
8
|
-
|
9
|
-
# require the generators
|
10
|
-
require 'generators/data_mapper_migration'
|
11
|
-
require 'generators/data_mapper_model'
|
12
|
-
require 'generators/data_mapper_resource_controller'
|
13
|
-
|
14
|
-
# include the helpers
|
15
|
-
Spec::Runner.configure do |config|
|
16
|
-
config.include Templater::Spec::Helpers
|
17
|
-
end
|
18
|
-
|
19
|
-
# copied from merb-more/merb-gen/spec/spec_helpers.rb
|
20
|
-
# 07/08/2008
|
21
|
-
|
22
|
-
shared_examples_for "named generator" do
|
23
|
-
|
24
|
-
describe '#file_name' do
|
25
|
-
|
26
|
-
it "should convert the name to snake case" do
|
27
|
-
@generator.name = 'SomeMoreStuff'
|
28
|
-
@generator.file_name.should == 'some_more_stuff'
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should preserve dashes" do
|
32
|
-
@generator.name = "project-pictures"
|
33
|
-
@generator.file_name.should == "project-pictures"
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#base_name' do
|
39
|
-
|
40
|
-
it "should convert the name to snake case" do
|
41
|
-
@generator.name = 'SomeMoreStuff'
|
42
|
-
@generator.base_name.should == 'some_more_stuff'
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should preserve dashes" do
|
46
|
-
@generator.name = "project-pictures"
|
47
|
-
@generator.base_name.should == "project-pictures"
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "#symbol_name" do
|
53
|
-
|
54
|
-
it "should snakify the name" do
|
55
|
-
@generator.name = "ProjectPictures"
|
56
|
-
@generator.symbol_name.should == "project_pictures"
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should replace dashes with underscores" do
|
60
|
-
@generator.name = "project-pictures"
|
61
|
-
@generator.symbol_name.should == "project_pictures"
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#class_name' do
|
67
|
-
|
68
|
-
it "should convert the name to camel case" do
|
69
|
-
@generator.name = 'some_more_stuff'
|
70
|
-
@generator.class_name.should == 'SomeMoreStuff'
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should convert a name with dashes to camel case" do
|
74
|
-
@generator.name = 'some-more-stuff'
|
75
|
-
@generator.class_name.should == 'SomeMoreStuff'
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#module_name' do
|
81
|
-
|
82
|
-
it "should convert the name to camel case" do
|
83
|
-
@generator.name = 'some_more_stuff'
|
84
|
-
@generator.module_name.should == 'SomeMoreStuff'
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should convert a name with dashes to camel case" do
|
88
|
-
@generator.name = 'some-more-stuff'
|
89
|
-
@generator.module_name.should == 'SomeMoreStuff'
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '#test_class_name' do
|
95
|
-
|
96
|
-
it "should convert the name to camel case and append 'test'" do
|
97
|
-
@generator.name = 'some_more_stuff'
|
98
|
-
@generator.test_class_name.should == 'SomeMoreStuffTest'
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
shared_examples_for "namespaced generator" do
|
106
|
-
|
107
|
-
describe "#class_name" do
|
108
|
-
it "should camelize the name" do
|
109
|
-
@generator.name = "project_pictures"
|
110
|
-
@generator.class_name.should == "ProjectPictures"
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should split off the last double colon separated chunk" do
|
114
|
-
@generator.name = "Test::Monkey::ProjectPictures"
|
115
|
-
@generator.class_name.should == "ProjectPictures"
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should split off the last slash separated chunk" do
|
119
|
-
@generator.name = "test/monkey/project_pictures"
|
120
|
-
@generator.class_name.should == "ProjectPictures"
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should convert a name with dashes to camel case" do
|
124
|
-
@generator.name = 'some-more-stuff'
|
125
|
-
@generator.class_name.should == 'SomeMoreStuff'
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "#module_name" do
|
130
|
-
it "should camelize the name" do
|
131
|
-
@generator.name = "project_pictures"
|
132
|
-
@generator.module_name.should == "ProjectPictures"
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should split off the last double colon separated chunk" do
|
136
|
-
@generator.name = "Test::Monkey::ProjectPictures"
|
137
|
-
@generator.module_name.should == "ProjectPictures"
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should split off the last slash separated chunk" do
|
141
|
-
@generator.name = "test/monkey/project_pictures"
|
142
|
-
@generator.module_name.should == "ProjectPictures"
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should convert a name with dashes to camel case" do
|
146
|
-
@generator.name = 'some-more-stuff'
|
147
|
-
@generator.module_name.should == 'SomeMoreStuff'
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe "#modules" do
|
152
|
-
it "should be empty if no modules are passed to the name" do
|
153
|
-
@generator.name = "project_pictures"
|
154
|
-
@generator.modules.should == []
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should split off all but the last double colon separated chunks" do
|
158
|
-
@generator.name = "Test::Monkey::ProjectPictures"
|
159
|
-
@generator.modules.should == ["Test", "Monkey"]
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should split off all but the last slash separated chunk" do
|
163
|
-
@generator.name = "test/monkey/project_pictures"
|
164
|
-
@generator.modules.should == ["Test", "Monkey"]
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "#file_name" do
|
169
|
-
it "should snakify the name" do
|
170
|
-
@generator.name = "ProjectPictures"
|
171
|
-
@generator.file_name.should == "project_pictures"
|
172
|
-
end
|
173
|
-
|
174
|
-
it "should preserve dashes" do
|
175
|
-
@generator.name = "project-pictures"
|
176
|
-
@generator.file_name.should == "project-pictures"
|
177
|
-
end
|
178
|
-
|
179
|
-
it "should split off the last double colon separated chunk and snakify it" do
|
180
|
-
@generator.name = "Test::Monkey::ProjectPictures"
|
181
|
-
@generator.file_name.should == "project_pictures"
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should split off the last slash separated chunk and snakify it" do
|
185
|
-
@generator.name = "test/monkey/project_pictures"
|
186
|
-
@generator.file_name.should == "project_pictures"
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe "#base_name" do
|
191
|
-
it "should snakify the name" do
|
192
|
-
@generator.name = "ProjectPictures"
|
193
|
-
@generator.base_name.should == "project_pictures"
|
194
|
-
end
|
195
|
-
|
196
|
-
it "should preserve dashes" do
|
197
|
-
@generator.name = "project-pictures"
|
198
|
-
@generator.base_name.should == "project-pictures"
|
199
|
-
end
|
200
|
-
|
201
|
-
it "should split off the last double colon separated chunk and snakify it" do
|
202
|
-
@generator.name = "Test::Monkey::ProjectPictures"
|
203
|
-
@generator.base_name.should == "project_pictures"
|
204
|
-
end
|
205
|
-
|
206
|
-
it "should split off the last slash separated chunk and snakify it" do
|
207
|
-
@generator.name = "test/monkey/project_pictures"
|
208
|
-
@generator.base_name.should == "project_pictures"
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "#symbol_name" do
|
213
|
-
it "should snakify the name and replace dashes with underscores" do
|
214
|
-
@generator.name = "project-pictures"
|
215
|
-
@generator.symbol_name.should == "project_pictures"
|
216
|
-
end
|
217
|
-
|
218
|
-
it "should split off the last slash separated chunk, snakify it and replace dashes with underscores" do
|
219
|
-
@generator.name = "test/monkey/project-pictures"
|
220
|
-
@generator.symbol_name.should == "project_pictures"
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
describe "#test_class_name" do
|
225
|
-
it "should camelize the name and append 'Test'" do
|
226
|
-
@generator.name = "project_pictures"
|
227
|
-
@generator.test_class_name.should == "ProjectPicturesTest"
|
228
|
-
end
|
229
|
-
|
230
|
-
it "should split off the last double colon separated chunk" do
|
231
|
-
@generator.name = "Test::Monkey::ProjectPictures"
|
232
|
-
@generator.test_class_name.should == "ProjectPicturesTest"
|
233
|
-
end
|
234
|
-
|
235
|
-
it "should split off the last slash separated chunk" do
|
236
|
-
@generator.name = "test/monkey/project_pictures"
|
237
|
-
@generator.test_class_name.should == "ProjectPicturesTest"
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe "#full_class_name" do
|
242
|
-
it "should camelize the name" do
|
243
|
-
@generator.name = "project_pictures"
|
244
|
-
@generator.full_class_name.should == "ProjectPictures"
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should camelize a name with dashes" do
|
248
|
-
@generator.name = "project-pictures"
|
249
|
-
@generator.full_class_name.should == "ProjectPictures"
|
250
|
-
end
|
251
|
-
|
252
|
-
it "should leave double colon separated chunks" do
|
253
|
-
@generator.name = "Test::Monkey::ProjectPictures"
|
254
|
-
@generator.full_class_name.should == "Test::Monkey::ProjectPictures"
|
255
|
-
end
|
256
|
-
|
257
|
-
it "should convert slashes to double colons and camel case" do
|
258
|
-
@generator.name = "test/monkey/project_pictures"
|
259
|
-
@generator.full_class_name.should == "Test::Monkey::ProjectPictures"
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe "#base_path" do
|
264
|
-
it "should be blank for no namespaces" do
|
265
|
-
@generator.name = "project_pictures"
|
266
|
-
@generator.base_path.should == ""
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should snakify and join namespace for double colon separated chunk" do
|
270
|
-
@generator.name = "Test::Monkey::ProjectPictures"
|
271
|
-
@generator.base_path.should == "test/monkey"
|
272
|
-
end
|
273
|
-
|
274
|
-
it "should leave slashes but only use the namespace part" do
|
275
|
-
@generator.name = "test/monkey/project_pictures"
|
276
|
-
@generator.base_path.should == "test/monkey"
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
end
|
data/spec/session_store_spec.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
|
3
|
-
require 'merb/session/data_mapper_session'
|
4
|
-
describe Merb::DataMapperSessionStore do
|
5
|
-
before(:all) do
|
6
|
-
DataMapper.setup(:default, "sqlite3::memory:")
|
7
|
-
end
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
Merb::Plugins.config[:merb_datamapper] = {}
|
11
|
-
@session_container = Merb::DataMapperSessionStore
|
12
|
-
@session_container.auto_migrate!
|
13
|
-
@sess_id = 'a'*32
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
describe "#retrieve_session" do
|
18
|
-
it "responds to retrieve_session" do
|
19
|
-
@session_container.should respond_to(:retrieve_session)
|
20
|
-
end
|
21
|
-
it "returns the data when given an existing session id" do
|
22
|
-
@session_container.create(:session_id => @sess_id, :data => {:foo => 'bar'})
|
23
|
-
session_data = @session_container.retrieve_session(@sess_id)
|
24
|
-
session_data.should_not be_nil
|
25
|
-
session_data[:foo].should == 'bar'
|
26
|
-
end
|
27
|
-
it "returns nil when a non-existent session_id is used" do
|
28
|
-
@session_container.retrieve_session(@sess_id).should be_nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
describe "#store_session" do
|
34
|
-
it "responds to store_session" do
|
35
|
-
@session_container.should respond_to(:store_session)
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "when a session_id doesn't exist" do
|
39
|
-
it "creates a new record" do
|
40
|
-
@session_container.all.should be_empty
|
41
|
-
@session_container.store_session(@sess_id, {:foo => 'bar'})
|
42
|
-
@session_container.all.should_not be_empty
|
43
|
-
end
|
44
|
-
|
45
|
-
it "saves the data" do
|
46
|
-
@session_container.store_session(@sess_id, {:foo => 'bar'})
|
47
|
-
session_data = @session_container.retrieve_session(@sess_id)
|
48
|
-
session_data.should_not be_nil
|
49
|
-
session_data[:foo].should == 'bar'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "when a session_id does exist" do
|
54
|
-
before(:each) do
|
55
|
-
@session_container.store_session(@sess_id, {:foo => 'bar'})
|
56
|
-
end
|
57
|
-
|
58
|
-
it "doesn't create a new session" do
|
59
|
-
@session_container.all.size.should == 1
|
60
|
-
@session_container.store_session(@sess_id, {:foo => 'FOOOO'})
|
61
|
-
@session_container.all.size.should == 1
|
62
|
-
end
|
63
|
-
|
64
|
-
it "saves the data" do
|
65
|
-
@session_container.store_session(@sess_id, {:foo => 'FOOOO'})
|
66
|
-
session_data = @session_container.retrieve_session(@sess_id)
|
67
|
-
session_data.should_not be_nil
|
68
|
-
session_data[:foo].should == 'FOOOO'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
describe "#delete_session" do
|
75
|
-
before(:each) do
|
76
|
-
@session_container.store_session(@sess_id, {:foo => 'bar'})
|
77
|
-
end
|
78
|
-
|
79
|
-
it "responds to #delete_session" do
|
80
|
-
@session_container.should respond_to(:delete_session)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "destroys an existing session" do
|
84
|
-
@session_container.all.size.should == 1
|
85
|
-
@session_container.delete_session(@sess_id)
|
86
|
-
@session_container.all.size.should == 0
|
87
|
-
end
|
88
|
-
|
89
|
-
it "doesn't destroy a session when the key doesn't match" do
|
90
|
-
@session_container.all.size.should == 1
|
91
|
-
@session_container.delete_session('b'*32)
|
92
|
-
@session_container.all.size.should == 1
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
describe "configuration options" do
|
97
|
-
before(:each) do
|
98
|
-
@session_container = Merb::DataMapperSessionStore
|
99
|
-
end
|
100
|
-
after(:each) do
|
101
|
-
Merb::Plugins.config[:merb_datamapper].clear
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "repository" do
|
105
|
-
it "uses the :default repository when no options are set" do
|
106
|
-
@session_container.default_repository_name.should == :default
|
107
|
-
end
|
108
|
-
it "uses the set name when provided" do
|
109
|
-
Merb::Plugins.config[:merb_datamapper][:session_repository_name] = :other
|
110
|
-
@session_container.default_repository_name.should == :other
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
describe "table name" do
|
116
|
-
it "uses the 'sessions' when no options are set" do
|
117
|
-
@session_container.storage_names[:default].should == 'sessions'
|
118
|
-
end
|
119
|
-
it "uses the set table name when it is set" do
|
120
|
-
pending "this should work but doesn't"
|
121
|
-
Merb::Plugins.config[:merb_datamapper][:session_storage_name] = 'foos'
|
122
|
-
@session_container.storage_names[:default].should == 'foos'
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
data/spec/spec.opts
DELETED