onebody-updateagent 0.4.1 → 0.4.2
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/VERSION +1 -0
- data/bin/update_onebody +11 -3
- data/lib/updateagent/updateagent.rb +3 -3
- data/lib/updateagent/updaters/people_updater.rb +9 -1
- metadata +3 -2
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.2
|
data/bin/update_onebody
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'yaml'
|
5
5
|
|
6
|
+
UPDATEAGENT_VERSION = File.read(File.dirname(__FILE__) + '/../VERSION').strip
|
7
|
+
|
6
8
|
options = {:confirm => true, :force => false}
|
7
9
|
config = nil
|
8
10
|
opt_parser = OptionParser.new do |opts|
|
@@ -32,8 +34,14 @@ opt_parser = OptionParser.new do |opts|
|
|
32
34
|
opts.on("-g", "--groups", "Sync groups.csv rather than people.csv") do |g|
|
33
35
|
options[:sync_groups] = true
|
34
36
|
end
|
35
|
-
|
36
|
-
|
37
|
+
# doesn't work yet
|
38
|
+
#opts.on("-d", "--delete", "Delete people and families not found in source file") do |d|
|
39
|
+
# options[:delete] = true
|
40
|
+
#end
|
41
|
+
opts.on("--version", "Show version and exit.") do
|
42
|
+
puts "OneBody UpdateAgent version #{UPDATEAGENT_VERSION}"
|
43
|
+
puts
|
44
|
+
exit
|
37
45
|
end
|
38
46
|
end
|
39
47
|
opt_parser.parse!
|
@@ -78,7 +86,7 @@ if ARGV[0] # path/to/people.csv or path/to/groups.csv
|
|
78
86
|
agent.compare(options[:force])
|
79
87
|
if agent.has_work?
|
80
88
|
if options[:confirm]
|
81
|
-
case ask("#{agent.
|
89
|
+
case ask("#{agent.create_count} record(s) to create and #{agent.update_count} record(s) to update. Continue? (Yes, No, Review) ") { |q| q.in = %w(yes no review y n r) }
|
82
90
|
when 'review', 'r'
|
83
91
|
agent.present
|
84
92
|
unless agent.confirm
|
@@ -112,8 +112,8 @@ class UpdateAgent
|
|
112
112
|
def present_record(row, new=false)
|
113
113
|
puts "#{row['legacy_id'].to_s.ljust(10)} #{name_for(row).to_s.ljust(40)} #{new ? '(new)' : ' '}"
|
114
114
|
if DEBUG
|
115
|
-
puts row.
|
116
|
-
puts row['remote_hash']
|
115
|
+
puts "Local values: #{row.values_for_hash(@attributes).join}"
|
116
|
+
puts "Remote values: #{row['remote_hash']}"
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -128,7 +128,7 @@ class UpdateAgent
|
|
128
128
|
index = 0
|
129
129
|
print "#{resource.name} 0/0\r"; STDOUT.flush
|
130
130
|
(@create + @update).each_slice(MAX_TO_BATCH_AT_A_TIME) do |records|
|
131
|
-
response = resource.post(:batch, {}, records.to_xml)
|
131
|
+
response = resource.post(:batch, {}, {:options => @options['remote_options'], :records => records}.to_xml)
|
132
132
|
statuses = Hash.from_xml(response.body)['records']
|
133
133
|
statuses.each do |status|
|
134
134
|
record = data_by_id[status['legacy_id']]
|
@@ -37,7 +37,7 @@ class PeopleUpdater < UpdateAgent
|
|
37
37
|
puts
|
38
38
|
@data = person_data
|
39
39
|
@attributes.reject! { |a| a =~ /^family_/ and a != 'family_id' }
|
40
|
-
@family_agent = FamilyUpdater.new(family_data.values)
|
40
|
+
@family_agent = FamilyUpdater.new(family_data.values, @options)
|
41
41
|
end
|
42
42
|
|
43
43
|
@@required_columns = %w(legacy_id legacy_family_id)
|
@@ -68,6 +68,14 @@ class PeopleUpdater < UpdateAgent
|
|
68
68
|
super
|
69
69
|
end
|
70
70
|
|
71
|
+
def create_count
|
72
|
+
@create.length + @family_agent.create.length
|
73
|
+
end
|
74
|
+
|
75
|
+
def update_count
|
76
|
+
@update.length + @family_agent.update.length
|
77
|
+
end
|
78
|
+
|
71
79
|
def push
|
72
80
|
@family_agent.push
|
73
81
|
super
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebody-updateagent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Morgan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-19 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -51,6 +51,7 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
|
53
53
|
files:
|
54
|
+
- VERSION
|
54
55
|
- example.yml
|
55
56
|
- README.markdown
|
56
57
|
- bin/update_onebody
|