minglemingle 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ # Copyright (c) 2008 Li Xiao
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'mm/cmds/abstract_command'
15
+
16
+ module MM
17
+ module Command
18
+ class Init < AbstractCommand
19
+ def do_once(clazz=nil)
20
+ if clazz.respond_to?(:site)
21
+ raise "Unknow Mingle project url. Type 'mm ?' for usage to init Mingle project url." if options[:site].blank?
22
+ clazz.site = options[:site]
23
+ end
24
+
25
+ "site => #{(options[:site]||"").gsub(/:[^@:]*@/, ":***@")}"
26
+ end
27
+
28
+ def parse(argv)
29
+ options[:site] = argv.first
30
+ end
31
+
32
+ def doc
33
+ %{
34
+ usage: mm init [site_url]
35
+
36
+ Synopsis:
37
+ mm init => show MingleMingle working directory settings.
38
+ mm init http://name:pass@domain.com/projects/project_identifiler/ => setup MingleMingle working directory with Mingle REST api project base url.
39
+ }
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,54 @@
1
+ # Copyright (c) 2008 Li Xiao
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'mm/transition_execution.tab.rb'
15
+ require 'mm/cmds/abstract_command'
16
+
17
+ module MM
18
+ module Command
19
+ class Run < AbstractCommand
20
+ def do_once
21
+ output "script => #{options[:script]}"
22
+
23
+ attrs = ::TransitionExecutionLanguageParser.new.parse(options[:script])
24
+ output "attrs => #{attrs.inspect}"
25
+ attrs[:properties] = attrs[:properties].collect{|key, value| {:name => key, :value => value}} if attrs[:properties]
26
+ create_transition_execution(attrs)
27
+ end
28
+
29
+ #don't want to cache options of this command
30
+ def cache_options
31
+ end
32
+
33
+ def parse(argv)
34
+ options[:script] = argv.join(' ')
35
+ end
36
+
37
+ def doc
38
+ %{
39
+ usage: mm run <transition_script>
40
+
41
+ transition script grammar:
42
+ <transition name> #<card_number>[options]
43
+ options:
44
+ 1. with <properties>: properties: prop_name1 => prop_value1, prop_name2 => prop_value2
45
+ 2. (<comment>): comment: should be ok for any words except '(' and ')'
46
+
47
+ Synopsis:
48
+ mm run 'complete development #1 with revision => 100, status => open (some comment)'
49
+ }
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,68 @@
1
+ # Copyright (c) 2008 Li Xiao
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'mm/cmds/run'
15
+
16
+ module MM
17
+ module Command
18
+ class Svncommit < AbstractCommand
19
+ TRANSITION_EXECUTION_SCRIPT_REGEX = /\[([^\]]+)\]/
20
+
21
+ def do_once
22
+ cmd = "svn ci #{svncmd_opts.join(' ')} -m #{options[:message].inspect}"
23
+ output "svn command: #{cmd}"
24
+ svnci = execute_cmd(cmd)
25
+ output svnci
26
+ if $?.exitstatus == 0
27
+ revision = svnci.split("\n").last.gsub(/[^0-9]/, '')
28
+ output "revision: #{revision}"
29
+ options[:message].gsub!(/#\{revision\}/, revision)
30
+ if options[:message] =~ TRANSITION_EXECUTION_SCRIPT_REGEX
31
+ run = Run.new
32
+ run.options[:script] = $1
33
+ run.do_once
34
+ end
35
+ end
36
+ end
37
+
38
+ #don't want to cache options of this command
39
+ def cache_options
40
+ end
41
+
42
+ def parse(argv)
43
+ @svncmd_opts = argv.dup
44
+ end
45
+
46
+ def svncmd_opts
47
+ @svncmd_opts || []
48
+ end
49
+
50
+ def option_parser
51
+ OptionParser.new do |opts|
52
+ opts.banner = "usage: mm svnci -m '[<transition_script>] other commit messages' [other svn options] [args]"
53
+ opts.separator "transition script: should be inside of '[' and ']'. Type 'mm help run' for help on transition script grammar. "
54
+ opts.separator 'specify a #{revision} in the message to run the transition with revision commited number'
55
+ opts.separator ""
56
+ opts.separator "Synopsis:"
57
+ opts.separator 'mm svnci -m "[complete development #1 with fixed_revision => #{revision}, status => closed (some comment)]: details, blabla..."'
58
+ opts.separator ""
59
+ opts.separator "Options:"
60
+
61
+ opts.on_tail("-m", "--message MESSAGE", "specify log message ARG") do |message|
62
+ options[:message] = message
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (c) 2008 Li Xiao
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'mm/cmds/abstract_command'
15
+ #not finished yet
16
+ module MM
17
+ module Command
18
+ class Tabs < AbstractCommand
19
+ def view(tabs)
20
+ output "All tabs: \n#{tabs.collect{|f| " * #{f.name}"}.join("\n")}"
21
+ end
22
+
23
+ def do_once
24
+ favorites.select{|f|f.tab_view}
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,40 @@
1
+ # Copyright (c) 2008 Li Xiao
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'mm/cmds/abstract_command'
15
+
16
+ module MM
17
+ module Command
18
+ class User < AbstractCommand
19
+ def do_once
20
+ output "user => #{options[:user]}"
21
+ identifier = options[:user].to_s.downcase
22
+ team_members.select {|user| user.id.to_s.downcase == options[:user] || user.login.to_s.downcase == options[:user]}
23
+ end
24
+
25
+ def parse(argv)
26
+ options[:user] = argv.join(' ').strip
27
+ end
28
+
29
+ def doc
30
+ %{
31
+ usage: mm user [login/user id]
32
+
33
+ Synopsis:
34
+ mm user 'login' => find team member info by login
35
+ mm user id => find team member info by id
36
+ }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ # Copyright (c) 2008 Li Xiao
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'mm/cmds/cards'
15
+
16
+ module MM
17
+ module Command
18
+ class View < Cards
19
+ def parse(argv)
20
+ options[:view] = argv.join(' ').strip
21
+ end
22
+
23
+ def doc
24
+ %{
25
+ usage: mm view <view_name>
26
+
27
+ Synopsis:
28
+ mm view My Work => show cards in the view
29
+ mm view My Work -a priority,owner => show cards in the view with attributes specified
30
+
31
+ Options:
32
+ -a att_name1,attr_name2 show specified attribute value.
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ # Copyright (c) 2008 Li Xiao
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'pstore'
15
+ module MM
16
+ class Repository
17
+
18
+ FILE_NAME = '.mm_pstore'
19
+
20
+ def self.destroy
21
+ File.delete(FILE_NAME) if File.exist?(FILE_NAME)
22
+ end
23
+
24
+ def [](key)
25
+ return nil unless File.exist?(FILE_NAME)
26
+
27
+ repository = PStore.new(FILE_NAME)
28
+ repository.transaction(true) do
29
+ repository[key]
30
+ end
31
+ end
32
+
33
+ def []=(key, value)
34
+ repository = PStore.new(FILE_NAME)
35
+ repository.transaction do
36
+ repository[key] = value
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,63 @@
1
+ # Copyright (c) 2008 Li Xiao
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ begin
15
+ require 'active_resource'
16
+ rescue LoadError
17
+ require 'rubygems'
18
+ require 'active_resource'
19
+ end
20
+
21
+ module MM
22
+ module Resource
23
+ class Card < ActiveResource::Base
24
+ def short_summarization
25
+ "##{number} #{name}"
26
+ end
27
+
28
+ def summarization
29
+ <<-SUMMARIZATION
30
+ #{short_summarization}
31
+
32
+ #{description}
33
+
34
+ SUMMARIZATION
35
+ end
36
+ end
37
+
38
+ class PropertyDefinition < ActiveResource::Base
39
+ def card_property?(obj_value)
40
+ obj_value.to_i > 0 && column_name =~ /card_id$/
41
+ end
42
+
43
+ def user_property?(obj_value)
44
+ obj_value.to_i > 0 && column_name =~ /user_id$/
45
+ end
46
+ end
47
+
48
+ class Project < ActiveResource::Base
49
+ end
50
+
51
+ class User < ActiveResource::Base
52
+ end
53
+
54
+ class TransitionExecution < ActiveResource::Base
55
+ end
56
+
57
+ class Transition < ActiveResource::Base
58
+ end
59
+
60
+ class Favorite < ActiveResource::Base
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,279 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by racc 1.4.5
4
+ # from racc grammer file "lib/mm/transition_execution.grammar".
5
+ #
6
+
7
+ require 'racc/parser'
8
+
9
+
10
+ require 'strscan'
11
+
12
+
13
+ class TransitionExecutionLanguageParser < Racc::Parser
14
+
15
+ module_eval <<'..end lib/mm/transition_execution.grammar modeval..id395e8e8615', 'lib/mm/transition_execution.grammar', 69
16
+
17
+ def unquote(value)
18
+ case value
19
+ when /^'(.*)'$/ then $1
20
+ when /^"(.*)"$/ then $1
21
+ else value
22
+ end
23
+ end
24
+
25
+ def remove_parentheses(value)
26
+ case value
27
+ when /\(([^\)]*)\)/ then $1
28
+ else value
29
+ end
30
+ end
31
+
32
+ def parse(str)
33
+ @input = str
34
+ tokens = []
35
+ str = "" if str.nil?
36
+ scanner = StringScanner.new(str + ' ')
37
+
38
+ until scanner.eos?
39
+ case
40
+ when scanner.scan(/\s+/)
41
+ # ignore space
42
+ when m = scanner.scan(/\d+\b/i)
43
+ tokens.push [:NUMBER, m]
44
+ when m = scanner.scan(/#\b/i)
45
+ tokens.push [:CARD, m]
46
+ when m = scanner.scan(/with\b/i)
47
+ tokens.push [:WITH, m]
48
+ when m = scanner.scan(/,/)
49
+ tokens.push [:COMMA, m]
50
+ when m = scanner.scan(/=>/i)
51
+ tokens.push [:MAP_TO, m]
52
+ when m = scanner.scan(/\(([^\)]*)\)/)
53
+ tokens.push [:COMMENT, remove_parentheses(m)]
54
+ when m = scanner.scan(/'([^']*)'/)
55
+ tokens.push [:IDENTIFIER, unquote(m)]
56
+ when m = scanner.scan(/"([^"]*)"/)
57
+ tokens.push [:IDENTIFIER, unquote(m)]
58
+ when m = scanner.scan(/[\w]+/)
59
+ tokens.push [:IDENTIFIER, m]
60
+ else
61
+ raise "unexpected characters #{scanner.peek(5)}"
62
+ end
63
+ end
64
+ tokens.push [false, false]
65
+ yyparse(tokens, :each)
66
+ end
67
+
68
+ def on_error(error_token_id, error_value, value_stack)
69
+ msg = "Could not parse MML: #{@input.bold} error_token_id: #{error_token_id}, error_value: #{error_value}"
70
+ msg << "after #{value_stack.last}" if value_stack.length > 1
71
+ msg << " (This could be due to invalid formatting, including whitespace and indentation."
72
+ msg << " Please check your MML statement and try again.)"
73
+ raise ParseError, msg
74
+ end
75
+ ..end lib/mm/transition_execution.grammar modeval..id395e8e8615
76
+
77
+ ##### racc 1.4.5 generates ###
78
+
79
+ racc_reduce_table = [
80
+ 0, 0, :racc_error,
81
+ 4, 10, :_reduce_1,
82
+ 0, 13, :_reduce_2,
83
+ 1, 13, :_reduce_none,
84
+ 0, 14, :_reduce_4,
85
+ 1, 14, :_reduce_5,
86
+ 1, 11, :_reduce_6,
87
+ 2, 12, :_reduce_7,
88
+ 2, 15, :_reduce_8,
89
+ 1, 17, :_reduce_9,
90
+ 3, 17, :_reduce_10,
91
+ 3, 18, :_reduce_11,
92
+ 3, 18, :_reduce_12,
93
+ 1, 16, :_reduce_13,
94
+ 2, 16, :_reduce_14 ]
95
+
96
+ racc_reduce_n = 15
97
+
98
+ racc_shift_n = 24
99
+
100
+ racc_action_table = [
101
+ 21, 22, 13, 2, 8, 10, 12, 6, 15, 16,
102
+ 19, 20, 2, 16 ]
103
+
104
+ racc_action_check = [
105
+ 19, 19, 8, 2, 4, 5, 6, 1, 9, 10,
106
+ 16, 18, 0, 20 ]
107
+
108
+ racc_action_pointer = [
109
+ 7, 5, -2, nil, 4, 2, 0, nil, 2, 1,
110
+ 4, nil, nil, nil, nil, nil, 6, nil, 3, -5,
111
+ 8, nil, nil, nil ]
112
+
113
+ racc_action_default = [
114
+ -15, -15, -13, -6, -15, -2, -15, -14, -15, -4,
115
+ -15, -3, -7, 24, -1, -5, -15, -8, -9, -15,
116
+ -15, -11, -12, -10 ]
117
+
118
+ racc_goto_table = [
119
+ 17, 3, 14, 7, 9, 5, 11, 1, 4, nil,
120
+ 23 ]
121
+
122
+ racc_goto_check = [
123
+ 8, 7, 5, 7, 4, 3, 6, 2, 1, nil,
124
+ 8 ]
125
+
126
+ racc_goto_pointer = [
127
+ nil, 8, 7, 4, -1, -7, 1, 1, -10, nil ]
128
+
129
+ racc_goto_default = [
130
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 18 ]
131
+
132
+ racc_token_table = {
133
+ false => 0,
134
+ Object.new => 1,
135
+ :CARD => 2,
136
+ :WITH => 3,
137
+ :MAP_TO => 4,
138
+ :IDENTIFIER => 5,
139
+ :NUMBER => 6,
140
+ :COMMENT => 7,
141
+ :COMMA => 8 }
142
+
143
+ racc_use_result_var = false
144
+
145
+ racc_nt_base = 9
146
+
147
+ Racc_arg = [
148
+ racc_action_table,
149
+ racc_action_check,
150
+ racc_action_default,
151
+ racc_action_pointer,
152
+ racc_goto_table,
153
+ racc_goto_check,
154
+ racc_goto_default,
155
+ racc_goto_pointer,
156
+ racc_nt_base,
157
+ racc_reduce_table,
158
+ racc_token_table,
159
+ racc_shift_n,
160
+ racc_reduce_n,
161
+ racc_use_result_var ]
162
+
163
+ Racc_token_to_s_table = [
164
+ '$end',
165
+ 'error',
166
+ 'CARD',
167
+ 'WITH',
168
+ 'MAP_TO',
169
+ 'IDENTIFIER',
170
+ 'NUMBER',
171
+ 'COMMENT',
172
+ 'COMMA',
173
+ '$start',
174
+ 'target',
175
+ 'transition_name',
176
+ 'card_number',
177
+ 'opt_user_entered_properties',
178
+ 'opt_comment',
179
+ 'user_entered_properties',
180
+ 'identifiers',
181
+ 'properties',
182
+ 'property']
183
+
184
+ Racc_debug_parser = false
185
+
186
+ ##### racc system variables end #####
187
+
188
+ # reduce 0 omitted
189
+
190
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 24
191
+ def _reduce_1( val, _values)
192
+ {
193
+ :transition => val[0],
194
+ :card => val[1],
195
+ :properties => val[2],
196
+ :comment => val[3]
197
+ }
198
+ end
199
+ .,.,
200
+
201
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 27
202
+ def _reduce_2( val, _values)
203
+ nil
204
+ end
205
+ .,.,
206
+
207
+ # reduce 3 omitted
208
+
209
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 32
210
+ def _reduce_4( val, _values)
211
+ nil
212
+ end
213
+ .,.,
214
+
215
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 33
216
+ def _reduce_5( val, _values)
217
+ val[0]
218
+ end
219
+ .,.,
220
+
221
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 37
222
+ def _reduce_6( val, _values)
223
+ val[0].join(" ")
224
+ end
225
+ .,.,
226
+
227
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 41
228
+ def _reduce_7( val, _values)
229
+ val[1]
230
+ end
231
+ .,.,
232
+
233
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 45
234
+ def _reduce_8( val, _values)
235
+ val[1]
236
+ end
237
+ .,.,
238
+
239
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 49
240
+ def _reduce_9( val, _values)
241
+ val[0]
242
+ end
243
+ .,.,
244
+
245
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 50
246
+ def _reduce_10( val, _values)
247
+ val[0].merge val[2]
248
+ end
249
+ .,.,
250
+
251
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 54
252
+ def _reduce_11( val, _values)
253
+ { val[0] => val[2] }
254
+ end
255
+ .,.,
256
+
257
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 55
258
+ def _reduce_12( val, _values)
259
+ { val[0] => val[2] }
260
+ end
261
+ .,.,
262
+
263
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 59
264
+ def _reduce_13( val, _values)
265
+ [val[0]]
266
+ end
267
+ .,.,
268
+
269
+ module_eval <<'.,.,', 'lib/mm/transition_execution.grammar', 60
270
+ def _reduce_14( val, _values)
271
+ [val[0]] + val[1]
272
+ end
273
+ .,.,
274
+
275
+ def _reduce_none( val, _values)
276
+ val[0]
277
+ end
278
+
279
+ end # class TransitionExecutionLanguageParser