Class: MergeTaggedValues

Inherits:
Merge
  • Object
show all
Defined in:
lib/xmimerge/merge_tagged_values.rb

Instance Method Summary collapse

Methods inherited from Merge

#check, #check_change_propertie, #merge

Constructor Details

#initialize(name, from_tag, to_tag) ⇒ MergeTaggedValues

Returns a new instance of MergeTaggedValues.



5
6
7
8
9
10
# File 'lib/xmimerge/merge_tagged_values.rb', line 5

def initialize(name, from_tag, to_tag)
	super()
	@name = name
	@from_tag = from_tag
	@to_tag = to_tag
end

Instance Method Details

#check_new(from_tagged_value) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/xmimerge/merge_tagged_values.rb', line 19

def check_new(from_tagged_value)

	@log.debug("Checking TaggedValue of #{@name} '#{from_tagged_value.name}'...") if @only_check

	to_tagged_value = @to_tag.tagged_value_by_name(from_tagged_value.name)
	if to_tagged_value.nil?			

		@log.debug("New Tagged Value #{from_tagged_value.name}...") if @only_check
		command = "\t+ #{@name}TaggedValue #{@from_tag.full_name} {'#{from_tagged_value.name}' = '#{from_tagged_value.value}'}"
		@commands.add_command_to_buffer(command)
		unless @only_check 
			if @commands.has_command?(command)
				@to_tag.add_xml_tagged_value(from_tagged_value.xml.to_xml)	
				@log.info "[OK] #{command}"
			else
				#@log.info "[NOT] #{command}"
			end
		end
	else
		if from_tagged_value.value != to_tagged_value.value
			@log.debug("Change Tagged Value #{from_tagged_value.name}...") if @only_check
			command = "\t* #{@name}TaggedValue #{@from_tag.full_name} {'#{from_tagged_value.name}'} '#{to_tagged_value.value}' --> '#{from_tagged_value.value}'"
			@commands.add_command_to_buffer(command)
			unless @only_check 
				if @commands.has_command?(command)
					@log.info "[OK] #{command}"
				else
					#@log.info "[NOT] #{command}"
				end
			end
		end
	end		
end

#check_removedObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/xmimerge/merge_tagged_values.rb', line 53

def check_removed
	to_tagged_values = @to_tag.tagged_values.each do |to_tagged_value|
		ok = false
		@from_tag.tagged_values.each do |from_tagged_value|
			if to_tagged_value.name == from_tagged_value.name
				ok = true
				break
			end
		end
		if !ok
			command = "\t- #{@name}TaggedValue #{@from_tag.full_name} {'#{to_tagged_value.name}'}"
			@commands.add_command_to_buffer(command)
			unless @only_check 
				if @commands.has_command?(command)
					@log.info "[OK] #{command}"
				else
					#@log.info "[NOT] #{command}"
				end
			end
		end
	end		
end

#verifyObject



12
13
14
15
16
17
# File 'lib/xmimerge/merge_tagged_values.rb', line 12

def verify
	@from_tag.tagged_values.each do |from_tagged_value|
		check_new(from_tagged_value)
	end
	check_removed
end