Empact-trackless_triggers 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ github-test.rb
data/CHANGELOG ADDED
@@ -0,0 +1,20 @@
1
+ = CHANGELOG
2
+
3
+ == 0.0.6
4
+
5
+ * Fix runtime & require issues
6
+
7
+
8
+ == 0.0.5
9
+
10
+ * Cleanup pkg/
11
+
12
+
13
+ == 0.0.2
14
+
15
+ * Convert to gem on github
16
+
17
+ == 0.0.1
18
+
19
+ * Birthday!
20
+
@@ -0,0 +1,45 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{Empact-trackless_triggers}
8
+ s.version = "0.0.7"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Aaron Patterson", "Christian Eager"]
12
+ s.date = %q{2010-08-09}
13
+ s.description = %q{Adds support for MySQL triggers in ActiveRecord}
14
+ s.email = %q{christian@perpenduum.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "CHANGELOG",
21
+ "Empact-trackless_triggers.gemspec",
22
+ "MIT-LICENSE",
23
+ "README",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "init.rb",
27
+ "lib/trackless_triggers.rb"
28
+ ]
29
+ s.homepage = %q{http://github.com/Empact/trackless-triggers}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.7}
33
+ s.summary = %q{Adds support for MySQL triggers in ActiveRecord}
34
+
35
+ if s.respond_to? :specification_version then
36
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
40
+ else
41
+ end
42
+ else
43
+ end
44
+ end
45
+
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2007 Aaron Patterson (aaronp@rubyforge.org)
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,26 @@
1
+ = Trigger Happy
2
+
3
+ Add triggers to your active record migrations.
4
+
5
+ == INSTALL
6
+
7
+ script/plugin install svn://rubyforge.org/var/svn/artriggers/trunk/trigger_happy
8
+
9
+ == EXAMPLE
10
+
11
+ Add a trigger:
12
+
13
+ add_trigger "ai_people",
14
+ :on => 'people',
15
+ :timing => 'after',
16
+ :event => 'insert',
17
+ :statement => 'INSERT INTO log (id, timestamp) VALUES (NEW.id, NOW())'
18
+
19
+ Remove a trigger:
20
+
21
+ drop_trigger 'ai_people'
22
+
23
+ == LIMITATIONS
24
+
25
+ Only works with mysql for now.
26
+
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |gemspec|
6
+ gemspec.name = "Empact-trackless_triggers"
7
+ gemspec.summary = "Adds support for MySQL triggers in ActiveRecord"
8
+ gemspec.description = "Adds support for MySQL triggers in ActiveRecord"
9
+ gemspec.email = "christian@perpenduum.com"
10
+ gemspec.homepage = "http://github.com/Empact/trackless-triggers"
11
+ gemspec.authors = ["Aaron Patterson","Christian Eager"]
12
+ end
13
+ rescue LoadError
14
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
15
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.7
data/init.rb ADDED
@@ -0,0 +1,3 @@
1
+ # require 'active_support'
2
+ require 'active_record'
3
+ require 'trackless_triggers'
@@ -0,0 +1,52 @@
1
+ require 'active_record'
2
+
3
+ module ActiveRecord
4
+ class SchemaDumper
5
+ private
6
+ alias trigger_old_tables tables
7
+ def tables(stream)
8
+ trigger_old_tables(stream)
9
+ @connection.tables.sort.each do |tbl|
10
+ next if (tbl == 'schema_info' || tbl == 'schema_migrations')
11
+ triggers(tbl, stream)
12
+ end
13
+ end
14
+
15
+ def triggers(table, stream)
16
+ triggers = @connection.triggers(table)
17
+ triggers.each do |trigger|
18
+ stream.print " add_trigger \"#{trigger.name}\", :on => \"#{trigger.reference_table}\", :timing => \"#{trigger.timing}\", :event => \"#{trigger.event}\", :statement => \"#{trigger.statement}\""
19
+ stream.puts
20
+ end
21
+ end
22
+ end
23
+
24
+ module ConnectionAdapters
25
+ class TriggerDefinition < Struct.new(:name, :event, :reference_table,
26
+ :statement, :timing, :created,
27
+ :sql_mode, :definer, :character_set_client, :collation_connection, :database_collation
28
+ )
29
+ end
30
+ class MysqlAdapter < AbstractAdapter
31
+ def triggers(table, name = nil)
32
+ triggers = []
33
+ execute("SHOW TRIGGERS LIKE '#{table}'", name).each do |row|
34
+ triggers << TriggerDefinition.new(*row)
35
+ end
36
+
37
+ triggers
38
+ end
39
+ end
40
+
41
+ module SchemaStatements
42
+ def add_trigger(name, opts = {})
43
+ sql = "CREATE TRIGGER #{name} #{opts[:timing]} #{opts[:event]} ON #{opts[:on]} FOR EACH ROW #{opts[:statement]}"
44
+ execute sql
45
+ end
46
+
47
+ def drop_trigger(name)
48
+ execute("DROP TRIGGER #{name}")
49
+ end
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Empact-trackless_triggers
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 7
10
+ version: 0.0.7
11
+ platform: ruby
12
+ authors:
13
+ - Aaron Patterson
14
+ - Christian Eager
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-08-09 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies: []
22
+
23
+ description: Adds support for MySQL triggers in ActiveRecord
24
+ email: christian@perpenduum.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files:
30
+ - README
31
+ files:
32
+ - .gitignore
33
+ - CHANGELOG
34
+ - Empact-trackless_triggers.gemspec
35
+ - MIT-LICENSE
36
+ - README
37
+ - Rakefile
38
+ - VERSION
39
+ - init.rb
40
+ - lib/trackless_triggers.rb
41
+ has_rdoc: true
42
+ homepage: http://github.com/Empact/trackless-triggers
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --charset=UTF-8
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_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
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.7
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Adds support for MySQL triggers in ActiveRecord
75
+ test_files: []
76
+