rally_workspace_utils 0.0.1 → 0.0.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.
@@ -38,6 +38,7 @@ end
38
38
  args = {:base_url => "https://rally1.rallydev.com/slm"}
39
39
 
40
40
  debug = false
41
+ audit = false
41
42
  logfile = STDOUT
42
43
 
43
44
  opts.each do |opt, arg|
@@ -45,7 +46,6 @@ opts.each do |opt, arg|
45
46
  when "--base_url"
46
47
  args[:base_url] = arg
47
48
  when "--from_workspace"
48
- puts "arg = #{arg}"
49
49
  args[:from_workspace] = arg
50
50
  when "--to_workspace"
51
51
  args[:to_workspace] = arg
@@ -58,6 +58,8 @@ opts.each do |opt, arg|
58
58
  RestBuilder::DEBUG = true
59
59
  when "--logfile"
60
60
  logfile = arg
61
+ when "--audit"
62
+ audit = true
61
63
  when "--help"
62
64
  usage
63
65
  else
@@ -84,7 +86,7 @@ end
84
86
  args[:logger] = logger
85
87
 
86
88
  translate = Translate.new(args)
87
- puts translate.inspect
88
89
  translate.run
90
+ translate.audit if audit
89
91
 
90
92
 
@@ -1,5 +1,3 @@
1
- require 'pp'
2
-
3
1
  class ObjectCopy
4
2
  def initialize(object)
5
3
  @object = object
@@ -56,7 +54,7 @@ class ObjectCopy
56
54
  attrdef = @object.typedef.custom_dropdown_attributes[attribute]
57
55
  unless attrdef.allowed_values.include? value
58
56
  values[attribute] = nil
59
- puts "Deleteing #{attribute} = #{value} from @{object.name} because it no longer exists"
57
+ @object.rally_rest.logger.info "Deleteing #{attribute} = #{value} from @{object.name} because it no longer exists"
60
58
  end
61
59
  end
62
60
  end
@@ -3,6 +3,8 @@ require File.dirname(__FILE__) + '/translation_audit'
3
3
 
4
4
  class Translate
5
5
  include TranslationAudit
6
+
7
+ attr_reader :logger
6
8
 
7
9
  def initialize(args)
8
10
  @base_url = args[:base_url]
@@ -29,7 +31,7 @@ class Translate
29
31
  $TRANSLATED = Marshal.load(f)
30
32
  end
31
33
 
32
- if $TRANSLATED[:from] != @from_workspace.oid && $TRANSLATED[:to] != @to_workspace.oid
34
+ if $TRANSLATED[:from] != @from_workspace.oid || $TRANSLATED[:to] != @to_workspace.oid
33
35
  $TRANSLATED = {}
34
36
  $TRANSLATED[:from] = @from_workspace.oid
35
37
  $TRANSLATED[:to] = @to_workspace.oid
@@ -1,3 +1,4 @@
1
+ require 'active_support'
1
2
 
2
3
  module TranslationAudit
3
4
  def audit
@@ -8,29 +9,32 @@ module TranslationAudit
8
9
  all_copied_fields_should_match_for :test_case_result, [:test_case]
9
10
  compare_each :test_case_result do |old, new|
10
11
  if old.test_case.name != new.test_case.name
11
- puts "#{old.type} -- #{old.name} is different"
12
+ self.logger.info diff_string(old, new)
12
13
  end
13
14
  end
14
15
 
15
16
  all_copied_fields_should_match_for :test_case_step, [:test_case]
16
17
  compare_each :test_case_step do |old, new|
17
18
  if old.test_case.name != new.test_case.name
18
- puts "#{old.type} -- #{old.name} is different"
19
+ self.logger.info diff_string(old, new)
19
20
  end
20
21
  end
21
22
  all_copied_fields_should_match_for :task, [:work_product]
22
23
  compare_each :task do |old, new|
24
+ next if old.work_product.type != "Story"
23
25
  if old.card.work_product.name != new.work_product.name
24
- puts "#{old.type} -- #{old.name} is different"
26
+ self.logger.info diff_string(old, new)
25
27
  end
26
28
  end
27
29
 
28
30
  compare_each :defect do |old, new|
29
31
  if !old.requirement.nil? && old.requirement.type == "Story"
30
32
  if new.requirement.children
31
- old.requirement.name.should == new.requirement.children.values.first.name
33
+ if old.requirement.name != new.requirement.children.values.first.name
34
+ end
32
35
  else
33
- old.requirement.name.should == new.requirement.name
36
+ if old.requirement.name != new.requirement.name
37
+ end
34
38
  end
35
39
  end
36
40
  end
@@ -38,9 +42,11 @@ module TranslationAudit
38
42
  compare_each :test_case do |old, new|
39
43
  if !old.work_product.nil? && old.work_product.type == "Story"
40
44
  if new.work_product.children
41
- old.work_product.name.should == new.work_product.children.values.first.name
45
+ if old.work_product.name != new.work_product.children.values.first.name
46
+ end
42
47
  else
43
- old.work_product.name.should == new.work_product.name
48
+ if old.work_product.name != new.work_product.name
49
+ end
44
50
  end
45
51
 
46
52
  end
@@ -51,7 +57,7 @@ module TranslationAudit
51
57
  @slm.find_all(type, :workspace => @from_workspace).each do |old_object|
52
58
  new_object = @slm.find(type, :workspace => @to_workspace) { equal :object_i_d, $TRANSLATED[old_object.oid] }.first
53
59
  if new_object.nil?
54
- puts "Cound not find an copy for object #{old_object.type} -- #{old_object.name} -- #{old_object.oid}"
60
+ self.logger.info "Cound not find a copy for object #{old_object.type} -- #{old_object.name} -- #{old_object.oid}"
55
61
  next
56
62
  end
57
63
  yield old_object, new_object
@@ -60,17 +66,32 @@ module TranslationAudit
60
66
 
61
67
  def all_copied_fields_should_match_for(type, additional_exceptions = [])
62
68
  compare_each(type) do |old_object, new_object|
63
- excepted_attributes = old_object.excepted_attributes + additional_exceptions
64
- old_hash = old_object.elements.reject { |k, v| excepted_attributes.include?(k) }
65
- new_hash = {}
66
- old_hash.each_key do |k|
67
- new_hash[k] = new_object.elements[k]
68
- end
69
- diff = old_hash.diff(new_hash)
69
+ diff = diff_objects(old_object, new_object, additional_exceptions)
70
70
  if diff.length > 0
71
- puts "#{old_hash.inspect} shoud == #{new_hash.inspect}"
72
- puts "all_copied_fields_should_match_for #{type} diff = #{diff.inspect}"
71
+ self.logger.info diff_string(old_object, new_object, additional_exceptions)
73
72
  end
74
73
  end
75
74
  end
75
+
76
+ def diff_objects(old_object, new_object, additional_exceptions = [])
77
+ excepted_attributes = old_object.excepted_attributes + additional_exceptions
78
+ old_hash = old_object.elements.reject { |k, v| excepted_attributes.include?(k) }
79
+ new_hash = {}
80
+ old_hash.each_key do |k|
81
+ new_hash[k] = new_object.elements[k]
82
+ end
83
+
84
+ old_hash.diff(new_hash)
85
+ end
86
+
87
+ def diff_string(old, new, additional_exceptions = [])
88
+ diff = diff_objects(old, new, additional_exceptions)
89
+ diff_string = "#{old.type} with name '#{old.name}' differs\n"
90
+ diff_string << "\told\t\t\tnew\n"
91
+ diff.each do |key, valye|
92
+ diff_string << "\t" << old.elements[key] << "\t\t\t" << new.elements[key] << "\n"
93
+ end
94
+ diff_string << "\n"
95
+ diff_string
96
+ end
76
97
  end
@@ -2,7 +2,7 @@ module Translate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: rally_workspace_utils
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
6
+ version: 0.0.2
7
7
  date: 2006-12-19 00:00:00 -07:00
8
8
  summary: A utility to translate a UseCase workspace to a UserStory workspace
9
9
  require_paths: