dm-rails 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/README.rdoc +44 -7
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/dm-rails.gemspec +15 -14
- data/lib/dm-rails/configuration.rb +19 -11
- data/lib/dm-rails/mass_assignment_security.rb +65 -0
- data/lib/dm-rails/railtie.rb +8 -3
- data/lib/dm-rails/railties/controller_runtime.rb +0 -1
- data/lib/dm-rails/railties/database.rake +2 -11
- data/lib/dm-rails/railties/log_subscriber.rb +0 -1
- data/lib/dm-rails/storage.rb +26 -7
- data/tasks/local_gemfile.rake +5 -7
- metadata +14 -16
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -6,18 +6,18 @@ Creating new datamapper apps on rails3 from scratch is actually really easy. The
|
|
6
6
|
|
7
7
|
== Generating a new application from scratch
|
8
8
|
|
9
|
-
|
9
|
+
To go from zero gems to a working rails3 app using datamapper, all you need are the latest {rubygems}[http://docs.rubygems.org/read/chapter/3] release, {bundler}[http://gembundler.com] and {rails}[http://github.com/rails/rails]. After possibly updating your rubygems, issue the following:
|
10
10
|
|
11
|
-
gem
|
12
|
-
gem install bundler --pre (optional, rails will likely pull in a current version)
|
13
|
-
gem install rails --pre
|
11
|
+
gem install rails
|
14
12
|
|
15
|
-
Once you have {rails}[http://github.com/rails/rails] and thus {bundler}[http://github.com/carlhuda/bundler] installed, you can bootstrap a rails
|
13
|
+
Once you have {rails}[http://github.com/rails/rails] and thus {bundler}[http://github.com/carlhuda/bundler] installed, you can bootstrap a rails application with a single command.
|
16
14
|
|
17
15
|
rails new project_name -m http://datamapper.org/templates/rails.rb
|
18
16
|
|
19
17
|
When run, the command will print out some options on how to proceed with your newly generated application.
|
20
18
|
|
19
|
+
Be aware that this command executes code loaded from the internet! It is currently the simplest way to bootstrap a new application, and a commonly used way to reuse rails application templates. Have a look at {rails templates}[http://github.com/datamapper/datamapper.github.com/tree/master/templates/] to know exactly what we'll do to your system, but be aware that a man-in-the-middle attack could alter that.
|
20
|
+
|
21
21
|
== rspec support
|
22
22
|
|
23
23
|
I haven't yet tested rspec support extensively, but the basics are working after a few modifications to the spec/spec_helper.rb file that the necessary
|
@@ -74,7 +74,7 @@ If you haven't done so for whatever reason, use
|
|
74
74
|
|
75
75
|
instead.
|
76
76
|
|
77
|
-
You may have noticed that rspec is included into both the `:development` and `:test` groups in the Gemfile the application template generated. I couldn't find another way to make it so that the above mentioned way of running the specs work. If rspec is not included into the `:development` group, rails must be informed explicitly about the environment it should run in, by prefixing the above rake commands with `RAILS_ENV=test`.
|
77
|
+
You may have noticed that rspec is included into both the `:development` and `:test` groups in the Gemfile the application template generated. I couldn't find another way to make it so that the above mentioned way of running the specs work. If rspec is not included into the `:development` group, rails must be informed explicitly about the environment it should run in, by prefixing the above rake commands with `RAILS_ENV=test`.
|
78
78
|
|
79
79
|
== Developing dm-rails
|
80
80
|
|
@@ -105,7 +105,7 @@ Using {bundler}[http://github.com/carlhuda/bundler] it's really easy to get an a
|
|
105
105
|
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
|
106
106
|
gem 'railties', RAILS_VERSION, :require => 'rails'
|
107
107
|
|
108
|
-
gem 'dm-rails',
|
108
|
+
gem 'dm-rails', '~> 1.0.3'
|
109
109
|
gem 'dm-sqlite-adapter', DM_VERSION
|
110
110
|
|
111
111
|
# You can use any of the other available database adapters.
|
@@ -487,6 +487,42 @@ or that you want to use your own naming convention, that is implemented in e.g.
|
|
487
487
|
|
488
488
|
For more detailed documentation about DataMapper naming conventions and the ones that are available by default, have a look at http://rdoc.info/projects/datamapper/dm-core and search for _NamingConventions_ in the Class List.
|
489
489
|
|
490
|
+
== Mass assignment protection
|
491
|
+
|
492
|
+
By default, `dm-rails` doesn't activate any support for mass assignment protection.
|
493
|
+
You can however activate it for your application by including the relevant module
|
494
|
+
either globally into all known models, or on a per model basis (the latter being
|
495
|
+
advised, for reasons explained below).
|
496
|
+
|
497
|
+
# Global installation (config/application.rb is a good place for adding this)
|
498
|
+
#
|
499
|
+
# Make .attr_protected and .attr_accessible available to all models
|
500
|
+
# NOTE: This won't work if you have code that includes DataMapper::Resource
|
501
|
+
# into any other module. This is done by dm-is-remixable for example, so to
|
502
|
+
# be safe, you should only do that if you really know what you're doing.
|
503
|
+
# Quite some plugins make use of dm-is-remixable, so be sure to check that out
|
504
|
+
# before you go ahead and do the following in your config/application.rb
|
505
|
+
DataMapper::Model.append_inclusions(Rails::DataMapper::MassAssignmentSecurity)
|
506
|
+
|
507
|
+
# Local installation (recommended)
|
508
|
+
#
|
509
|
+
# Include the mass assignment protection only into models that actually need it
|
510
|
+
# This is the preferred way of doing things, at least for now. You will only
|
511
|
+
# have the functionality available where you actually need it, and you don't run
|
512
|
+
# into problems with third party code including DataMapper::Resource into other
|
513
|
+
# modules.
|
514
|
+
|
515
|
+
class Person
|
516
|
+
|
517
|
+
include DataMapper::Resource
|
518
|
+
include DataMapper::MassAssignmentSecurity
|
519
|
+
|
520
|
+
property :id, Serial
|
521
|
+
property :login, String
|
522
|
+
|
523
|
+
attr_protected :login
|
524
|
+
|
525
|
+
end
|
490
526
|
|
491
527
|
== Using additional datamapper plugins
|
492
528
|
|
@@ -549,6 +585,7 @@ Thx to all contributors, every patch, big or small is very much appreciated!
|
|
549
585
|
* Patrik Sundberg ({sundbp}[http://github.com/sundbp])
|
550
586
|
* Corin Langosch ({gucki}[http://github.com/gucki])
|
551
587
|
* Jared Morgan ({jm81}[http://github.com/jm81])
|
588
|
+
* Blake Gentry ({bgentry}[http://github.com/bgentry])
|
552
589
|
|
553
590
|
== Copyright
|
554
591
|
|
data/Rakefile
CHANGED
@@ -16,10 +16,10 @@ begin
|
|
16
16
|
gem.rubyforge_project = 'datamapper'
|
17
17
|
|
18
18
|
gem.add_dependency 'dm-core', '~> 1.0.0'
|
19
|
-
gem.add_dependency 'dm-active_model', '~> 1.0.
|
20
|
-
gem.add_dependency 'activesupport', '~> 3.0.0
|
21
|
-
gem.add_dependency 'actionpack', '~> 3.0.0
|
22
|
-
gem.add_dependency 'railties', '~> 3.0.0
|
19
|
+
gem.add_dependency 'dm-active_model', '~> 1.0.3'
|
20
|
+
gem.add_dependency 'activesupport', '~> 3.0.0'
|
21
|
+
gem.add_dependency 'actionpack', '~> 3.0.0'
|
22
|
+
gem.add_dependency 'railties', '~> 3.0.0'
|
23
23
|
end
|
24
24
|
|
25
25
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.4
|
2
2
|
|
data/dm-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-rails}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Martin Gamsjaeger (snusnu)", "Dan Kubb"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-24}
|
13
13
|
s.description = %q{Integrate DataMapper with Rails 3}
|
14
14
|
s.email = %q{gamsnjaga@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"dm-rails.gemspec",
|
28
28
|
"lib/dm-rails.rb",
|
29
29
|
"lib/dm-rails/configuration.rb",
|
30
|
+
"lib/dm-rails/mass_assignment_security.rb",
|
30
31
|
"lib/dm-rails/middleware/identity_map.rb",
|
31
32
|
"lib/dm-rails/railtie.rb",
|
32
33
|
"lib/dm-rails/railties/controller_runtime.rb",
|
@@ -64,23 +65,23 @@ Gem::Specification.new do |s|
|
|
64
65
|
|
65
66
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
66
67
|
s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0"])
|
67
|
-
s.add_runtime_dependency(%q<dm-active_model>, ["~> 1.0.
|
68
|
-
s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0
|
69
|
-
s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0
|
70
|
-
s.add_runtime_dependency(%q<railties>, ["~> 3.0.0
|
68
|
+
s.add_runtime_dependency(%q<dm-active_model>, ["~> 1.0.3"])
|
69
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0"])
|
70
|
+
s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0"])
|
71
|
+
s.add_runtime_dependency(%q<railties>, ["~> 3.0.0"])
|
71
72
|
else
|
72
73
|
s.add_dependency(%q<dm-core>, ["~> 1.0.0"])
|
73
|
-
s.add_dependency(%q<dm-active_model>, ["~> 1.0.
|
74
|
-
s.add_dependency(%q<activesupport>, ["~> 3.0.0
|
75
|
-
s.add_dependency(%q<actionpack>, ["~> 3.0.0
|
76
|
-
s.add_dependency(%q<railties>, ["~> 3.0.0
|
74
|
+
s.add_dependency(%q<dm-active_model>, ["~> 1.0.3"])
|
75
|
+
s.add_dependency(%q<activesupport>, ["~> 3.0.0"])
|
76
|
+
s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
|
77
|
+
s.add_dependency(%q<railties>, ["~> 3.0.0"])
|
77
78
|
end
|
78
79
|
else
|
79
80
|
s.add_dependency(%q<dm-core>, ["~> 1.0.0"])
|
80
|
-
s.add_dependency(%q<dm-active_model>, ["~> 1.0.
|
81
|
-
s.add_dependency(%q<activesupport>, ["~> 3.0.0
|
82
|
-
s.add_dependency(%q<actionpack>, ["~> 3.0.0
|
83
|
-
s.add_dependency(%q<railties>, ["~> 3.0.0
|
81
|
+
s.add_dependency(%q<dm-active_model>, ["~> 1.0.3"])
|
82
|
+
s.add_dependency(%q<activesupport>, ["~> 3.0.0"])
|
83
|
+
s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
|
84
|
+
s.add_dependency(%q<railties>, ["~> 3.0.0"])
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
@@ -8,18 +8,19 @@ module Rails
|
|
8
8
|
|
9
9
|
class Configuration
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
11
|
+
attr_accessor :raw
|
12
|
+
attr_accessor :root
|
14
13
|
|
15
|
-
|
14
|
+
def self.create
|
15
|
+
Rails::DataMapper.configuration ||= new
|
16
|
+
end
|
16
17
|
|
17
18
|
def environments
|
18
19
|
raw.keys
|
19
20
|
end
|
20
21
|
|
21
22
|
def repositories
|
22
|
-
@repositories ||=
|
23
|
+
@repositories ||= raw.reject { |k,v| k =~ /defaults/ }.inject({}) do |repositories, pair|
|
23
24
|
environment, config = pair.first, pair.last
|
24
25
|
repositories[environment] = begin
|
25
26
|
c = config['repositories'] || {}
|
@@ -36,24 +37,31 @@ module Rails
|
|
36
37
|
|
37
38
|
private
|
38
39
|
|
39
|
-
def initialize(root, database_yml_hash)
|
40
|
-
@root, @raw = root, database_yml_hash
|
41
|
-
end
|
42
|
-
|
43
40
|
def normalize_repository_config(hash)
|
44
41
|
config = {}
|
45
42
|
hash.each do |key, value|
|
43
|
+
|
46
44
|
config[key] = if value.kind_of?(Hash)
|
47
45
|
normalize_repository_config(value)
|
48
46
|
elsif key == 'port'
|
49
47
|
value.to_i
|
50
48
|
elsif key == 'adapter' && value == 'postgresql'
|
51
49
|
'postgres'
|
52
|
-
elsif key == 'database' && hash['adapter']
|
53
|
-
value == ':memory:' ? value : File.expand_path(hash[
|
50
|
+
elsif (key == 'database' || key == 'path') && hash['adapter'] =~ /sqlite/
|
51
|
+
value == ':memory:' ? value : File.expand_path(hash[key], root)
|
54
52
|
else
|
55
53
|
value
|
56
54
|
end
|
55
|
+
|
56
|
+
# FIXME Rely on a new dm-sqlite-adapter to do the right thing
|
57
|
+
# For now, we need to make sure that both 'path' and 'database'
|
58
|
+
# point to the same thing, since dm-sqlite-adapter always passes
|
59
|
+
# both to the underlying do_sqlite3 adapter and there's no
|
60
|
+
# guarantee which one will be used
|
61
|
+
|
62
|
+
config['path'] = config[key] if key == 'database'
|
63
|
+
config['database'] = config[key] if key == 'path'
|
64
|
+
|
57
65
|
end
|
58
66
|
config
|
59
67
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'dm-core'
|
2
|
+
require 'active_support/core_ext/class/attribute'
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'active_model'
|
5
|
+
|
6
|
+
module ActiveModel
|
7
|
+
module MassAssignmentSecurity
|
8
|
+
module Sanitizer
|
9
|
+
# Returns all attributes not denied by the authorizer. Property keys can
|
10
|
+
# be a Symbol, String, DataMapper::Property, or DataMapper::Relationship
|
11
|
+
def sanitize(attributes)
|
12
|
+
sanitized_attributes = attributes.reject do |key, value|
|
13
|
+
key_name = key.name rescue key
|
14
|
+
deny?(key_name)
|
15
|
+
end
|
16
|
+
debug_protected_attribute_removal(attributes, sanitized_attributes)
|
17
|
+
sanitized_attributes
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module DataMapper
|
24
|
+
# = Active Model Mass-Assignment Security
|
25
|
+
module MassAssignmentSecurity
|
26
|
+
extend ::ActiveSupport::Concern
|
27
|
+
include ::ActiveModel::MassAssignmentSecurity
|
28
|
+
|
29
|
+
module ClassMethods
|
30
|
+
extend ::ActiveModel::MassAssignmentSecurity::ClassMethods
|
31
|
+
|
32
|
+
def logger
|
33
|
+
@logger ||= ::DataMapper.logger
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
# Allows you to set all the attributes at once by passing in a hash with keys
|
39
|
+
# matching the attribute names (which again matches the column names).
|
40
|
+
#
|
41
|
+
# If +guard_protected_attributes+ is true (the default), then sensitive
|
42
|
+
# attributes can be protected from this form of mass-assignment by using
|
43
|
+
# the +attr_protected+ macro. Or you can alternatively specify which
|
44
|
+
# attributes *can* be accessed with the +attr_accessible+ macro. Then all the
|
45
|
+
# attributes not included in that won't be allowed to be mass-assigned.
|
46
|
+
#
|
47
|
+
# class User < ActiveRecord::Base
|
48
|
+
# attr_protected :is_admin
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# user = User.new
|
52
|
+
# user.attributes = { :username => 'Phusion', :is_admin => true }
|
53
|
+
# user.username # => "Phusion"
|
54
|
+
# user.is_admin? # => false
|
55
|
+
#
|
56
|
+
# user.send(:attributes=, { :username => 'Phusion', :is_admin => true }, false)
|
57
|
+
# user.is_admin? # => true
|
58
|
+
def attributes=(attributes, guard_protected_attributes = true)
|
59
|
+
attributes = sanitize_for_mass_assignment(attributes) if guard_protected_attributes
|
60
|
+
super(attributes)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/lib/dm-rails/railtie.rb
CHANGED
@@ -16,21 +16,26 @@ require 'dm-rails/setup'
|
|
16
16
|
require "dm-rails/railties/log_subscriber"
|
17
17
|
require "dm-rails/railties/i18n_support"
|
18
18
|
|
19
|
+
# The module provided in there is made available
|
20
|
+
# but users will still need to include it into the
|
21
|
+
# models they want it to use it in.
|
22
|
+
require 'dm-rails/mass_assignment_security'
|
19
23
|
|
20
24
|
module Rails
|
21
25
|
module DataMapper
|
22
26
|
|
23
27
|
class Railtie < Rails::Railtie
|
24
28
|
|
29
|
+
config.data_mapper = Rails::DataMapper::Configuration.create
|
30
|
+
|
25
31
|
config.generators.orm :data_mapper, :migration => true
|
26
32
|
|
27
33
|
|
28
34
|
# Support overwriting crucial steps in subclasses
|
29
35
|
|
30
36
|
def configure_data_mapper(app)
|
31
|
-
app.config.data_mapper = Rails
|
32
|
-
|
33
|
-
)
|
37
|
+
app.config.data_mapper.root = Rails.root
|
38
|
+
app.config.data_mapper.raw = app.config.database_configuration
|
34
39
|
end
|
35
40
|
|
36
41
|
def setup_i18n_support(app)
|
@@ -6,10 +6,6 @@ namespace :db do
|
|
6
6
|
desc 'Create the database, load the schema, and initialize with the seed data'
|
7
7
|
task :setup => [ 'db:create', 'db:automigrate', 'db:seed' ]
|
8
8
|
|
9
|
-
namespace :test do
|
10
|
-
task :prepare => ['db:setup']
|
11
|
-
end
|
12
|
-
|
13
9
|
namespace :create do
|
14
10
|
desc 'Create all the local databases defined in config/database.yml'
|
15
11
|
task :all => :environment do
|
@@ -17,12 +13,9 @@ namespace :db do
|
|
17
13
|
end
|
18
14
|
end
|
19
15
|
|
20
|
-
desc "Create
|
16
|
+
desc "Create all local databases defined for the current Rails.env"
|
21
17
|
task :create => :environment do
|
22
18
|
Rails::DataMapper.storage.create_environment(Rails::DataMapper.configuration.repositories[Rails.env])
|
23
|
-
if Rails.env.development? && Rails::DataMapper.configuration.repositories['test']
|
24
|
-
Rails::DataMapper.storage.create_environment(Rails::DataMapper.configuration.repositories['test'])
|
25
|
-
end
|
26
19
|
end
|
27
20
|
|
28
21
|
namespace :drop do
|
@@ -32,7 +25,7 @@ namespace :db do
|
|
32
25
|
end
|
33
26
|
end
|
34
27
|
|
35
|
-
desc "
|
28
|
+
desc "Drop all local databases defined for the current Rails.env"
|
36
29
|
task :drop => :environment do
|
37
30
|
Rails::DataMapper.storage.drop_environment(Rails::DataMapper.configuration.repositories[Rails.env])
|
38
31
|
end
|
@@ -42,7 +35,6 @@ namespace :db do
|
|
42
35
|
task :automigrate => :environment do
|
43
36
|
require 'dm-migrations'
|
44
37
|
Rails::DataMapper.configuration.repositories[Rails.env].each do |repository, config|
|
45
|
-
::DataMapper.setup(repository.to_sym, config)
|
46
38
|
::DataMapper.auto_migrate!(repository.to_sym)
|
47
39
|
puts "[datamapper] Finished auto_migrate! for :#{repository} repository '#{config['database']}'"
|
48
40
|
end
|
@@ -52,7 +44,6 @@ namespace :db do
|
|
52
44
|
task :autoupgrade => :environment do
|
53
45
|
require 'dm-migrations'
|
54
46
|
Rails::DataMapper.configuration.repositories[Rails.env].each do |repository, config|
|
55
|
-
::DataMapper.setup(repository.to_sym, config)
|
56
47
|
::DataMapper.auto_upgrade!(repository.to_sym)
|
57
48
|
puts "[datamapper] Finished auto_upgrade! for :#{repository} repository '#{config['database']}'"
|
58
49
|
end
|
data/lib/dm-rails/storage.rb
CHANGED
@@ -67,13 +67,11 @@ module Rails
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def create
|
70
|
-
_create
|
71
|
-
puts "[datamapper] Created database '#{database}'"
|
70
|
+
puts create_message if _create
|
72
71
|
end
|
73
72
|
|
74
73
|
def drop
|
75
|
-
_drop
|
76
|
-
puts "[datamapper] Dropped database '#{database}'"
|
74
|
+
puts drop_message if _drop
|
77
75
|
end
|
78
76
|
|
79
77
|
def database
|
@@ -92,11 +90,28 @@ module Rails
|
|
92
90
|
@charset ||= config['charset'] || ENV['CHARSET'] || 'utf8'
|
93
91
|
end
|
94
92
|
|
93
|
+
def create_message
|
94
|
+
"[datamapper] Created database '#{database}'"
|
95
|
+
end
|
96
|
+
|
97
|
+
def drop_message
|
98
|
+
"[datamapper] Dropped database '#{database}'"
|
99
|
+
end
|
100
|
+
|
95
101
|
class Sqlite < Storage
|
96
102
|
def _create
|
97
|
-
|
98
|
-
#
|
99
|
-
|
103
|
+
# This is a noop for sqlite
|
104
|
+
#
|
105
|
+
# Both auto_migrate!/auto_upgrade! will create the actual database
|
106
|
+
# if the connection has been setup properly and there actually
|
107
|
+
# are statements to execute (i.e. at least one model is declared)
|
108
|
+
#
|
109
|
+
# DataMapper.setup alone won't create the actual database so there
|
110
|
+
# really is no API to simply create an empty database for sqlite3.
|
111
|
+
#
|
112
|
+
# we return true to indicate success nevertheless
|
113
|
+
|
114
|
+
true
|
100
115
|
end
|
101
116
|
|
102
117
|
def _drop
|
@@ -104,6 +119,10 @@ module Rails
|
|
104
119
|
path.unlink if path.file?
|
105
120
|
end
|
106
121
|
|
122
|
+
def create_message
|
123
|
+
"[datamapper] db:create is a noop for sqlite3, use db:automigrate instead (#{database})"
|
124
|
+
end
|
125
|
+
|
107
126
|
private
|
108
127
|
|
109
128
|
def in_memory?
|
data/tasks/local_gemfile.rake
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
desc "Support bundling from local source code (allows BUNDLE_GEMFILE=Gemfile.local bundle foo)"
|
2
2
|
task :local_gemfile do |t|
|
3
3
|
|
4
|
-
root
|
5
|
-
datamapper
|
6
|
-
|
7
|
-
source_regex = /DATAMAPPER = 'git:\/\/github.com\/datamapper'/
|
8
|
-
gem_source_regex = /:git => \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/
|
4
|
+
root = Pathname(__FILE__).dirname.parent
|
5
|
+
datamapper = root.parent
|
9
6
|
|
10
7
|
root.join('Gemfile.local').open('w') do |f|
|
11
8
|
root.join('Gemfile').open.each do |line|
|
12
|
-
line.sub!(
|
13
|
-
line.sub!(
|
9
|
+
line.sub!(/DATAMAPPER = 'git:\/\/github.com\/datamapper'/, "DATAMAPPER = '#{datamapper}'")
|
10
|
+
line.sub!(/:git => \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/, ':path => "#{DATAMAPPER}/\1"')
|
11
|
+
line.sub!(/do_options\[:git\] = \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/, 'do_options[:path] = "#{DATAMAPPER}/\1"')
|
14
12
|
f.puts line
|
15
13
|
end
|
16
14
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Martin Gamsjaeger (snusnu)
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-10-24 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -43,12 +43,12 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
hash:
|
46
|
+
hash: 17
|
47
47
|
segments:
|
48
48
|
- 1
|
49
49
|
- 0
|
50
|
-
-
|
51
|
-
version: 1.0.
|
50
|
+
- 3
|
51
|
+
version: 1.0.3
|
52
52
|
type: :runtime
|
53
53
|
version_requirements: *id002
|
54
54
|
- !ruby/object:Gem::Dependency
|
@@ -59,13 +59,12 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
hash:
|
62
|
+
hash: 7
|
63
63
|
segments:
|
64
64
|
- 3
|
65
65
|
- 0
|
66
66
|
- 0
|
67
|
-
|
68
|
-
version: 3.0.0.rc
|
67
|
+
version: 3.0.0
|
69
68
|
type: :runtime
|
70
69
|
version_requirements: *id003
|
71
70
|
- !ruby/object:Gem::Dependency
|
@@ -76,13 +75,12 @@ dependencies:
|
|
76
75
|
requirements:
|
77
76
|
- - ~>
|
78
77
|
- !ruby/object:Gem::Version
|
79
|
-
hash:
|
78
|
+
hash: 7
|
80
79
|
segments:
|
81
80
|
- 3
|
82
81
|
- 0
|
83
82
|
- 0
|
84
|
-
|
85
|
-
version: 3.0.0.rc
|
83
|
+
version: 3.0.0
|
86
84
|
type: :runtime
|
87
85
|
version_requirements: *id004
|
88
86
|
- !ruby/object:Gem::Dependency
|
@@ -93,13 +91,12 @@ dependencies:
|
|
93
91
|
requirements:
|
94
92
|
- - ~>
|
95
93
|
- !ruby/object:Gem::Version
|
96
|
-
hash:
|
94
|
+
hash: 7
|
97
95
|
segments:
|
98
96
|
- 3
|
99
97
|
- 0
|
100
98
|
- 0
|
101
|
-
|
102
|
-
version: 3.0.0.rc
|
99
|
+
version: 3.0.0
|
103
100
|
type: :runtime
|
104
101
|
version_requirements: *id005
|
105
102
|
description: Integrate DataMapper with Rails 3
|
@@ -122,6 +119,7 @@ files:
|
|
122
119
|
- dm-rails.gemspec
|
123
120
|
- lib/dm-rails.rb
|
124
121
|
- lib/dm-rails/configuration.rb
|
122
|
+
- lib/dm-rails/mass_assignment_security.rb
|
125
123
|
- lib/dm-rails/middleware/identity_map.rb
|
126
124
|
- lib/dm-rails/railtie.rb
|
127
125
|
- lib/dm-rails/railties/controller_runtime.rb
|