Module: Josef::Diff
Instance Method Summary collapse
- #be_create?(local_group) ⇒ Boolean
- #be_delete?(remote_group) ⇒ Boolean
- #changed?(local_group) ⇒ Boolean
- #remote_diff(remote, local, mode = "apply") ⇒ Object
- #should_be_tareget?(local_group) ⇒ Boolean
Methods included from Local
#exculued?, #exculued_groups, #exculued_groups!, #local, #local!
Methods included from Remote
#remote, #remote!, #remote_apply, #remote_dump
Methods included from GoogleWorkspace::Group
#create_group, #delete_group, #groups, #groups!
Methods included from GoogleWorkspace::Members
#add_member, #del_member, #member_mail_addreses, #members_by
Methods included from GoogleWorkspace::Config
#actor, #actor!, #credential_path, #domains, #token_path
Methods included from GoogleWorkspace::Client
#authorize!, #client, #client!
Instance Method Details
#be_create?(local_group) ⇒ Boolean
21 22 23 |
# File 'lib/josef/diff.rb', line 21 def be_create?(local_group) remote.find{|g| g[:group_mail_address] == local_group[:group_mail_address]}.nil? end |
#be_delete?(remote_group) ⇒ Boolean
25 26 27 |
# File 'lib/josef/diff.rb', line 25 def be_delete?(remote_group) local.find{|g| g[:group_mail_address] == remote_group[:group_mail_address]}.nil? end |
#changed?(local_group) ⇒ Boolean
14 15 16 17 18 19 |
# File 'lib/josef/diff.rb', line 14 def changed?(local_group) remote_group = remote.find{|g| g[:group_mail_address] == local_group[:group_mail_address]} return false if local_group[:members].sort == remote_group[:members].sort true end |
#remote_diff(remote, local, mode = "apply") ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/josef/diff.rb', line 29 def remote_diff(remote, local, mode = "apply") local.each do | local_group | next unless should_be_tareget?(local_group) if be_create?(local_group) puts "#{local_group[:group_mail_address]} will be create:#{mode}" local_group[:members].each do | member | puts "+ #{member}" end elsif changed?(local_group) puts "#{local_group[:group_mail_address]} will be change:#{mode}" remote_members = remote.find{|g| g[:group_mail_address] == local_group[:group_mail_address]}[:members] add = local_group[:members] - remote_members del = remote_members - local_group[:members] add.each do | add_member | puts "+ #{add_member}" end del.each do | del_member | puts "- #{del_member}" end end end remote.each do | remote_group | next unless should_be_tareget?(remote_group) if be_delete?(remote_group) puts "#{remote_group[:group_mail_address]} will be delete:#{mode}" end end end |
#should_be_tareget?(local_group) ⇒ Boolean
8 9 10 11 12 |
# File 'lib/josef/diff.rb', line 8 def should_be_tareget?(local_group) return false if exculued?(local_group[:group_mail_address]) true end |