merb_datamapper 0.5 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/LICENSE +1 -1
  2. data/Rakefile +10 -5
  3. data/datamapper_generators/migration/migration_generator.rb +1 -1
  4. data/datamapper_generators/model/model_generator.rb +33 -12
  5. data/datamapper_generators/model/templates/app/models/%model_file_name%.rb +5 -0
  6. data/datamapper_generators/resource_controller/resource_controller_generator.rb +65 -19
  7. data/datamapper_generators/resource_controller/templates/app/controllers/%controller_file_name%.rb +68 -0
  8. data/datamapper_generators/resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +16 -0
  9. data/datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/edit.html.erb +3 -0
  10. data/datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/index.html.erb +3 -0
  11. data/datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/new.html.erb +3 -0
  12. data/datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/show.html.erb +3 -0
  13. data/lib/merb/orms/data_mapper/base.rb +6 -0
  14. data/lib/merb/orms/data_mapper/connection.rb +15 -9
  15. data/lib/merb/orms/data_mapper/{database.sample.yml → database.yml.sample} +0 -0
  16. data/lib/merb/session/data_mapper_session.rb +10 -7
  17. data/lib/merb_datamapper.rb +13 -8
  18. data/lib/{merb/orms/data_mapper/tasks/databases.rb → merb_datamapper/merbtasks.rb} +10 -4
  19. metadata +83 -69
  20. data/datamapper_generators/model/templates/new_model_template.erb +0 -6
  21. data/datamapper_generators/resource_controller/templates/controller.rb +0 -58
  22. data/datamapper_generators/resource_controller/templates/edit.html.erb +0 -1
  23. data/datamapper_generators/resource_controller/templates/helper.rb +0 -5
  24. data/datamapper_generators/resource_controller/templates/index.html.erb +0 -1
  25. data/datamapper_generators/resource_controller/templates/new.html.erb +0 -1
  26. data/datamapper_generators/resource_controller/templates/show.html.erb +0 -1
  27. data/lib/merbtasks.rb +0 -0
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007 YOUR NAME
1
+ Copyright (c) 2007 Jason Toy
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
3
3
 
4
4
  PLUGIN = "merb_datamapper"
5
5
  NAME = "merb_datamapper"
6
- VERSION = "0.5"
6
+ VERSION = "0.9.2"
7
7
  AUTHOR = "Jason Toy"
8
8
  EMAIL = "jtoy@rubynow.com"
9
9
  HOMEPAGE = "http://merbivore.com"
@@ -20,22 +20,27 @@ spec = Gem::Specification.new do |s|
20
20
  s.author = AUTHOR
21
21
  s.email = EMAIL
22
22
  s.homepage = HOMEPAGE
23
- s.add_dependency('merb', '>= 0.5')
23
+ s.add_dependency('merb-core', '>= 0.9.2')
24
24
  s.add_dependency('datamapper', '>= 0.2.3')
25
25
  s.require_path = 'lib'
26
26
  s.autorequire = PLUGIN
27
27
  s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs,datamapper_generators}/**/*")
28
28
  end
29
29
 
30
+ windows = (PLATFORM =~ /win32|cygwin/) rescue nil
31
+
32
+ SUDO = windows ? "" : "sudo"
33
+
30
34
  Rake::GemPackageTask.new(spec) do |pkg|
31
35
  pkg.gem_spec = spec
32
36
  end
33
37
 
34
- task :install do
35
- sh %{rake package}
36
- sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
38
+ desc "Install merb_datamapper"
39
+ task :install => :package do
40
+ sh %{#{SUDO} gem install pkg/#{NAME}-#{VERSION} --no-rdoc --no-ri --no-update-sources}
37
41
  end
38
42
 
43
+ desc 'Release the current version on rubyforge'
39
44
  task :release => :package do
40
45
  sh %{rubyforge add_release merb #{PLUGIN} #{VERSION} pkg/#{NAME}-#{VERSION}.gem}
41
46
  end
@@ -1,4 +1,4 @@
1
- require 'merb'
1
+ # require 'merb'
2
2
  class MigrationGenerator < RubiGen::Base
3
3
 
4
4
  default_options :author => nil
@@ -1,17 +1,38 @@
1
- require 'merb/generators/merb_generator_helpers'
2
-
3
- class ModelGenerator < Merb::GeneratorHelpers::ModelGeneratorBase
1
+ class ModelGenerator < Merb::GeneratorBase
2
+ attr_reader :model_attributes, :model_class_name, :model_file_name
4
3
 
5
- def initialize( *args )
6
- super( *args )
7
- options[:skip_migration] = true
8
- @model_template_name = "new_model_template.erb"
9
- # @migration_generator_name = "dm_migration"
10
- @model_test_generator_name = "merb_model_test"
4
+ def initialize(args, runtime_args = {})
5
+ @base = File.dirname(__FILE__)
6
+ super
7
+ @model_file_name = args.shift.snake_case
8
+ @model_class_name = @model_file_name.to_const_string
9
+ @model_attributes = Hash[*(args.map{|a| a.split(":") }.flatten)]
10
+ @model_file_name = "#{@model_class_name.snake_case}"
11
+
11
12
  end
12
13
 
13
- def self.superclass
14
- RubiGen::Base
15
- end
14
+ def manifest
15
+ record do |m|
16
+ @m = m
16
17
 
18
+ @assigns = { :model_file_name => model_file_name,
19
+ :model_attributes => model_attributes,
20
+ :model_class_name => model_class_name
21
+ }
22
+ copy_dirs
23
+ copy_files
24
+
25
+ m.dependency "merb_model_test", [model_file_name], @assigns
26
+ end
27
+ end
28
+
29
+ protected
30
+ def banner
31
+ <<-EOS.split("\n").map{|x| x.strip}.join("\n")
32
+ Creates a Datamapper Model stub..
33
+
34
+ USAGE: #{spec.name}"
35
+ EOS
36
+ end
37
+
17
38
  end
@@ -0,0 +1,5 @@
1
+ class <%= model_class_name %> < DataMapper::Base
2
+ <% model_attributes.each do |attr| -%>
3
+ <%= "property :#{attr.first}, :#{attr.last}" %>
4
+ <% end -%>
5
+ end
@@ -1,28 +1,74 @@
1
- require 'merb/generators/merb_generator_helpers'
2
-
3
- class ResourceControllerGenerator < Merb::GeneratorHelpers::ControllerGeneratorBase
4
-
1
+ class ResourceControllerGenerator < Merb::GeneratorBase
2
+
3
+ attr_reader :controller_class_name,
4
+ :controller_file_name,
5
+ :controller_base_path,
6
+ :controller_modules,
7
+ :model_class_name,
8
+ :full_controller_const,
9
+ :singular_model,
10
+ :plural_model
11
+
12
+ def initialize(args, runtime_args = {})
13
+ @base = File.dirname(__FILE__)
14
+
15
+ super
16
+ name = args.shift
17
+ nfp = name.snake_case.gsub("::", "/")
18
+ nfp = nfp.split("/")
19
+ @model_class_name = nfp.pop.singularize.to_const_string
20
+ @model_class_name = runtime_args[:model_class_name] if runtime_args[:model_class_name]
21
+ @singular_model = @model_class_name.snake_case
22
+ @plural_model = @singular_model.pluralize
23
+
24
+ nfp << @plural_model
25
+
26
+ @controller_file_name = nfp.join("/")
27
+
28
+ # Need to setup the directories
29
+ unless @controller_file_name == File.basename(@controller_file_name)
30
+ @controller_base_path = controller_file_name.split("/")[0..-2].join("/")
31
+ end
32
+
33
+ @controller_modules = @controller_file_name.to_const_string.split("::")[0..-2]
34
+ @controller_class_name = @controller_file_name.to_const_string.split("::").last
5
35
 
6
- def initialize(*args)
7
- puts args.inspect
8
- runtime_options = args.last.is_a?(Hash) ? args.pop : {}
9
- name, *actions = args.flatten
10
- runtime_options[:actions] = %w[index show new edit]
11
- runtime_options[:test_stub_generator] = "merb_controller_test"
12
- super( [name], runtime_options )
36
+ @full_controller_const = ((@controller_modules.dup || []) << @controller_class_name).join("::")
13
37
  end
14
-
15
- def self.superclass
16
- RubiGen::Base
38
+
39
+ def manifest
40
+ record do |m|
41
+ @m = m
42
+
43
+ # Create the controller directory
44
+ m.directory File.join("app/controllers", controller_base_path) if controller_base_path
45
+
46
+ # Create the helpers directory
47
+ m.directory File.join("app/helpers", controller_base_path) if controller_base_path
48
+
49
+ @assigns = {
50
+ :controller_modules => controller_modules,
51
+ :controller_class_name => controller_class_name,
52
+ :controller_file_name => controller_file_name,
53
+ :controller_base_path => controller_base_path,
54
+ :full_controller_const => full_controller_const,
55
+ :model_class_name => model_class_name,
56
+ :singular_model => singular_model,
57
+ :plural_model => plural_model
58
+ }
59
+ copy_dirs
60
+ copy_files
61
+
62
+ m.dependency "merb_resource_controller_test", [@controller_class_name], @assigns
63
+ end
17
64
  end
18
65
 
19
66
  protected
20
67
  def banner
21
- <<-EOS
22
- Creates a Merb controller, views and specs using Datamapper Models
68
+ <<-EOS.split("\n").map{|x| x.strip}.join("\n")
69
+ Creates a basic Merb resource controller.
23
70
 
24
- USAGE: #{$0} #{spec.name} resource_name"
25
- EOS
71
+ USAGE: #{spec.name} my_resource
72
+ EOS
26
73
  end
27
-
28
74
  end
@@ -0,0 +1,68 @@
1
+ <% counter = 0 -%>
2
+ <% controller_modules.each_with_index do |mod, i| -%>
3
+ <%= " " * i %>module <%= mod %>
4
+ <% counter = i -%>
5
+ <% end -%>
6
+ <% counter = counter == 0 ? 0 : (counter + 1) -%>
7
+ <%= " " * counter %>class <%= controller_class_name %> < Application
8
+ <%= " " * counter %> # provides :xml, :yaml, :js
9
+
10
+ <%= " " * counter %> def index
11
+ <%= " " * counter %> @<%= plural_model %> = <%= model_class_name %>.all
12
+ <%= " " * counter %> display @<%= plural_model %>
13
+ <%= " " * counter %> end
14
+
15
+ <%= " " * counter %> def show
16
+ <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.first(params[:id])
17
+ <%= " " * counter %> raise NotFound unless @<%= singular_model %>
18
+ <%= " " * counter %> display @<%= singular_model %>
19
+ <%= " " * counter %> end
20
+
21
+ <%= " " * counter %> def new
22
+ <%= " " * counter %> only_provides :html
23
+ <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.new
24
+ <%= " " * counter %> render
25
+ <%= " " * counter %> end
26
+
27
+ <%= " " * counter %> def edit
28
+ <%= " " * counter %> only_provides :html
29
+ <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.first(params[:id])
30
+ <%= " " * counter %> raise NotFound unless @<%= singular_model %>
31
+ <%= " " * counter %> render
32
+ <%= " " * counter %> end
33
+
34
+ <%= " " * counter %> def create
35
+ <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
36
+ <%= " " * counter %> if @<%= singular_model %>.save
37
+ <%= " " * counter %> redirect url(:<%= (controller_modules.collect{|m| m.downcase} << singular_model).join("_") %>, @<%= singular_model %>)
38
+ <%= " " * counter %> else
39
+ <%= " " * counter %> render :new
40
+ <%= " " * counter %> end
41
+ <%= " " * counter %> end
42
+
43
+ <%= " " * counter %> def update
44
+ <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.first(params[:id])
45
+ <%= " " * counter %> raise NotFound unless @<%= singular_model %>
46
+ <%= " " * counter %> if @<%= singular_model %>.update_attributes(params[:<%= singular_model %>])
47
+ <%= " " * counter %> redirect url(:<%= (controller_modules.collect{|m| m.downcase} << singular_model).join("_") %>, @<%= singular_model %>)
48
+ <%= " " * counter %> else
49
+ <%= " " * counter %> raise BadRequest
50
+ <%= " " * counter %> end
51
+ <%= " " * counter %> end
52
+
53
+ <%= " " * counter %> def destroy
54
+ <%= " " * counter %> @<%= singular_model %> = <%= model_class_name %>.first(params[:id])
55
+ <%= " " * counter %> raise NotFound unless @<%= singular_model %>
56
+ <%= " " * counter %> if @<%= singular_model %>.destroy!
57
+ <%= " " * counter %> redirect url(:<%= (controller_modules.collect{|m| m.downcase} << singular_model).join("_") %>)
58
+ <%= " " * counter %> else
59
+ <%= " " * counter %> raise BadRequest
60
+ <%= " " * counter %> end
61
+ <%= " " * counter %> end
62
+
63
+ <%= " " * counter %>end
64
+ <% counter = counter == 0 ? 0 : (counter - 1) -%>
65
+ <% controller_modules.reverse.each_with_index do |mod, i| -%>
66
+ <%= " " * counter %>end # <%= mod %>
67
+ <% counter = counter - 1 -%>
68
+ <% end -%>
@@ -0,0 +1,16 @@
1
+ <% counter = 1 -%>
2
+ module Merb
3
+ <% controller_modules.each_with_index do |mod, i| -%>
4
+ <%= " " * i %>module <%= mod %>
5
+ <% counter = i -%>
6
+ <% end -%>
7
+ <% counter = counter == 0 ? 0 : (counter + 1) -%>
8
+ <%= " " * counter %>module <%= controller_class_name %>Helper
9
+
10
+ <%= " " * counter %>end
11
+ <% counter = counter == 0 ? 0 : (counter - 1) -%>
12
+ <% controller_modules.reverse.each_with_index do |mod, i| -%>
13
+ <%= " " * counter %>end # <%= mod %>
14
+ <% counter = counter - 1 -%>
15
+ <% end -%>
16
+ end
@@ -0,0 +1,3 @@
1
+ <h1><%= full_controller_const %> controller, edit action</h1>
2
+
3
+ <p>Edit this file in <tt>app/views/<%= controller_file_name %>/edit.html.erb</tt></p>
@@ -0,0 +1,3 @@
1
+ <h1><%= full_controller_const %> controller, index action</h1>
2
+
3
+ <p>Edit this file in <tt>app/views/<%= controller_file_name %>/index.html.erb</tt></p>
@@ -0,0 +1,3 @@
1
+ <h1><%= full_controller_const %> controller, new action</h1>
2
+
3
+ <p>Edit this file in <tt>app/views/<%= controller_file_name %>/new.html.erb</tt></p>
@@ -0,0 +1,3 @@
1
+ <h1><%= full_controller_const %> controller, show action</h1>
2
+
3
+ <p>Edit this file in <tt>app/views/<%= controller_file_name %>/show.html.erb</tt></p>
@@ -0,0 +1,6 @@
1
+ module Merb::Orms::DataMapper::Base
2
+ def to_param
3
+ key
4
+ end
5
+ end
6
+ DataMapper::Base.send(:include, Merb::Orms::DataMapper::Base)
@@ -6,8 +6,8 @@ module Merb
6
6
  module DataMapper
7
7
  class << self
8
8
  def config_file() Merb.root / "config" / "database.yml" end
9
- def sample_dest() Merb.root / "config" / "database.sample.yml" end
10
- def sample_source() File.dirname(__FILE__) / "database.sample.yml" end
9
+ def sample_dest() Merb.root / "config" / "database.yml.sample" end
10
+ def sample_source() File.dirname(__FILE__) / "database.yml.sample" end
11
11
 
12
12
  def copy_sample_config
13
13
  FileUtils.cp sample_source, sample_dest unless File.exists?(sample_dest)
@@ -19,7 +19,13 @@ module Merb
19
19
  # Convert string keys to symbols
20
20
  full_config = Erubis.load_yaml_file(config_file)
21
21
  config = (Merb::Plugins.config[:merb_datamapper] = {})
22
- (full_config[Merb.environment.to_sym] || full_config[Merb.environment]).each { |k, v| config[k.to_sym] = v }
22
+ (full_config[Merb.environment.to_sym] || full_config[Merb.environment]).each do |k, v|
23
+ if k == 'port'
24
+ config[k.to_sym] = v.to_i
25
+ else
26
+ config[k.to_sym] = v
27
+ end
28
+ end
23
29
  config
24
30
  end
25
31
  end
@@ -27,12 +33,12 @@ module Merb
27
33
  # Database connects as soon as the gem is loaded
28
34
  def connect
29
35
  if File.exists?(config_file)
30
- puts "Connecting to database..."
36
+ Merb.logger.info!("Connecting to database...")
31
37
  ::DataMapper::Database.setup(config)
32
38
  else
33
39
  copy_sample_config
34
- puts "No database.yml file found in #{Merb.root}/config."
35
- puts "A sample file was created called database.sample.yml for you to copy and edit."
40
+ Merb.logger.error! "No database.yml file found in #{Merb.root}/config."
41
+ Merb.logger.error! "A sample file was created called database.sample.yml for you to copy and edit."
36
42
  exit(1)
37
43
  end
38
44
  end
@@ -40,9 +46,9 @@ module Merb
40
46
  # Registering this ORM lets the user choose DataMapper as a session store
41
47
  # in merb.yml's session_store: option.
42
48
  def register_session_type
43
- Merb::BootLoader.register_session_type("datamapper",
44
- "merb/session/data_mapper_session",
45
- "Using DataMapper database sessions")
49
+ Merb.register_session_type("datamapper",
50
+ "merb/session/data_mapper_session",
51
+ "Using DataMapper database sessions")
46
52
  end
47
53
  end
48
54
  end
@@ -3,17 +3,19 @@ require 'base64'
3
3
  module Merb
4
4
  module SessionMixin
5
5
  def setup_session
6
- Merb.logger.info("Setting up session")
7
- before = cookies[_session_id_key]
6
+ before_value = cookies[_session_id_key]
8
7
  request.session, cookies[_session_id_key] = Merb::DataMapperSession.persist(cookies[_session_id_key])
9
8
  @_fingerprint = Marshal.dump(request.session.data).hash
10
- @_new_cookie = cookies[_session_id_key] != before
9
+ @_new_cookie = cookies[_session_id_key] != before_value
11
10
  end
12
-
11
+
13
12
  def finalize_session
14
- Merb.logger.info("Finalize session")
15
13
  request.session.save if @_fingerprint != Marshal.dump(request.session.data).hash
16
- set_cookie(_session_id_key, request.session.session_id, _session_expiry) if (@_new_cookie || request.session.needs_new_cookie)
14
+ set_cookie(_session_id_key, request.session.session_id, Time.now + _session_expiry) if (@_new_cookie || request.session.needs_new_cookie)
15
+ end
16
+
17
+ def session_store_type
18
+ "datamapper"
17
19
  end
18
20
  end
19
21
 
@@ -22,8 +24,9 @@ module Merb
22
24
  class DataMapperSession < DataMapper::Base
23
25
 
24
26
  set_table_name "sessions"
25
- property :session_id, :text, :lazy => false, :key => true
27
+ property :session_id, :string, :length => 255, :lazy => false, :key => true
26
28
  property :data, :text, :lazy => false
29
+ property :updated_at, :datetime
27
30
 
28
31
  attr_accessor :needs_new_cookie
29
32
 
@@ -1,11 +1,16 @@
1
- # make sure we're running inside Merb
2
1
  if defined?(Merb::Plugins)
3
- if Merb::BootLoader.app_loaded?
4
- puts "Warning: The merb_datamapper gem must be loaded before the application"
5
- else
6
- require "merb/orms/data_mapper/connection"
7
- Merb::Orms::DataMapper.connect
8
- Merb::Orms::DataMapper.register_session_type
2
+ require File.join(File.dirname(__FILE__) / "merb" / "orms" / "data_mapper" / "connection")
3
+ require File.join(File.dirname(__FILE__) / "merb" / "orms" / "data_mapper" / "base")
4
+ Merb::Plugins.add_rakefiles "merb_datamapper" / "merbtasks"
5
+
6
+ class Merb::Orms::DataMapper::Connect < Merb::BootLoader
7
+
8
+ after BeforeAppRuns
9
+
10
+ def self.run
11
+ Merb::Orms::DataMapper.connect
12
+ Merb::Orms::DataMapper.register_session_type
13
+ end
14
+
9
15
  end
10
- Merb::Plugins.add_rakefiles "merb/orms/data_mapper/tasks/databases"
11
16
  end
@@ -1,24 +1,30 @@
1
1
  require 'fileutils'
2
2
 
3
3
  namespace :dm do
4
+
5
+ task :merb_start do
6
+ Merb.start :adapter => 'runner',
7
+ :environment => ENV['MERB_ENV'] || 'development'
8
+ end
9
+
4
10
  namespace :db do
5
11
  desc "Perform automigration"
6
- task :automigrate => :merb_env do
12
+ task :automigrate => :merb_start do
7
13
  DataMapper::Persistence.auto_migrate!
8
14
  end
9
15
  end
10
16
 
11
17
  namespace :sessions do
12
18
  desc "Creates session migration"
13
- task :create => :merb_env do
19
+ task :create => :merb_start do
14
20
  dest = File.join(Merb.root, "schema", "migrations","001_add_sessions_table.rb")
15
21
  source = File.join(File.dirname(__FILE__), "merb", "session","001_add_sessions_table.rb")
16
22
  #FileUtils.cp source, dest unless File.exists?(dest)
17
23
  end
18
24
 
19
25
  desc "Clears sessions"
20
- task :clear => :merb_env do
21
- table_name = (Merb::Plugins.config[:datamapper][:session_table_name] || "sessions")
26
+ task :clear => :merb_start do
27
+ table_name = ((Merb::Plugins.config[:datamapper] || {})[:session_table_name] || "sessions")
22
28
  #Merb::Orms::DataMapper.connect.execute("DELETE FROM #{table_name}")
23
29
  end
24
30
  end
metadata CHANGED
@@ -1,101 +1,115 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: merb_datamapper
5
3
  version: !ruby/object:Gem::Version
6
- version: "0.5"
7
- date: 2008-01-09 00:00:00 -08:00
8
- summary: Merb plugin that provides DataMapper support for Merb
9
- require_paths:
10
- - lib
11
- email: jtoy@rubynow.com
12
- homepage: http://merbivore.com
13
- rubyforge_project:
14
- description: Merb plugin that provides DataMapper support for Merb
15
- autorequire: merb_datamapper
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.9.2
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Jason Toy
8
+ autorequire: merb_datamapper
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-03-24 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: merb-core
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.2
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: datamapper
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 0.2.3
32
+ version:
33
+ description: Merb plugin that provides DataMapper support for Merb
34
+ email: jtoy@rubynow.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - README
41
+ - LICENSE
42
+ - TODO
31
43
  files:
32
44
  - LICENSE
33
45
  - README
34
46
  - Rakefile
35
47
  - TODO
36
48
  - lib/merb
37
- - lib/merb_datamapper.rb
38
- - lib/merbtasks.rb
39
49
  - lib/merb/orms
40
- - lib/merb/session
41
50
  - lib/merb/orms/data_mapper
51
+ - lib/merb/orms/data_mapper/base.rb
42
52
  - lib/merb/orms/data_mapper/connection.rb
43
- - lib/merb/orms/data_mapper/database.sample.yml
44
- - lib/merb/orms/data_mapper/tasks
45
- - lib/merb/orms/data_mapper/tasks/databases.rb
53
+ - lib/merb/orms/data_mapper/database.yml.sample
54
+ - lib/merb/session
46
55
  - lib/merb/session/data_mapper_session.rb
56
+ - lib/merb_datamapper
57
+ - lib/merb_datamapper/merbtasks.rb
58
+ - lib/merb_datamapper.rb
47
59
  - specs/merb_sequel_spec.rb
48
60
  - specs/spec_helper.rb
49
61
  - datamapper_generators/migration
50
- - datamapper_generators/model
51
- - datamapper_generators/resource_controller
52
62
  - datamapper_generators/migration/migration_generator.rb
53
63
  - datamapper_generators/migration/templates
54
- - datamapper_generators/migration/USAGE
55
64
  - datamapper_generators/migration/templates/new_migration.erb
65
+ - datamapper_generators/migration/USAGE
66
+ - datamapper_generators/model
56
67
  - datamapper_generators/model/model_generator.rb
57
68
  - datamapper_generators/model/templates
69
+ - datamapper_generators/model/templates/app
70
+ - datamapper_generators/model/templates/app/models
71
+ - datamapper_generators/model/templates/app/models/%model_file_name%.rb
58
72
  - datamapper_generators/model/USAGE
59
- - datamapper_generators/model/templates/new_model_template.erb
73
+ - datamapper_generators/resource_controller
60
74
  - datamapper_generators/resource_controller/resource_controller_generator.rb
61
75
  - datamapper_generators/resource_controller/templates
76
+ - datamapper_generators/resource_controller/templates/app
77
+ - datamapper_generators/resource_controller/templates/app/controllers
78
+ - datamapper_generators/resource_controller/templates/app/controllers/%controller_file_name%.rb
79
+ - datamapper_generators/resource_controller/templates/app/helpers
80
+ - datamapper_generators/resource_controller/templates/app/helpers/%controller_file_name%_helper.rb
81
+ - datamapper_generators/resource_controller/templates/app/views
82
+ - datamapper_generators/resource_controller/templates/app/views/%controller_file_name%
83
+ - datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/edit.html.erb
84
+ - datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/index.html.erb
85
+ - datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/new.html.erb
86
+ - datamapper_generators/resource_controller/templates/app/views/%controller_file_name%/show.html.erb
62
87
  - datamapper_generators/resource_controller/USAGE
63
- - datamapper_generators/resource_controller/templates/controller.rb
64
- - datamapper_generators/resource_controller/templates/edit.html.erb
65
- - datamapper_generators/resource_controller/templates/helper.rb
66
- - datamapper_generators/resource_controller/templates/index.html.erb
67
- - datamapper_generators/resource_controller/templates/new.html.erb
68
- - datamapper_generators/resource_controller/templates/show.html.erb
69
- test_files: []
70
-
88
+ has_rdoc: true
89
+ homepage: http://merbivore.com
90
+ post_install_message:
71
91
  rdoc_options: []
72
92
 
73
- extra_rdoc_files:
74
- - README
75
- - LICENSE
76
- - TODO
77
- executables: []
78
-
79
- extensions: []
80
-
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ version:
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ version:
81
107
  requirements: []
82
108
 
83
- dependencies:
84
- - !ruby/object:Gem::Dependency
85
- name: merb
86
- version_requirement:
87
- version_requirements: !ruby/object:Gem::Version::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: "0.5"
92
- version:
93
- - !ruby/object:Gem::Dependency
94
- name: datamapper
95
- version_requirement:
96
- version_requirements: !ruby/object:Gem::Version::Requirement
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: 0.2.3
101
- version:
109
+ rubyforge_project:
110
+ rubygems_version: 1.0.1
111
+ signing_key:
112
+ specification_version: 2
113
+ summary: Merb plugin that provides DataMapper support for Merb
114
+ test_files: []
115
+
@@ -1,6 +0,0 @@
1
- class <%= class_name %> < DataMapper::Base
2
- <% table_attributes.each do |attr| -%>
3
- <%= "property :#{attr.name}, :#{attr.type}" %>
4
- <% end -%>
5
- end
6
-
@@ -1,58 +0,0 @@
1
- <% klass = class_name.singularize -%>
2
- <% ivar = class_name.snake_case.singularize -%>
3
- class <%= class_name %> < Application
4
- provides :xml, :js, :yaml
5
-
6
- def index
7
- @<%= ivar.pluralize %> = <%= klass %>.all
8
- render @<%= ivar.pluralize %>
9
- end
10
-
11
- def show(id)
12
- @<%= ivar %> = <%= klass %>[id]
13
- raise NotFound unless @<%= ivar %>
14
- render @<%= ivar %>
15
- end
16
-
17
- def new
18
- only_provides :html
19
- @<%= ivar %> = <%= klass %>.new
20
- render @<%= ivar %>
21
- end
22
-
23
- def create(<%= ivar %>)
24
- @<%= ivar %> = <%= klass %>.new(<%= ivar %>)
25
- if @<%= ivar %>.save
26
- redirect url(:<%= ivar %>, @<%= ivar %>)
27
- else
28
- render :action => :new
29
- end
30
- end
31
-
32
- def edit(id)
33
- only_provides :html
34
- @<%= ivar %> = <%= klass %>[id]
35
- raise NotFound unless @<%= ivar %>
36
- render
37
- end
38
-
39
- def update(id, <%= ivar %>)
40
- @<%= ivar %> = <%= klass %>[id]
41
- raise NotFound unless @<%= ivar %>
42
- if @<%= ivar %>.update_attributes(<%= ivar %>)
43
- redirect url(:<%= ivar %>, @<%= ivar %>)
44
- else
45
- raise BadRequest
46
- end
47
- end
48
-
49
- def destroy(id)
50
- @<%= ivar %> = <%= klass %>[id]
51
- raise NotFound unless @<%= ivar %>
52
- if @<%= ivar %>.destroy!
53
- redirect url(:<%= ivar.pluralize %>)
54
- else
55
- raise BadRequest
56
- end
57
- end
58
- end
@@ -1 +0,0 @@
1
- Edit for <%= class_name %>
@@ -1,5 +0,0 @@
1
- module Merb
2
- module <%= class_name.pluralize %>Helper
3
-
4
- end
5
- end
@@ -1 +0,0 @@
1
- Index for <%= class_name %>
@@ -1 +0,0 @@
1
- New for <%= class_name %>
@@ -1 +0,0 @@
1
- Show for <%= class_name %>
data/lib/merbtasks.rb DELETED
File without changes