seven1m-onebody-updateagent 0.1.4 → 0.2.0

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/README.markdown CHANGED
@@ -69,13 +69,13 @@ Usage
69
69
 
70
70
  To run UpdateAgent:
71
71
 
72
- update_onebody -c path/to/config.yml path/to/people.yml
72
+ update_onebody -c path/to/config.yml path/to/people.csv
73
73
 
74
74
  If you plan to schedule UpdateAgent to run periodically without human intervention,
75
75
  you'll want to at least use the `-y` switch, which assumes *yes* to any questions:
76
76
 
77
- update_onebody -c path/to/config.yml -y path/to/people.yml
77
+ update_onebody -c path/to/config.yml -y path/to/people.csv
78
78
 
79
79
  You may also log all output:
80
80
 
81
- update_onebody -c path/to/config.yml -y -l path/to/updateagent.log path/to/people.yml
81
+ update_onebody -c path/to/config.yml -y -l path/to/updateagent.log path/to/people.csv
data/bin/update_onebody CHANGED
@@ -26,6 +26,9 @@ opt_parser = OptionParser.new do |opts|
26
26
  CONVERTER_CONFIG = c
27
27
  end
28
28
  end
29
+ opts.on("-g", "--groups", "Sync groups.csv rather than people.csv") do |g|
30
+ options[:sync_groups] = true
31
+ end
29
32
  end
30
33
  opt_parser.parse!
31
34
 
@@ -38,30 +41,50 @@ unless options[:config_file]
38
41
  exit
39
42
  end
40
43
 
41
- if ARGV[0] # path/to/people.csv
44
+ if ARGV[0] # path/to/people.csv or path/to/groups.csv
45
+ $: << 'lib'
42
46
  require 'onebody-updateagent'
43
47
  puts "Update Agent running at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}"
44
- agent = PeopleUpdater.new(ARGV[0])
45
- puts "comparing records..."
46
- agent.compare(options[:force])
47
- if agent.has_work?
48
- if options[:confirm]
49
- case ask("#{agent.create.length + agent.update.length} record(s) to push. Continue? (Yes, No, Review) ") { |q| q.in = %w(yes no review y n r) }
50
- when 'review', 'r'
51
- agent.present
52
- unless agent.confirm
48
+ if options[:sync_groups]
49
+ agent = ExternalGroupUpdater.new(ARGV[0])
50
+ puts "comparing records..."
51
+ agent.compare
52
+ if agent.has_work?
53
+ if options[:confirm]
54
+ case ask("#{agent.create.length + agent.update.length} record(s) to push. Continue? (Yes, No) ") { |q| q.in = %w(yes no y n) }
55
+ when 'no', 'n'
56
+ puts "Canceled by user\n"
57
+ exit
58
+ end
59
+ end
60
+ agent.push
61
+ puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
62
+ else
63
+ puts "Nothing to push\n\n"
64
+ end
65
+ else # sync people
66
+ agent = PeopleUpdater.new(ARGV[0])
67
+ puts "comparing records..."
68
+ agent.compare(options[:force])
69
+ if agent.has_work?
70
+ if options[:confirm]
71
+ case ask("#{agent.create.length + agent.update.length} record(s) to push. Continue? (Yes, No, Review) ") { |q| q.in = %w(yes no review y n r) }
72
+ when 'review', 'r'
73
+ agent.present
74
+ unless agent.confirm
75
+ puts "Canceled by user\n"
76
+ exit
77
+ end
78
+ when 'no', 'n'
53
79
  puts "Canceled by user\n"
54
80
  exit
55
81
  end
56
- when 'no', 'n'
57
- puts "Canceled by user\n"
58
- exit
59
82
  end
83
+ agent.push
84
+ puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
85
+ else
86
+ puts "Nothing to push\n\n"
60
87
  end
61
- agent.push
62
- puts "Completed at #{Time.now.strftime('%m/%d/%Y %I:%M %p')}\n\n"
63
- else
64
- puts "Nothing to push\n\n"
65
88
  end
66
89
  else
67
90
  puts opt_parser.help
@@ -13,6 +13,7 @@ require 'updateagent/hash_extensions'
13
13
  require 'updateagent/updateagent'
14
14
  require 'updateagent/updaters/people_updater'
15
15
  require 'updateagent/updaters/family_updater'
16
+ require 'updateagent/updaters/external_group_updater'
16
17
 
17
18
  if defined?(USE_CONVERTER)
18
19
  require "updateagent/converters/#{USE_CONVERTER.downcase}_converter"
@@ -4,5 +4,6 @@ class Base < ActiveResource::Base
4
4
  self.password = USER_KEY
5
5
  end
6
6
 
7
- class Person < Base; end
8
- class Family < Base; end
7
+ class Person < Base; end
8
+ class Family < Base; end
9
+ class ExternalGroup < Base; end
@@ -18,6 +18,10 @@ class UpdateAgent
18
18
  read_from_file(data)
19
19
  end
20
20
  end
21
+ check_for_invalid_columns
22
+ end
23
+
24
+ def check_for_invalid_columns
21
25
  if invalid = @data.detect { |row| row['id'] }
22
26
  puts "Error: one or more records contain an 'id' column."
23
27
  puts "You must utilize 'legacy_id' rather than 'id' so that"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seven1m-onebody-updateagent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
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-04-08 00:00:00 -07:00
12
+ date: 2009-05-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -65,6 +65,7 @@ files:
65
65
  - lib/updateagent/updaters/people_updater.rb
66
66
  has_rdoc: false
67
67
  homepage: http://github.com/seven1m/onebody-updateagent
68
+ licenses:
68
69
  post_install_message:
69
70
  rdoc_options: []
70
71
 
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
86
  requirements: []
86
87
 
87
88
  rubyforge_project:
88
- rubygems_version: 1.2.0
89
+ rubygems_version: 1.3.5
89
90
  signing_key:
90
91
  specification_version: 2
91
92
  summary: Companion to OneBody that handles sync with external data source.