rubysync 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.txt +7 -0
- data/Manifest.txt +18 -76
- data/Rakefile +2 -2
- data/bin/rubysync +60 -21
- data/bin/rubysync.rb +60 -21
- data/examples/ar_webapp/public/dispatch.cgi +1 -1
- data/examples/ar_webapp/public/dispatch.fcgi +1 -1
- data/examples/ar_webapp/public/dispatch.rb +1 -1
- data/examples/csv_to_ldap/config/connectors/hr_connector.rb +14 -0
- data/examples/csv_to_ldap/config/connectors/ldap_vault_connector.rb +11 -0
- data/examples/{ar_webapp/.DS_Store → csv_to_ldap/config/db/HrImportPipeline(vault)_assoc_to_path.db} +0 -0
- data/{.DS_Store → examples/csv_to_ldap/config/db/HrImportPipeline(vault)_mirror.db} +0 -0
- data/examples/csv_to_ldap/config/db/HrImportPipeline(vault)_path_to_assoc.db +0 -0
- data/examples/csv_to_ldap/config/pipelines/hr_import_pipeline.rb +24 -0
- data/examples/csv_to_ldap/in/henchmen.csv.bak +3 -0
- data/examples/csv_to_xml/config/connectors/databank_connector.rb +8 -0
- data/examples/csv_to_xml/config/connectors/hr_connector.rb +14 -0
- data/examples/csv_to_xml/config/db/HrImportPipeline(vault)_assoc_to_path.db +0 -0
- data/examples/csv_to_xml/config/db/HrImportPipeline(vault)_mirror.db +0 -0
- data/examples/csv_to_xml/config/db/HrImportPipeline(vault)_path_to_assoc.db +0 -0
- data/examples/csv_to_xml/config/pipelines/hr_import_pipeline.rb +24 -0
- data/examples/csv_to_xml/databank.xml +1 -0
- data/examples/csv_to_xml/in/henchmen.csv.bak +3 -0
- data/examples/csv_to_xml/transcript.txt +1 -2
- data/examples/data/henchmen.csv +3 -0
- data/examples/data/more.csv +2 -0
- data/lib/ruby_sync/connectors/active_record_connector.rb +19 -4
- data/lib/ruby_sync/connectors/base_connector.rb +3 -9
- data/lib/ruby_sync/connectors/file_connector.rb +2 -2
- data/lib/ruby_sync/event.rb +16 -9
- data/lib/ruby_sync/pipelines/base_pipeline.rb +137 -164
- data/lib/ruby_sync/util/utilities.rb +14 -21
- data/lib/ruby_sync.rb +37 -39
- data/test/ruby_sync_test.rb +3 -2
- data/test/tc_active_record_connector.rb +15 -6
- data/test/tc_csv_file_connector.rb +10 -6
- data/test/tc_ldap_connector.rb +1 -1
- data/test/tc_memory_connectors.rb +5 -3
- data/test/tc_transformation.rb +15 -7
- data/test/tc_utilities.rb +1 -1
- data/test/tc_xml_connectors.rb +4 -0
- data/test/ts_rubysync.rb +3 -1
- metadata +21 -81
- data/.project +0 -17
- data/docs/in_pipeline.graffle +0 -2690
- data/docs/out_pipeline.graffle +0 -3274
- data/docs/to_sync.txt +0 -15
- data/docs/walkthru.txt +0 -186
- data/examples/ar_client_webapp/README +0 -182
- data/examples/ar_client_webapp/Rakefile +0 -10
- data/examples/ar_client_webapp/app/controllers/application.rb +0 -7
- data/examples/ar_client_webapp/app/controllers/user_controller.rb +0 -5
- data/examples/ar_client_webapp/app/helpers/application_helper.rb +0 -3
- data/examples/ar_client_webapp/app/helpers/user_helper.rb +0 -2
- data/examples/ar_client_webapp/app/models/user.rb +0 -2
- data/examples/ar_client_webapp/config/boot.rb +0 -45
- data/examples/ar_client_webapp/config/database.yml +0 -36
- data/examples/ar_client_webapp/config/environment.rb +0 -60
- data/examples/ar_client_webapp/config/environments/development.rb +0 -21
- data/examples/ar_client_webapp/config/environments/production.rb +0 -18
- data/examples/ar_client_webapp/config/environments/test.rb +0 -19
- data/examples/ar_client_webapp/config/routes.rb +0 -23
- data/examples/ar_client_webapp/db/migrate/001_create_users.rb +0 -13
- data/examples/ar_client_webapp/db/schema.rb +0 -13
- data/examples/ar_client_webapp/doc/README_FOR_APP +0 -2
- data/examples/ar_client_webapp/log/development.log +0 -753
- data/examples/ar_client_webapp/log/production.log +0 -0
- data/examples/ar_client_webapp/log/server.log +0 -0
- data/examples/ar_client_webapp/log/test.log +0 -0
- data/examples/ar_client_webapp/public/.htaccess +0 -40
- data/examples/ar_client_webapp/public/404.html +0 -30
- data/examples/ar_client_webapp/public/500.html +0 -30
- data/examples/ar_client_webapp/public/dispatch.cgi +0 -10
- data/examples/ar_client_webapp/public/dispatch.fcgi +0 -24
- data/examples/ar_client_webapp/public/dispatch.rb +0 -10
- data/examples/ar_client_webapp/public/favicon.ico +0 -0
- data/examples/ar_client_webapp/public/images/rails.png +0 -0
- data/examples/ar_client_webapp/public/index.html +0 -277
- data/examples/ar_client_webapp/public/javascripts/application.js +0 -2
- data/examples/ar_client_webapp/public/javascripts/controls.js +0 -833
- data/examples/ar_client_webapp/public/javascripts/dragdrop.js +0 -942
- data/examples/ar_client_webapp/public/javascripts/effects.js +0 -1088
- data/examples/ar_client_webapp/public/javascripts/prototype.js +0 -2515
- data/examples/ar_client_webapp/public/robots.txt +0 -1
- data/examples/ar_client_webapp/script/about +0 -3
- data/examples/ar_client_webapp/script/breakpointer +0 -3
- data/examples/ar_client_webapp/script/console +0 -3
- data/examples/ar_client_webapp/script/destroy +0 -3
- data/examples/ar_client_webapp/script/generate +0 -3
- data/examples/ar_client_webapp/script/performance/benchmarker +0 -3
- data/examples/ar_client_webapp/script/performance/profiler +0 -3
- data/examples/ar_client_webapp/script/plugin +0 -3
- data/examples/ar_client_webapp/script/process/inspector +0 -3
- data/examples/ar_client_webapp/script/process/reaper +0 -3
- data/examples/ar_client_webapp/script/process/spawner +0 -3
- data/examples/ar_client_webapp/script/runner +0 -3
- data/examples/ar_client_webapp/script/server +0 -3
- data/examples/ar_client_webapp/test/fixtures/users.yml +0 -5
- data/examples/ar_client_webapp/test/functional/user_controller_test.rb +0 -18
- data/examples/ar_client_webapp/test/test_helper.rb +0 -28
- data/examples/ar_client_webapp/test/unit/user_test.rb +0 -10
- data/examples/ar_client_webapp/tmp/sessions/ruby_sess.e2e3c63a67baef6d +0 -0
- data/examples/ar_webapp/app/.DS_Store +0 -0
- data/examples/ar_webapp/app/views/.DS_Store +0 -0
- data/examples/ar_webapp/app/views/people/.DS_Store +0 -0
- data/examples/ims2/connectors/hr_db_connector.rb +0 -6
- data/examples/ims2/connectors/my_csv_connector.rb +0 -12
- data/examples/ims2/pipelines/hr_import_pipeline.rb +0 -33
- data/examples/my_ims/connectors/my_csv_connector.rb +0 -10
- data/examples/my_ims/connectors/my_db_connector.rb +0 -7
- data/examples/my_ims/pipelines/my_pipeline.rb +0 -33
- data/lib/rubysync.rb +0 -19
- data/nbproject/private/private.properties +0 -3
- data/nbproject/project.properties +0 -8
- data/nbproject/project.xml +0 -16
- data/rubysync.tmproj +0 -568
- data/test/tc_rubysync.rb +0 -28
data/HISTORY.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.1.0 / 2007-09-26
|
2
|
+
|
3
|
+
* Dropped the map_client_to_vault and map_vault_to_client methods. in_transform and out_transform now handle that
|
4
|
+
this enables calculated and literal values as well as simple mappings
|
5
|
+
* Now uses the class loader from activesupport - much more stable
|
6
|
+
* Refreshed the examples
|
7
|
+
|
1
8
|
== 0.0.5 / 2007-09-18
|
2
9
|
|
3
10
|
* Fixed gem dependency issues
|
data/Manifest.txt
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
.DS_Store
|
2
|
-
.project
|
3
1
|
COPYING
|
4
2
|
HISTORY.txt
|
5
3
|
Manifest.txt
|
@@ -7,71 +5,11 @@ README.txt
|
|
7
5
|
Rakefile
|
8
6
|
bin/rubysync
|
9
7
|
bin/rubysync.rb
|
10
|
-
docs/in_pipeline.graffle
|
11
8
|
docs/init_openldap.ldif
|
12
|
-
docs/out_pipeline.graffle
|
13
9
|
docs/schema/99rubysync.ldif
|
14
10
|
docs/schema/rubysync.schema
|
15
|
-
docs/to_sync.txt
|
16
|
-
docs/walkthru.txt
|
17
|
-
examples/ar_client_webapp/README
|
18
|
-
examples/ar_client_webapp/Rakefile
|
19
|
-
examples/ar_client_webapp/app/controllers/application.rb
|
20
|
-
examples/ar_client_webapp/app/controllers/user_controller.rb
|
21
|
-
examples/ar_client_webapp/app/helpers/application_helper.rb
|
22
|
-
examples/ar_client_webapp/app/helpers/user_helper.rb
|
23
|
-
examples/ar_client_webapp/app/models/user.rb
|
24
|
-
examples/ar_client_webapp/config/boot.rb
|
25
|
-
examples/ar_client_webapp/config/database.yml
|
26
|
-
examples/ar_client_webapp/config/environment.rb
|
27
|
-
examples/ar_client_webapp/config/environments/development.rb
|
28
|
-
examples/ar_client_webapp/config/environments/production.rb
|
29
|
-
examples/ar_client_webapp/config/environments/test.rb
|
30
|
-
examples/ar_client_webapp/config/routes.rb
|
31
|
-
examples/ar_client_webapp/db/migrate/001_create_users.rb
|
32
|
-
examples/ar_client_webapp/db/schema.rb
|
33
|
-
examples/ar_client_webapp/doc/README_FOR_APP
|
34
|
-
examples/ar_client_webapp/log/development.log
|
35
|
-
examples/ar_client_webapp/log/production.log
|
36
|
-
examples/ar_client_webapp/log/server.log
|
37
|
-
examples/ar_client_webapp/log/test.log
|
38
|
-
examples/ar_client_webapp/public/.htaccess
|
39
|
-
examples/ar_client_webapp/public/404.html
|
40
|
-
examples/ar_client_webapp/public/500.html
|
41
|
-
examples/ar_client_webapp/public/dispatch.cgi
|
42
|
-
examples/ar_client_webapp/public/dispatch.fcgi
|
43
|
-
examples/ar_client_webapp/public/dispatch.rb
|
44
|
-
examples/ar_client_webapp/public/favicon.ico
|
45
|
-
examples/ar_client_webapp/public/images/rails.png
|
46
|
-
examples/ar_client_webapp/public/index.html
|
47
|
-
examples/ar_client_webapp/public/javascripts/application.js
|
48
|
-
examples/ar_client_webapp/public/javascripts/controls.js
|
49
|
-
examples/ar_client_webapp/public/javascripts/dragdrop.js
|
50
|
-
examples/ar_client_webapp/public/javascripts/effects.js
|
51
|
-
examples/ar_client_webapp/public/javascripts/prototype.js
|
52
|
-
examples/ar_client_webapp/public/robots.txt
|
53
|
-
examples/ar_client_webapp/script/about
|
54
|
-
examples/ar_client_webapp/script/breakpointer
|
55
|
-
examples/ar_client_webapp/script/console
|
56
|
-
examples/ar_client_webapp/script/destroy
|
57
|
-
examples/ar_client_webapp/script/generate
|
58
|
-
examples/ar_client_webapp/script/performance/benchmarker
|
59
|
-
examples/ar_client_webapp/script/performance/profiler
|
60
|
-
examples/ar_client_webapp/script/plugin
|
61
|
-
examples/ar_client_webapp/script/process/inspector
|
62
|
-
examples/ar_client_webapp/script/process/reaper
|
63
|
-
examples/ar_client_webapp/script/process/spawner
|
64
|
-
examples/ar_client_webapp/script/runner
|
65
|
-
examples/ar_client_webapp/script/server
|
66
|
-
examples/ar_client_webapp/test/fixtures/users.yml
|
67
|
-
examples/ar_client_webapp/test/functional/user_controller_test.rb
|
68
|
-
examples/ar_client_webapp/test/test_helper.rb
|
69
|
-
examples/ar_client_webapp/test/unit/user_test.rb
|
70
|
-
examples/ar_client_webapp/tmp/sessions/ruby_sess.e2e3c63a67baef6d
|
71
|
-
examples/ar_webapp/.DS_Store
|
72
11
|
examples/ar_webapp/README
|
73
12
|
examples/ar_webapp/Rakefile
|
74
|
-
examples/ar_webapp/app/.DS_Store
|
75
13
|
examples/ar_webapp/app/controllers/application.rb
|
76
14
|
examples/ar_webapp/app/controllers/hobbies_controller.rb
|
77
15
|
examples/ar_webapp/app/controllers/interests_controller.rb
|
@@ -87,9 +25,7 @@ examples/ar_webapp/app/models/ruby_sync_observer.rb
|
|
87
25
|
examples/ar_webapp/app/models/ruby_sync_operation.rb
|
88
26
|
examples/ar_webapp/app/models/ruby_sync_state.rb
|
89
27
|
examples/ar_webapp/app/models/ruby_sync_value.rb
|
90
|
-
examples/ar_webapp/app/views/.DS_Store
|
91
28
|
examples/ar_webapp/app/views/layouts/application.rhtml
|
92
|
-
examples/ar_webapp/app/views/people/.DS_Store
|
93
29
|
examples/ar_webapp/app/views/people/show.rhtml
|
94
30
|
examples/ar_webapp/config/boot.rb
|
95
31
|
examples/ar_webapp/config/database.yml
|
@@ -159,12 +95,24 @@ examples/ar_webapp/test/unit/ruby_sync_observer_test.rb
|
|
159
95
|
examples/ar_webapp/test/unit/ruby_sync_operation_test.rb
|
160
96
|
examples/ar_webapp/test/unit/ruby_sync_state_test.rb
|
161
97
|
examples/ar_webapp/test/unit/ruby_sync_value_test.rb
|
162
|
-
examples/
|
163
|
-
examples/
|
164
|
-
examples/
|
165
|
-
examples/
|
166
|
-
examples/
|
167
|
-
examples/
|
98
|
+
examples/csv_to_ldap/config/connectors/hr_connector.rb
|
99
|
+
examples/csv_to_ldap/config/connectors/ldap_vault_connector.rb
|
100
|
+
examples/csv_to_ldap/config/db/HrImportPipeline(vault)_assoc_to_path.db
|
101
|
+
examples/csv_to_ldap/config/db/HrImportPipeline(vault)_mirror.db
|
102
|
+
examples/csv_to_ldap/config/db/HrImportPipeline(vault)_path_to_assoc.db
|
103
|
+
examples/csv_to_ldap/config/pipelines/hr_import_pipeline.rb
|
104
|
+
examples/csv_to_ldap/in/henchmen.csv.bak
|
105
|
+
examples/csv_to_xml/config/connectors/databank_connector.rb
|
106
|
+
examples/csv_to_xml/config/connectors/hr_connector.rb
|
107
|
+
examples/csv_to_xml/config/db/HrImportPipeline(vault)_assoc_to_path.db
|
108
|
+
examples/csv_to_xml/config/db/HrImportPipeline(vault)_mirror.db
|
109
|
+
examples/csv_to_xml/config/db/HrImportPipeline(vault)_path_to_assoc.db
|
110
|
+
examples/csv_to_xml/config/pipelines/hr_import_pipeline.rb
|
111
|
+
examples/csv_to_xml/databank.xml
|
112
|
+
examples/csv_to_xml/in/henchmen.csv.bak
|
113
|
+
examples/csv_to_xml/transcript.txt
|
114
|
+
examples/data/henchmen.csv
|
115
|
+
examples/data/more.csv
|
168
116
|
lib/net/ldif.rb
|
169
117
|
lib/ruby_sync.rb
|
170
118
|
lib/ruby_sync/connectors/active_record_association_handler.rb
|
@@ -184,11 +132,6 @@ lib/ruby_sync/operation.rb
|
|
184
132
|
lib/ruby_sync/pipelines/base_pipeline.rb
|
185
133
|
lib/ruby_sync/util/metaid.rb
|
186
134
|
lib/ruby_sync/util/utilities.rb
|
187
|
-
lib/rubysync.rb
|
188
|
-
nbproject/private/private.properties
|
189
|
-
nbproject/project.properties
|
190
|
-
nbproject/project.xml
|
191
|
-
rubysync.tmproj
|
192
135
|
test/data/example1.ldif
|
193
136
|
test/data/example2.ldif
|
194
137
|
test/data/example3.ldif
|
@@ -209,7 +152,6 @@ test/tc_ldap_connector.rb
|
|
209
152
|
test/tc_ldap_vault.rb
|
210
153
|
test/tc_ldif.rb
|
211
154
|
test/tc_memory_connectors.rb
|
212
|
-
test/tc_rubysync.rb
|
213
155
|
test/tc_transformation.rb
|
214
156
|
test/tc_utilities.rb
|
215
157
|
test/tc_xml_connectors.rb
|
data/Rakefile
CHANGED
@@ -15,9 +15,9 @@
|
|
15
15
|
|
16
16
|
require 'rubygems'
|
17
17
|
require 'hoe'
|
18
|
-
require './lib/
|
18
|
+
require './lib/ruby_sync.rb'
|
19
19
|
|
20
|
-
Hoe.new('rubysync',
|
20
|
+
Hoe.new('rubysync', RubySync::VERSION) do |p|
|
21
21
|
p.rubyforge_name = 'rubysync'
|
22
22
|
p.author = 'Ritchie Young'
|
23
23
|
p.email = 'ritchiey@gmail.com'
|
data/bin/rubysync
CHANGED
@@ -76,7 +76,7 @@
|
|
76
76
|
|
77
77
|
lib_path = File.dirname(__FILE__) + '/../lib'
|
78
78
|
$:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
|
79
|
-
require
|
79
|
+
require 'ruby_sync'
|
80
80
|
require "simpleconsole"
|
81
81
|
require 'rdoc/usage'
|
82
82
|
|
@@ -187,7 +187,7 @@ class Controller < SimpleConsole::Controller
|
|
187
187
|
private
|
188
188
|
|
189
189
|
def configure_logging
|
190
|
-
log_levels = [Logger::WARN, Logger::INFO, Logger::DEBUG]
|
190
|
+
log_levels = [::Logger::WARN, ::Logger::INFO, ::Logger::DEBUG]
|
191
191
|
verbosity = [(params[:verbose]||0), log_levels.size-1].min
|
192
192
|
log.level = log_levels[verbosity]
|
193
193
|
end
|
@@ -264,9 +264,6 @@ def fields
|
|
264
264
|
puts @field_names.join("\n")
|
265
265
|
end
|
266
266
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
267
|
end
|
271
268
|
|
272
269
|
|
@@ -285,8 +282,7 @@ end
|
|
285
282
|
|
286
283
|
def pipeline_template name, vault_name, client_name
|
287
284
|
vault = (vault_name)? ::RubySync::Connectors::BaseConnector.class_for(vault_name) : nil
|
288
|
-
vault_fields = vault && vault.fields ||
|
289
|
-
possible_fields = (vault_fields.map {|n| ":#{n}"}).join(", ")
|
285
|
+
vault_fields = vault && vault.fields || []
|
290
286
|
|
291
287
|
client = (client_name)? ::RubySync::Connectors::BaseConnector.class_for(client_name) : nil
|
292
288
|
client_fields = client && client.fields || []
|
@@ -301,33 +297,76 @@ class #{name.to_s.camelize}Pipeline < RubySync::Pipelines::BasePipeline
|
|
301
297
|
#{vault_specifier}
|
302
298
|
|
303
299
|
# Remove any fields that you don't want to set in the client from the vault
|
304
|
-
allow_out #{
|
300
|
+
allow_out #{allow_through(vault_fields)}
|
305
301
|
|
306
302
|
# Remove any fields that you don't want to set in the vault from the client
|
307
|
-
allow_in #{
|
303
|
+
allow_in #{allow_through(client_fields)}
|
308
304
|
|
309
305
|
# If the client and vault have different names for the same field, define the
|
310
306
|
# the mapping here. For example, if the vault has a field called "first name" and
|
311
307
|
# the client has a field called givenName you may put:
|
312
|
-
# 'first name'
|
313
|
-
#
|
314
|
-
#
|
315
|
-
#
|
316
|
-
|
317
|
-
#{(vault_fields.map {|f| "#'#{f}' => 'a_client_field'"}).join(",\n\t\t")}
|
318
|
-
})
|
319
|
-
|
308
|
+
# map 'first name', 'givenName'
|
309
|
+
#
|
310
|
+
# You can also calculate the values for fields. For more info, see
|
311
|
+
# http://rubysync.org/docs/rubysync-transformations/
|
312
|
+
|
320
313
|
# "in" means going from client to vault
|
321
|
-
|
322
|
-
|
314
|
+
in_transform do
|
315
|
+
#{transform_fields(vault_fields, 'vault', 'client')}
|
316
|
+
end
|
323
317
|
|
324
318
|
# "out" means going from vault to client
|
325
|
-
|
326
|
-
|
319
|
+
out_transform do
|
320
|
+
#{transform_fields(client_fields, 'client', 'vault')}
|
321
|
+
end
|
322
|
+
|
323
|
+
# if the vault doesn't already hold an association for this record
|
324
|
+
# from the client, perform a search here to see if a match can be found
|
325
|
+
# in_match do
|
326
|
+
# end
|
327
|
+
|
328
|
+
# if the vault doesn't have an association linking this record to one on
|
329
|
+
# the client, perform a search here to see if an existing client record
|
330
|
+
# matches this record
|
331
|
+
# out_match do
|
332
|
+
# end
|
333
|
+
|
334
|
+
# If this evaluates to false, it will veto the creation of a record on
|
335
|
+
# the vault. Good for checking you've got the required fields etc
|
336
|
+
# in_create_if do
|
337
|
+
# end
|
338
|
+
|
339
|
+
# if this evaluates to false for an outgoing event then it will
|
340
|
+
# veto the creation of a new record on the client
|
341
|
+
# out_create_if do
|
342
|
+
# end
|
343
|
+
|
344
|
+
# Should evaluate to the path for placing a new record on the vault
|
345
|
+
# in_place do
|
346
|
+
# end
|
347
|
+
|
348
|
+
# Should evaluate to the path for placing a new record on the client
|
349
|
+
# out_place do
|
350
|
+
# end
|
351
|
+
|
352
|
+
|
353
|
+
# These statements control logging. In log level 2 or higher (specify -v 2),
|
354
|
+
# the event will be dumped to the log at any of the places specified below.
|
355
|
+
# Uncomment and edit to taste.
|
356
|
+
# dump_before :in_filter, :in_transform, :in_place, :out_filter, :out_place, :out_transform
|
357
|
+
# dump_after :in_filter, :in_transform, :in_place, :out_filter, :out_place, :out_transform
|
358
|
+
|
327
359
|
|
328
360
|
end
|
329
361
|
end;
|
330
362
|
end
|
331
363
|
|
364
|
+
def allow_through fields
|
365
|
+
(fields.empty? ? %w{allow these fields through} : fields).to_ruby
|
366
|
+
end
|
367
|
+
|
368
|
+
def transform_fields fields, mine, other
|
369
|
+
(fields.empty? ? ['sample',mine,'fields'] : fields).map {|f| "#map '#{f}', '#{other}_field'"}.join("\n ")
|
370
|
+
end
|
332
371
|
|
333
372
|
SimpleConsole::Application.run(ARGV, Controller, View)
|
data/bin/rubysync.rb
CHANGED
@@ -76,7 +76,7 @@
|
|
76
76
|
|
77
77
|
lib_path = File.dirname(__FILE__) + '/../lib'
|
78
78
|
$:.unshift lib_path unless $:.include?(lib_path) || $:.include?(File.expand_path(lib_path))
|
79
|
-
require
|
79
|
+
require 'ruby_sync'
|
80
80
|
require "simpleconsole"
|
81
81
|
require 'rdoc/usage'
|
82
82
|
|
@@ -187,7 +187,7 @@ class Controller < SimpleConsole::Controller
|
|
187
187
|
private
|
188
188
|
|
189
189
|
def configure_logging
|
190
|
-
log_levels = [Logger::WARN, Logger::INFO, Logger::DEBUG]
|
190
|
+
log_levels = [::Logger::WARN, ::Logger::INFO, ::Logger::DEBUG]
|
191
191
|
verbosity = [(params[:verbose]||0), log_levels.size-1].min
|
192
192
|
log.level = log_levels[verbosity]
|
193
193
|
end
|
@@ -264,9 +264,6 @@ def fields
|
|
264
264
|
puts @field_names.join("\n")
|
265
265
|
end
|
266
266
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
267
|
end
|
271
268
|
|
272
269
|
|
@@ -285,8 +282,7 @@ end
|
|
285
282
|
|
286
283
|
def pipeline_template name, vault_name, client_name
|
287
284
|
vault = (vault_name)? ::RubySync::Connectors::BaseConnector.class_for(vault_name) : nil
|
288
|
-
vault_fields = vault && vault.fields ||
|
289
|
-
possible_fields = (vault_fields.map {|n| ":#{n}"}).join(", ")
|
285
|
+
vault_fields = vault && vault.fields || []
|
290
286
|
|
291
287
|
client = (client_name)? ::RubySync::Connectors::BaseConnector.class_for(client_name) : nil
|
292
288
|
client_fields = client && client.fields || []
|
@@ -301,33 +297,76 @@ class #{name.to_s.camelize}Pipeline < RubySync::Pipelines::BasePipeline
|
|
301
297
|
#{vault_specifier}
|
302
298
|
|
303
299
|
# Remove any fields that you don't want to set in the client from the vault
|
304
|
-
allow_out #{
|
300
|
+
allow_out #{allow_through(vault_fields)}
|
305
301
|
|
306
302
|
# Remove any fields that you don't want to set in the vault from the client
|
307
|
-
allow_in #{
|
303
|
+
allow_in #{allow_through(client_fields)}
|
308
304
|
|
309
305
|
# If the client and vault have different names for the same field, define the
|
310
306
|
# the mapping here. For example, if the vault has a field called "first name" and
|
311
307
|
# the client has a field called givenName you may put:
|
312
|
-
# 'first name'
|
313
|
-
#
|
314
|
-
#
|
315
|
-
#
|
316
|
-
|
317
|
-
#{(vault_fields.map {|f| "#'#{f}' => 'a_client_field'"}).join(",\n\t\t")}
|
318
|
-
})
|
319
|
-
|
308
|
+
# map 'first name', 'givenName'
|
309
|
+
#
|
310
|
+
# You can also calculate the values for fields. For more info, see
|
311
|
+
# http://rubysync.org/docs/rubysync-transformations/
|
312
|
+
|
320
313
|
# "in" means going from client to vault
|
321
|
-
|
322
|
-
|
314
|
+
in_transform do
|
315
|
+
#{transform_fields(vault_fields, 'vault', 'client')}
|
316
|
+
end
|
323
317
|
|
324
318
|
# "out" means going from vault to client
|
325
|
-
|
326
|
-
|
319
|
+
out_transform do
|
320
|
+
#{transform_fields(client_fields, 'client', 'vault')}
|
321
|
+
end
|
322
|
+
|
323
|
+
# if the vault doesn't already hold an association for this record
|
324
|
+
# from the client, perform a search here to see if a match can be found
|
325
|
+
# in_match do
|
326
|
+
# end
|
327
|
+
|
328
|
+
# if the vault doesn't have an association linking this record to one on
|
329
|
+
# the client, perform a search here to see if an existing client record
|
330
|
+
# matches this record
|
331
|
+
# out_match do
|
332
|
+
# end
|
333
|
+
|
334
|
+
# If this evaluates to false, it will veto the creation of a record on
|
335
|
+
# the vault. Good for checking you've got the required fields etc
|
336
|
+
# in_create_if do
|
337
|
+
# end
|
338
|
+
|
339
|
+
# if this evaluates to false for an outgoing event then it will
|
340
|
+
# veto the creation of a new record on the client
|
341
|
+
# out_create_if do
|
342
|
+
# end
|
343
|
+
|
344
|
+
# Should evaluate to the path for placing a new record on the vault
|
345
|
+
# in_place do
|
346
|
+
# end
|
347
|
+
|
348
|
+
# Should evaluate to the path for placing a new record on the client
|
349
|
+
# out_place do
|
350
|
+
# end
|
351
|
+
|
352
|
+
|
353
|
+
# These statements control logging. In log level 2 or higher (specify -v 2),
|
354
|
+
# the event will be dumped to the log at any of the places specified below.
|
355
|
+
# Uncomment and edit to taste.
|
356
|
+
# dump_before :in_filter, :in_transform, :in_place, :out_filter, :out_place, :out_transform
|
357
|
+
# dump_after :in_filter, :in_transform, :in_place, :out_filter, :out_place, :out_transform
|
358
|
+
|
327
359
|
|
328
360
|
end
|
329
361
|
end;
|
330
362
|
end
|
331
363
|
|
364
|
+
def allow_through fields
|
365
|
+
(fields.empty? ? %w{allow these fields through} : fields).to_ruby
|
366
|
+
end
|
367
|
+
|
368
|
+
def transform_fields fields, mine, other
|
369
|
+
(fields.empty? ? ['sample',mine,'fields'] : fields).map {|f| "#map '#{f}', '#{other}_field'"}.join("\n ")
|
370
|
+
end
|
332
371
|
|
333
372
|
SimpleConsole::Application.run(ARGV, Controller, View)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class HrConnector < RubySync::Connectors::CsvFileConnector
|
2
|
+
|
3
|
+
# True if the first line of each file is a header
|
4
|
+
# and should be ignored
|
5
|
+
header_line true
|
6
|
+
|
7
|
+
field_names 'id,first_name,last_name,skills'.split(',')
|
8
|
+
path_field 'id'
|
9
|
+
in_path "#{File.dirname(__FILE__)}/../../in"
|
10
|
+
#out_path '/directory/to/write/files/to'
|
11
|
+
in_glob '*.csv'
|
12
|
+
out_extension '.csv'
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class LdapVaultConnector < RubySync::Connectors::LdapConnector
|
2
|
+
|
3
|
+
host 'localhost'
|
4
|
+
port 389
|
5
|
+
username 'cn=Manager,dc=my-domain,dc=com'
|
6
|
+
password 'secret'
|
7
|
+
search_filter "cn=*"
|
8
|
+
search_base "ou=users,o=my-organization,dc=my-domain,dc=com"
|
9
|
+
#:bind_method :simple
|
10
|
+
|
11
|
+
end
|
data/examples/{ar_webapp/.DS_Store → csv_to_ldap/config/db/HrImportPipeline(vault)_assoc_to_path.db}
RENAMED
Binary file
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class HrImportPipeline < RubySync::Pipelines::BasePipeline
|
2
|
+
|
3
|
+
client :hr
|
4
|
+
|
5
|
+
vault :ldap_vault
|
6
|
+
|
7
|
+
# Remove any fields that you don't want to set in the vault from the client
|
8
|
+
allow_in 'id', 'first_name', 'last_name', 'skills'
|
9
|
+
|
10
|
+
# "in" means going from client to vault
|
11
|
+
in_transform do
|
12
|
+
map 'cn', 'id'
|
13
|
+
map 'sn', 'last_name'
|
14
|
+
map 'givenname', 'first_name'
|
15
|
+
map('employeeType') { value_of('skills').split(':') }
|
16
|
+
drop_changes_to 'skills'
|
17
|
+
map('objectclass') { 'inetOrgPerson' }
|
18
|
+
end
|
19
|
+
# Should evaluate to the path for placing a new record on the vault
|
20
|
+
in_place do
|
21
|
+
"cn=#{source_path},ou=users,o=my-organization,dc=my-domain,dc=com"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class HrConnector < RubySync::Connectors::CsvFileConnector
|
2
|
+
|
3
|
+
# True if the first line of each file is a header
|
4
|
+
# and should be ignored
|
5
|
+
header_line true
|
6
|
+
|
7
|
+
field_names 'id,first_name,last_name,skills'.split(',')
|
8
|
+
path_field 'id'
|
9
|
+
in_path "#{File.dirname(__FILE__)}/../../in"
|
10
|
+
#out_path '/directory/to/write/files/to'
|
11
|
+
in_glob '*.csv'
|
12
|
+
out_extension '.csv'
|
13
|
+
|
14
|
+
end
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class HrImportPipeline < RubySync::Pipelines::BasePipeline
|
2
|
+
|
3
|
+
client :hr
|
4
|
+
|
5
|
+
vault :databank
|
6
|
+
|
7
|
+
# Remove any fields that you don't want to set in the vault from the client
|
8
|
+
allow_in 'id', 'first_name', 'last_name', 'skills'
|
9
|
+
|
10
|
+
# "in" means going from client to vault
|
11
|
+
in_transform do
|
12
|
+
map 'cn', 'id'
|
13
|
+
map 'sn', 'last_name'
|
14
|
+
map 'givenname', 'first_name'
|
15
|
+
map('employeeType') { value_of('skills').split(':') }
|
16
|
+
drop_changes_to 'skills'
|
17
|
+
map('objectclass') { 'inetOrgPerson' }
|
18
|
+
end
|
19
|
+
# Should evaluate to the path for placing a new record on the vault
|
20
|
+
in_place do
|
21
|
+
"cn=#{source_path},ou=users,o=my-organization,dc=my-domain,dc=com"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<entries><entry id='cn=bobby,ou=users,o=my-organization,dc=my-domain,dc=com'><attr name='cn'><value>bobby</value></attr><attr name='givenname'><value>BareKnuckle</value></attr><attr name='objectclass'><value>inetOrgPerson</value></attr><attr name='sn'><value>Bobby</value></attr><attr name='employeeType'><value>pugilism</value><value>yoga</value></attr></entry><entry id='cn=tt,ou=users,o=my-organization,dc=my-domain,dc=com'><attr name='cn'><value>tt</value></attr><attr name='givenname'><value>Testy</value></attr><attr name='objectclass'><value>inetOrgPerson</value></attr><attr name='sn'><value>Terry</value></attr><attr name='employeeType'><value>kidnapping</value><value>interrogation</value><value>juggling</value></attr></entry></entries>
|
@@ -0,0 +1 @@
|
|
1
|
+
$ rubysync create config
|
2
|
|
1
3
|
# True if the first line of each file is a header
|
2
4
|
# and should be ignored
|
3
5
|
header_line true
|
4
6
|
field_names 'id,first_name,last_name,skills'.split(',')
|
5
7
|
path_field 'id'
|
6
8
|
in_path "#{File.dirname(__FILE__)}/../../in"
|
7
9
|
#out_path '/directory/to/write/files/to'
|
8
10
|
in_glob '*.csv'
|
9
11
|
out_extension '.csv'
|
10
12
|
|
11
13
|
|
12
14
|
client :hr
|
13
15
|
vault :databank
|
14
16
|
# Remove any fields that you don't want to set in the vault from the client
|
15
17
|
allow_in 'id', 'first_name', 'last_name', 'skills'
|
16
18
|
# "in" means going from client to vault
|
17
19
|
in_transform do
|
18
20
|
map 'cn', 'id'
|
19
21
|
map 'sn', 'last_name'
|
20
22
|
map 'givenname', 'first_name'
|
21
23
|
map('employeeType') { value_of('skills').split(':') }
|
22
24
|
drop_changes_to 'skills'
|
23
25
|
map('objectclass') { 'inetOrgPerson' }
|
24
26
|
end
|
25
27
|
# Should evaluate to the path for placing a new record on the vault
|
26
28
|
in_place do
|
27
29
|
"cn=#{source_path},ou=users,o=my-organization,dc=my-domain,dc=com"
|
28
30
|
end
|
29
|
-
--
|
30
|
-
--
|
31
31
|
<entry id='cn=bobby,ou=users,o=my-organization,dc=my-domain,dc=com'>
|
32
32
|
<attr name='cn'>
|
33
33
|
<value>bobby</value>
|
34
34
|
</attr>
|
35
35
|
<attr name='givenname'>
|
36
36
|
<value>BareKnuckle</value>
|
37
37
|
</attr>
|
38
38
|
<attr name='objectclass'>
|
39
39
|
<value>inetOrgPerson</value>
|
40
40
|
</attr>
|
41
41
|
<attr name='sn'>
|
42
42
|
<value>Bobby</value>
|
43
43
|
</attr>
|
44
44
|
<attr name='employeeType'>
|
45
45
|
<value>pugilism</value>
|
46
46
|
<value>yoga</value>
|
47
47
|
</attr>
|
48
48
|
</entry>
|
49
49
|
<entry id='cn=tt,ou=users,o=my-organization,dc=my-domain,dc=com'>
|
50
50
|
<attr name='cn'>
|
51
51
|
<value>tt</value>
|
52
52
|
</attr>
|
53
53
|
<attr name='givenname'>
|
54
54
|
<value>Testy</value>
|
55
55
|
</attr>
|
56
56
|
<attr name='objectclass'>
|
57
57
|
<value>inetOrgPerson</value>
|
58
58
|
</attr>
|
59
59
|
<attr name='sn'>
|
60
60
|
<value>Terry</value>
|
61
61
|
</attr>
|
62
62
|
<attr name='employeeType'>
|
63
63
|
<value>kidnapping</value>
|
64
64
|
<value>interrogation</value>
|
65
65
|
<value>juggling</value>
|
66
66
|
</attr>
|
67
67
|
</entry>
|