Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 152 lines (94 sloc) 6.184 kb
76fcfe83 »
2009-03-21 first commit
1 = datamapper4rails
2
3 * http://datamapper4rail.rubyforge.org
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
4 * http://github.org/mkristian/datamapper4rails
76fcfe83 »
2009-03-21 first commit
5
6 == DESCRIPTION:
7
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
8 collection of datamapper related extensions. mostly needed to run within rails. the restful transactions is around filter for rails actions if needed to control such transaction on per action base otherwise use the rack extension from rack-datamapper. datamapper store is a session store for rails which uses datamapper as persistent layer and is just a wrapper around the datamapper session store from rack-datamapper. the generators produces datamapper models for your rails application.
76fcfe83 »
2009-03-21 first commit
9
10 == FEATURES/PROBLEMS:
11
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
12 * the generators introduce an "overlay" of templates. with that a generator can reuse the generator code and just replace one or more templates. i.e. datamapper_model just replaces the model.rb template to produce model using datamapper.
76fcfe83 »
2009-03-21 first commit
13
14 == SYNOPSIS:
15
16 === restful transaction
17
18 wraps all modifying requests (POST, PUT, DELETE) into a transaction. any error/exception as well render of a page will rollback the transaction. typically if a POST, PUT or DELETE succeeds then a redirect gets send back to browser.
19
20 credits of the main idea goes to http://www.redhillonrails.org
21
22 is implemented as around filter in rails and gets prepend to the filters of the action_controller of rails
23
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
24 require 'datamapper4rails/restful_transations'
25
26 === restful transactions, transactions or identity_maps from rack-datamapper
27
28 inside rails add something like this to your config
29
30 config.middleware.use 'DataMapper::IdentityMaps'
31 config.middleware.use 'DataMapper::RestfulTransactions'
32
33 or add the repository name to it if you want something else then :default
34
35 config.middleware.use 'DataMapper::IdentityMaps', :ldap
36 config.middleware.use 'DataMapper::RestfulTransactions', :users
37
76fcfe83 »
2009-03-21 first commit
38
39 === datamapper session store
40
7b7ff7b6 »
2009-08-19 corrected the session store config to follow the way it works for rai…
41 add in your config/initializers/session.rb
76fcfe83 »
2009-03-21 first commit
42
7b7ff7b6 »
2009-08-19 corrected the session store config to follow the way it works for rai…
43 ActionController::Base.session_store = :datamapper_store
76fcfe83 »
2009-03-21 first commit
44
7b7ff7b6 »
2009-08-19 corrected the session store config to follow the way it works for rai…
45 in case you need a memory cache for your sessions on top of it add the following. but be aware that there is no cleanup of the memory session.
76fcfe83 »
2009-03-21 first commit
46
7b7ff7b6 »
2009-08-19 corrected the session store config to follow the way it works for rai…
47 ActionController::Base.session = { :cache => true }
76fcfe83 »
2009-03-21 first commit
48
49 === generators for datamapper models
50
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
51 IMPORTANT: datamapper_scaffold generate valid application code but the test do NOT run due to missing fixtures with datamapper. the rspec version works well though.
76fcfe83 »
2009-03-21 first commit
52
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
53 * datamapper-install: rake task for datamapper with automigrate, autoupgrade and migrate
54 * datamapper_model
55 * datamapper_rspec_model
56 * datamapper_scaffold
57 * datamapper_rspec_scaffold
76fcfe83 »
2009-03-21 first commit
58
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
59 the last four generators follow the parameters of the underlying generator:
60 generator_name model_name [[attribute_name:attribute_type] ...]
76fcfe83 »
2009-03-21 first commit
61
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
62 to use the overlay write the generator like this
76fcfe83 »
2009-03-21 first commit
63
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
64 class MyModelGenerator < ModelGenerator
65 def manifest
66 overlay_dirs.add_generator("model")
67 super
68 end
69 end
76fcfe83 »
2009-03-21 first commit
70
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
71 and put whatever templates you want to overwrite in your templates directory, i.e. all your models need to have nice to_s methods.
76fcfe83 »
2009-03-21 first commit
72
a22c40e9 »
2009-10-08 new version
73 === patch for the rspec-rails gem
74
75 add a file like spec/support/datamapper with
76
77 require 'datamapper4rails/rspec'
78
79 this allows rspec to stub_model with datamapper
80
76fcfe83 »
2009-03-21 first commit
81 === restful adapter
82
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
83 DEPRECATED
76fcfe83 »
2009-03-21 first commit
84 this comes partly from dm-ldap-adapter and partly from dm-more/adapter/rest_adapter. the restful adapter allows to Create, Retrieve, Update and Delete resources via a restful service.
85
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
86 == rails template
87
88 there is a rails template 'datamapper_rails_templates.rb' in root of the gem - do not know where and how to pack it. the latest I keep on 'github.org/jeremy/rails-templates'
89
90 === to test the template there is helper class
91
92 task :integration_tests => [:install] do
93 require 'datamapper4rails/integration_test'
94 Datamapper4Rails::IntegrationTest.new do |t|
95 t.rails_template = 'my_template.rb'
96 t.directory = 'tmp' # defaults to tmp and is also the generated application name
97 t.generate "datamapper_model role name:string"
98 t.generate "datamapper_scaffold domain name:string"
99 t.generate "datamapper_rspec_model user name:string"
100 t.generate "datamapper_rspec_scaffold group name:string"
101 end
102 end
103
104 == more examples
105
106 just run 'rake integration' and have a look at the sample rails application in 'tmp'
107
108 == jruby
109
110 at the time of writing there is a bug/restriction in rails which prevents unpacked gems with java extension or version number postfixed with '-java' to work.
111
112 if you are familiar with maven (maven.apache.org) you can use the maven plugin from github.org/mkristian/rails-maven-plugin to freeze rails gems and patch it in place
113
114 mvn de.saumya.mojo:rails-maven-plugin:rails-freeze-gems
115
116 the 'rake integration_tests' does not work due to the fact that generating rails with a template falls back to native ruby for certain tasks which will fail due to missing (java) gems.
117
118 same is true for using the rails template. in case you want to use a rails template directly with jruby consider the rails-maven-plugin which can setup a mavenized rails application with the help of rails templates.
119
76fcfe83 »
2009-03-21 first commit
120 == REQUIREMENTS:
121
475691f6 »
2009-10-07 jruby fixes, add dm-serializer to template, deprecated warning, ...
122 * rails_datamapper, rack-datamapper
76fcfe83 »
2009-03-21 first commit
123
124 == INSTALL:
125
126 * sudo gem install datamapper4rails
127
128 == LICENSE:
129
130 (The MIT License)
131
132 Copyright (c) 2009 Kristian Meier
133
134 Permission is hereby granted, free of charge, to any person obtaining
135 a copy of this software and associated documentation files (the
136 'Software'), to deal in the Software without restriction, including
137 without limitation the rights to use, copy, modify, merge, publish,
138 distribute, sublicense, and/or sell copies of the Software, and to
139 permit persons to whom the Software is furnished to do so, subject to
140 the following conditions:
141
142 The above copyright notice and this permission notice shall be
143 included in all copies or substantial portions of the Software.
144
145 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
146 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
147 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
148 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
149 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
150 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
151 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.