mingle-macro-development-toolkit 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 1.3.3 January 2011
2
+
3
+ * Minor bug fix
4
+
5
+ == 1.3.2 August 2010
6
+
7
+ * Minor bug fix
8
+
1
9
  == 1.3.1 March 2010
2
10
 
3
11
  * 1 bug fix
@@ -1,18 +1,20 @@
1
1
  = Macro Development Toolkit - supporting development of custom macros for Mingle
2
2
 
3
- This toolkit provides support for developing, testing and deploying custom Mingle macros.
3
+ http://mingle-macros.rubyforge.org/
4
+
5
+ This toolkit provides support for developing, testing and deploying custom Mingle macros.
4
6
 
5
7
  Use the built in generator to create a skeleton of a plugin which you can then deploy to an instance of Mingle running
6
8
  version 2.2 or later of the software.
7
9
 
8
- This allows you to take advantage of free charting utilities such as the Google Charts API, to create
10
+ This allows you to take advantage of free charting utilities such as the Google Charts API, to create
9
11
  new visualizations, specific to your project or organization.
10
12
 
11
13
  == FEATURES:
12
14
 
13
15
  * A command line tool to generate the skeleton of a custom Mingle macro
14
16
  * A unit test helper that uses locally available YAML fixture files to facilitate unit testing of the macros
15
- * An integration test helper that can
17
+ * An integration test helper that can
16
18
  * obtain data from a remote instance of Mingle
17
19
  * test MQL execution against a remote instance of Mingle
18
20
  * Rake task to deploy the custom macro as a plugin to a locally deployed Mingle instance
@@ -28,16 +30,16 @@ then use:
28
30
  == GETTING STARTED:
29
31
 
30
32
  To get started with this gem after you install it, use the new_mingle_macro script to generate a skeleton for your
31
- macro, along with test helpers. Say you wanted to create a new macro called "risk_meter" start out by creating
33
+ macro, along with test helpers. Say you wanted to create a new macro called "risk_meter" start out by creating
32
34
  the macro skeleton as follows
33
35
 
34
36
  % new_mingle_macro risk_meter
35
37
 
36
- The skeleton project will also contain a file, called "getting_started.txt" that will walk you through the steps
38
+ The skeleton project will also contain a file, called "getting_started.txt" that will walk you through the steps
37
39
  of fleshing out your macro.
38
40
 
39
41
  == SUPPORT:
40
-
42
+
41
43
  For any issues/clarifications/comments with installation or using this gem, contact us at the Mingle forums[http://community.thoughtworks.com/pages/home]. You can also get in touch with the ThoughtWorks Studios support
42
44
  team over email at support@thoughtworks.com
43
45
 
data/Rakefile CHANGED
@@ -17,32 +17,24 @@ end
17
17
  require File.dirname(__FILE__) + '/lib/macro_development_toolkit'
18
18
 
19
19
 
20
- # if ARGV[0] == "repackage"
21
-
22
- %w[newgem rubigen hoe].each { |f| require f }
23
- # Hoe.plugin :newgem
24
- # Hoe.plugin :website
25
-
26
- # Generate all the Rake tasks
27
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
28
- $hoe = Hoe.spec('mingle-macro-development-toolkit') do |p|
29
- p.version = MacroDevelopmentToolkit::VERSION
30
- p.developer('ThoughtWorks Inc', 'support@thoughtworks.com')
31
- p.post_install_message = 'getting_started.txt'
32
- p.rubyforge_name = 'mingle-macros'
33
- p.extra_deps = [
34
- ['activesupport','>= 2.0.2'],
35
- ]
36
- p.summary = "This toolkit provides support for developing, testing and deploying custom Mingle macros."
37
- p.extra_rdoc_files = ['README.rdoc']
38
- p.clean_globs |= %w[**/.DS_Store tmp *.log]
39
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
40
- p.remote_rdoc_dir = ''
41
- p.rsync_args = '-av --delete --ignore-errors'
42
- end
43
-
44
- require 'newgem/tasks'
45
-
46
- # end
20
+ %w[newgem rubigen hoe].each { |f| require f }
21
+
22
+ # Generate all the Rake tasks
23
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
24
+ $hoe = Hoe.spec('mingle-macro-development-toolkit') do |p|
25
+ p.version = MacroDevelopmentToolkit::VERSION
26
+ p.developer('ThoughtWorks Inc', 'support@thoughtworks.com')
27
+ p.post_install_message = 'getting_started.txt'
28
+ p.rubyforge_name = 'mingle-macros'
29
+ p.extra_deps = [
30
+ ['activesupport','2.3.5'],
31
+ ]
32
+ p.summary = "This toolkit provides support for developing, testing and deploying custom Mingle macros."
33
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
34
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
35
+ p.remote_rdoc_dir = ''
36
+ p.rsync_args = '-av --delete --ignore-errors'
37
+ end
38
+ require 'newgem/tasks'
47
39
 
48
40
  Dir['tasks/**/*.rake'].each { |t| load t }
data/bin/new_mingle_macro CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- #Copyright 2010 ThoughtWorks, Inc. All rights reserved.
2
+ #Copyright 2011 ThoughtWorks, Inc. All rights reserved.
3
3
 
4
4
  module NewMingleMacro
5
5
  module Messages
@@ -23,7 +23,7 @@ underscores (_). Is this OK? [Yes/No]"
23
23
  SPECIAL_CHARACTER_REPLACEMENT_MESSAGE
24
24
 
25
25
  AUTO_GENERATED_CLASS_NAME_MESSAGE = <<-AUTO_GENERATED_CLASS_NAME_MESSAGE
26
- Warning: You did not provide a class name for your macro. A class name has been generated
26
+ Succeeded with warnings: You did not provide a class name for your macro. A class name has been generated
27
27
  for you. This name should be considered a guide and we highly recommend naming your own
28
28
  classes name with appropriate namespaces to avoid collisions with standard libraries
29
29
  or Mingle classes. Please run this tool with no command-line arguments to learn
@@ -35,10 +35,16 @@ end
35
35
  require 'erb'
36
36
  require 'fileutils'
37
37
  begin
38
- require 'active_support'
38
+ require 'active_support/all'
39
39
  rescue LoadError
40
40
  require 'rubygems'
41
- require 'active_support'
41
+ require 'active_support/all'
42
+ end
43
+
44
+ require 'active_support/version'
45
+ REQUIRED_ACTIVE_SUPPORT_VERSION = '2.3.5'
46
+ unless ActiveSupport::VERSION::STRING == REQUIRED_ACTIVE_SUPPORT_VERSION
47
+ raise "For guaranteed compatibility with Mingle, you must develop macros using ActiveSupport #{REQUIRED_ACTIVE_SUPPORT_VERSION}. You are using version #{ActiveSupport::VERSION::STRING}"
42
48
  end
43
49
 
44
50
  def print_usage
@@ -6,12 +6,13 @@ require File.join(File.dirname(__FILE__), 'rest_loader')
6
6
 
7
7
  class Test::Unit::TestCase
8
8
 
9
- def project(name)
10
- @project ||= load_project_resource(name)
9
+ def project(resource)
10
+ @projects ||= {}
11
+ @projects[resource] ||= load_project_resource(resource)
11
12
  end
12
13
 
13
14
  def projects(*resources)
14
- @projects ||= resources.map{ |resource| load_project_resource(resource) }
15
+ resources.collect {|resource| project(resource)}
15
16
  end
16
17
 
17
18
  def errors
@@ -25,7 +26,6 @@ class Test::Unit::TestCase
25
26
  private
26
27
 
27
28
  def load_project_resource(resource)
28
- RESTfulLoaders::ProjectLoader.new(resource, nil, self).project
29
+ RESTfulLoaders::ProjectLoader.new(resource, self).project
29
30
  end
30
-
31
31
  end
@@ -6,17 +6,8 @@ require File.join(File.dirname(__FILE__), 'fixture_loader')
6
6
  class Test::Unit::TestCase
7
7
 
8
8
  def project(name)
9
- @project ||= load_project_fixture(name)
9
+ @projects ||= {}
10
+ @projects[name] ||= FixtureLoaders::ProjectLoader.new(name).project
10
11
  end
11
-
12
- def projects(*names)
13
- @projects ||= names.map { |name| load_project_fixture(name) }
14
- end
15
-
16
- private
17
-
18
- def load_project_fixture(name)
19
- FixtureLoaders::ProjectLoader.new(name).project
20
- end
21
-
22
- end
12
+
13
+ end
@@ -4,7 +4,7 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
5
 
6
6
  module MacroDevelopmentToolkit
7
- VERSION = '1.3.2'
7
+ VERSION = '1.3.3'
8
8
  end
9
9
 
10
10
  require 'yaml'
@@ -1,5 +1,5 @@
1
1
  module Mingle
2
- # Copyright 2009 ThoughtWorks, Inc. All rights reserved.
2
+ # Copyright 2010 ThoughtWorks, Inc. All rights reserved.
3
3
 
4
4
  # This is a lightweight representation of a project.
5
5
  # From an instance of this class you can the name & identifier of the project.
@@ -27,14 +27,14 @@ module Mingle
27
27
  end
28
28
 
29
29
  # *returns*: A list CardTypes as configured for this project.
30
- # There will always be atleast one element in this list.
30
+ # There will always be at least one element in this list.
31
31
  def card_types
32
- @card_types_loader.load
32
+ @card_types_loader.load.collect(&:card_type)
33
33
  end
34
34
 
35
35
  # *returns*: An list of PropertyDefinitions as configured for this project, which may be empty
36
36
  def property_definitions
37
- @property_definitions_loader.load
37
+ @property_definitions_loader.load.collect(&:property_definition)
38
38
  end
39
39
 
40
40
  # *accepts*: The name of a project variable configured for this project
@@ -9,179 +9,143 @@ module MingleModelLoaders
9
9
  @macro_context = macro_context
10
10
  @alert_receiver = alert_receiver
11
11
  end
12
-
13
- def card_types_property_definitions_by_card_type_id_loader(card_type_id)
14
- LoadCardTypesPropertyDefinitionsByCardTypeId.new(card_type_id, @project)
15
- end
16
-
17
- def card_types_property_definitions_by_property_definition_id_loader(property_definition_id)
18
- LoadCardTypesPropertyDefinitionsByPropertyDefinitionId.new(property_definition_id, @project)
19
- end
20
-
21
- def values_by_property_definition_id_loader(property_definition_id)
22
- LoadValuesByPropertyDefinitionId.new(property_definition_id, @project)
23
- end
24
-
25
- def card_type_by_id_loader(card_type_id)
26
- LoadCardTypeById.new(card_type_id, @project)
27
- end
28
-
29
- def property_definition_by_id_loader(property_definition_id)
30
- LoadPropertyDefinitionById.new(property_definition_id, @project)
31
- end
32
-
33
- def card_types_by_project_id_loader
34
- LoadCardTypesByProjectId.new(@project)
35
- end
36
-
37
- def property_definitions_by_project_id_loader
38
- LoadPropertyDefinitionsByProjectId.new(@project)
39
- end
40
-
41
- def team_by_project_id_loader
42
- LoadTeamByProjectId.new(@project)
43
- end
44
-
45
- def project_variables_by_project_id_loader
46
- LoadProjectVariablesByProjectId.new(@project)
47
- end
48
12
  end
49
13
 
50
14
  class ProjectLoader < Base
51
15
  def project
16
+ @proj ||= load
17
+ end
18
+
19
+ def load
52
20
  project = Mingle::Project.new(@project, :content_provider => @macro_context[:content_provider], :alert_receiver => @alert_receiver)
53
- project.card_types_loader = card_types_by_project_id_loader
54
- project.property_definitions_loader = property_definitions_by_project_id_loader
55
- project.team_loader = team_by_project_id_loader
56
- project.project_variables_loader = project_variables_by_project_id_loader
21
+ project.card_types_loader = CardTypesLoader.new(@project)
22
+ project.property_definitions_loader = PropertyDefinitionsLoader.new(@project)
23
+ project.team_loader = TeamLoader.new(@project)
24
+ project.project_variables_loader = ProjectVariablesLoader.new(@project)
57
25
  project
58
26
  end
59
27
  end
60
-
61
- class LoadCardTypesByProjectId < Base
28
+
29
+ class CardTypesLoader
30
+ def initialize(project)
31
+ @project = project
32
+ end
33
+
62
34
  def load
63
35
  @project.with_active_project do
64
36
  @project.card_types.collect do |ct|
65
- card_type = Mingle::CardType.new(ct)
66
- card_type.card_types_property_definitions_loader = card_types_property_definitions_by_card_type_id_loader(ct.id)
67
- card_type
68
- end.sort_by(&:position)
37
+ CardTypeLoader.new(ct)
38
+ end.sort_by {|loader| loader.card_type.position}
69
39
  end
70
- end
40
+ end
71
41
  end
72
-
73
- class LoadPropertyDefinitionsByProjectId < Base
42
+
43
+ class CardTypeLoader
44
+ def initialize(ct)
45
+ @ct = ct
46
+ end
47
+
48
+ def card_type
49
+ @card_type ||= load
50
+ end
51
+
52
+ def load
53
+ ct = Mingle::CardType.new(@ct)
54
+ ct.card_types_property_definitions_loader = CardTypesPropertyDefinitionsLoader.new(@ct)
55
+ ct
56
+ end
57
+ end
58
+
59
+ class PropertyDefinitionsLoader
60
+ def initialize(project)
61
+ @project = project
62
+ end
63
+
74
64
  def load
75
65
  @project.with_active_project do
76
66
  (@project.predefined_property_definitions + @project.all_property_definitions).collect do |pd|
77
- property_definition = Mingle::PropertyDefinition.new(pd)
78
- property_definition.card_types_property_definitions_loader = card_types_property_definitions_by_property_definition_id_loader(pd.id)
79
- property_definition.values_loader = values_by_property_definition_id_loader(pd.id)
80
- property_definition
67
+ PropertyDefinitionLoader.new(pd)
81
68
  end
82
69
  end
83
- end
70
+ end
84
71
  end
85
-
86
- class LoadCardTypesPropertyDefinitionsByCardTypeId < Base
87
- def initialize(card_type_id, fixture_file_name)
88
- super(fixture_file_name)
89
- @card_type_id = card_type_id
90
- end
91
72
 
73
+ class PropertyDefinitionLoader
74
+ def initialize(pd)
75
+ @pd = pd
76
+ end
77
+
78
+ def property_definition
79
+ @property_definition ||= load
80
+ end
81
+
92
82
  def load
93
- @project.with_active_project do
94
- @project.card_types.find(@card_type_id).property_type_mappings.collect do |ctpd|
95
- card_type_property_definition = Mingle::CardTypePropertyDefinition.new(ctpd)
96
- card_type_property_definition.card_type_loader = card_type_by_id_loader(ctpd.card_type_id)
97
- card_type_property_definition.property_definition_loader = property_definition_by_id_loader(ctpd.property_definition_id)
98
- card_type_property_definition
99
- end.sort_by(&:position).compact
100
- end
101
- end
102
-
103
- end
104
-
105
- class LoadCardTypesPropertyDefinitionsByPropertyDefinitionId < Base
106
- def initialize(property_definition_id, fixture_file_name)
107
- super(fixture_file_name)
108
- @property_definition_id = property_definition_id
109
- end
110
-
111
- def load
112
- @project.with_active_project do
113
- @project.all_property_definitions.detect { |pd| pd.id == @property_definition_id }.property_type_mappings do |ctpd|
114
- card_type_property_definition = Mingle::CardTypePropertyDefinition.new(ctpd)
115
- card_type_property_definition.card_type_loader = card_type_by_id_loader(ctpd.card_type_id)
116
- card_type_property_definition.property_definition_loader = property_definition_by_id_loader(ctpd.property_definition_id)
117
- card_type_property_definition
118
- end.compact.sort_by(&:position).compact
119
- end
120
- end
121
-
83
+ pd = Mingle::PropertyDefinition.new(@pd)
84
+ pd.card_types_property_definitions_loader = CardTypesPropertyDefinitionsLoader.new(@pd)
85
+ pd.values_loader = PropertyValuesLoader.new(@pd)
86
+ pd
87
+ end
122
88
  end
123
-
124
- class LoadCardTypeById < Base
125
- def initialize(card_type_id, fixture_file_name)
126
- super(fixture_file_name)
127
- @card_type_id = card_type_id
128
- end
129
-
130
- def load
131
- @project.with_active_project do
132
- ct = Mingle::CardType.new(@project.card_types.find(@card_type_id))
133
- ct.card_types_property_definitions_loader = card_types_property_definitions_by_card_type_id_loader(@card_type_id)
134
- ct
135
- end
136
- end
137
- end
138
-
139
- class LoadPropertyDefinitionById < Base
140
- def initialize(property_definition_id, fixture_file_name)
141
- super(fixture_file_name)
142
- @property_definition_id = property_definition_id
89
+
90
+ class CardTypesPropertyDefinitionsLoader
91
+ def initialize(card_type_or_property_definition)
92
+ @card_type_or_property_definition = card_type_or_property_definition
143
93
  end
144
-
94
+
145
95
  def load
146
- @project.with_active_project do
147
- pd = Mingle::PropertyDefinition.new(@project.all_property_definitions.detect { |pd| pd.id == @property_definition_id })
148
- pd.card_types_property_definitions_loader = card_types_property_definitions_by_property_definition_id_loader(@property_definition_id)
149
- pd.values_loader = values_by_property_definition_id_loader(@property_definition_id)
150
- pd
96
+ if @card_type_or_property_definition.respond_to?(:property_type_mappings)
97
+ @card_type_or_property_definition.property_type_mappings.collect do |mapping|
98
+ ct = CardTypeLoader.new(mapping.card_type)
99
+ pd = PropertyDefinitionLoader.new(mapping.property_definition)
100
+ OpenStruct.new(:card_type => ct.load, :property_definition => pd.load)
101
+ end
102
+ else #pre_defined_property
103
+ @card_type_or_property_definition.project.with_active_project do |project|
104
+ project.card_types.collect do |card_type|
105
+ ct = CardTypeLoader.new(card_type)
106
+ pd = PropertyDefinitionLoader.new(@card_type_or_property_definition)
107
+ OpenStruct.new(:card_type => ct.load, :property_definition => pd.load)
108
+ end
109
+ end
151
110
  end
152
- end
153
- end
154
-
155
- class LoadValuesByPropertyDefinitionId < Base
156
- def initialize(property_definition_id, fixture_file_name)
157
- super(fixture_file_name)
158
- @property_definition_id = property_definition_id
159
111
  end
112
+ end
160
113
 
114
+ class PropertyValuesLoader
115
+ def initialize(property_definition)
116
+ @property_definition = property_definition
117
+ end
118
+
161
119
  def load
162
- @project.with_active_project do
163
- @project.all_property_definitions.detect { |pd| pd.id == @property_definition_id }.light_property_values.collect do |pv|
164
- property_value = Mingle::PropertyValue.new(pv)
165
- property_value.property_definition_loader = property_definition_by_id_loader(@property_definition_id)
166
- property_value
167
- end.compact
168
- end
169
- end
120
+ @property_definition.light_property_values.collect do |pv|
121
+ property_value = Mingle::PropertyValue.new(pv)
122
+ property_value.property_definition_loader = PropertyDefinitionLoader.new(@property_definition)
123
+ property_value
124
+ end.compact
125
+ end
170
126
  end
171
127
 
172
- class LoadTeamByProjectId < Base
128
+ class TeamLoader
129
+ def initialize(project)
130
+ @project = project
131
+ end
132
+
173
133
  def load
174
134
  @project.with_active_project do
175
135
  @project.users.collect { |user| Mingle::User.new(user) }
176
136
  end
177
- end
137
+ end
178
138
  end
179
-
180
- class LoadProjectVariablesByProjectId < Base
139
+
140
+ class ProjectVariablesLoader
141
+ def initialize(project)
142
+ @project = project
143
+ end
144
+
181
145
  def load
182
146
  @project.with_active_project do
183
147
  @project.project_variables.collect { |plv| Mingle::ProjectVariable.new(plv) }
184
148
  end
185
- end
149
+ end
186
150
  end
187
- end
151
+ end