ocelot 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ocelot/database.rb +13 -8
- data/lib/ocelot/dsl.rb +8 -1
- data/ocelot.gemspec +3 -3
- metadata +4 -4
data/lib/ocelot/database.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'thread'
|
2
2
|
require 'active_record'
|
3
|
-
require 'active_record/connection_adapters/mysql2_adapter'
|
4
3
|
require 'active_record/connection_adapters/abstract/connection_pool'
|
5
4
|
|
6
5
|
module Ocelot
|
@@ -10,17 +9,23 @@ module Ocelot
|
|
10
9
|
attr_accessor :use_source
|
11
10
|
|
12
11
|
def initialize(source, target)
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
[source, target].each do |db|
|
13
|
+
require "active_record/connection_adapters/#{db['adapter']}_adapter"
|
14
|
+
end
|
16
15
|
|
17
|
-
|
16
|
+
self.target = ActiveRecord::Base.send("#{target['adapter']}_connection".to_s, target.symbolize_keys!)
|
17
|
+
self.source = ActiveRecord::Base.send("#{source['adapter']}_connection".to_s, source.symbolize_keys!)
|
18
|
+
|
19
|
+
self.use_source = true
|
20
|
+
|
21
|
+
# AR doesn't like oop much, monkeypatch lots o stuff
|
18
22
|
ActiveRecord::ConnectionAdapters::ConnectionHandler.class_variable_set(:@@conn, self)
|
19
23
|
ActiveRecord::ConnectionAdapters::ConnectionHandler.class_eval do
|
20
|
-
def retrieve_connection(klass)
|
21
|
-
@@conn.current_connection
|
24
|
+
def retrieve_connection(klass)
|
25
|
+
@@conn.current_connection
|
22
26
|
end
|
23
|
-
end
|
27
|
+
end
|
28
|
+
|
24
29
|
|
25
30
|
ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
|
26
31
|
attr_reader :last_query
|
data/lib/ocelot/dsl.rb
CHANGED
@@ -6,6 +6,10 @@ module Ocelot
|
|
6
6
|
attr_accessor :rules
|
7
7
|
attr_accessor :filters
|
8
8
|
|
9
|
+
def watch(val)
|
10
|
+
@watch = val
|
11
|
+
end
|
12
|
+
|
9
13
|
def initialize
|
10
14
|
@rules = {}
|
11
15
|
@filters = {}
|
@@ -55,6 +59,9 @@ module Ocelot
|
|
55
59
|
@filters[clazz] = ScriptFilter.new(p)
|
56
60
|
end
|
57
61
|
|
62
|
+
alias :target= :target
|
63
|
+
alias :source= :source
|
64
|
+
|
58
65
|
def go
|
59
66
|
Ocelot::logger = logger
|
60
67
|
Ocelot::connection = Ocelot::Connection.new(source, target)
|
@@ -71,7 +78,7 @@ module Ocelot
|
|
71
78
|
copier.extra_rules = rules
|
72
79
|
copier.extra_filters = filters
|
73
80
|
|
74
|
-
if
|
81
|
+
if !@watch
|
75
82
|
copier.go
|
76
83
|
else
|
77
84
|
copier_thread = Thread.new(copier) do
|
data/ocelot.gemspec
CHANGED
@@ -3,13 +3,13 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ocelot"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.3"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["spencer p"]
|
9
9
|
s.email = ["exussum@gmail.com"]
|
10
10
|
s.homepage = ""
|
11
|
-
s.summary = %q{DBA like tool to copy
|
12
|
-
s.description = %q{
|
11
|
+
s.summary = %q{DBA like tool to copy ActiveRecords from one db to another}
|
12
|
+
s.description = %q{A rule based system for copying data from one database to another for active record.}
|
13
13
|
s.files = `hg locate | egrep -v '^\\.'`.split("\n")
|
14
14
|
s.executables = "ocelot"
|
15
15
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ocelot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- spencer p
|
@@ -10,11 +10,11 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-21 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
17
|
-
description:
|
17
|
+
description: A rule based system for copying data from one database to another for active record.
|
18
18
|
email:
|
19
19
|
- exussum@gmail.com
|
20
20
|
executables:
|
@@ -64,6 +64,6 @@ rubyforge_project:
|
|
64
64
|
rubygems_version: 1.6.2
|
65
65
|
signing_key:
|
66
66
|
specification_version: 3
|
67
|
-
summary: DBA like tool to copy
|
67
|
+
summary: DBA like tool to copy ActiveRecords from one db to another
|
68
68
|
test_files: []
|
69
69
|
|