forked from datamapper/dm-more
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
158 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
=== 0.9.11 / not released | ||
|
||
* Made a gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2008 Tom Malone | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
History.txt | ||
LICENSE | ||
Manifest.txt | ||
README.txt | ||
Rakefile | ||
TODO | ||
lib/rails_datamapper.rb | ||
lib/rails_datamapper/rails_datamapper.rb | ||
lib/rails_datamapper/version.rb | ||
generators/dm_model/dm_model_generator.rb | ||
generators/dm_model/templates/migration.rb | ||
generators/dm_model/templates/model.rb | ||
generators/dm_model/templates/unit_test.rb | ||
generators/rspec_dm_model/rspec_dm_model_generator.rb | ||
generators/rspec_dm_model/templates/model.rb | ||
generators/rspec_dm_model/templates/model_spec.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
This is a Rails plugin that provides datamapper as an orm | ||
|
||
== Setup | ||
|
||
add the following line to your projects environment.rb | ||
|
||
config.gem "rails_datamapper" | ||
|
||
== Generators | ||
|
||
Two generators are added by default | ||
|
||
script/generate dm_model | ||
script/generate rspec_dm_model | ||
|
||
These by default add an active record migrations but you can call | ||
|
||
script/generate dm_model --skip-migration | ||
script/generate rspec_dm_model --skip-migration | ||
|
||
To avoid any dependency on active record add this to your projects environment.rb | ||
|
||
config.frameworks -= [ :active_record ] | ||
|
||
== Future | ||
I really should sort out migrations but with rails3 round the corner don't hold your breath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'pathname' | ||
require 'rubygems' | ||
|
||
ROOT = Pathname(__FILE__).dirname.expand_path | ||
JRUBY = RUBY_PLATFORM =~ /java/ | ||
WINDOWS = Gem.win_platform? | ||
SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS']) | ||
|
||
require ROOT + 'lib/rails_datamapper/version' | ||
|
||
AUTHOR = 'Tom Malone' | ||
EMAIL = 'tomjmalone [a] gmail [d] com' | ||
GEM_NAME = 'rails_datamapper' | ||
GEM_VERSION = DataMapper::RailsDatamapper::VERSION | ||
GEM_DEPENDENCIES = [['dm-core', "~>#{GEM_VERSION}"]] | ||
GEM_CLEAN = %w[ pkg ] | ||
GEM_EXTRAS = { :has_rdoc => false, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] } | ||
|
||
PROJECT_NAME = 'datamapper' | ||
PROJECT_URL = "http://github.com/sam/dm-more/tree/master/#{GEM_NAME}" | ||
PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'Rails Plugin for datamapper' | ||
|
||
[ ROOT, ROOT.parent ].each do |dir| | ||
Pathname.glob(dir.join('tasks/**/*.rb').to_s).each { |f| require f } | ||
end |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,5 @@ | ||
def config_file() | ||
Rails.root + "/config/database.yml" | ||
end | ||
|
||
def create_connection() | ||
conf = config.dup | ||
repositories = conf.delete(:repositories) | ||
::DataMapper.setup(:default, conf) unless conf.empty? | ||
end | ||
|
||
def get_config_for_environment | ||
if hash = full_config[RAILS_ENV] | ||
symbolize_keys(hash) | ||
elsif hash = full_config[RAILS_ENV.to_sym] | ||
hash | ||
else | ||
raise ArgumentError, "missing environment '#{RAILS_ENV}' in config file #{config_file}" | ||
end | ||
end | ||
|
||
def full_config | ||
@full_config ||= YAML::load(ERB.new(IO.read(config_file)).result) | ||
end | ||
|
||
def config | ||
@config ||= get_config_for_environment | ||
end | ||
|
||
def symbolize_keys(h) | ||
config = {} | ||
|
||
h.each do |k, v| | ||
if k == 'port' | ||
config[k.to_sym] = v.to_i | ||
elsif k == 'adapter' && v == 'postgresql' | ||
config[k.to_sym] = 'postgres' | ||
elsif v.is_a?(Hash) | ||
config[k.to_sym] = symbolize_keys(v) | ||
else | ||
config[k.to_sym] = v | ||
end | ||
end | ||
|
||
config | ||
end | ||
gem 'dm-core', '~>0.9.11' | ||
require 'pathname' | ||
require 'dm-core' | ||
require Pathname(__FILE__).dirname.expand_path / 'rails_datamapper/rails_datamapper' | ||
create_connection() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
def config_file() | ||
Rails.root + "/config/database.yml" | ||
end | ||
|
||
def create_connection() | ||
conf = config.dup | ||
repositories = conf.delete(:repositories) | ||
::DataMapper.setup(:default, conf) unless conf.empty? | ||
end | ||
|
||
def get_config_for_environment | ||
if hash = full_config[RAILS_ENV] | ||
symbolize_keys(hash) | ||
elsif hash = full_config[RAILS_ENV.to_sym] | ||
hash | ||
else | ||
raise ArgumentError, "missing environment '#{RAILS_ENV}' in config file #{config_file}" | ||
end | ||
end | ||
|
||
def full_config | ||
@full_config ||= YAML::load(ERB.new(IO.read(config_file)).result) | ||
end | ||
|
||
def config | ||
@config ||= get_config_for_environment | ||
end | ||
|
||
def symbolize_keys(h) | ||
config = {} | ||
|
||
h.each do |k, v| | ||
if k == 'port' | ||
config[k.to_sym] = v.to_i | ||
elsif k == 'adapter' && v == 'postgresql' | ||
config[k.to_sym] = 'postgres' | ||
elsif v.is_a?(Hash) | ||
config[k.to_sym] = symbolize_keys(v) | ||
else | ||
config[k.to_sym] = v | ||
end | ||
end | ||
|
||
config | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module DataMapper | ||
module RailsDatamapper | ||
VERSION = '0.9.11' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def sudo_gem(cmd) | ||
sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false | ||
end | ||
|
||
desc "Install #{GEM_NAME} #{GEM_VERSION}" | ||
task :install => [ :package ] do | ||
sudo_gem "install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources" | ||
end | ||
|
||
desc "Uninstall #{GEM_NAME} #{GEM_VERSION}" | ||
task :uninstall => [ :clobber ] do | ||
sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -Ix" | ||
end |