rally_workspace_utils 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -43,7 +43,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
43
43
  p.clean_globs = CLEAN #An array of file patterns to delete on clean.
44
44
 
45
45
  p.extra_deps = []
46
- p.extra_deps << ["rally_rest_api", ">= 0.6.2"]
46
+ p.extra_deps << ["rally_rest_api", ">= 0.6.3"]
47
47
  p.extra_deps << ["activesupport"]
48
48
 
49
49
 
@@ -65,7 +65,7 @@ class DefectCopy < ObjectCopy
65
65
  # tangle the duplicate defects
66
66
  unless @object.duplicates.nil?
67
67
  dups = []
68
- @object.duplicates.values.each do |dup|
68
+ @object.duplicates.each do |dup|
69
69
  dups << fetch_object(:defect, dup.oid, new_workspace)
70
70
  end
71
71
  values[:duplicates] = dups
@@ -4,17 +4,20 @@ class ObjectCopy
4
4
  end
5
5
 
6
6
  def copy(new_workspace, additional_values = {})
7
- @object.rally_rest.logger.info "Copying #{@object.type} -- #{@object.name}"
8
- values = shallow_copy(@object, new_workspace)
9
- values.merge! additional_values
7
+ unless TranslationStore[@object.oid]
8
+ values = shallow_copy(@object, new_workspace)
9
+ values.merge! additional_values
10
10
 
11
- values[:workspace] = new_workspace
12
- values[:project] = find_project_in_new_workspace(new_workspace)
11
+ values[:workspace] = new_workspace
12
+ values[:project] = find_project_in_new_workspace(new_workspace)
13
13
 
14
- @new_object = create_object(new_workspace.rally_rest, values)
15
- remember @object, @new_object
14
+ @object.rally_rest.logger.info "Copying #{@object.type} -- #{@object.name}"
15
+ @new_object = create_object(new_workspace.rally_rest, values)
16
+ remember @object, @new_object
17
+ else
18
+ @new_object = fetch_object(@object.type_as_symbol, @object.oid, new_workspace)
19
+ end
16
20
  copy_children(new_workspace)
17
-
18
21
  @new_object
19
22
  end
20
23
 
@@ -37,10 +40,10 @@ class ObjectCopy
37
40
  end
38
41
 
39
42
  def fetch_project(project_name, workspace)
40
- @@cached_projects ||= {}
41
- return @@cached_projects[project_name] if @@cached_projects.key? project_name
43
+ cached_projects = TranslationStore.instance.projects
44
+ return cached_projects[project_name] if cached_projects.key? project_name
42
45
  project = workspace.rally_rest.find(:project, :workspace => workspace) { equal :name, project_name }.first
43
- @@cached_projects[project_name] = project
46
+ cached_projects[project_name] = project
44
47
  end
45
48
 
46
49
  def shallow_copy(object, new_workspace)
@@ -70,26 +73,27 @@ class ObjectCopy
70
73
  end
71
74
 
72
75
  def user_exists?(username)
73
- @@cached_users ||= {}
76
+ cached_users = TranslationStore.instance.users
74
77
 
75
78
  return true if username.nil?
76
- return @@cached_users[username] if @@cached_users.key? username
79
+ return cached_users[username] if cached_users.key? username
77
80
 
78
81
  result = @object.rally_rest.find(:user) { equal :login_name, username }
79
82
  if result.total_result_count > 0
80
- @@cached_users[username] = true
83
+ cached_users[username] = true
81
84
  else
82
- @@cached_users[username] = false
85
+ cached_users[username] = false
83
86
  end
84
87
  end
85
88
 
86
89
  def fetch_object(type, oid, workspace)
87
- @@cached_objects ||= {}
90
+ cached_objects = TranslationStore.instance.objects
88
91
  new_oid = TranslationStore[oid]
89
- return @@cached_objects[new_oid] if @@cached_objects.key? oid
92
+ return cached_objects[new_oid] if cached_objects.key? oid
90
93
 
91
94
  object = @object.rally_rest.find(type, :workspace => workspace) { equal :object_i_d, new_oid }.first
92
- @@cached_objects[new_oid] = object
95
+ cached_objects[new_oid] = object
93
96
  end
97
+
94
98
  end
95
99
 
@@ -37,7 +37,7 @@ class StoryCopy < ObjectCopy
37
37
  end
38
38
 
39
39
  def copy_children(new_workspace)
40
- @object.cards.first.tasks.values.flatten.each do |task|
40
+ @object.cards.first.tasks.each do |task|
41
41
  task.copy(new_workspace, :work_product => @new_object)
42
42
  end if !@object.cards.nil? && !@object.cards.first.tasks.nil?
43
43
  end
@@ -17,10 +17,10 @@ class Translate
17
17
  end
18
18
 
19
19
  def run
20
- @slm = RallyRestAPI.new(:base_url => @base_url, :username => @username, :password => @password, :logger => @logger)
20
+ @slm = RallyRestAPI.new(:base_url => @base_url, :username => @username, :password => @password, :logger => @logger, :parse_collections_as_hash => false)
21
21
 
22
- @from_workspace = @slm.user.subscription.workspaces.values.flatten.find { |w| w.name == @from_workspace_name }
23
- @to_workspace = @slm.user.subscription.workspaces.values.flatten.find { |w| w.name == @to_workspace_name }
22
+ @from_workspace = @slm.user.subscription.workspaces.find { |w| w.name == @from_workspace_name }
23
+ @to_workspace = @slm.user.subscription.workspaces.find { |w| w.name == @to_workspace_name }
24
24
 
25
25
  raise "No such workspace #{@from_workspace_name}" unless @from_workspace
26
26
  raise "No such workspace #{@to_workspace_name}" unless @to_workspace
@@ -30,9 +30,8 @@ class Translate
30
30
  begin
31
31
  # now do the copy
32
32
  [:iteration, :release, :story, :defect, :test_case].each do |type|
33
- # @slm.find_all(type, :workspace => @from_workspace, :order => [:creation_date, :desc]).each do |o|
34
- @slm.find_all(type, :workspace => @from_workspace).each do |o|
35
- o.copy(@to_workspace) unless TranslationStore[o.oid]
33
+ @slm.find_all(type, :workspace => @from_workspace, :order => [:creation_date, :desc]).each do |o|
34
+ o.copy(@to_workspace)
36
35
  end
37
36
  end unless store.copy_finished?
38
37
  store.copy_finished!
@@ -46,15 +45,9 @@ class Translate
46
45
  store.tangle_finished!
47
46
  rescue Exception => e
48
47
  @logger.info "Caught an exception #{e}. Remembering where we were."
48
+ @logger.info e.backtrace.join("\n")
49
49
  # Remember where we were if there was a failure
50
50
  store.dump
51
51
  end
52
52
  end
53
-
54
- def dump_oids
55
- File.open("TRANSLATED", "w+") do |f|
56
- Marshal.dump($TRANSLATED, f)
57
- end
58
- end
59
-
60
53
  end
@@ -30,7 +30,7 @@ module TranslationAudit
30
30
  compare_each :defect do |old, new|
31
31
  if !old.requirement.nil? && old.requirement.type == "Story"
32
32
  if new.requirement.children
33
- if old.requirement.name != new.requirement.children.values.first.name
33
+ if old.requirement.name != new.requirement.children.first.name
34
34
  end
35
35
  else
36
36
  if old.requirement.name != new.requirement.name
@@ -42,7 +42,7 @@ module TranslationAudit
42
42
  compare_each :test_case do |old, new|
43
43
  if !old.work_product.nil? && old.work_product.type == "Story"
44
44
  if new.work_product.children
45
- if old.work_product.name != new.work_product.children.values.first.name
45
+ if old.work_product.name != new.work_product.children.first.name
46
46
  end
47
47
  else
48
48
  if old.work_product.name != new.work_product.name
@@ -1,5 +1,6 @@
1
1
 
2
2
  class TranslationStore
3
+ attr_reader :projects, :users, :objects
3
4
  private_class_method :new
4
5
 
5
6
  def TranslationStore.instance(from_workspace = nil, to_workspace = nil)
@@ -22,6 +23,9 @@ class TranslationStore
22
23
  @w1 = w1.oid
23
24
  @w2 = w2.oid
24
25
  @store = {}
26
+ @projects = {}
27
+ @users = {}
28
+ @objects = {}
25
29
  @store[:copy] = false
26
30
  @store[:tangle] = false
27
31
  load
@@ -71,6 +75,7 @@ class TranslationStore
71
75
 
72
76
  def cleanup
73
77
  File.delete(filename) if File.exists? filename
78
+ self.class.send(:remove_class_variable, :@@instance) if defined? @@instance
74
79
  end
75
80
 
76
81
  end
@@ -2,7 +2,7 @@ module Translate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -3,8 +3,8 @@ 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.3
7
- date: 2006-12-20 00:00:00 -07:00
6
+ version: 0.0.4
7
+ date: 2007-01-03 00:00:00 -07:00
8
8
  summary: A utility to translate a UseCase workspace to a UserStory workspace
9
9
  require_paths:
10
10
  - lib
@@ -69,7 +69,7 @@ dependencies:
69
69
  requirements:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 0.6.2
72
+ version: 0.6.3
73
73
  version:
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: activesupport