mingle-macro-development-toolkit 1.3.3 → 2.0.0

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.
Files changed (75) hide show
  1. data/{History.txt → History} +11 -0
  2. data/{LICENSE.txt → LICENSE} +0 -0
  3. data/{README.txt → README} +4 -2
  4. data/Rakefile +15 -40
  5. data/bin/new_mingle_macro +25 -137
  6. data/lib/mingle_macro_development_toolkit.rb +4 -0
  7. data/lib/mingle_macro_development_toolkit/loaders.rb +5 -0
  8. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/base.rb +19 -0
  9. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/card_type_loader.rb +15 -0
  10. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/card_types_loader.rb +10 -0
  11. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/card_types_property_definitions_loader.rb +12 -0
  12. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/project_loader.rb +16 -0
  13. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/project_variables_loader.rb +10 -0
  14. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/property_definition_loader.rb +16 -0
  15. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/property_definitions_loader.rb +10 -0
  16. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/property_values_loader.rb +10 -0
  17. data/lib/mingle_macro_development_toolkit/loaders/fixture_loaders/team_loader.rb +10 -0
  18. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/base.rb +85 -0
  19. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_type_loader.rb +19 -0
  20. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_types_loader.rb +14 -0
  21. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/card_types_property_definitions_loader.rb +32 -0
  22. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/project_loader.rb +26 -0
  23. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/project_variables_loader.rb +14 -0
  24. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/property_definition_loader.rb +20 -0
  25. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/property_definitions_loader.rb +14 -0
  26. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/property_values_loader.rb +14 -0
  27. data/lib/mingle_macro_development_toolkit/loaders/restful_loaders/team_loader.rb +14 -0
  28. data/templates/Rakefile +23 -0
  29. data/{getting_started.txt → templates/getting_started.txt} +93 -93
  30. data/templates/init.rb +1 -0
  31. data/{example → templates/lib}/macro.rb +0 -0
  32. data/{test/project_data → templates/test/data/exports}/macro_toolkit_test_template.mingle +0 -0
  33. data/{test/fixtures/sample → templates/test/data/fixtures}/card_types.yml +0 -0
  34. data/{test/fixtures/sample → templates/test/data/fixtures}/project_variables.yml +0 -0
  35. data/{test/fixtures/sample → templates/test/data/fixtures}/projects.yml +0 -0
  36. data/{test/fixtures/sample → templates/test/data/fixtures}/property_definitions.yml +0 -0
  37. data/{test/fixtures/sample → templates/test/data/fixtures}/property_type_mappings.yml +0 -0
  38. data/{test/fixtures/sample → templates/test/data/fixtures}/property_values.yml +0 -0
  39. data/{test/fixtures/sample → templates/test/data/fixtures}/users.yml +0 -0
  40. data/{example → templates/test/integration}/integration_test.rb +4 -5
  41. data/templates/test/integration/integration_test_helper.rb +23 -0
  42. data/templates/test/test_helper.rb +4 -0
  43. data/{example → templates/test/unit}/unit_test.rb +7 -7
  44. data/templates/test/unit/unit_test_helper.rb +13 -0
  45. data/test/data/exports/macro_toolkit_test_template.mingle +0 -0
  46. data/test/data/fixtures/card_types.yml +37 -0
  47. data/test/data/fixtures/project_variables.yml +7 -0
  48. data/test/data/fixtures/projects.yml +4 -0
  49. data/test/data/fixtures/property_definitions.yml +51 -0
  50. data/test/data/fixtures/property_type_mappings.yml +81 -0
  51. data/test/data/fixtures/property_values.yml +19 -0
  52. data/test/data/fixtures/users.yml +16 -0
  53. data/test/integration/integration_test_helper.rb +3 -13
  54. data/test/integration/{rest_loader_test.rb → restful_loaders_test.rb} +4 -4
  55. data/test/test_helper.rb +2 -0
  56. data/test/unit/{fixture_loader_test.rb → fixture_loaders_test.rb} +2 -2
  57. data/test/unit/unit_test_helper.rb +7 -6
  58. metadata +101 -100
  59. data/example/Rakefile +0 -6
  60. data/example/deploy.rake +0 -10
  61. data/example/init.rb +0 -10
  62. data/example/integration_test_helper.rb +0 -31
  63. data/example/unit_test_helper.rb +0 -13
  64. data/lib/macro_development_toolkit.rb +0 -29
  65. data/lib/macro_development_toolkit/mingle/card_type.rb +0 -41
  66. data/lib/macro_development_toolkit/mingle/card_type_property_definition.rb +0 -26
  67. data/lib/macro_development_toolkit/mingle/project.rb +0 -168
  68. data/lib/macro_development_toolkit/mingle/project_variable.rb +0 -24
  69. data/lib/macro_development_toolkit/mingle/property_definition.rb +0 -105
  70. data/lib/macro_development_toolkit/mingle/property_value.rb +0 -67
  71. data/lib/macro_development_toolkit/mingle/user.rb +0 -33
  72. data/lib/macro_development_toolkit/mingle_model_loader.rb +0 -151
  73. data/tasks/test.rake +0 -16
  74. data/test/integration/rest_loader.rb +0 -233
  75. data/test/unit/fixture_loader.rb +0 -109
data/example/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- %w[rubygems rake rake/clean rake/testtask fileutils macro_development_toolkit].each { |f| require f }
2
-
3
- Dir['tasks/**/*.rake'].each { |t| load t }
4
-
5
- desc "Runs all units and integration tests"
6
- task :test => ['test:units', 'test:integration']
data/example/deploy.rake DELETED
@@ -1,10 +0,0 @@
1
- namespace :macro do |ns|
2
-
3
- task :deploy do
4
- macro_folder = File.expand_path(File.join(File.dirname(__FILE__), '..'))
5
- mingle_plugins_folder = File.join(ENV['MINGLE_LOCATION'], 'vendor', 'plugins')
6
- FileUtils.cp_r(macro_folder, mingle_plugins_folder)
7
- puts "#{macro_folder} successfully copied over to #{mingle_plugins_folder}. Restart the Mingle server to start using the macro."
8
- end
9
-
10
- end
data/example/init.rb DELETED
@@ -1,10 +0,0 @@
1
- begin
2
- require 'macro_development_toolkit'
3
- rescue LoadError
4
- require 'rubygems'
5
- require 'macro_development_toolkit'
6
- end
7
-
8
- if defined?(RAILS_ENV) && RAILS_ENV == 'production' && defined?(MinglePlugins)
9
- MinglePlugins::Macros.register(<%= macro_class_name %>, '<%= macro_name %>')
10
- end
@@ -1,31 +0,0 @@
1
- require 'delegate'
2
- require 'test/unit'
3
- require File.join(File.dirname(__FILE__), '..', '..', 'init.rb')
4
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', '<%= macro_name %>')
5
- require File.join(File.dirname(__FILE__), 'rest_loader')
6
-
7
- class Test::Unit::TestCase
8
-
9
- def project(resource)
10
- @projects ||= {}
11
- @projects[resource] ||= load_project_resource(resource)
12
- end
13
-
14
- def projects(*resources)
15
- resources.collect {|resource| project(resource)}
16
- end
17
-
18
- def errors
19
- @errors ||= []
20
- end
21
-
22
- def alert(message)
23
- errors << message
24
- end
25
-
26
- private
27
-
28
- def load_project_resource(resource)
29
- RESTfulLoaders::ProjectLoader.new(resource, self).project
30
- end
31
- end
@@ -1,13 +0,0 @@
1
- require 'test/unit'
2
- require File.join(File.dirname(__FILE__), '..', '..', 'init.rb')
3
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', '<%= macro_name %>')
4
- require File.join(File.dirname(__FILE__), 'fixture_loader')
5
-
6
- class Test::Unit::TestCase
7
-
8
- def project(name)
9
- @projects ||= {}
10
- @projects[name] ||= FixtureLoaders::ProjectLoader.new(name).project
11
- end
12
-
13
- end
@@ -1,29 +0,0 @@
1
- # Copyright 2010 ThoughtWorks, Inc. All rights reserved.
2
-
3
- $:.unshift(File.dirname(__FILE__)) unless
4
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
-
6
- module MacroDevelopmentToolkit
7
- VERSION = '1.3.3'
8
- end
9
-
10
- require 'yaml'
11
- require 'ostruct'
12
- require 'net/http'
13
- begin
14
- require 'rubygems'
15
- rescue Exception
16
- #ignore
17
- end
18
- begin
19
- require 'active_support'
20
- rescue Exception
21
- unless defined? RAILS_ENV && RAILS_ENV == 'production'
22
- $: << 'vendor/gems/activesupport-2.3.3/lib'
23
- require 'active_support'
24
- end
25
- end
26
-
27
- Dir.glob(File.join("#{File.dirname(__FILE__)}", 'macro_development_toolkit', '**', '*')).reverse.each do |f|
28
- require f unless File.directory?(f)
29
- end
@@ -1,41 +0,0 @@
1
- module Mingle
2
- # Copyright 2009 ThoughtWorks, Inc. All rights reserved.
3
-
4
- # This is a lightweight representation of a card type in Mingle.
5
- # From an instance of this class you can the name, color and position of the card type,
6
- # in addition to Property Definitions that are associated with it.
7
- class CardType
8
-
9
- def initialize(full_card_type)
10
- @full_card_type = full_card_type
11
- end
12
-
13
- # *returns*: The name of this CardType
14
- def name
15
- @full_card_type.name
16
- end
17
-
18
- # *returns*: The hex color code for this CardType
19
- def color
20
- @full_card_type.color.gsub('#', '')
21
- end
22
-
23
- # *returns*: The position of this CardType among all the CardTypes on the project.
24
- # The first card type has position 1
25
- def position
26
- @full_card_type.position
27
- end
28
-
29
- # *returns*: The PropertyDefinitions associated with this CardType
30
- def property_definitions
31
- @card_types_property_definitions_loader.load.collect(&:property_definition)
32
- end
33
-
34
- def to_s
35
- "CardType[name=#{name},color=#{color},position=#{position}]"
36
- end
37
-
38
- attr_writer :card_types_property_definitions_loader
39
- end
40
-
41
- end
@@ -1,26 +0,0 @@
1
- module Mingle
2
- # Copyright 2010 ThoughtWorks, Inc. All rights reserved.
3
-
4
- # This is a lightweight representation of the relationship between a card_type
5
- # and a property definition as configured in Mingle.
6
- class CardTypePropertyDefinition
7
- def initialize(card_type_property_definition)
8
- @card_type_property_definition = card_type_property_definition
9
- end
10
-
11
- def position
12
- @card_type_property_definition.position.to_i
13
- end
14
-
15
- def card_type
16
- @card_type_loader.load
17
- end
18
-
19
- def property_definition
20
- @property_definition_loader.load
21
- end
22
-
23
- attr_writer :card_type_loader, :property_definition_loader
24
- end
25
-
26
- end
@@ -1,168 +0,0 @@
1
- module Mingle
2
- # Copyright 2010 ThoughtWorks, Inc. All rights reserved.
3
-
4
- # This is a lightweight representation of a project.
5
- # From an instance of this class you can the name & identifier of the project.
6
- # You can also get a list of property definitions and card types on the project,
7
- # in addition to information about the team and project variables.
8
- # This class also provides an interface to the MQL execution facilities provided by Mingle.
9
- class Project
10
-
11
- VERSION_ONE = 'v1'
12
- VERSION_TWO = 'v2'
13
-
14
- def initialize(project, card_query_options)
15
- @full_project = project
16
- @card_query_options = card_query_options
17
- end
18
-
19
- # *returns*: The identifier of this project
20
- def identifier
21
- @full_project.identifier
22
- end
23
-
24
- # *returns*: The name of this project
25
- def name
26
- @full_project.name
27
- end
28
-
29
- # *returns*: A list CardTypes as configured for this project.
30
- # There will always be at least one element in this list.
31
- def card_types
32
- @card_types_loader.load.collect(&:card_type)
33
- end
34
-
35
- # *returns*: An list of PropertyDefinitions as configured for this project, which may be empty
36
- def property_definitions
37
- @property_definitions_loader.load.collect(&:property_definition)
38
- end
39
-
40
- # *accepts*: The name of a project variable configured for this project
41
- #
42
- # *returns*: The display value of the PropertyValue(s) that project_variable_name represents
43
- def value_of_project_variable(project_variable_name)
44
- @project_variables_loader.load.detect { |pv| pv.name == project_variable_name }.value
45
- end
46
-
47
- # *accepts*: A valid MQL string. To see what constitutes valid MQL,
48
- # look here[http://studios.thoughtworks.com/mingle-agile-project-management/3.0/help/index.html]
49
- #
50
- # *returns*: An Array of Hashes, in which each Hash represents one row of results from the MQL execution
51
- # The keys in the Hash are the names of the properties selected, with all the alphanumeric characters
52
- # downcased and all the spaces and special characters replaced with underscores(_).
53
- #
54
- # Executing a mql statement with explictly supplied property names will return results as follows
55
- # mql = select number,"defect status" where type=defect
56
- #
57
- # [
58
- # {"number"=>"106", "defect_status"=>"Fixed"},
59
- # {"number"=>"70", "defect_status"=>"Fixed"},
60
- # {"number"=>"69", "defect_status"=>"New"},
61
- # {"number"=>"68", "defect_status"=>"In Progress"},
62
- # ...
63
- # ...
64
- # ]
65
- #
66
- # If aggregate functions are selected, the values look as below
67
- # mql = select "defect status", count(*) where type=defect group by "defect status"
68
- #
69
- # [
70
- # {"count"=>"14", "defect_status"=>"New"},
71
- # {"count"=>"3", "defect_status"=>"Open"},
72
- # {"count"=>"1", "defect_status"=>"In Progress"},
73
- # {"count"=>"2", "defect_status"=>"Fixed"},
74
- # {"count"=>"1", "defect_status"=>"Closed"}
75
- # ]
76
- #
77
- # If no columns are explicitly provided, the results contain the raw column names specific
78
- # properties. It is not possible to interpret these results in the general case with the current
79
- # version of the macro development toolkit, so this is not a particularly useful form of
80
- # MQL to execute. The documentation here is provided here just for completeness and should
81
- # not be used as a recommended way of using this call. The structure of this response is
82
- # subject to change in future versions of the toolkit.
83
- #
84
- # mql = type=defect
85
- #
86
- # {
87
- # "cp_testing_status"=>"Ready to Be Tested",
88
- # "cp_actual_effort"=>nil,
89
- # "created_at"=>"2009-09-09 21:45:34",
90
- # "cp_story_count"=>nil,
91
- # "caching_stamp"=>"2",
92
- # "cp_release_card_id"=>"2",
93
- # "cp_risk_liklihood"=>nil,
94
- # "cp_build_completed"=>"452",
95
- # "cp_closed"=>nil,
96
- # "has_macros"=>"f",
97
- # "description"=>"",
98
- # "cp_release_start_date"=>nil,
99
- # "cp_risk_status"=>nil,
100
- # "cp_story_time_to_life"=>nil,
101
- # "cp_total_open_iterations"=>nil,
102
- # "cp_defect_time_to_life"=>"50.00",
103
- # "cp_development_started_on"=>nil,
104
- # "card_type_name"=>"Defect",
105
- # "cp_added_to_scope_on"=>nil,
106
- # "cp_owner_user_id"=>nil,
107
- # "cp_added_to_scope_card_id"=>nil,
108
- # "cp_type_of_test"=>nil,
109
- # "cp_velocity"=>nil,
110
- # "cp_feature_card_id"=>"60"
111
- # }
112
- #
113
- # Note: In versions of the toolkit beyond 1.3, the keys for the aggregate function
114
- # (such as COUNT, SUM etc.) have been normalized to follow the same conventions as a
115
- # property name, i.e. lowecase and stripped of all spaces.
116
- # If you wish to get the results in the old form, set the optional second parameter
117
- # of this call to be Project::VERSION_ONE, while you transition your macros to use the new form.
118
- # The old version of response will be deprecated in a future version of Mingle and the toolkit.
119
- def execute_mql(mql, version = VERSION_TWO)
120
- @full_project.with_active_project do
121
- CardQuery.parse(mql, @card_query_options).values_for_macro(:api_version => version)
122
- end
123
- end
124
-
125
- # The macros on a page determine whether the page content is cached. Macros that use certain MQL concepts
126
- # (for example TODAY, CURRENT USER, or cross-project functionality) should report that they cannot be
127
- # cached so that the page they are on is not cached. This method indicates whether a MQL query uses
128
- # those concepts, and can be used by a macro to determine whether or not to report that it should be
129
- # cached.
130
- #
131
- # *accepts*: A valid MQL string. To see what constitutes valid MQL,
132
- # look here[http://studios.thoughtworks.com/mingle-agile-project-management/3.0/help/index.html]
133
- #
134
- # *returns*: A boolean indicating whether the data pertaining to the MQL can be cached
135
- def can_be_cached?(mql)
136
- @full_project.with_active_project do
137
- CardQuery.parse(mql, @card_query_options).can_be_cached?
138
- end
139
- end
140
-
141
- # *returns*: The full list of Users who are members of this project
142
- def team
143
- @team_loader.load
144
- end
145
-
146
- # *accepts*: Any Number
147
- #
148
- # *returns*: The argument number formatted to the precision configured for the project (default 2)
149
- def format_number_with_project_precision(number)
150
- @full_project.to_num(number)
151
- end
152
-
153
- # *accepts*: Any Number
154
- #
155
- # *returns*: The argument date formatted using the date format configured for the project
156
- def format_date_with_project_date_format(date)
157
- @full_project.format_date(date)
158
- end
159
-
160
- attr_writer :card_types_loader, :property_definitions_loader, :team_loader, :project_variables_loader
161
-
162
- private
163
- def add_alert(message)
164
- @card_query_options[:alert_receiver].alert(message) if @card_query_options[:alert_receiver]
165
- end
166
- end
167
-
168
- end
@@ -1,24 +0,0 @@
1
- module Mingle
2
- # Copyright 2009 ThoughtWorks, Inc. All rights reserved.
3
-
4
- # This is a lightweight representation of a ProjectVariable in Mingle
5
- # A property defintion is a mnemonic name that represents a particular
6
- # value for one or more PropertyDefinitions
7
- class ProjectVariable
8
-
9
- def initialize(full_project_variable)
10
- @full_project_variable = full_project_variable
11
- end
12
-
13
- # *returns*: The name of this variable
14
- def name
15
- @full_project_variable.name
16
- end
17
-
18
- # *returns*: The display value of the value configured for this project variable
19
- def value
20
- @full_project_variable.display_value
21
- end
22
- end
23
-
24
- end
@@ -1,105 +0,0 @@
1
- module Mingle
2
- # Copyright 2009 ThoughtWorks, Inc. All rights reserved.
3
-
4
- # This is a lightweight representation of a ProjectDefinition in Mingle
5
- class PropertyDefinition
6
-
7
- MANAGED_TEXT_TYPE = "Managed text list"
8
- ANY_TEXT_TYPE = "Any text"
9
- MANAGED_NUMBER_TYPE = "Managed number list"
10
- ANY_NUMBER_TYPE = "Any number"
11
- DATE_TYPE = "Date"
12
- FORMULA_TYPE = "Formula"
13
- USER_TYPE = "Automatically generated from the team list"
14
- CARD_TYPE = "Card"
15
- AGGREGATE_TYPE = "Aggregate"
16
- TREE_RELATIONSHIP_TYPE = "Any card used in tree"
17
-
18
- def initialize(full_property_definition)
19
- @full_property_definition = full_property_definition
20
- end
21
-
22
- # *returns*: The name of this PropertyDefinition
23
- def name
24
- @full_property_definition.name
25
- end
26
-
27
- # *returns*: The description of this PropertyDefinition
28
- def description
29
- @full_property_definition.description
30
- end
31
-
32
- # *returns*: A list of CardTypes that this PropertyDefinition is valid for
33
- def card_types
34
- @card_types_property_definitions_loader.load.collect(&:card_type).sort_by(&:position)
35
- end
36
-
37
- # *returns*: A short description of the property definition.
38
- # This will be one of the above values
39
- # - MANAGED_TEXT_TYPE
40
- # - ANY_TEXT_TYPE
41
- # - MANAGED_NUMBER_TYPE
42
- # - ANY_NUMBER_TYPE
43
- # - DATE_TYPE
44
- # - FORMULA_TYPE
45
- # - USER_TYPE
46
- # - CARD_TYPE
47
- # - AGGREGATE_TYPE
48
- # - TREE_RELATIONSHIP_TYPE
49
- def type_description
50
- @full_property_definition.type_description
51
- end
52
-
53
- # *returns*: A list of explicitly defined values that this PropertyDefinition has
54
- # This method should ONLY be called for property definitions that are of the following types
55
- # - MANAGED_TEXT_TYPE
56
- # - MANAGED_NUMBER_TYPE
57
- # - USER_TYPE
58
- #
59
- # Attempting to call this method for the following types will throw an Exception
60
- # - ANY_TEXT_TYPE
61
- # - ANY_NUMBER_TYPE
62
- # - FORMULA_TYPE
63
- # - AGGREGATE_TYPE
64
- # - CARD_TYPE
65
- # - TREE_RELATIONSHIP_TYPE
66
- # - DATE_TYPE
67
- #
68
- # To get the values for the above types, you can use MQL, such as "SELECT property_name" to get
69
- # a list of values
70
- def values
71
- valid_property_types_to_call_value_on = [MANAGED_TEXT_TYPE, MANAGED_NUMBER_TYPE, USER_TYPE]
72
- unless valid_property_types_to_call_value_on.any? {|t| self.type_description == t}
73
- raise "Do not call this method for property definitions of types other than MANAGED_TEXT_TYPE, MANAGED_NUMBER_TYPE, USER_TYPE."
74
- end
75
- @values_loader.load
76
- end
77
-
78
- # *returns*: True if a property definition has only textual values, such as ones of Un/managed text types
79
- def textual?
80
- type_description == MANAGED_TEXT_TYPE || type_description == ANY_TEXT_TYPE
81
- end
82
-
83
- # *returns*: True if a property definition has only numeric values, such as ones of Un/managed number types
84
- def numeric?
85
- type_description == MANAGED_NUMBER_TYPE || type_description == ANY_NUMBER_TYPE
86
- end
87
-
88
- # *returns*: True if a property definition has only calculated values, such as ones of Formula & Aggregate types
89
- def calculated?
90
- type_description == FORMULA_TYPE || type_description == AGGREGATE_TYPE
91
- end
92
-
93
- # *returns*: True if a property definition has only numeric values, such as the Date type
94
- def date?
95
- type_description == DATE_TYPE
96
- end
97
-
98
- def to_s
99
- "PropertyDefinition[name=#{name},type=#{type}]"
100
- end
101
-
102
- attr_writer :card_types_property_definitions_loader, :values_loader
103
- end
104
-
105
- end