Initial work for re-packaging as gem.
This commit is contained in:
parent
3820a5cdb6
commit
42175ca94a
23
.gitignore
vendored
23
.gitignore
vendored
|
@ -1,2 +1,23 @@
|
|||
## MAC OS
|
||||
.DS_Store
|
||||
|
||||
## TEXTMATE
|
||||
*.tmproj
|
||||
tmtags
|
||||
|
||||
## EMACS
|
||||
*~
|
||||
\#*
|
||||
.\#*
|
||||
|
||||
## VIM
|
||||
*.swp
|
||||
|
||||
## PROJECT::GENERAL
|
||||
coverage
|
||||
rdoc
|
||||
pkg
|
||||
|
||||
## PROJECT::SPECIFIC
|
||||
log/*.log
|
||||
test.db
|
||||
test.db
|
||||
|
|
18
Gemfile
18
Gemfile
|
@ -1,5 +1,17 @@
|
|||
source :gemcutter
|
||||
|
||||
gem "rails", "= 3.0.0rc"
|
||||
gem "factory_girl", "= 1.3.2"
|
||||
gem "delorean", :version => "= 0.2.0"
|
||||
gem "rails", ">= 3.0.0.rc"
|
||||
|
||||
group :test do
|
||||
# Database Adapters
|
||||
gem "mysql", ">= 2.8.1"
|
||||
gem "pg", ">= 0.9.0"
|
||||
gem "sqlite3-ruby", ">= 1.3.1"
|
||||
|
||||
# Support libs
|
||||
gem "factory_girl", ">= 1.3.2"
|
||||
gem "delorean", ">= 0.2.0"
|
||||
|
||||
# Debugging
|
||||
gem "ruby-debug", ">= 0.9.3"
|
||||
end
|
||||
|
|
48
Rakefile
48
Rakefile
|
@ -1,8 +1,26 @@
|
|||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'rake/testtask'
|
||||
|
||||
task :default => ["display:notice"]
|
||||
begin
|
||||
require 'jeweler'
|
||||
require 'bundler'
|
||||
Jeweler::Tasks.new do |gem|
|
||||
gem.name = "activerecord-import"
|
||||
gem.summary = %Q{Bulk-loading extension for ActiveRecord}
|
||||
gem.description = %Q{Extraction of the ActiveRecord::Base#import functionality from ar-extensions for Rails 3 and beyond}
|
||||
gem.email = "zach.dennis@gmail.com"
|
||||
gem.homepage = "http://github.com/zdennis/activerecord-import"
|
||||
gem.authors = ["Zach Dennis"]
|
||||
gem.files = FileList["VERSION", "Rakefile", "README*", "lib/**/*"]
|
||||
gem.add_bundler_dependencies
|
||||
|
||||
ADAPTERS = %w(mysql postgresql sqlite3)
|
||||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
||||
end
|
||||
Jeweler::GemcutterTasks.new
|
||||
rescue LoadError
|
||||
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
||||
end
|
||||
|
||||
namespace :display do
|
||||
task :notice do
|
||||
|
@ -11,12 +29,38 @@ namespace :display do
|
|||
puts
|
||||
end
|
||||
end
|
||||
task :default => ["display:notice"]
|
||||
|
||||
ADAPTERS = %w(mysql postgresql sqlite3)
|
||||
ADAPTERS.each do |adapter|
|
||||
namespace :test do
|
||||
desc "Runs #{adapter} database tests."
|
||||
Rake::TestTask.new(adapter) do |t|
|
||||
t.test_files = FileList["test/adapters/#{adapter}.rb", "test/*_test.rb", "test/#{adapter}/**/*_test.rb"]
|
||||
end
|
||||
task adapter => :check_dependencies
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
require 'rcov/rcovtask'
|
||||
Rcov::RcovTask.new do |test|
|
||||
test.libs << 'test'
|
||||
test.pattern = "test/*_test.rb"
|
||||
test.verbose = true
|
||||
end
|
||||
rescue LoadError
|
||||
task :rcov do
|
||||
abort "RCov is not available. In order to run rcov, you must: sudo gem install rcov"
|
||||
end
|
||||
end
|
||||
|
||||
require 'rake/rdoctask'
|
||||
Rake::RDocTask.new do |rdoc|
|
||||
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
||||
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = "activerecord-import #{version}"
|
||||
rdoc.rdoc_files.include('README*')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
||||
require File.expand_path('../test_helper', __FILE__)
|
||||
|
||||
describe "#import" do
|
||||
it "should return the number of inserts performed" do
|
||||
|
|
|
@ -5,7 +5,7 @@ class ActiveSupport::TestCase
|
|||
factory_girl_args = args.shift || {}
|
||||
|
||||
if n
|
||||
returning Array.new do |collection|
|
||||
Array.new.tap do |collection|
|
||||
n.times.each { collection << Factory.build(factory.to_s.singularize.to_sym, factory_girl_args) }
|
||||
end
|
||||
else
|
||||
|
@ -19,7 +19,7 @@ class ActiveSupport::TestCase
|
|||
factory_girl_args = args.shift || {}
|
||||
|
||||
if n
|
||||
returning Array.new do |collection|
|
||||
Array.new.tap do |collection|
|
||||
n.times.each { collection << Factory.create(factory.to_s.singularize.to_sym, factory_girl_args) }
|
||||
end
|
||||
else
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
ENV["RAILS_ENV"] = "test"
|
||||
require 'pathname'
|
||||
this_dir = Pathname.new File.dirname(__FILE__)
|
||||
$LOAD_PATH << this_dir.join("../lib")
|
||||
test_dir = Pathname.new File.dirname(__FILE__)
|
||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
||||
|
||||
require "fileutils"
|
||||
require "rubygems"
|
||||
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
|
||||
require "bundler"
|
||||
Bundler.setup
|
||||
|
||||
gem "rails", "3.0.0.beta"
|
||||
require "rails"
|
||||
require "rails/test_help"
|
||||
require "active_record/fixtures"
|
||||
require "active_support/test_case"
|
||||
require 'active_support/core_ext/object/returning'
|
||||
|
||||
require "delorean"
|
||||
|
||||
|
@ -17,6 +23,13 @@ require "logger"
|
|||
|
||||
require "ruby-debug"
|
||||
|
||||
# load test helpers
|
||||
class MyApplication < Rails::Application ; end
|
||||
adapter = ENV["ARE_DB"] || "sqlite3"
|
||||
|
||||
# load the library
|
||||
require "activerecord-import/#{adapter}"
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
include ActiveRecord::TestFixtures
|
||||
self.use_transactional_fixtures = true
|
||||
|
@ -84,17 +97,10 @@ def describe(description, &blk)
|
|||
ActiveSupport::TestCase.describe(description, true, &blk)
|
||||
end
|
||||
|
||||
# load test helpers
|
||||
require "rails"
|
||||
class MyApplication < Rails::Application ; end
|
||||
adapter = ENV["ARE_DB"] || "sqlite3"
|
||||
|
||||
# load the library
|
||||
require "activerecord-import/#{adapter}"
|
||||
|
||||
FileUtils.mkdir_p'log'
|
||||
ActiveRecord::Base.logger = Logger.new("log/test.log")
|
||||
ActiveRecord::Base.logger.level = Logger::DEBUG
|
||||
ActiveRecord::Base.configurations["test"] = YAML.load(this_dir.join("database.yml").open)[adapter]
|
||||
ActiveRecord::Base.configurations["test"] = YAML.load(test_dir.join("database.yml").open)[adapter]
|
||||
ActiveRecord::Base.establish_connection "test"
|
||||
|
||||
ActiveSupport::Notifications.subscribe(/active_record.sql/) do |event, _, _, _, hsh|
|
||||
|
@ -105,9 +111,9 @@ require "factory_girl"
|
|||
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each{ |file| require file }
|
||||
|
||||
# Load base/generic schema
|
||||
require this_dir.join("schema/version")
|
||||
require this_dir.join("schema/generic_schema")
|
||||
adapter_schema = this_dir.join("schema/#{adapter}_schema.rb")
|
||||
require test_dir.join("schema/version")
|
||||
require test_dir.join("schema/generic_schema")
|
||||
adapter_schema = test_dir.join("schema/#{adapter}_schema.rb")
|
||||
require adapter_schema if File.exists?(adapter_schema)
|
||||
|
||||
Dir[File.dirname(__FILE__) + "/models/*.rb"].each{ |file| require file }
|
||||
|
|
Loading…
Reference in a new issue