rails_datamapper 0.9.11 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +7 -0
- data/Manifest.txt +3 -7
- data/{README.txt → README.rdoc} +14 -4
- data/Rakefile +8 -18
- data/datamapper.rake +50 -6
- data/generators/dm_install/dm_install_generator.rb +2 -2
- data/generators/dm_install/templates/datamapper.rake +8 -8
- data/generators/dm_migration/dm_migration_generator.rb +2 -1
- data/generators/dm_migration/templates/migration.rb +11 -1
- data/generators/dm_model/dm_model_generator.rb +5 -4
- data/generators/dm_model/templates/model.rb +4 -5
- data/generators/rspec_dm_model/rspec_dm_model_generator.rb +4 -6
- data/generators/rspec_dm_model/templates/model_spec.rb +2 -3
- data/lib/rails_datamapper/session_store.rb +63 -0
- data/lib/rails_datamapper/version.rb +3 -3
- data/lib/rails_datamapper.rb +57 -11
- data/tasks/install.rb +1 -1
- metadata +12 -85
- data/History.txt +0 -5
- data/generators/dm_model/templates/migration.rb +0 -16
- data/generators/rspec_dm_model/templates/model.rb +0 -14
- data/init.rb +0 -2
- data/lib/rails_datamapper/rails_datamapper.rb +0 -45
- data/lib/rails_datamapper/validations.rb +0 -9
data/History.rdoc
ADDED
data/Manifest.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
History.
|
1
|
+
History.rdoc
|
2
2
|
LICENSE
|
3
3
|
Manifest.txt
|
4
|
-
README.
|
4
|
+
README.rdoc
|
5
5
|
Rakefile
|
6
6
|
TODO
|
7
7
|
datamapper.rake
|
@@ -10,15 +10,11 @@ generators/dm_install/templates/datamapper.rake
|
|
10
10
|
generators/dm_migration/dm_migration_generator.rb
|
11
11
|
generators/dm_migration/templates/migration.rb
|
12
12
|
generators/dm_model/dm_model_generator.rb
|
13
|
-
generators/dm_model/templates/migration.rb
|
14
13
|
generators/dm_model/templates/model.rb
|
15
14
|
generators/dm_model/templates/unit_test.rb
|
16
15
|
generators/rspec_dm_model/rspec_dm_model_generator.rb
|
17
|
-
generators/rspec_dm_model/templates/model.rb
|
18
16
|
generators/rspec_dm_model/templates/model_spec.rb
|
19
|
-
init.rb
|
20
17
|
lib/rails_datamapper.rb
|
21
|
-
lib/rails_datamapper/
|
22
|
-
lib/rails_datamapper/validations.rb
|
18
|
+
lib/rails_datamapper/session_store.rb
|
23
19
|
lib/rails_datamapper/version.rb
|
24
20
|
tasks/install.rb
|
data/{README.txt → README.rdoc}
RENAMED
@@ -12,12 +12,13 @@ This will install the datamapper rake tasks:
|
|
12
12
|
|
13
13
|
script/generate dm_install
|
14
14
|
|
15
|
-
|
15
|
+
Three generators are added by default
|
16
16
|
|
17
17
|
script/generate dm_model
|
18
18
|
script/generate rspec_dm_model
|
19
|
+
script/generate dm_migration
|
19
20
|
|
20
|
-
|
21
|
+
The first two add a migration but you can call
|
21
22
|
|
22
23
|
script/generate dm_model --skip-migration
|
23
24
|
script/generate rspec_dm_model --skip-migration
|
@@ -26,5 +27,14 @@ To avoid any dependency on active record add this to your projects environment.r
|
|
26
27
|
|
27
28
|
config.frameworks -= [ :active_record ]
|
28
29
|
|
29
|
-
==
|
30
|
-
|
30
|
+
== Session Store
|
31
|
+
|
32
|
+
Change config/initializers/session_store.rb to something like the following:
|
33
|
+
|
34
|
+
ActionController::Base.session_store = :data_mapper_store
|
35
|
+
ActionController::Base.session = {
|
36
|
+
:expires_after => 7.days,
|
37
|
+
:key => '_session_id',
|
38
|
+
}
|
39
|
+
|
40
|
+
Then create the sessions table with: rake db:sessions:create
|
data/Rakefile
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
require 'rubygems'
|
3
2
|
|
4
3
|
ROOT = Pathname(__FILE__).dirname.expand_path
|
5
4
|
JRUBY = RUBY_PLATFORM =~ /java/
|
@@ -8,27 +7,18 @@ SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
|
|
8
7
|
|
9
8
|
require ROOT + 'lib/rails_datamapper/version'
|
10
9
|
|
11
|
-
AUTHOR
|
12
|
-
EMAIL
|
13
|
-
GEM_NAME
|
14
|
-
GEM_VERSION
|
15
|
-
GEM_DEPENDENCIES = [
|
16
|
-
|
17
|
-
|
18
|
-
[ 'dm-migrations', GEM_VERSION ],
|
19
|
-
[ 'dm-serializer', GEM_VERSION ],
|
20
|
-
[ 'dm-timestamps', GEM_VERSION ],
|
21
|
-
[ 'dm-validations', GEM_VERSION ],
|
22
|
-
[ 'dm-types', GEM_VERSION ],
|
23
|
-
]
|
24
|
-
|
25
|
-
GEM_CLEAN = %w[ pkg ]
|
26
|
-
GEM_EXTRAS = { :has_rdoc => false, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] }
|
10
|
+
AUTHOR = 'Tom Malone'
|
11
|
+
EMAIL = 'tomjmalone [a] gmail [d] com'
|
12
|
+
GEM_NAME = 'rails_datamapper'
|
13
|
+
GEM_VERSION = Rails::DataMapper::VERSION
|
14
|
+
GEM_DEPENDENCIES = [['dm-core', GEM_VERSION]]
|
15
|
+
GEM_CLEAN = %w[ pkg ]
|
16
|
+
GEM_EXTRAS = { :has_rdoc => false, :extra_rdoc_files => %w[ README.rdoc LICENSE TODO History.rdoc ] }
|
27
17
|
|
28
18
|
PROJECT_NAME = 'datamapper'
|
29
19
|
PROJECT_URL = "http://github.com/datamapper/dm-more/tree/master/#{GEM_NAME}"
|
30
20
|
PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'Rails Plugin for datamapper'
|
31
21
|
|
32
22
|
[ ROOT, ROOT.parent ].each do |dir|
|
33
|
-
Pathname.glob(dir.join('tasks/**/*.rb').to_s).each { |
|
23
|
+
Pathname.glob(dir.join('tasks/**/*.rb').to_s).sort.each { |filename| require filename }
|
34
24
|
end
|
data/datamapper.rake
CHANGED
@@ -1,36 +1,80 @@
|
|
1
|
+
|
2
|
+
# Monkey patch to allow overriding defined rake tasks (instead of
|
3
|
+
# adding to them, which is the default behaviour when specifying tasks
|
4
|
+
# >1 times).
|
5
|
+
|
6
|
+
Rake::TaskManager.class_eval do
|
7
|
+
def remove_task(task_name)
|
8
|
+
@tasks.delete(task_name.to_s)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def remove_task(task_name)
|
13
|
+
returning Rake.application do |app|
|
14
|
+
app.remove_task(app[task_name].name)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Until AR/DM co-existence becomes practically possible, presume
|
19
|
+
# mutual exclusivity between the two. Thus we wipe all pre-existing
|
20
|
+
# db tasks which we assume to be ActiveRecord-based and thus won't
|
21
|
+
# work).
|
22
|
+
|
23
|
+
Rake.application.tasks.select do |t|
|
24
|
+
t.class == Rake::Task && t.name.starts_with?("db")
|
25
|
+
end.each { |t| remove_task(t.name) }
|
26
|
+
|
1
27
|
namespace :db do
|
2
28
|
|
3
|
-
desc
|
29
|
+
desc 'Perform automigration'
|
4
30
|
task :automigrate => :environment do
|
31
|
+
FileList["app/models/**/*.rb"].each do |model|
|
32
|
+
load model
|
33
|
+
end
|
5
34
|
::DataMapper.auto_migrate!
|
6
35
|
end
|
7
36
|
|
8
|
-
desc
|
37
|
+
desc 'Perform non destructive automigration'
|
9
38
|
task :autoupgrade => :environment do
|
39
|
+
FileList["app/models/**/*.rb"].each do |model|
|
40
|
+
load model
|
41
|
+
end
|
10
42
|
::DataMapper.auto_upgrade!
|
11
43
|
end
|
12
44
|
|
13
45
|
namespace :migrate do
|
14
46
|
task :load => :environment do
|
15
47
|
gem 'dm-migrations'
|
16
|
-
FileList[
|
48
|
+
FileList['db/migrations/*.rb'].each do |migration|
|
17
49
|
load migration
|
18
50
|
end
|
19
51
|
end
|
20
52
|
|
21
|
-
desc
|
53
|
+
desc 'Migrate up using migrations'
|
22
54
|
task :up, :version, :needs => :load do |t, args|
|
23
55
|
version = args[:version]
|
24
56
|
migrate_up!(version)
|
25
57
|
end
|
26
58
|
|
27
|
-
desc
|
59
|
+
desc 'Migrate down using migrations'
|
28
60
|
task :down, :version, :needs => :load do |t, args|
|
29
61
|
version = args[:version]
|
30
62
|
migrate_down!(version)
|
31
63
|
end
|
32
64
|
end
|
33
65
|
|
34
|
-
desc
|
66
|
+
desc 'Migrate the database to the latest version'
|
35
67
|
task :migrate => 'db:migrate:up'
|
68
|
+
|
69
|
+
namespace :sessions do
|
70
|
+
desc "Creates the sessions table for DataMapperStore"
|
71
|
+
task :create => :environment do
|
72
|
+
::DataMapperStore::Session.auto_migrate!
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Clear the sessions table for DataMapperStore"
|
76
|
+
task :clear => :environment do
|
77
|
+
::DataMapperStore::Session.all.destroy!
|
78
|
+
end
|
79
|
+
end
|
36
80
|
end
|
@@ -4,8 +4,8 @@ class DmInstallGenerator < Rails::Generator::Base
|
|
4
4
|
|
5
5
|
def manifest
|
6
6
|
record do |m|
|
7
|
-
m.directory
|
8
|
-
m.template
|
7
|
+
m.directory 'lib/tasks'
|
8
|
+
m.template 'datamapper.rake', 'lib/tasks/datamapper.rake'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
namespace :db do
|
2
2
|
|
3
|
-
desc
|
3
|
+
desc 'Perform automigration'
|
4
4
|
task :automigrate => :environment do
|
5
|
-
FileList[
|
5
|
+
FileList['app/models/**/*.rb'].each do |model|
|
6
6
|
load model
|
7
7
|
end
|
8
8
|
::DataMapper.auto_migrate!
|
9
9
|
end
|
10
10
|
|
11
|
-
desc
|
11
|
+
desc 'Perform non destructive automigration'
|
12
12
|
task :autoupgrade => :environment do
|
13
|
-
FileList[
|
13
|
+
FileList['app/models/**/*.rb'].each do |model|
|
14
14
|
load model
|
15
15
|
end
|
16
16
|
::DataMapper.auto_upgrade!
|
@@ -19,24 +19,24 @@ namespace :db do
|
|
19
19
|
namespace :migrate do
|
20
20
|
task :load => :environment do
|
21
21
|
gem 'dm-migrations'
|
22
|
-
FileList[
|
22
|
+
FileList['db/migrations/*.rb'].each do |migration|
|
23
23
|
load migration
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
desc
|
27
|
+
desc 'Migrate up using migrations'
|
28
28
|
task :up, :version, :needs => :load do |t, args|
|
29
29
|
version = args[:version]
|
30
30
|
migrate_up!(version)
|
31
31
|
end
|
32
32
|
|
33
|
-
desc
|
33
|
+
desc 'Migrate down using migrations'
|
34
34
|
task :down, :version, :needs => :load do |t, args|
|
35
35
|
version = args[:version]
|
36
36
|
migrate_down!(version)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
desc
|
40
|
+
desc 'Migrate the database to the latest version'
|
41
41
|
task :migrate => 'db:migrate:up'
|
42
42
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'rails_generator/generators/components/migration/migration_generator'
|
2
|
+
require 'active_record'
|
2
3
|
|
3
4
|
class DmMigrationGenerator < Rails::Generator::NamedBase
|
4
5
|
|
5
6
|
def manifest
|
6
7
|
record do |m|
|
7
|
-
m.migration_template
|
8
|
+
m.migration_template 'migration.rb', 'db/migrate'
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
@@ -1,7 +1,17 @@
|
|
1
|
-
migration
|
1
|
+
migration 1, :<%= class_name.underscore %> do
|
2
2
|
up do
|
3
|
+
create_table :<%= table_name %> do
|
4
|
+
<% Array(attributes).each do |attribute| -%>
|
5
|
+
column :<%= attribute.name if attribute %>, <%= attribute.type.to_s.capitalize %>, :nullable? => false
|
6
|
+
<% end -%>
|
7
|
+
<% unless options[:skip_timestamps] -%>
|
8
|
+
column :created_at, DateTime, :nullable? => false
|
9
|
+
column :updated_at, DateTime, :nullable? => false
|
10
|
+
<% end -%>
|
11
|
+
end
|
3
12
|
end
|
4
13
|
|
5
14
|
down do
|
15
|
+
drop_table :<%= table_name %>
|
6
16
|
end
|
7
17
|
end
|
@@ -1,23 +1,24 @@
|
|
1
1
|
require 'rails_generator/generators/components/model/model_generator'
|
2
2
|
require 'active_record'
|
3
3
|
|
4
|
-
class DmModelGenerator <ModelGenerator
|
4
|
+
class DmModelGenerator < ModelGenerator
|
5
5
|
|
6
6
|
def manifest
|
7
7
|
record do |m|
|
8
|
+
|
8
9
|
# Check for class naming collisions.
|
9
10
|
m.class_collisions class_path, class_name, "#{class_name}Test"
|
10
11
|
|
11
12
|
# Model, test, and fixture directories.
|
12
13
|
m.directory File.join('app/models', class_path)
|
13
|
-
m.directory File.join('test/unit',
|
14
|
+
m.directory File.join('test/unit', class_path)
|
14
15
|
|
15
16
|
# Model class, unit test, and fixtures.
|
16
17
|
m.template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
17
|
-
m.template 'unit_test.rb', File.join('test/unit',
|
18
|
+
m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
|
18
19
|
|
19
20
|
unless options[:skip_migration]
|
20
|
-
m.migration_template 'migration.rb', 'db/migrate', :assigns => {
|
21
|
+
m.migration_template 'dm_migration:migration.rb', 'db/migrate', :assigns => {
|
21
22
|
:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
|
22
23
|
}, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
|
23
24
|
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
class <%= class_name %>
|
2
2
|
include DataMapper::Resource
|
3
|
-
property :id, Serial
|
4
3
|
|
5
|
-
|
4
|
+
property :id, Serial
|
5
|
+
<% Array(attributes).each do |attribute| -%>
|
6
6
|
property :<%= attribute.name %>, <%= attribute.type.to_s.capitalize %>, :nullable => false
|
7
|
-
|
8
7
|
<% end -%>
|
9
|
-
<% unless options[:skip_timestamps]
|
8
|
+
<% unless options[:skip_timestamps] -%>
|
10
9
|
property :created_at, DateTime, :nullable => false
|
11
10
|
property :updated_at, DateTime, :nullable => false
|
12
|
-
|
13
11
|
<% end -%>
|
12
|
+
|
14
13
|
end
|
@@ -10,21 +10,19 @@ class RspecDmModelGenerator <ModelGenerator
|
|
10
10
|
m.class_collisions class_path, class_name
|
11
11
|
|
12
12
|
# Model, spec, and fixture directories.
|
13
|
-
m.directory File.join('app/models',
|
13
|
+
m.directory File.join('app/models', class_path)
|
14
14
|
m.directory File.join('spec/models', class_path)
|
15
15
|
|
16
16
|
# Model class, spec and fixtures.
|
17
|
-
m.template 'model.rb',
|
18
|
-
m.template 'model_spec.rb',
|
17
|
+
m.template 'dm_model:model.rb', File.join('app/models', class_path, "#{file_name}.rb")
|
18
|
+
m.template 'model_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb")
|
19
19
|
|
20
20
|
unless options[:skip_migration]
|
21
|
-
m.migration_template '
|
21
|
+
m.migration_template 'dm_migration:migration.rb', 'db/migrate', :assigns => {
|
22
22
|
:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
|
23
23
|
}, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
|
24
24
|
end
|
25
|
-
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
29
27
|
|
30
28
|
end
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), <%= ([ "'..'" ] * class_nesting_depth).join(', ') %>, '..', 'spec_helper')
|
2
2
|
|
3
3
|
describe <%= class_name %> do
|
4
4
|
before(:each) do
|
5
5
|
@<%= file_name %> = <%= class_name %>.new
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
9
|
-
end
|
8
|
+
it 'should be awesome'
|
10
9
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'dm-core'
|
2
|
+
|
3
|
+
# Implements DataMapper-specific session store.
|
4
|
+
|
5
|
+
module ActionController
|
6
|
+
module Session
|
7
|
+
class DataMapperStore < AbstractStore
|
8
|
+
|
9
|
+
# Options passed in here are specified at:
|
10
|
+
# config/initializers/session_store.rb
|
11
|
+
|
12
|
+
def initialize(app, options = {})
|
13
|
+
options.symbolize_keys!
|
14
|
+
options[:expire_after] = options[:expires] || nil
|
15
|
+
|
16
|
+
super
|
17
|
+
|
18
|
+
unless (self.class.class_variable_defined? :@@session_class and @@session_class)
|
19
|
+
@@session_class = options.delete(:session_class) || ::DataMapperStore::Session
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def get_session(env, sid)
|
25
|
+
sid ||= generate_sid
|
26
|
+
session = @@session_class.first(:session_id => sid)
|
27
|
+
[sid, session.nil? ? {} : session.data]
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_session(env, sid, session_data)
|
31
|
+
session = @@session_class.first(:session_id => sid) ||
|
32
|
+
@@session_class.new(:session_id => sid)
|
33
|
+
session.data = session_data || {}
|
34
|
+
session.updated_at = Time.now if session.dirty?
|
35
|
+
|
36
|
+
session.save
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module DataMapperStore
|
43
|
+
class Session
|
44
|
+
include ::DataMapper::Resource
|
45
|
+
|
46
|
+
def self.name
|
47
|
+
"session"
|
48
|
+
end
|
49
|
+
|
50
|
+
property :id, Serial
|
51
|
+
property :session_id, String, :unique_index => true
|
52
|
+
property :data, Text, :nullable => false, :default => ::Base64.encode64(Marshal.dump({}))
|
53
|
+
property :updated_at, DateTime, :nullable => true, :index => true
|
54
|
+
|
55
|
+
def data=(data)
|
56
|
+
attribute_set(:data, ::Base64.encode64(Marshal.dump(data)))
|
57
|
+
end
|
58
|
+
|
59
|
+
def data
|
60
|
+
Marshal.load(::Base64.decode64(attribute_get(:data)))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/rails_datamapper.rb
CHANGED
@@ -1,15 +1,61 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
require '
|
3
|
-
require 'dm-aggregates'
|
4
|
-
require 'dm-migrations'
|
5
|
-
require 'dm-serializer'
|
6
|
-
require 'dm-timestamps'
|
7
|
-
require 'dm-validations'
|
8
|
-
require 'dm-types'
|
2
|
+
require 'extlib/pathname'
|
9
3
|
|
10
|
-
|
4
|
+
require 'rails_datamapper/session_store'
|
11
5
|
|
12
|
-
|
13
|
-
|
6
|
+
module Rails
|
7
|
+
module DataMapper
|
8
|
+
class << self
|
9
|
+
extend ActiveSupport::Memoizable
|
14
10
|
|
15
|
-
create_connection
|
11
|
+
def create_connection
|
12
|
+
# TODO: handle Rails and Merb style database.yml files
|
13
|
+
conf = config.dup
|
14
|
+
repositories = conf.delete(:repositories)
|
15
|
+
::DataMapper.setup(:default, conf) unless conf.empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def config_file
|
21
|
+
Rails.root / 'config' / 'database.yml'
|
22
|
+
end
|
23
|
+
|
24
|
+
def full_config
|
25
|
+
YAML::load(ERB.new(config_file.read).result)
|
26
|
+
end
|
27
|
+
|
28
|
+
memoize :full_config
|
29
|
+
|
30
|
+
def config
|
31
|
+
if hash = full_config[Rails.env] || full_config[Rails.env.to_sym]
|
32
|
+
normalize_config(hash)
|
33
|
+
else
|
34
|
+
raise ArgumentError, "missing environment '#{Rails.env}' in config file #{config_file}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
memoize :config
|
39
|
+
|
40
|
+
def normalize_config(hash)
|
41
|
+
config = {}
|
42
|
+
|
43
|
+
hash.symbolize_keys.each do |key, value|
|
44
|
+
config[key] = if value.kind_of?(Hash)
|
45
|
+
normalize_config(value)
|
46
|
+
elsif key == :port
|
47
|
+
value.to_i
|
48
|
+
elsif key == :adapter && value == 'postgresql'
|
49
|
+
'postgres'
|
50
|
+
else
|
51
|
+
value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
config
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Rails::DataMapper.create_connection
|
data/tasks/install.rb
CHANGED
@@ -4,7 +4,7 @@ end
|
|
4
4
|
|
5
5
|
desc "Install #{GEM_NAME} #{GEM_VERSION}"
|
6
6
|
task :install => [ :package ] do
|
7
|
-
sudo_gem "install
|
7
|
+
sudo_gem "install pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
|
8
8
|
end
|
9
9
|
|
10
10
|
desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_datamapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Malone
|
@@ -9,79 +9,10 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
name: dm-core
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - "="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.11
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: dm-aggregates
|
27
|
-
type: :runtime
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.11
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: dm-migrations
|
37
|
-
type: :runtime
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - "="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 0.9.11
|
44
|
-
version:
|
45
|
-
- !ruby/object:Gem::Dependency
|
46
|
-
name: dm-serializer
|
47
|
-
type: :runtime
|
48
|
-
version_requirement:
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 0.9.11
|
54
|
-
version:
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: dm-timestamps
|
57
|
-
type: :runtime
|
58
|
-
version_requirement:
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - "="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: 0.9.11
|
64
|
-
version:
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: dm-validations
|
67
|
-
type: :runtime
|
68
|
-
version_requirement:
|
69
|
-
version_requirements: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: 0.9.11
|
74
|
-
version:
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: dm-types
|
77
|
-
type: :runtime
|
78
|
-
version_requirement:
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 0.9.11
|
84
|
-
version:
|
14
|
+
dependencies: []
|
15
|
+
|
85
16
|
description: Rails Plugin for datamapper
|
86
17
|
email:
|
87
18
|
- tomjmalone [a] gmail [d] com
|
@@ -90,15 +21,15 @@ executables: []
|
|
90
21
|
extensions: []
|
91
22
|
|
92
23
|
extra_rdoc_files:
|
93
|
-
- README.
|
24
|
+
- README.rdoc
|
94
25
|
- LICENSE
|
95
26
|
- TODO
|
96
|
-
- History.
|
27
|
+
- History.rdoc
|
97
28
|
files:
|
98
|
-
- History.
|
29
|
+
- History.rdoc
|
99
30
|
- LICENSE
|
100
31
|
- Manifest.txt
|
101
|
-
- README.
|
32
|
+
- README.rdoc
|
102
33
|
- Rakefile
|
103
34
|
- TODO
|
104
35
|
- datamapper.rake
|
@@ -107,26 +38,22 @@ files:
|
|
107
38
|
- generators/dm_migration/dm_migration_generator.rb
|
108
39
|
- generators/dm_migration/templates/migration.rb
|
109
40
|
- generators/dm_model/dm_model_generator.rb
|
110
|
-
- generators/dm_model/templates/migration.rb
|
111
41
|
- generators/dm_model/templates/model.rb
|
112
42
|
- generators/dm_model/templates/unit_test.rb
|
113
43
|
- generators/rspec_dm_model/rspec_dm_model_generator.rb
|
114
|
-
- generators/rspec_dm_model/templates/model.rb
|
115
44
|
- generators/rspec_dm_model/templates/model_spec.rb
|
116
|
-
- init.rb
|
117
45
|
- lib/rails_datamapper.rb
|
118
|
-
- lib/rails_datamapper/
|
119
|
-
- lib/rails_datamapper/validations.rb
|
46
|
+
- lib/rails_datamapper/session_store.rb
|
120
47
|
- lib/rails_datamapper/version.rb
|
121
48
|
- tasks/install.rb
|
122
|
-
has_rdoc:
|
49
|
+
has_rdoc: false
|
123
50
|
homepage: http://github.com/datamapper/dm-more/tree/master/rails_datamapper
|
124
51
|
licenses: []
|
125
52
|
|
126
53
|
post_install_message:
|
127
54
|
rdoc_options:
|
128
55
|
- --main
|
129
|
-
- README.
|
56
|
+
- README.rdoc
|
130
57
|
require_paths:
|
131
58
|
- lib
|
132
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -144,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
71
|
requirements: []
|
145
72
|
|
146
73
|
rubyforge_project: datamapper
|
147
|
-
rubygems_version: 1.3.
|
74
|
+
rubygems_version: 1.3.5
|
148
75
|
signing_key:
|
149
76
|
specification_version: 3
|
150
77
|
summary: Rails Plugin for datamapper
|
data/History.txt
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :<%= table_name %> do |t|
|
4
|
-
<% for attribute in attributes -%>
|
5
|
-
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
-
<% end -%>
|
7
|
-
<% unless options[:skip_timestamps] %>
|
8
|
-
t.timestamps
|
9
|
-
<% end -%>
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.down
|
14
|
-
drop_table :<%= table_name %>
|
15
|
-
end
|
16
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class <%= class_name %>
|
2
|
-
include DataMapper::Resource
|
3
|
-
property :id, Serial
|
4
|
-
|
5
|
-
<% for attribute in attributes -%>
|
6
|
-
property :<%= attribute.name %>, <%= attribute.type.to_s.capitalize %>, :nullable => false
|
7
|
-
|
8
|
-
<% end -%>
|
9
|
-
<% unless options[:skip_timestamps] %>
|
10
|
-
property :created_at, DateTime, :nullable => false
|
11
|
-
property :updated_at, DateTime, :nullable => false
|
12
|
-
|
13
|
-
<% end -%>
|
14
|
-
end
|
data/init.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
def config_file()
|
2
|
-
RAILS_ROOT + "/config/database.yml"
|
3
|
-
end
|
4
|
-
|
5
|
-
def create_connection()
|
6
|
-
conf = config.dup
|
7
|
-
repositories = conf.delete(:repositories)
|
8
|
-
::DataMapper.setup(:default, conf) unless conf.empty?
|
9
|
-
end
|
10
|
-
|
11
|
-
def get_config_for_environment
|
12
|
-
if hash = full_config[RAILS_ENV]
|
13
|
-
symbolize_keys(hash)
|
14
|
-
elsif hash = full_config[RAILS_ENV.to_sym]
|
15
|
-
hash
|
16
|
-
else
|
17
|
-
raise ArgumentError, "missing environment '#{RAILS_ENV}' in config file #{config_file}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def full_config
|
22
|
-
@full_config ||= YAML::load(ERB.new(IO.read(config_file)).result)
|
23
|
-
end
|
24
|
-
|
25
|
-
def config
|
26
|
-
@config ||= get_config_for_environment
|
27
|
-
end
|
28
|
-
|
29
|
-
def symbolize_keys(h)
|
30
|
-
config = {}
|
31
|
-
|
32
|
-
h.each do |k, v|
|
33
|
-
if k == 'port'
|
34
|
-
config[k.to_sym] = v.to_i
|
35
|
-
elsif k == 'adapter' && v == 'postgresql'
|
36
|
-
config[k.to_sym] = 'postgres'
|
37
|
-
elsif v.is_a?(Hash)
|
38
|
-
config[k.to_sym] = symbolize_keys(v)
|
39
|
-
else
|
40
|
-
config[k.to_sym] = v
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
config
|
45
|
-
end
|