rubysync 0.0.3 → 0.0.4
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/HISTORY.txt +4 -0
- data/Manifest.txt +25 -12
- data/README.txt +0 -2
- data/bin/rubysync +20 -6
- data/bin/rubysync.rb +333 -0
- data/docs/in_pipeline.graffle +2690 -0
- data/docs/init_openldap.ldif +11 -0
- data/docs/out_pipeline.graffle +3274 -0
- data/docs/schema/99rubysync.ldif +27 -0
- data/docs/schema/rubysync.schema +16 -0
- data/docs/to_sync.txt +15 -0
- data/docs/walkthru.txt +186 -0
- data/lib/ruby_sync.rb +7 -29
- data/lib/ruby_sync/connectors/base_connector.rb +55 -86
- data/lib/ruby_sync/connectors/csv_file_connector.rb +16 -4
- data/lib/ruby_sync/connectors/ldap_associations.rb +126 -0
- data/lib/ruby_sync/connectors/ldap_changelog_connector.rb +127 -0
- data/lib/ruby_sync/connectors/ldap_connector.rb +29 -192
- data/lib/ruby_sync/connectors/memory_connector.rb +1 -1
- data/lib/ruby_sync/connectors/xml_connector.rb +105 -32
- data/lib/ruby_sync/event.rb +40 -12
- data/lib/ruby_sync/operation.rb +18 -2
- data/lib/ruby_sync/pipelines/base_pipeline.rb +44 -6
- data/lib/ruby_sync/util/utilities.rb +97 -4
- data/lib/rubysync.rb +1 -1
- data/rubysync.tmproj +279 -59
- data/test/.LCKts_rubysync.rb~ +1 -0
- data/test/ruby_sync_test.rb +9 -4
- data/test/{test_active_record_vault.rb → tc_active_record_connector.rb} +11 -7
- data/test/{test_base_connector.rb → tc_base_connector.rb} +1 -1
- data/test/{test_base_pipeline.rb → tc_base_pipeline.rb} +1 -1
- data/test/tc_changelog_ldap_connector.rb +93 -0
- data/test/{test_csv_file_connector.rb → tc_csv_file_connector.rb} +14 -5
- data/test/{test_event.rb → tc_event.rb} +1 -1
- data/test/{test_ldap_changelog.rb → tc_ldap_changelog.rb} +1 -1
- data/test/{test_ldap_connector.rb → tc_ldap_connector.rb} +20 -22
- data/test/{test_ldap_vault.rb → tc_ldap_vault.rb} +2 -2
- data/test/{test_ldif.rb → tc_ldif.rb} +1 -1
- data/test/{test_memory_connectors.rb → tc_memory_connectors.rb} +10 -6
- data/test/{test_rubysync.rb → tc_rubysync.rb} +4 -4
- data/test/tc_transformation.rb +71 -0
- data/test/{test_utilities.rb → tc_utilities.rb} +28 -1
- data/test/tc_xml_connectors.rb +107 -6
- data/test/ts_rubysync.rb +11 -6
- metadata +33 -28
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (c) 2007 Ritchie Young. All rights reserved.
|
4
|
+
#
|
5
|
+
# This file is part of RubySync.
|
6
|
+
#
|
7
|
+
# RubySync is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# RubySync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
11
|
+
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with RubySync; if not, write to the
|
14
|
+
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
15
|
+
|
16
|
+
#
|
17
|
+
# Tests transformation operations in the Event class
|
18
|
+
#
|
19
|
+
[File.dirname(__FILE__) + '/../lib', File.dirname(__FILE__)].each do |lib_path|
|
20
|
+
$:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
|
21
|
+
end
|
22
|
+
require 'ruby_sync_test'
|
23
|
+
require 'ruby_sync/connectors/xml_connector'
|
24
|
+
|
25
|
+
|
26
|
+
class TransformationVaultConnector < RubySync::Connectors::MemoryConnector
|
27
|
+
dbm_path "/tmp/rubysync_xml"
|
28
|
+
end
|
29
|
+
|
30
|
+
class TransformationClientConnector < RubySync::Connectors::MemoryConnector
|
31
|
+
dbm_path "/tmp/rubysync_memory"
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
class TransformationTestPipeline < RubySync::Pipelines::BasePipeline
|
36
|
+
client :transformation_vault
|
37
|
+
vault :transformation_client
|
38
|
+
|
39
|
+
in_transform do
|
40
|
+
map :first_name, :givenName
|
41
|
+
map :last_name, :sn
|
42
|
+
# Calculated value
|
43
|
+
map(:hobbies) {values_for(:interests).join ':'}
|
44
|
+
# Constant string
|
45
|
+
map(:note) {"Created by RubySync"}
|
46
|
+
map(:shopping) {%w/fish milk bread/}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class TcTransformation < Test::Unit::TestCase
|
51
|
+
|
52
|
+
include RubySyncTest
|
53
|
+
|
54
|
+
def client_path() 'bob'; end
|
55
|
+
def vault_path() 'bob'; end
|
56
|
+
|
57
|
+
def testPipeline
|
58
|
+
TransformationTestPipeline
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_transform
|
62
|
+
@client['bob'] = @bob_details
|
63
|
+
@pipeline.run_once
|
64
|
+
assert_equal @bob_details['givenName'], @vault['bob']['first_name']
|
65
|
+
assert_equal @bob_details['sn'], @vault['bob']['last_name']
|
66
|
+
assert_equal "Created by RubySync", @vault['bob']['note'][0]
|
67
|
+
assert_equal "music:makeup", @vault['bob']['hobbies'][0]
|
68
|
+
assert_equal %w/fish milk bread/, @vault['bob']['shopping']
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -45,7 +45,7 @@ class C < A
|
|
45
45
|
end
|
46
46
|
|
47
47
|
|
48
|
-
class
|
48
|
+
class TcUtilities < Test::Unit::TestCase
|
49
49
|
|
50
50
|
def test_class_option
|
51
51
|
b = B.new
|
@@ -60,4 +60,31 @@ class TestUtilities < Test::Unit::TestCase
|
|
60
60
|
assert_equal WRONG, c.just_one
|
61
61
|
end
|
62
62
|
|
63
|
+
|
64
|
+
def test_effective_operations
|
65
|
+
a = A.new
|
66
|
+
entry = {
|
67
|
+
"sn" => "Fox",
|
68
|
+
"givenName" => %w{Michael Andrew},
|
69
|
+
"shows" => "Family Ties"
|
70
|
+
}
|
71
|
+
|
72
|
+
op = RubySync::Operation
|
73
|
+
ops = [
|
74
|
+
op.add("fans", ["Ritchie"]),
|
75
|
+
op.add("shows", ["Scrubs", "Boston Legal"]),
|
76
|
+
op.replace("givenName", %w{Michael J}),
|
77
|
+
op.delete("movies","Bright Lights, Big City")
|
78
|
+
]
|
79
|
+
|
80
|
+
e = a.effective_operations(ops, entry)
|
81
|
+
|
82
|
+
assert_equal op.add("fans", ["Ritchie"]), e[0]
|
83
|
+
assert_equal op.replace("shows", ["Scrubs", "Boston Legal"]), e[1]
|
84
|
+
assert_equal op.replace("givenName", %w{Michael J}), e[2]
|
85
|
+
assert_equal 3, e.size
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
|
63
90
|
end
|
data/test/tc_xml_connectors.rb
CHANGED
@@ -24,24 +24,125 @@ require 'hashlike_tests'
|
|
24
24
|
require 'ruby_sync/connectors/xml_connector'
|
25
25
|
|
26
26
|
|
27
|
-
class
|
27
|
+
class XmlTestAConnector < RubySync::Connectors::XmlConnector
|
28
28
|
dbm_path "/tmp/rubysync_a"
|
29
29
|
filename "/tmp/rubysync_a.xml"
|
30
30
|
end
|
31
31
|
|
32
|
-
class
|
32
|
+
class XmlTestBConnector < RubySync::Connectors::XmlConnector
|
33
33
|
dbm_path "/tmp/rubysync_b"
|
34
34
|
filename "/tmp/rubysync_b.xml"
|
35
35
|
end
|
36
36
|
|
37
|
-
class
|
38
|
-
|
39
|
-
vault :test_b
|
37
|
+
class XmlTestConnector < RubySync::Connectors::XmlConnector
|
38
|
+
filename "/tmp/rubysync_test.xml"
|
40
39
|
end
|
41
40
|
|
42
|
-
class
|
41
|
+
class XmlTestPipeline < RubySync::Pipelines::BasePipeline
|
42
|
+
client :xml_test_a
|
43
|
+
vault :xml_test_b
|
44
|
+
end
|
45
|
+
|
46
|
+
class TcXmlConnectors < Test::Unit::TestCase
|
43
47
|
|
44
48
|
include RubySyncTest
|
45
49
|
include HashlikeTests
|
46
50
|
|
51
|
+
alias_method :old_setup, :setup
|
52
|
+
def setup
|
53
|
+
old_setup
|
54
|
+
@tc = XmlTestConnector.new
|
55
|
+
File.delete_if_exists [@client.filename, @vault.filename, @tc.filename]
|
56
|
+
xml_test_document
|
57
|
+
@tc.started
|
58
|
+
end
|
59
|
+
|
60
|
+
alias_method :old_teardown, :teardown
|
61
|
+
def teardown
|
62
|
+
@tc.stopped
|
63
|
+
end
|
64
|
+
|
65
|
+
def testPipeline
|
66
|
+
XmlTestPipeline
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# def test_with_xml()
|
71
|
+
# File.delete(@client.filename)
|
72
|
+
# mrA = {
|
73
|
+
# 'sn' => "A",
|
74
|
+
# 'givenName' => 'Mr'
|
75
|
+
# }
|
76
|
+
# @client.with_xml do |content|
|
77
|
+
# assert_equal({}, content)
|
78
|
+
# content['a'] = mrA
|
79
|
+
# end
|
80
|
+
# @client.with_xml do |content|
|
81
|
+
# assert_equal(mrA, content['a'])
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
|
85
|
+
|
86
|
+
def test_xml_delete
|
87
|
+
assert_not_nil @tc['ctd']
|
88
|
+
assert_equal ['Dummy'],@tc["ctd"]['sn']
|
89
|
+
@tc.delete "ctd"
|
90
|
+
assert_nil @tc['ctd']
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_to_xml
|
94
|
+
entry = {
|
95
|
+
'sn'=>['Smith'],
|
96
|
+
'givenName'=>%w/Bobby Earl/
|
97
|
+
}
|
98
|
+
|
99
|
+
xml = @tc.to_xml('bob', entry)
|
100
|
+
doc = REXML::Document.new()
|
101
|
+
doc << xml
|
102
|
+
assert_equal doc, xml.document
|
103
|
+
values = []
|
104
|
+
xml.each_element("attr[@name='sn']/value") {|e| values << e.text}
|
105
|
+
assert_equal as_array(entry['sn']), values
|
106
|
+
values = []
|
107
|
+
xml.each_element("attr[@name='givenName']/value") {|e| values << e.text}
|
108
|
+
assert_equal entry['givenName'], values
|
109
|
+
assert_equal entry, @tc.to_entry(xml)
|
110
|
+
end
|
111
|
+
|
112
|
+
def xml_test_document
|
113
|
+
File.open(@tc.filename, "w") do |f|
|
114
|
+
f.write <<END
|
115
|
+
<?xml version="1.0"?>
|
116
|
+
<entries>
|
117
|
+
<entry id="ritchie">
|
118
|
+
<attr name="sn">
|
119
|
+
<value>Young</value>
|
120
|
+
</attr>
|
121
|
+
<attr name="givenName">
|
122
|
+
<value>Ritchie</value>
|
123
|
+
</attr>
|
124
|
+
<attr name="hobbies">
|
125
|
+
<value>Juggling</value>
|
126
|
+
<value>Running</value>
|
127
|
+
<value>Skipping</value>
|
128
|
+
</attr>
|
129
|
+
</entry>
|
130
|
+
<entry id="ctd">
|
131
|
+
<attr name="sn">
|
132
|
+
<value>Dummy</value>
|
133
|
+
</attr>
|
134
|
+
<attr name="givenName">
|
135
|
+
<value>Crash</value>
|
136
|
+
<value>Test</value>
|
137
|
+
</attr>
|
138
|
+
<attr name="hobbies">
|
139
|
+
<value>Falling</value>
|
140
|
+
<value>Crashing</value>
|
141
|
+
<value>Burning</value>
|
142
|
+
</attr>
|
143
|
+
</entry>
|
144
|
+
</entries>
|
145
|
+
END
|
146
|
+
end
|
147
|
+
end
|
47
148
|
end
|
data/test/ts_rubysync.rb
CHANGED
@@ -14,9 +14,14 @@
|
|
14
14
|
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
15
15
|
|
16
16
|
require 'test/unit'
|
17
|
-
|
18
|
-
require '
|
19
|
-
require '
|
20
|
-
require '
|
21
|
-
|
22
|
-
|
17
|
+
require 'tc_csv_file_connector'
|
18
|
+
require 'tc_memory_connectors'
|
19
|
+
require 'tc_ldif'
|
20
|
+
require 'tc_base_pipeline'
|
21
|
+
require 'tc_xml_connectors'
|
22
|
+
require 'tc_transformation'
|
23
|
+
#require 'tc_active_record_connector'
|
24
|
+
|
25
|
+
# The following require some setup on your computer before they'll work
|
26
|
+
|
27
|
+
#require 'tc_ldap_connector'
|
metadata
CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rubysync
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.0.4
|
7
|
+
date: 2007-09-18 00:00:00 +08:00
|
8
8
|
summary: Event driven identity synchronization engine
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: ritchiey@gmail.com
|
12
12
|
homepage: " by Ritchie Young"
|
13
13
|
rubyforge_project: rubysync
|
14
|
-
description: "You can configure RubySync to perform transformations on the data as it syncs. RubySync is designed both as a handy utility to pack into your directory management toolkit or as a fully-fledged provisioning system for your organisation. == FEATURES/PROBLEMS:
|
14
|
+
description: "You can configure RubySync to perform transformations on the data as it syncs. RubySync is designed both as a handy utility to pack into your directory management toolkit or as a fully-fledged provisioning system for your organisation. == FEATURES/PROBLEMS: == SYNOPSIS: This sets up the skeleton of a configuration for importing comma delimeted text files into a database. Note, if the application happens to be a Rails app then it can also export changes."
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -38,6 +38,14 @@ files:
|
|
38
38
|
- Rakefile
|
39
39
|
- bin/.DS_Store
|
40
40
|
- bin/rubysync
|
41
|
+
- bin/rubysync.rb
|
42
|
+
- docs/in_pipeline.graffle
|
43
|
+
- docs/init_openldap.ldif
|
44
|
+
- docs/out_pipeline.graffle
|
45
|
+
- docs/schema/99rubysync.ldif
|
46
|
+
- docs/schema/rubysync.schema
|
47
|
+
- docs/to_sync.txt
|
48
|
+
- docs/walkthru.txt
|
41
49
|
- examples/.DS_Store
|
42
50
|
- examples/ar_client_webapp/README
|
43
51
|
- examples/ar_client_webapp/Rakefile
|
@@ -210,6 +218,8 @@ files:
|
|
210
218
|
- lib/ruby_sync/connectors/connector_event_processing.rb
|
211
219
|
- lib/ruby_sync/connectors/csv_file_connector.rb
|
212
220
|
- lib/ruby_sync/connectors/file_connector.rb
|
221
|
+
- lib/ruby_sync/connectors/ldap_associations.rb
|
222
|
+
- lib/ruby_sync/connectors/ldap_changelog_connector.rb
|
213
223
|
- lib/ruby_sync/connectors/ldap_connector.rb
|
214
224
|
- lib/ruby_sync/connectors/memory_connector.rb
|
215
225
|
- lib/ruby_sync/connectors/xml_connector.rb
|
@@ -224,6 +234,7 @@ files:
|
|
224
234
|
- nbproject/project.xml
|
225
235
|
- rubysync.tmproj
|
226
236
|
- test/.DS_Store
|
237
|
+
- test/.LCKts_rubysync.rb~
|
227
238
|
- test/data/example1.ldif
|
228
239
|
- test/data/example2.ldif
|
229
240
|
- test/data/example3.ldif
|
@@ -233,33 +244,24 @@ files:
|
|
233
244
|
- test/data/example7.ldif
|
234
245
|
- test/hashlike_tests.rb
|
235
246
|
- test/ruby_sync_test.rb
|
247
|
+
- test/tc_active_record_connector.rb
|
248
|
+
- test/tc_base_connector.rb
|
249
|
+
- test/tc_base_pipeline.rb
|
250
|
+
- test/tc_changelog_ldap_connector.rb
|
251
|
+
- test/tc_csv_file_connector.rb
|
252
|
+
- test/tc_event.rb
|
253
|
+
- test/tc_ldap_changelog.rb
|
254
|
+
- test/tc_ldap_connector.rb
|
255
|
+
- test/tc_ldap_vault.rb
|
256
|
+
- test/tc_ldif.rb
|
257
|
+
- test/tc_memory_connectors.rb
|
258
|
+
- test/tc_rubysync.rb
|
259
|
+
- test/tc_transformation.rb
|
260
|
+
- test/tc_utilities.rb
|
236
261
|
- test/tc_xml_connectors.rb
|
237
|
-
- test/test_active_record_vault.rb
|
238
|
-
- test/test_base_connector.rb
|
239
|
-
- test/test_base_pipeline.rb
|
240
|
-
- test/test_csv_file_connector.rb
|
241
|
-
- test/test_event.rb
|
242
|
-
- test/test_ldap_changelog.rb
|
243
|
-
- test/test_ldap_connector.rb
|
244
|
-
- test/test_ldap_vault.rb
|
245
|
-
- test/test_ldif.rb
|
246
|
-
- test/test_memory_connectors.rb
|
247
|
-
- test/test_rubysync.rb
|
248
|
-
- test/test_utilities.rb
|
249
262
|
- test/ts_rubysync.rb
|
250
|
-
test_files:
|
251
|
-
|
252
|
-
- test/test_base_connector.rb
|
253
|
-
- test/test_base_pipeline.rb
|
254
|
-
- test/test_csv_file_connector.rb
|
255
|
-
- test/test_event.rb
|
256
|
-
- test/test_ldap_changelog.rb
|
257
|
-
- test/test_ldap_connector.rb
|
258
|
-
- test/test_ldap_vault.rb
|
259
|
-
- test/test_ldif.rb
|
260
|
-
- test/test_memory_connectors.rb
|
261
|
-
- test/test_rubysync.rb
|
262
|
-
- test/test_utilities.rb
|
263
|
+
test_files: []
|
264
|
+
|
263
265
|
rdoc_options:
|
264
266
|
- --main
|
265
267
|
- README.txt
|
@@ -267,11 +269,14 @@ extra_rdoc_files:
|
|
267
269
|
- HISTORY.txt
|
268
270
|
- Manifest.txt
|
269
271
|
- README.txt
|
272
|
+
- docs/to_sync.txt
|
273
|
+
- docs/walkthru.txt
|
270
274
|
- examples/ar_client_webapp/public/robots.txt
|
271
275
|
- examples/ar_webapp/public/robots.txt
|
272
276
|
executables:
|
273
277
|
- .DS_Store
|
274
278
|
- rubysync
|
279
|
+
- rubysync.rb
|
275
280
|
extensions: []
|
276
281
|
|
277
282
|
requirements: []
|