acts_as_working_days 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +13 -0
- data/Rakefile +23 -0
- data/acts_as_working_days.gemspec +29 -0
- data/init.rb +9 -0
- data/install.rb +1 -0
- data/lib/acts_as_working_days.rb +43 -0
- data/lib/generators/acts_as_working_days/migration/migration_generator.rb +32 -0
- data/lib/generators/acts_as_working_days/migration/templates/active_record/migration.rb +25 -0
- data/lib/tasks/acts_as_working_days_tasks.rake +14 -0
- data/rails/init.rb +1 -0
- data/test/acts_as_working_days_plugin.sqlite3.db +0 -0
- data/test/acts_as_working_days_test.rb +76 -0
- data/test/database.yml +23 -0
- data/test/debug.log +161 -0
- data/test/schema.rb +18 -0
- data/test/test_helper.rb +34 -0
- data/test/working_day_test.rb +9 -0
- data/uninstall.rb +1 -0
- metadata +85 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Pablo Cantero
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the acts_as_working_days plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the acts_as_working_days plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'ActsAsWorkingDays'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rake/gempackagetask'
|
2
|
+
|
3
|
+
PKG_FILES = FileList[
|
4
|
+
'[a-zA-Z]*',
|
5
|
+
'generators/**/*',
|
6
|
+
'lib/**/*',
|
7
|
+
'rails/**/*',
|
8
|
+
'tasks/**/*',
|
9
|
+
'test/**/*'
|
10
|
+
]
|
11
|
+
|
12
|
+
spec = Gem::Specification.new do |s|
|
13
|
+
s.name = "acts_as_working_days"
|
14
|
+
s.version = "0.0.1"
|
15
|
+
s.author = "Pablo Cantero"
|
16
|
+
s.email = "pablo@pablocantero.com"
|
17
|
+
s.homepage = "http://pablocantero.com/"
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.summary = "acts_as_working_days is a Rails plugin to add working days on models"
|
20
|
+
s.files = PKG_FILES.to_a
|
21
|
+
s.require_path = "lib"
|
22
|
+
s.has_rdoc = false
|
23
|
+
s.extra_rdoc_files = ["README.rdoc"]
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Turn this plugin into a gem.'
|
27
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
28
|
+
pkg.gem_spec = spec
|
29
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'acts_as_working_days'
|
2
|
+
|
3
|
+
#TODO Não é vendor/plugins/yaffle/lib/yaffle.rb: - Conforme o Guia
|
4
|
+
%w{ models }.each do |dir|
|
5
|
+
path = File.join(File.dirname(__FILE__), 'app', dir)
|
6
|
+
$LOAD_PATH << path
|
7
|
+
ActiveSupport::Dependencies.load_paths << path
|
8
|
+
ActiveSupport::Dependencies.load_once_paths.delete(path)
|
9
|
+
end
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module ActsAsWorkingDays
|
2
|
+
def self.included(base)
|
3
|
+
base.send :extend, ClassMethods
|
4
|
+
end
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
# any method placed here will apply to classes, like Hickwall
|
8
|
+
def acts_as_working_days
|
9
|
+
# adding relationship to self class
|
10
|
+
has_many :working_days, :as => :workable
|
11
|
+
send :include, InstanceMethods
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module InstanceMethods
|
16
|
+
def working_day?(params ={:week_day => Time.now.wday, :hour => Time.now.hour, :min => Time.now.min })
|
17
|
+
result = working_days.where("week_day = :week_day AND ((start_hour < :hour) OR (start_hour = :hour AND start_min <= :min)) AND ((end_hour > :hour) OR (end_hour = :hour AND end_min <= :min))",
|
18
|
+
{
|
19
|
+
:week_day => params[:week_day],
|
20
|
+
:hour => params[:hour],
|
21
|
+
:min => params[:min]
|
22
|
+
})
|
23
|
+
!result.empty?
|
24
|
+
end
|
25
|
+
|
26
|
+
def put_working_day(params = {:week_day => Time.now.wday, :start_hour => 0, :start_min => 0, :end_hour => 23, :end_min => 59})
|
27
|
+
working_day = nil
|
28
|
+
working_days.each do | wd |
|
29
|
+
if wd.week_day == params[:week_day]
|
30
|
+
working_day = wd
|
31
|
+
break
|
32
|
+
end
|
33
|
+
end
|
34
|
+
if working_day.nil?
|
35
|
+
working_days.build(params)
|
36
|
+
else
|
37
|
+
working_day.update_attributes(params)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
ActiveRecord::Base.send :include, ActsAsWorkingDays
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module ActsAsWorkingDays
|
4
|
+
class MigrationGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
desc "Generates migration for Tag and Tagging models"
|
8
|
+
|
9
|
+
def self.orm
|
10
|
+
Rails::Generators.options[:rails][:orm]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)) )
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.orm_has_migration?
|
18
|
+
[:active_record].include? orm
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.next_migration_number(path)
|
22
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_migration_file
|
26
|
+
if self.class.orm_has_migration?
|
27
|
+
migration_template 'migration.rb', 'db/migrate/acts_as_working_days_migration'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class ActsAsWorkingDaysMigration < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table :working_days, :force => true do |t|
|
5
|
+
#Date time columns
|
6
|
+
t.integer :week_day
|
7
|
+
t.integer :start_hour
|
8
|
+
t.integer :start_min
|
9
|
+
t.integer :end_hour
|
10
|
+
t.integer :end_min
|
11
|
+
#Polymorphic columns
|
12
|
+
t.integer :workable_id
|
13
|
+
t.string :workable_type
|
14
|
+
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
add_index :working_days, [:workable_id, :workable_type]
|
20
|
+
|
21
|
+
def self.down
|
22
|
+
drop_table :working_days
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# namespace :db do
|
2
|
+
# namespace :migrate do
|
3
|
+
# description = "Migrate the database through scripts in vendor/plugins/acts_as_working_days/lib/db/migrate"
|
4
|
+
# description << "and update db/schema.rb by invoking db:schema:dump."
|
5
|
+
# description << "Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
6
|
+
#
|
7
|
+
# desc description
|
8
|
+
# task :act_as_working_days => :environment do
|
9
|
+
# ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
10
|
+
# ActiveRecord::Migrator.migrate("vendor/plugins/acts_as_working_days/lib/db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
11
|
+
# Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
12
|
+
# end
|
13
|
+
# end
|
14
|
+
# end
|
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'acts_as_working_days'
|
Binary file
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class ActsAsWorkingDaysTest < Test::Unit::TestCase
|
4
|
+
load_schema
|
5
|
+
|
6
|
+
# called before every single test
|
7
|
+
def setup
|
8
|
+
#@nuclear_power_plant = Company.new(:name => 'Springfield Nuclear Power Plant')
|
9
|
+
#@nuclear_power_plant.save
|
10
|
+
Company.delete_all
|
11
|
+
end
|
12
|
+
|
13
|
+
class Company < ActiveRecord::Base
|
14
|
+
acts_as_working_days
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_schema_has_loaded_correctly
|
18
|
+
assert_equal [], Company.all
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_put_working_day
|
22
|
+
the_leftorium = Company.new(:name => 'The Leftorium')
|
23
|
+
assert_equal [], the_leftorium.working_days
|
24
|
+
working_day = the_leftorium.put_working_day(:week_day => 0, :start_hour => 8, :start_min => 30, :end_hour => 18, :end_min => 45)
|
25
|
+
the_leftorium.save
|
26
|
+
assert_equal [working_day], the_leftorium.working_days
|
27
|
+
assert_equal 0, working_day.week_day
|
28
|
+
assert_equal 8, working_day.start_hour
|
29
|
+
assert_equal 30, working_day.start_min
|
30
|
+
assert_equal 18, working_day.end_hour
|
31
|
+
assert_equal 45, working_day.end_min
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_put_updating_a_working_day
|
35
|
+
moes_tavern = Company.new(:name => 'Moes Tavern')
|
36
|
+
working_day = moes_tavern.put_working_day(:week_day => 0, :start_hour => 8, :start_min => 30, :end_hour => 18, :end_min => 45)
|
37
|
+
moes_tavern.save
|
38
|
+
#Updating working day
|
39
|
+
moes_tavern.put_working_day(:week_day => 0, :start_hour => 10, :start_min => 13, :end_hour => 19, :end_min => 23)
|
40
|
+
moes_tavern.save
|
41
|
+
working_day = moes_tavern.working_days.first
|
42
|
+
assert_equal 0, working_day.week_day
|
43
|
+
assert_equal 10, working_day.start_hour
|
44
|
+
assert_equal 13, working_day.start_min
|
45
|
+
assert_equal 19, working_day.end_hour
|
46
|
+
assert_equal 23, working_day.end_min
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_true_working_day
|
50
|
+
moes_tavern = Company.new(:name => 'Moes Tavern')
|
51
|
+
moes_tavern.put_working_day(:week_day => 0, :start_hour => 8, :start_min => 30, :end_hour => 18, :end_min => 45)
|
52
|
+
moes_tavern.save
|
53
|
+
assert_equal true, moes_tavern.working_day?(:week_day => 0, :hour => 12, :minute => 0)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_uniqueness_week_day_per_model
|
57
|
+
nuclear_power_plant = Company.new(:name => 'Springfield Nuclear Power Plant')
|
58
|
+
working_day = nuclear_power_plant.put_working_day(:week_day => 0, :start_hour => 8, :start_min => 30, :end_hour => 18, :end_min => 45)
|
59
|
+
nuclear_power_plant.put_working_day(:week_day => 0, :start_hour => 9, :start_min => 15, :end_hour => 19, :end_min => 30)
|
60
|
+
nuclear_power_plant.save
|
61
|
+
assert_equal [working_day], nuclear_power_plant.working_days
|
62
|
+
nuclear_power_plant.put_working_day(:week_day => 0, :start_hour => 6, :start_min => 0, :end_hour => 16, :end_min => 15)
|
63
|
+
nuclear_power_plant.save
|
64
|
+
assert_equal [working_day], nuclear_power_plant.working_days
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_false_working_day
|
68
|
+
kwik_e_mart = Company.new(:name => 'Kwik-E-Mart')
|
69
|
+
kwik_e_mart.put_working_day(:week_day => 1, :start_hour => 8, :start_min => 30, :end_hour => 18, :end_min => 45)
|
70
|
+
kwik_e_mart.save
|
71
|
+
assert_equal false, kwik_e_mart.working_day?(:week_day => 0, :hour => 12, :min => 0)
|
72
|
+
assert_equal false, kwik_e_mart.working_day?(:week_day => 1, :hour => 21)
|
73
|
+
assert_equal false, kwik_e_mart.working_day?(:week_day => 1, :hour => 7, :min => 15)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
data/test/database.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
sqlite:
|
2
|
+
:adapter: sqlite
|
3
|
+
#TODO Não é dbfile como no guide
|
4
|
+
:database: vendor/plugins/acts_as_working_days/test/acts_as_working_days_plugin.sqlite.db
|
5
|
+
|
6
|
+
sqlite3:
|
7
|
+
:adapter: sqlite3
|
8
|
+
#TODO Não é dbfile como no guide
|
9
|
+
:database: vendor/plugins/acts_as_working_days/test/acts_as_working_days_plugin.sqlite3.db
|
10
|
+
|
11
|
+
postgresql:
|
12
|
+
:adapter: postgresql
|
13
|
+
:username: postgres
|
14
|
+
:password: postgres
|
15
|
+
:database: acts_as_working_days_test
|
16
|
+
:min_messages: ERROR
|
17
|
+
|
18
|
+
mysql:
|
19
|
+
:adapter: mysql
|
20
|
+
:host: localhost
|
21
|
+
:username: root
|
22
|
+
:password: password
|
23
|
+
:database: acts_as_working_days_test
|
data/test/debug.log
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
# Logfile created on Fri Nov 19 18:17:34 -0200 2010 by logger.rb/22285
|
2
|
+
[1m[36mSQL (0.3ms)[0m [1mselect sqlite_version(*)[0m
|
3
|
+
[1m[35mSQL (0.4ms)[0m SELECT name
|
4
|
+
FROM sqlite_master
|
5
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
6
|
+
|
7
|
+
[1m[36mSQL (2.4ms)[0m [1mCREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
8
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
9
|
+
FROM sqlite_master
|
10
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
11
|
+
|
12
|
+
[1m[36mSQL (1.3ms)[0m [1mCREATE TABLE "working_days" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "week_day" integer, "start_hour" integer, "start_min" integer, "end_hour" integer, "end_min" integer, "workable_id" integer, "workable_type" varchar(255), "created_at" datetime, "updated_at" datetime) [0m
|
13
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
14
|
+
FROM sqlite_master
|
15
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
16
|
+
|
17
|
+
[1m[36mSQL (1.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
18
|
+
[1m[35mSQL (0.1ms)[0m PRAGMA index_list("schema_migrations")
|
19
|
+
[1m[36mSQL (1.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
20
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
21
|
+
FROM sqlite_master
|
22
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
23
|
+
|
24
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
25
|
+
[1m[35mSQL (1.0ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('0')
|
26
|
+
[1m[36mSQL (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
27
|
+
[1m[35mSQL (0.3ms)[0m SELECT name
|
28
|
+
FROM sqlite_master
|
29
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
30
|
+
|
31
|
+
[1m[36mSQL (2.0ms)[0m [1mDROP TABLE "companies"[0m
|
32
|
+
[1m[35mSQL (1.2ms)[0m CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
|
33
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
34
|
+
FROM sqlite_master
|
35
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
36
|
+
[0m
|
37
|
+
[1m[35mSQL (1.1ms)[0m DROP TABLE "working_days"
|
38
|
+
[1m[36mSQL (1.3ms)[0m [1mCREATE TABLE "working_days" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "week_day" integer, "start_hour" integer, "start_min" integer, "end_hour" integer, "end_min" integer, "workable_id" integer, "workable_type" varchar(255), "created_at" datetime, "updated_at" datetime) [0m
|
39
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
40
|
+
FROM sqlite_master
|
41
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
42
|
+
|
43
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
44
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
45
|
+
FROM sqlite_master
|
46
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
47
|
+
|
48
|
+
[1m[36mSQL (0.1ms)[0m [1mDELETE FROM "companies" WHERE 1=1[0m
|
49
|
+
[1m[35mWorkingDay Load (0.1ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 1) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
50
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "companies" ("name") VALUES ('Kwik-E-Mart')[0m
|
51
|
+
[1m[35mWorkingDay Load (0.1ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 1) AND ("working_days"."workable_id" = 1) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
52
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:34.276908', 18, 45, 8, 30, '2010-11-19 20:17:34.276908', 1, 1, 'ActsAsWorkingDaysTest::Company')[0m
|
53
|
+
[1m[35mSQL (0.3ms)[0m SELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "working_days" WHERE ("working_days".workable_id = 1 AND "working_days".workable_type = 'ActsAsWorkingDaysTest::Company') AND (week_day = 0 AND ((start_hour < 12) OR (start_hour = 12 AND start_min <= 0)) AND ((end_hour > 12) OR (end_hour = 12 AND end_min <= 0)))) AS subquery
|
54
|
+
[1m[36mSQL (0.3ms)[0m [1mSELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "working_days" WHERE ("working_days".workable_id = 1 AND "working_days".workable_type = 'ActsAsWorkingDaysTest::Company') AND (week_day = 1 AND ((start_hour < 21) OR (start_hour = 21 AND start_min <= NULL)) AND ((end_hour > 21) OR (end_hour = 21 AND end_min <= NULL)))) AS subquery[0m
|
55
|
+
[1m[35mSQL (0.2ms)[0m SELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "working_days" WHERE ("working_days".workable_id = 1 AND "working_days".workable_type = 'ActsAsWorkingDaysTest::Company') AND (week_day = 1 AND ((start_hour < 7) OR (start_hour = 7 AND start_min <= 15)) AND ((end_hour > 7) OR (end_hour = 7 AND end_min <= 15)))) AS subquery
|
56
|
+
[1m[36mSQL (1.2ms)[0m [1mDELETE FROM "companies" WHERE 1=1[0m
|
57
|
+
[1m[35mWorkingDay Load (0.2ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
58
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "companies" ("name") VALUES ('Moes Tavern')[0m
|
59
|
+
[1m[35mWorkingDay Load (0.1ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 2) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
60
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:34.293433', 18, 45, 8, 30, '2010-11-19 20:17:34.293433', 0, 2, 'ActsAsWorkingDaysTest::Company')[0m
|
61
|
+
[1m[35mWorkingDay Load (0.2ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 2) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') AND ("working_days".id <> 2) LIMIT 1
|
62
|
+
[1m[36mSQL (0.3ms)[0m [1mUPDATE "working_days" SET "end_hour" = 19, "end_min" = 23, "start_hour" = 10, "start_min" = 13, "updated_at" = '2010-11-19 20:17:34.300106' WHERE ("working_days"."id" = 2)[0m
|
63
|
+
[1m[35mSQL (1.0ms)[0m DELETE FROM "companies" WHERE 1=1
|
64
|
+
[1m[36mWorkingDay Load (0.2ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
65
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "companies" ("name") VALUES ('The Leftorium')
|
66
|
+
[1m[36mWorkingDay Load (0.1ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 3) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
67
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:34.309800', 18, 45, 8, 30, '2010-11-19 20:17:34.309800', 0, 3, 'ActsAsWorkingDaysTest::Company')
|
68
|
+
[1m[36mSQL (1.2ms)[0m [1mDELETE FROM "companies" WHERE 1=1[0m
|
69
|
+
[1m[35mActsAsWorkingDaysTest::Company Load (0.1ms)[0m SELECT "companies".* FROM "companies"
|
70
|
+
[1m[36mSQL (0.1ms)[0m [1mDELETE FROM "companies" WHERE 1=1[0m
|
71
|
+
[1m[35mWorkingDay Load (0.1ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
72
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "companies" ("name") VALUES ('Moes Tavern')[0m
|
73
|
+
[1m[35mWorkingDay Load (0.1ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 4) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
74
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:34.320302', 18, 45, 8, 30, '2010-11-19 20:17:34.320302', 0, 4, 'ActsAsWorkingDaysTest::Company')[0m
|
75
|
+
[1m[35mSQL (0.2ms)[0m SELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "working_days" WHERE ("working_days".workable_id = 4 AND "working_days".workable_type = 'ActsAsWorkingDaysTest::Company') AND (week_day = 0 AND ((start_hour < 12) OR (start_hour = 12 AND start_min <= NULL)) AND ((end_hour > 12) OR (end_hour = 12 AND end_min <= NULL)))) AS subquery
|
76
|
+
[1m[36mSQL (1.0ms)[0m [1mDELETE FROM "companies" WHERE 1=1[0m
|
77
|
+
[1m[35mWorkingDay Load (0.2ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
78
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:34.329076', 19, 30, 9, 15, '2010-11-19 20:17:34.329076', 0, NULL, 'ActsAsWorkingDaysTest::Company')[0m
|
79
|
+
[1m[35mWorkingDay Load (0.2ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') AND ("working_days".id <> 5) LIMIT 1
|
80
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "companies" ("name") VALUES ('Springfield Nuclear Power Plant')[0m
|
81
|
+
[1m[35mWorkingDay Load (0.1ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 5) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') AND ("working_days".id <> 5) LIMIT 1
|
82
|
+
[1m[36mSQL (0.1ms)[0m [1mUPDATE "working_days" SET "updated_at" = '2010-11-19 20:17:34.336563', "workable_id" = 5 WHERE ("working_days"."id" = 5)[0m
|
83
|
+
[1m[35mWorkingDay Load (0.2ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 5) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') AND ("working_days".id <> 5) LIMIT 1
|
84
|
+
[1m[36mSQL (0.3ms)[0m [1mUPDATE "working_days" SET "end_hour" = 16, "end_min" = 15, "start_hour" = 6, "start_min" = 0, "updated_at" = '2010-11-19 20:17:34.341172' WHERE ("working_days"."id" = 5)[0m
|
85
|
+
[1m[36mSQL (0.2ms)[0m [1mselect sqlite_version(*)[0m
|
86
|
+
[1m[35mSQL (0.4ms)[0m SELECT name
|
87
|
+
FROM sqlite_master
|
88
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
89
|
+
|
90
|
+
[1m[36mSQL (2.6ms)[0m [1mDROP TABLE "companies"[0m
|
91
|
+
[1m[35mSQL (1.1ms)[0m CREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255))
|
92
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
93
|
+
FROM sqlite_master
|
94
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
95
|
+
[0m
|
96
|
+
[1m[35mSQL (1.1ms)[0m DROP TABLE "working_days"
|
97
|
+
[1m[36mSQL (1.3ms)[0m [1mCREATE TABLE "working_days" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "week_day" integer, "start_hour" integer, "start_min" integer, "end_hour" integer, "end_min" integer, "workable_id" integer, "workable_type" varchar(255), "created_at" datetime, "updated_at" datetime) [0m
|
98
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
99
|
+
FROM sqlite_master
|
100
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
101
|
+
|
102
|
+
[1m[36mSQL (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
103
|
+
[1m[35mSQL (0.1ms)[0m select sqlite_version(*)
|
104
|
+
[1m[36mSQL (0.3ms)[0m [1m SELECT name
|
105
|
+
FROM sqlite_master
|
106
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
107
|
+
[0m
|
108
|
+
[1m[35mSQL (1.2ms)[0m DROP TABLE "companies"
|
109
|
+
[1m[36mSQL (1.0ms)[0m [1mCREATE TABLE "companies" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
110
|
+
[1m[35mSQL (0.2ms)[0m SELECT name
|
111
|
+
FROM sqlite_master
|
112
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
113
|
+
|
114
|
+
[1m[36mSQL (1.4ms)[0m [1mDROP TABLE "working_days"[0m
|
115
|
+
[1m[35mSQL (1.5ms)[0m CREATE TABLE "working_days" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "week_day" integer, "start_hour" integer, "start_min" integer, "end_hour" integer, "end_min" integer, "workable_id" integer, "workable_type" varchar(255), "created_at" datetime, "updated_at" datetime)
|
116
|
+
[1m[36mSQL (0.4ms)[0m [1m SELECT name
|
117
|
+
FROM sqlite_master
|
118
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
119
|
+
[0m
|
120
|
+
[1m[35mSQL (0.1ms)[0m SELECT version FROM "schema_migrations"
|
121
|
+
[1m[36mSQL (0.2ms)[0m [1m SELECT name
|
122
|
+
FROM sqlite_master
|
123
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
124
|
+
[0m
|
125
|
+
[1m[35mSQL (0.1ms)[0m DELETE FROM "companies" WHERE 1=1
|
126
|
+
[1m[36mWorkingDay Load (0.1ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 1) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
127
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "companies" ("name") VALUES ('Kwik-E-Mart')
|
128
|
+
[1m[36mWorkingDay Load (0.1ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 1) AND ("working_days"."workable_id" = 1) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
129
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:39.252654', 18, 45, 8, 30, '2010-11-19 20:17:39.252654', 1, 1, 'ActsAsWorkingDaysTest::Company')
|
130
|
+
[1m[36mSQL (0.3ms)[0m [1mSELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "working_days" WHERE ("working_days".workable_id = 1 AND "working_days".workable_type = 'ActsAsWorkingDaysTest::Company') AND (week_day = 0 AND ((start_hour < 12) OR (start_hour = 12 AND start_min <= 0)) AND ((end_hour > 12) OR (end_hour = 12 AND end_min <= 0)))) AS subquery[0m
|
131
|
+
[1m[35mSQL (0.2ms)[0m SELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "working_days" WHERE ("working_days".workable_id = 1 AND "working_days".workable_type = 'ActsAsWorkingDaysTest::Company') AND (week_day = 1 AND ((start_hour < 21) OR (start_hour = 21 AND start_min <= NULL)) AND ((end_hour > 21) OR (end_hour = 21 AND end_min <= NULL)))) AS subquery
|
132
|
+
[1m[36mSQL (0.2ms)[0m [1mSELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "working_days" WHERE ("working_days".workable_id = 1 AND "working_days".workable_type = 'ActsAsWorkingDaysTest::Company') AND (week_day = 1 AND ((start_hour < 7) OR (start_hour = 7 AND start_min <= 15)) AND ((end_hour > 7) OR (end_hour = 7 AND end_min <= 15)))) AS subquery[0m
|
133
|
+
[1m[35mSQL (1.1ms)[0m DELETE FROM "companies" WHERE 1=1
|
134
|
+
[1m[36mWorkingDay Load (0.2ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
135
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "companies" ("name") VALUES ('Moes Tavern')
|
136
|
+
[1m[36mWorkingDay Load (0.1ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 2) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
137
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:39.268266', 18, 45, 8, 30, '2010-11-19 20:17:39.268266', 0, 2, 'ActsAsWorkingDaysTest::Company')
|
138
|
+
[1m[36mWorkingDay Load (0.2ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 2) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') AND ("working_days".id <> 2) LIMIT 1[0m
|
139
|
+
[1m[35mSQL (0.3ms)[0m UPDATE "working_days" SET "end_hour" = 19, "end_min" = 23, "start_hour" = 10, "start_min" = 13, "updated_at" = '2010-11-19 20:17:39.273344' WHERE ("working_days"."id" = 2)
|
140
|
+
[1m[36mSQL (1.1ms)[0m [1mDELETE FROM "companies" WHERE 1=1[0m
|
141
|
+
[1m[35mWorkingDay Load (0.2ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
142
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "companies" ("name") VALUES ('The Leftorium')[0m
|
143
|
+
[1m[35mWorkingDay Load (0.1ms)[0m SELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 3) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1
|
144
|
+
[1m[36mSQL (0.1ms)[0m [1mINSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:39.283311', 18, 45, 8, 30, '2010-11-19 20:17:39.283311', 0, 3, 'ActsAsWorkingDaysTest::Company')[0m
|
145
|
+
[1m[35mSQL (1.1ms)[0m DELETE FROM "companies" WHERE 1=1
|
146
|
+
[1m[36mActsAsWorkingDaysTest::Company Load (0.1ms)[0m [1mSELECT "companies".* FROM "companies"[0m
|
147
|
+
[1m[35mSQL (0.1ms)[0m DELETE FROM "companies" WHERE 1=1
|
148
|
+
[1m[36mWorkingDay Load (0.2ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
149
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "companies" ("name") VALUES ('Moes Tavern')
|
150
|
+
[1m[36mWorkingDay Load (0.1ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 4) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
151
|
+
[1m[35mSQL (0.1ms)[0m INSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:39.294696', 18, 45, 8, 30, '2010-11-19 20:17:39.294696', 0, 4, 'ActsAsWorkingDaysTest::Company')
|
152
|
+
[1m[36mSQL (0.3ms)[0m [1mSELECT COUNT(*) AS count_id FROM (SELECT 1 FROM "working_days" WHERE ("working_days".workable_id = 4 AND "working_days".workable_type = 'ActsAsWorkingDaysTest::Company') AND (week_day = 0 AND ((start_hour < 12) OR (start_hour = 12 AND start_min <= NULL)) AND ((end_hour > 12) OR (end_hour = 12 AND end_min <= NULL)))) AS subquery[0m
|
153
|
+
[1m[35mSQL (1.1ms)[0m DELETE FROM "companies" WHERE 1=1
|
154
|
+
[1m[36mWorkingDay Load (0.2ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') LIMIT 1[0m
|
155
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "working_days" ("created_at", "end_hour", "end_min", "start_hour", "start_min", "updated_at", "week_day", "workable_id", "workable_type") VALUES ('2010-11-19 20:17:39.304368', 19, 30, 9, 15, '2010-11-19 20:17:39.304368', 0, NULL, 'ActsAsWorkingDaysTest::Company')
|
156
|
+
[1m[36mWorkingDay Load (0.2ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" IS NULL) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') AND ("working_days".id <> 5) LIMIT 1[0m
|
157
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "companies" ("name") VALUES ('Springfield Nuclear Power Plant')
|
158
|
+
[1m[36mWorkingDay Load (0.1ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 5) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') AND ("working_days".id <> 5) LIMIT 1[0m
|
159
|
+
[1m[35mSQL (0.1ms)[0m UPDATE "working_days" SET "updated_at" = '2010-11-19 20:17:39.312441', "workable_id" = 5 WHERE ("working_days"."id" = 5)
|
160
|
+
[1m[36mWorkingDay Load (0.2ms)[0m [1mSELECT "working_days"."id" FROM "working_days" WHERE ("working_days"."week_day" = 0) AND ("working_days"."workable_id" = 5) AND ("working_days"."workable_type" = 'ActsAsWorkingDaysTest::Company') AND ("working_days".id <> 5) LIMIT 1[0m
|
161
|
+
[1m[35mSQL (0.3ms)[0m UPDATE "working_days" SET "end_hour" = 16, "end_min" = 15, "start_hour" = 6, "start_min" = 0, "updated_at" = '2010-11-19 20:17:39.317952' WHERE ("working_days"."id" = 5)
|
data/test/schema.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
ActiveRecord::Schema.define(:version => 0) do
|
2
|
+
create_table :companies, :force => true do |t|
|
3
|
+
t.string :name
|
4
|
+
end
|
5
|
+
create_table :working_days, :force => true do |t|
|
6
|
+
#Date time columns
|
7
|
+
t.integer :week_day
|
8
|
+
t.integer :start_hour
|
9
|
+
t.integer :start_min
|
10
|
+
t.integer :end_hour
|
11
|
+
t.integer :end_min
|
12
|
+
#Polymorphic columns
|
13
|
+
t.integer :workable_id
|
14
|
+
t.string :workable_type
|
15
|
+
|
16
|
+
t.timestamps
|
17
|
+
end
|
18
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
2
|
+
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
|
6
|
+
|
7
|
+
def load_schema
|
8
|
+
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
9
|
+
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
10
|
+
|
11
|
+
db_adapter = ENV['DB']
|
12
|
+
|
13
|
+
# no db passed, try one of these fine config-free DBs before bombing.
|
14
|
+
db_adapter ||=
|
15
|
+
begin
|
16
|
+
require 'rubygems'
|
17
|
+
require 'sqlite'
|
18
|
+
'sqlite'
|
19
|
+
rescue MissingSourceFile
|
20
|
+
begin
|
21
|
+
require 'sqlite3'
|
22
|
+
'sqlite3'
|
23
|
+
rescue MissingSourceFile
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if db_adapter.nil?
|
28
|
+
raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
|
29
|
+
end
|
30
|
+
|
31
|
+
ActiveRecord::Base.establish_connection(config[db_adapter])
|
32
|
+
load(File.dirname(__FILE__) + "/schema.rb")
|
33
|
+
require File.dirname(__FILE__) + '/../rails/init'
|
34
|
+
end
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_working_days
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Pablo Cantero
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-19 00:00:00 -02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: pablo@pablocantero.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- acts_as_working_days.gemspec
|
32
|
+
- init.rb
|
33
|
+
- install.rb
|
34
|
+
- MIT-LICENSE
|
35
|
+
- Rakefile
|
36
|
+
- README.rdoc
|
37
|
+
- uninstall.rb
|
38
|
+
- lib/acts_as_working_days.rb
|
39
|
+
- lib/generators/acts_as_working_days/migration/migration_generator.rb
|
40
|
+
- lib/generators/acts_as_working_days/migration/templates/active_record/migration.rb
|
41
|
+
- lib/tasks/acts_as_working_days_tasks.rake
|
42
|
+
- rails/init.rb
|
43
|
+
- test/acts_as_working_days_plugin.sqlite3.db
|
44
|
+
- test/acts_as_working_days_test.rb
|
45
|
+
- test/database.yml
|
46
|
+
- test/debug.log
|
47
|
+
- test/schema.rb
|
48
|
+
- test/test_helper.rb
|
49
|
+
- test/working_day_test.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://pablocantero.com/
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.3.7
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: acts_as_working_days is a Rails plugin to add working days on models
|
84
|
+
test_files: []
|
85
|
+
|