mingle-macro-development-toolkit 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 1.1 April 8, 2009
2
+
3
+ * 1 bug fix
4
+ * Fix project variable value to return the display value. In response to post http://community.thoughtworks.com/posts/462f0f399b
data/README.rdoc CHANGED
@@ -23,7 +23,7 @@ The preferred method of installing the Macro Development Toolkit is through its
23
23
  RubyGems[http://www.rubygems.org/] installed for that, though. If you have it,
24
24
  then use:
25
25
 
26
- % [sudo] gem install macro_development_toolkit-1.0.gem
26
+ % [sudo] gem install mingle-macro-development-toolkit
27
27
 
28
28
  == GETTING STARTED:
29
29
 
@@ -63,4 +63,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
63
63
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
64
64
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
65
65
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
66
- THE SOFTWARE.
66
+ THE SOFTWARE.
data/bin/new_mingle_macro CHANGED
@@ -15,7 +15,7 @@ def print_usage
15
15
 
16
16
  Usage: new_mingle_macro <macro_name> [macro_class_name]
17
17
 
18
- macro_name : The name of your new macro. Should be aplphabetic, possibly including underscores(_)
18
+ macro_name : The name of your new macro. Should be alphabetic, possibly including underscores(_)
19
19
  macro_class_name: (optional) The name of the class that implements the macro. Should be a CamelCased alphabetic string. Defaults to CamelCased version of macro_name.
20
20
 
21
21
  EOS
@@ -34,11 +34,11 @@ if macro_name !~ /^[_A-Za-z]+$/
34
34
  macro_name = macro_name.gsub(/[^_A-Za-z]/, '_').squeeze('_')
35
35
  end
36
36
 
37
- macro_class_name = ARGV[1] || macro_name.gsub(/\W/, '_').classify
38
- if macro_class_name.classify != macro_class_name
39
- print "Your macro class name is not a valid class name. Continue with the default class name of #{macro_name.classify}? [Yes/No]"
37
+ macro_class_name = ARGV[1] || macro_name.gsub(/\W/, '_').camelize
38
+ if macro_class_name.camelize != macro_class_name
39
+ print "Your macro class name is not a valid class name. Continue with the default class name of #{macro_name.camelize}? [Yes/No]"
40
40
  exit if STDIN.gets.downcase =~ /^n/
41
- macro_class_name = macro_name.classify
41
+ macro_class_name = macro_name.camelize
42
42
  end
43
43
 
44
44
  if File.exists?(macro_name)
@@ -1,5 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/integration_test_helper.rb'
2
2
 
3
+ # The Mingle API supports basic authentication and must be used in order to run integration tests. However it is disabled in the default configuration. To enable basic authentication, you need set the basic_authentication_enabled configuration option to true in the Mingle data directory/config/auth_config.yml file where Mingle data directory is the path to the mingle data directory on your installation e.g.basic_authentication_enabled: true.
4
+
3
5
  class <%= macro_class_name %>IntegrationTest < Test::Unit::TestCase
4
6
 
5
7
  PROJECT_RESOURCE = 'http://username:password@your.mingle.server:port/lightweight_projects/your_project_identifier.xml'
data/getting_started.txt CHANGED
@@ -125,6 +125,44 @@ class WorkGauge
125
125
 
126
126
  end
127
127
 
128
+ You can output any html source as the result of the macro execution including script tag.
129
+ The following example demonstrates how to embed Google Maps with JavaScript.
130
+
131
+ class GoogleMap
132
+
133
+ def initialize(parameters, project, current_user)
134
+ @latitude = parameters['latitude'] || 39.55
135
+ @longitude = parameters['longitude'] || 116.25
136
+ @zoom_level = parameters['zoom_level'] || 8
137
+ end
138
+
139
+ def execute
140
+ <<-HTML
141
+ h2. Google Maps JavaScript API Example: Simple Map
142
+
143
+ <div id="map_canvas" style="width: 600px; height: 400px"></div>
144
+ <script src="http://maps.google.com/maps?file=api" type="text/javascript"></script>
145
+ <script type="text/javascript">
146
+ // register the initialize function for executing after page loaded.
147
+ MingleJavascript.register(function initialize() {
148
+ if (GBrowserIsCompatible()) {
149
+ var map = new GMap2(document.getElementById("map_canvas"));
150
+ map.setCenter(new GLatLng(#{@latitude}, #{@longitude}), #{@zoom_level});
151
+ }
152
+ })
153
+ </script>
154
+ HTML
155
+ end
156
+
157
+ def can_be_cached?
158
+ false # if appropriate, switch to true once you move your macro to production
159
+ end
160
+
161
+ end
162
+
163
+ Long running or integration macros which run on server will result in long page render times. We recommend these sort
164
+ of macros use javascript or JSONP for cross-domain.
165
+
128
166
  You can find both simpler and more complex examples in the vendor/plugins/sample_macros directory.
129
167
 
130
168
  Unit testing your macro
@@ -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.0'
7
+ VERSION = '1.1'
8
8
  end
9
9
 
10
10
  require 'yaml'
@@ -50,6 +50,20 @@ module Mingle
50
50
  CardQuery.parse(mql, @card_query_options).values
51
51
  end
52
52
 
53
+ # The macros on a page determine whether the page content is cached. Macros that use certain MQL concepts
54
+ # (for example TODAY, CURRENT USER, or cross-project functionality) should report that they cannot be
55
+ # cached so that the page they are on is not cached. This method indicates whether a MQL query uses
56
+ # those concepts, and can be used by a macro to determine whether or not to report that it should be
57
+ # cached.
58
+ #
59
+ # *accepts*: A valid MQL string. To see what constitutes valid MQL,
60
+ # look here[http://studios.thoughtworks.com/mingle-agile-project-management/2.2/help/index.html]
61
+ #
62
+ # *returns*: A boolean indicating whether the data pertaining to the MQL can be cached
63
+ def can_be_cached?(mql)
64
+ CardQuery.parse(mql, @card_query_options).can_be_cached?
65
+ end
66
+
53
67
  # *returns*: The full list of Users who are members of this project
54
68
  def team
55
69
  @team_loader.load
@@ -16,7 +16,7 @@ module Mingle
16
16
 
17
17
  # *returns*: The display value of the value configured for this project variable
18
18
  def value
19
- @full_project_variable.value
19
+ @full_project_variable.display_value
20
20
  end
21
21
  end
22
22
 
@@ -95,28 +95,29 @@ module RESTfulLoaders
95
95
  end
96
96
 
97
97
  def execute_mql(mql)
98
- begin
99
- @mql_executor.execute_mql(mql, self)
100
- rescue => e
101
- __getobj__.send(:add_alert, e.message)
102
- []
103
- end
98
+ @mql_executor.execute_mql(mql, self)
99
+ rescue => e
100
+ __getobj__.send(:add_alert, e.message)
101
+ []
102
+ end
103
+
104
+ def can_be_cached?(mql)
105
+ @mql_executor.can_be_cached?(mql, self)
106
+ rescue => e
107
+ __getobj__.send(:add_alert, e.message)
108
+ []
104
109
  end
105
110
 
106
111
  def format_number_with_project_precision(number)
107
- begin
108
- @mql_executor.format_number_with_project_precision(number, self)
109
- rescue => e
110
- __getobj__.send(:add_alert, e.message)
111
- end
112
+ @mql_executor.format_number_with_project_precision(number, self)
113
+ rescue => e
114
+ __getobj__.send(:add_alert, e.message)
112
115
  end
113
116
 
114
117
  def format_date_with_project_date_format(date)
115
- begin
116
- @mql_executor.format_date_with_project_date_format(date, self)
117
- rescue => e
118
- __getobj__.send(:add_alert, e.message)
119
- end
118
+ @mql_executor.format_date_with_project_date_format(date, self)
119
+ rescue => e
120
+ __getobj__.send(:add_alert, e.message)
120
121
  end
121
122
  end
122
123
 
@@ -146,6 +147,13 @@ module RESTfulLoaders
146
147
  build_request_url(:path => "/projects/#{project.identifier}/cards/execute_mql.xml", :query => "mql=#{mql}"))))
147
148
  end
148
149
 
150
+ def can_be_cached?(mql, project)
151
+ from_xml_data(
152
+ Hash.from_xml(
153
+ get(
154
+ build_request_url(:path => "/projects/#{project.identifier}/cards/can_be_cached.xml", :query => "mql=#{mql}"))))
155
+ end
156
+
149
157
  def format_number_with_project_precision(number, project)
150
158
  from_xml_data(
151
159
  Hash.from_xml(
@@ -83,4 +83,9 @@ class RestLoaderTest < Test::Unit::TestCase
83
83
  assert_raise(RuntimeError) { added_on.values }
84
84
  end
85
85
 
86
+ def test_should_tell_whether_mql_query_is_cacheable
87
+ assert project(TEST_PROJECT).can_be_cached?("SELECT 'Estimate - planning'")
88
+ assert_equal false, project(TEST_PROJECT).can_be_cached?("SELECT 'Estimate - planning' WHERE 'Added On' IS TODAY")
89
+ end
90
+
86
91
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mingle-macro-development-toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.0"
4
+ version: "1.1"
5
5
  platform: ruby
6
6
  authors:
7
7
  - ThoughtWorks Inc
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-08 00:00:00 -08:00
12
+ date: 2009-04-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -43,10 +43,12 @@ extra_rdoc_files:
43
43
  - getting_started.txt
44
44
  - README.rdoc
45
45
  - LICENSE.txt
46
+ - History.txt
46
47
  files:
47
48
  - getting_started.txt
48
49
  - README.rdoc
49
50
  - LICENSE.txt
51
+ - History.txt
50
52
  - Rakefile
51
53
  - lib/macro_development_toolkit.rb
52
54
  - lib/macro_development_toolkit/mingle/card_type_property_definition.rb
@@ -102,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
104
  requirements: []
103
105
 
104
106
  rubyforge_project: mingle-macros
105
- rubygems_version: 1.3.0
107
+ rubygems_version: 1.3.1
106
108
  signing_key:
107
109
  specification_version: 2
108
110
  summary: ""