Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
capotej committed Apr 23, 2010
0 parents commit a3def9c
Show file tree
Hide file tree
Showing 14 changed files with 252 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2010 [name of plugin creator]

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.
13 changes: 13 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Existential
===========

Introduction goes here.


Example
=======

Example goes here.


Copyright (c) 2010 [name of plugin creator], released under the MIT license
23 changes: 23 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

desc 'Default: run unit tests.'
task :default => :test

desc 'Test the existential plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

desc 'Generate documentation for the existential plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Existential'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
1 change: 1 addition & 0 deletions install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Install hook code here
1 change: 1 addition & 0 deletions lib/existential.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Existential
1 change: 1 addition & 0 deletions rails/init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Include hook code here
4 changes: 4 additions & 0 deletions tasks/existential_tasks.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :existential do
# # Task goes here
# end
3 changes: 3 additions & 0 deletions test/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sqlite3:
adapter: sqlite3
database: vendor/plugins/existential/test/existential_plugin.sqlite3
116 changes: 116 additions & 0 deletions test/debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Logfile created on Thu Apr 22 20:13:13 -0700 2010 by logger.rb/22283
SQL (0.2ms) select sqlite_version(*)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.0ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.7ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "user_id" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
SQL (1.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) SELECT version FROM "schema_migrations"
SQL (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
SQL (0.2ms) select sqlite_version(*)
SQL (0.6ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.9ms) DROP TABLE "users"
SQL (0.9ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.0ms) DROP TABLE "posts"
SQL (1.0ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "user_id" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) SELECT version FROM "schema_migrations"
SQL (0.2ms) select sqlite_version(*)
SQL (0.5ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.3ms) DROP TABLE "users"
SQL (0.9ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.0ms) DROP TABLE "posts"
SQL (1.0ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "user_id" varchar(255)) 
SQL (0.3ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) SELECT version FROM "schema_migrations"
SQL (0.2ms) select sqlite_version(*)
SQL (0.6ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.5ms) DROP TABLE "users"
SQL (1.0ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.0ms) DROP TABLE "posts"
SQL (0.9ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "user_id" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) SELECT version FROM "schema_migrations"
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.3ms) DROP TABLE "users"
SQL (0.9ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
SQL (0.3ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.9ms) DROP TABLE "posts"
SQL (0.9ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "user_id" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) SELECT version FROM "schema_migrations"
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.3ms) DROP TABLE "users"
SQL (1.0ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) 
SQL (0.3ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (1.0ms) DROP TABLE "posts"
SQL (0.9ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "user_id" varchar(255)) 
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.4ms) SELECT version FROM "schema_migrations"
ExistentialTest::User Load (0.2ms) SELECT * FROM "users" 
ExistentialTest::Post Load (0.1ms) SELECT * FROM "posts" 
Binary file added test/existential_plugin.sqlite3
Binary file not shown.
19 changes: 19 additions & 0 deletions test/existential_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'test/unit'
require 'test_helper'

class ExistentialTest < Test::Unit::TestCase
load_schema

class User < ActiveRecord::Base
end

class Post < ActiveRecord::Base
end

def test_schema_loaded_correctly
assert_equal [], User.all
assert_equal [], Post.all
end


end
13 changes: 13 additions & 0 deletions test/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ActiveRecord::Schema.define(:version => 0) do
create_table :users, :force => true do |t|
t.string :name
end

create_table :posts, :force => true do |t|
t.string :name
t.string :user_id
end



end
37 changes: 37 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'rubygems'
require 'active_support'
require 'active_support/test_case'

ENV['RAILS_ENV'] = 'test'
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'

require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))

def load_schema
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")

db_adapter = ENV['DB']

# no db passed, try one of these fine config-free DBs before bombing.
db_adapter ||=
begin
require 'rubygems'
require 'sqlite'
'sqlite'
rescue MissingSourceFile
begin
require 'sqlite3'
'sqlite3'
rescue MissingSourceFile
end
end

if db_adapter.nil?
raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
end

ActiveRecord::Base.establish_connection(config[db_adapter])
load(File.dirname(__FILE__) + "/schema.rb")
require File.dirname(__FILE__) + '/../rails/init.rb'
end
1 change: 1 addition & 0 deletions uninstall.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Uninstall hook code here

0 comments on commit a3def9c

Please sign in to comment.