assembla 0.7.3 → 0.8.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.
- data/VERSION +1 -1
- data/a2smbla-0.3.0.gem +0 -0
- data/assembla.gemspec +3 -2
- data/lib/assembla.rb +67 -22
- data/lib/extensions.rb +1 -0
- data/lib/interpreter.rb +37 -1
- data/lib/ticket.rb +2 -2
- data/rdoc/classes/AssEmBlr.html +100 -161
- data/rdoc/created.rid +1 -1
- data/rdoc/files/lib/assembla_rb.html +2 -7
- data/rdoc/fr_method_index.html +3 -7
- data/spec/assembla_spec.rb +36 -9
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/a2smbla-0.3.0.gem
ADDED
Binary file
|
data/assembla.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{assembla}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.8.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ignacy Moryc"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-03-15}
|
13
13
|
s.default_executable = %q{ass}
|
14
14
|
s.description = %q{This gem provides access to assembla tickets. It supports listing, creating and modyfing functionality}
|
15
15
|
s.email = %q{imoryc@gmail.com}
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
"README.textile",
|
23
23
|
"Rakefile",
|
24
24
|
"VERSION",
|
25
|
+
"a2smbla-0.3.0.gem",
|
25
26
|
"assembla.gemspec",
|
26
27
|
"bin/ass",
|
27
28
|
"config_default.yml",
|
data/lib/assembla.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# This program allows you to use command line to perform
|
2
|
-
# your typical assembla.com tasks.
|
3
|
-
# for new tickets, change status, reasign them or create new ones
|
2
|
+
# your typical assembla.com tasks.
|
4
3
|
#
|
5
4
|
# Author:: Ignacy Moryc (mailto:imoryc@gmail.com)
|
6
5
|
# License:: MIT
|
7
|
-
|
8
|
-
# This is the main program class
|
6
|
+
|
9
7
|
|
10
8
|
|
11
9
|
require 'open-uri'
|
@@ -21,14 +19,15 @@ class AssEmBlr
|
|
21
19
|
|
22
20
|
attr_accessor :page, :parsed, :url, :user, :password
|
23
21
|
|
24
|
-
# This metod requires for the config file to be present
|
25
22
|
def initialize(config_file = "~/.assembla")
|
26
23
|
config = YAML::parse( File.open(File.expand_path(config_file)))
|
27
|
-
@url
|
28
|
-
@user
|
24
|
+
@url = config["url"].value
|
25
|
+
@user = config["user"].value
|
29
26
|
@password = config["password"].value
|
30
|
-
@me
|
27
|
+
@me = config["me"].value
|
31
28
|
|
29
|
+
# For testing purposes if the url has no HTTP in it we assume
|
30
|
+
# that assembla space is saved to a local file
|
32
31
|
(@url =~ /http/) ? \
|
33
32
|
self.page = Hpricot(open(@url, :http_basic_authentication=>[@user, @password])) \
|
34
33
|
: self.page = Hpricot(open(@url))
|
@@ -42,46 +41,83 @@ class AssEmBlr
|
|
42
41
|
self.parsed = all.evaluate(self.page)
|
43
42
|
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
# Find operates with different arguments:
|
45
|
+
# * :id - ticket's id number
|
46
|
+
# * :status - The same as Assembla ticket status ["New", "Accepted", "Test", "Fixed", "Invalid"]
|
47
|
+
# * :summary - ticket description
|
48
|
+
# * :assigned_to - the person to whom the ticket is assigned to
|
49
|
+
# Also you can use params in pairs, like this:
|
50
|
+
# * :assigned_to and :status
|
51
|
+
def find(args)
|
52
|
+
if args.length == 1
|
53
|
+
return find_id(args[:id]) if (args[:id])
|
54
|
+
return find_with_status(args[:status]) if (args[:status])
|
55
|
+
return find_with_summary(args[:summary]) if (args[:summary])
|
56
|
+
return find_assigned_to(args[:assigned_to]) if (args[:assigned_to])
|
57
|
+
elsif args.length == 2
|
58
|
+
return find_assigned_and_with_status(args[:assigned_to], args[:status]) if (args[:status] && args[:assigned_to])
|
49
59
|
end
|
50
60
|
end
|
51
61
|
|
52
|
-
def find_assigned_to(to = @me)
|
62
|
+
def find_assigned_to(to = @me) #:nodoc:
|
53
63
|
ass = AssignedTo.new
|
54
64
|
assigned_to = ass.evaluate(self.parsed, to)
|
55
65
|
end
|
56
66
|
|
57
|
-
def find_my_active_tickets
|
67
|
+
def find_my_active_tickets #:nodoc:
|
58
68
|
ass = find_assigned_to(@me)
|
59
69
|
new = find_with_status("New")
|
70
|
+
test = find_with_status("Test")
|
60
71
|
accepted = find_with_status("Accepted")
|
61
|
-
(accepted + new + ass).uniq
|
72
|
+
((accepted + new + ass) - test).uniq
|
62
73
|
end
|
63
74
|
|
64
|
-
def find_with_status(status = "New")
|
75
|
+
def find_with_status(status = "New") #:nodoc:
|
65
76
|
st = Status.new
|
66
77
|
active = st.evaluate(self.parsed, status)
|
67
78
|
end
|
68
79
|
|
80
|
+
def find_with_summary(text) #:nodoc:
|
81
|
+
sum = Summary.new
|
82
|
+
summary = sum.evaluate(self.parsed, text)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Prints the tickets to STDOUT
|
69
86
|
def print(tickets)
|
70
87
|
puts_title_line
|
71
88
|
tickets.each { |t| puts t.to_s }
|
72
89
|
end
|
73
|
-
|
74
|
-
def find_id(id)
|
90
|
+
|
91
|
+
def find_id(id) #:nodoc:
|
75
92
|
result = Id.new
|
76
|
-
result.evaluate(self.parsed, id)
|
93
|
+
result.evaluate(self.parsed, id).first
|
77
94
|
end
|
78
95
|
|
79
|
-
|
96
|
+
# This function uses OR condition for search
|
97
|
+
# I commented it out for now - because I can see
|
98
|
+
# no use for it.
|
99
|
+
# def find_assigned_or_with_status(to, status)
|
100
|
+
# st = Status.new
|
101
|
+
# as = AssignedTo.new
|
102
|
+
# st.evaluate(self.parsed, status) | as.evaluate(self.parsed, to)
|
103
|
+
# end
|
104
|
+
|
105
|
+
def find_assigned_and_with_status(to, status) #:nodoc:
|
106
|
+
st = Status.new
|
107
|
+
as = AssignedTo.new
|
108
|
+
st.evaluate(self.parsed, status) & as.evaluate(self.parsed, to)
|
109
|
+
end
|
110
|
+
|
111
|
+
# This method uses Assembla's Ticket REST API
|
112
|
+
# http://www.assembla.com/wiki/show/breakoutdocs/Ticket_REST_API
|
113
|
+
# to change tickets status.
|
114
|
+
# It returns text of http response from Aseembla server.
|
115
|
+
def update_tickets_status(id, status)
|
116
|
+
status_number = get_id_from_status(status)
|
80
117
|
space = @url.gsub(/https:\/\/www\.assembla.com(.+)/, '\1')
|
81
118
|
url = space + '/' + id.to_s
|
82
|
-
puts url
|
83
119
|
request = Net::HTTP::Put.new(url, initheader = {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'})
|
84
|
-
request.body = "<ticket><status type='integer'
|
120
|
+
request.body = "<ticket><status type='integer'>#{status_number}</status></ticket>"
|
85
121
|
request.basic_auth @user, @password
|
86
122
|
Net::HTTP.start("www.assembla.com", 80 ) do |http|
|
87
123
|
response = http.request(request)
|
@@ -91,6 +127,15 @@ class AssEmBlr
|
|
91
127
|
|
92
128
|
private
|
93
129
|
|
130
|
+
def get_id_from_status(s) #:nodoc:
|
131
|
+
statuses = { "New" => 0,
|
132
|
+
"Accepted" => 1,
|
133
|
+
"Invalid" => 2,
|
134
|
+
"Fixed" => 3,
|
135
|
+
"Test" => 4 }
|
136
|
+
return statuses[s]
|
137
|
+
end
|
138
|
+
|
94
139
|
# This is a helper method for printing table header
|
95
140
|
def puts_title_line
|
96
141
|
puts
|
data/lib/extensions.rb
CHANGED
data/lib/interpreter.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
|
+
# Author:: Ignacy Moryc (mailto:imoryc@gmail.com)
|
2
|
+
# License:: MIT
|
3
|
+
|
1
4
|
require File.dirname(__FILE__) + '/extensions'
|
2
5
|
|
3
|
-
class Expression
|
6
|
+
class Expression #:nodoc:
|
7
|
+
|
8
|
+
# def |(other)
|
9
|
+
# Or.new(self, other)
|
10
|
+
# end
|
4
11
|
|
12
|
+
# def &(other)
|
13
|
+
# And.new(self, other)
|
14
|
+
# end
|
15
|
+
|
5
16
|
end
|
6
17
|
|
7
18
|
class All < Expression
|
19
|
+
# Returns all ticket from current space
|
8
20
|
def evaluate(page)
|
9
21
|
returning result = [] do
|
10
22
|
(page/"tr.ticket_row").each do |ticket|
|
@@ -18,6 +30,7 @@ class All < Expression
|
|
18
30
|
end
|
19
31
|
|
20
32
|
class Status < Expression
|
33
|
+
# Searches tickets by status
|
21
34
|
def evaluate(tickets, status)
|
22
35
|
returning result = [] do
|
23
36
|
tickets.each { |t| result.push(t) if t.status == status }
|
@@ -26,6 +39,7 @@ class Status < Expression
|
|
26
39
|
end
|
27
40
|
|
28
41
|
class Id < Expression
|
42
|
+
# Searches tickets by id
|
29
43
|
def evaluate(tickets, id)
|
30
44
|
returning result = [] do
|
31
45
|
tickets.each { |t| result.push(t) if t.id == id }
|
@@ -34,9 +48,31 @@ class Id < Expression
|
|
34
48
|
end
|
35
49
|
|
36
50
|
class AssignedTo < Expression
|
51
|
+
# Searches tickets by assigned user
|
37
52
|
def evaluate(tickets, to)
|
38
53
|
returning result = [] do
|
39
54
|
tickets.each { |t| result.push(t) if t.assigned_to == to }
|
40
55
|
end
|
41
56
|
end
|
42
57
|
end
|
58
|
+
|
59
|
+
class Summary < Expression
|
60
|
+
# Searches tickets by summary
|
61
|
+
def evaluate(tickets, text)
|
62
|
+
returning result = [] do
|
63
|
+
tickets.each { |t| result.push(t) if t.summary.match(text) }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# class Or < Expression
|
69
|
+
# def initialize(tickets1, tickets2)
|
70
|
+
# (tickets1 + tickets).sort.uniq
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
|
74
|
+
# class And < Expression
|
75
|
+
# def initialize(tickets1, tickets2)
|
76
|
+
# (tickets1 + tickets).sort.uniq
|
77
|
+
# end
|
78
|
+
# end
|
data/lib/ticket.rb
CHANGED
@@ -11,14 +11,14 @@
|
|
11
11
|
class Ticket
|
12
12
|
attr_accessor :id, :summary, :status, :assigned_to
|
13
13
|
|
14
|
-
def initialize(id, summary, status, assigned_to)
|
14
|
+
def initialize(id, summary, status, assigned_to) #:nodoc:
|
15
15
|
self.id = id.to_i
|
16
16
|
self.summary = summary
|
17
17
|
self.status = status
|
18
18
|
self.assigned_to = assigned_to
|
19
19
|
end
|
20
20
|
|
21
|
-
def to_s
|
21
|
+
def to_s #:nodoc:
|
22
22
|
"#{self.id.to_s.center(5)}|#{self.assigned_to.center(18)}|#{self.status.to_s.center(10)}| #{self.summary} \n"
|
23
23
|
end
|
24
24
|
|
data/rdoc/classes/AssEmBlr.html
CHANGED
@@ -86,15 +86,11 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
90
|
-
<a href="#M000008">find_id</a>
|
91
|
-
<a href="#M000005">find_my_active_tickets</a>
|
92
|
-
<a href="#M000006">find_with_status</a>
|
89
|
+
<a href="#M000003">find</a>
|
93
90
|
<a href="#M000001">new</a>
|
94
|
-
<a href="#
|
95
|
-
<a href="#M000003">print_tickets</a>
|
91
|
+
<a href="#M000004">print</a>
|
96
92
|
<a href="#M000002">tickets</a>
|
97
|
-
<a href="#
|
93
|
+
<a href="#M000005">update_tickets_status</a>
|
98
94
|
</div>
|
99
95
|
</div>
|
100
96
|
|
@@ -154,28 +150,31 @@
|
|
154
150
|
|
155
151
|
<div class="method-heading">
|
156
152
|
<a href="#M000001" class="method-signature">
|
157
|
-
<span class="method-name">new</span><span class="method-args">()</span>
|
153
|
+
<span class="method-name">new</span><span class="method-args">(config_file = "~/.assembla")</span>
|
158
154
|
</a>
|
159
155
|
</div>
|
160
156
|
|
161
157
|
<div class="method-description">
|
162
|
-
<p>
|
163
|
-
This metod requires for the config file to be present
|
164
|
-
</p>
|
165
158
|
<p><a class="source-toggle" href="#"
|
166
159
|
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
167
160
|
<div class="method-source-code" id="M000001-source">
|
168
161
|
<pre>
|
169
|
-
<span class="ruby-comment cmt"># File lib/assembla.rb, line
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
162
|
+
<span class="ruby-comment cmt"># File lib/assembla.rb, line 22</span>
|
163
|
+
22: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">config_file</span> = <span class="ruby-value str">"~/.assembla"</span>)
|
164
|
+
23: <span class="ruby-identifier">config</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">parse</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">config_file</span>)))
|
165
|
+
24: <span class="ruby-ivar">@url</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value str">"url"</span>].<span class="ruby-identifier">value</span>
|
166
|
+
25: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value str">"user"</span>].<span class="ruby-identifier">value</span>
|
167
|
+
26: <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value str">"password"</span>].<span class="ruby-identifier">value</span>
|
168
|
+
27: <span class="ruby-ivar">@me</span> = <span class="ruby-identifier">config</span>[<span class="ruby-value str">"me"</span>].<span class="ruby-identifier">value</span>
|
169
|
+
28:
|
170
|
+
29: <span class="ruby-comment cmt"># For testing purposes if the url has no HTTP in it we assume</span>
|
171
|
+
30: <span class="ruby-comment cmt"># that assembla space is saved to a local file</span>
|
172
|
+
31: (<span class="ruby-ivar">@url</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/http/</span>) <span class="ruby-operator">?</span> \
|
173
|
+
32: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">page</span> = <span class="ruby-constant">Hpricot</span>(<span class="ruby-identifier">open</span>(<span class="ruby-ivar">@url</span>, <span class="ruby-identifier">:http_basic_authentication=</span><span class="ruby-operator">></span>[<span class="ruby-ivar">@user</span>, <span class="ruby-ivar">@password</span>])) \
|
174
|
+
33: <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">page</span> = <span class="ruby-constant">Hpricot</span>(<span class="ruby-identifier">open</span>(<span class="ruby-ivar">@url</span>))
|
175
|
+
34:
|
176
|
+
35: <span class="ruby-identifier">tickets</span>
|
177
|
+
36: <span class="ruby-keyword kw">end</span>
|
179
178
|
</pre>
|
180
179
|
</div>
|
181
180
|
</div>
|
@@ -183,149 +182,85 @@ This metod requires for the config file to be present
|
|
183
182
|
|
184
183
|
<h3 class="section-bar">Public Instance methods</h3>
|
185
184
|
|
186
|
-
<div id="method-
|
187
|
-
<a name="
|
185
|
+
<div id="method-M000003" class="method-detail">
|
186
|
+
<a name="M000003"></a>
|
188
187
|
|
189
188
|
<div class="method-heading">
|
190
|
-
<a href="#
|
191
|
-
<span class="method-name">
|
189
|
+
<a href="#M000003" class="method-signature">
|
190
|
+
<span class="method-name">find</span><span class="method-args">(args)</span>
|
192
191
|
</a>
|
193
192
|
</div>
|
194
193
|
|
195
194
|
<div class="method-description">
|
196
|
-
<p
|
197
|
-
|
198
|
-
|
199
|
-
<
|
200
|
-
|
201
|
-
49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_assigned_to</span>(<span class="ruby-identifier">to</span> = <span class="ruby-ivar">@me</span>)
|
202
|
-
50: <span class="ruby-identifier">ass</span> = <span class="ruby-constant">AssignedTo</span>.<span class="ruby-identifier">new</span>
|
203
|
-
51: <span class="ruby-identifier">assigned_to</span> = <span class="ruby-identifier">ass</span>.<span class="ruby-identifier">evaluate</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parsed</span>, <span class="ruby-identifier">to</span>)
|
204
|
-
52: <span class="ruby-keyword kw">end</span>
|
205
|
-
</pre>
|
206
|
-
</div>
|
207
|
-
</div>
|
208
|
-
</div>
|
209
|
-
|
210
|
-
<div id="method-M000008" class="method-detail">
|
211
|
-
<a name="M000008"></a>
|
195
|
+
<p>
|
196
|
+
Find operates with different arguments:
|
197
|
+
</p>
|
198
|
+
<ul>
|
199
|
+
<li>:id - ticket‘s id number
|
212
200
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
</div>
|
218
|
-
|
219
|
-
<div class="method-description">
|
220
|
-
<p><a class="source-toggle" href="#"
|
221
|
-
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
222
|
-
<div class="method-source-code" id="M000008-source">
|
223
|
-
<pre>
|
224
|
-
<span class="ruby-comment cmt"># File lib/assembla.rb, line 71</span>
|
225
|
-
71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_id</span>(<span class="ruby-identifier">id</span>)
|
226
|
-
72: <span class="ruby-identifier">result</span> = <span class="ruby-constant">Id</span>.<span class="ruby-identifier">new</span>
|
227
|
-
73: <span class="ruby-identifier">found</span> = <span class="ruby-identifier">result</span>.<span class="ruby-identifier">evaluate</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parsed</span>, <span class="ruby-constant">Id</span>)
|
228
|
-
74: <span class="ruby-keyword kw">end</span>
|
229
|
-
</pre>
|
230
|
-
</div>
|
231
|
-
</div>
|
232
|
-
</div>
|
201
|
+
</li>
|
202
|
+
<li>:status - The same as Assembla ticket status ["New",
|
203
|
+
"Accepted", "Test", "Fixed",
|
204
|
+
"Invalid"]
|
233
205
|
|
234
|
-
|
235
|
-
|
206
|
+
</li>
|
207
|
+
<li>:summary - ticket description
|
236
208
|
|
237
|
-
|
238
|
-
|
239
|
-
<span class="method-name">find_my_active_tickets</span><span class="method-args">()</span>
|
240
|
-
</a>
|
241
|
-
</div>
|
242
|
-
|
243
|
-
<div class="method-description">
|
244
|
-
<p><a class="source-toggle" href="#"
|
245
|
-
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
246
|
-
<div class="method-source-code" id="M000005-source">
|
247
|
-
<pre>
|
248
|
-
<span class="ruby-comment cmt"># File lib/assembla.rb, line 54</span>
|
249
|
-
54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_my_active_tickets</span>
|
250
|
-
55: <span class="ruby-identifier">ass</span> = <span class="ruby-identifier">find_assigned_to</span>(<span class="ruby-ivar">@me</span>)
|
251
|
-
56: <span class="ruby-identifier">new</span> = <span class="ruby-identifier">find_with_status</span>(<span class="ruby-value str">"New"</span>)
|
252
|
-
57: <span class="ruby-identifier">accepted</span> = <span class="ruby-identifier">find_with_status</span>(<span class="ruby-value str">"Accepted"</span>)
|
253
|
-
58: (<span class="ruby-identifier">accepted</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">new</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">ass</span>).<span class="ruby-identifier">uniq</span>
|
254
|
-
59: <span class="ruby-keyword kw">end</span>
|
255
|
-
</pre>
|
256
|
-
</div>
|
257
|
-
</div>
|
258
|
-
</div>
|
209
|
+
</li>
|
210
|
+
<li>:assigned_to - the person to whom the ticket is assigned to
|
259
211
|
|
260
|
-
|
261
|
-
|
212
|
+
</li>
|
213
|
+
</ul>
|
214
|
+
<p>
|
215
|
+
Also you can use params in pairs, like this:
|
216
|
+
</p>
|
217
|
+
<ul>
|
218
|
+
<li>:assigned_to and :status
|
262
219
|
|
263
|
-
|
264
|
-
|
265
|
-
<span class="method-name">find_with_status</span><span class="method-args">(status = "New")</span>
|
266
|
-
</a>
|
267
|
-
</div>
|
268
|
-
|
269
|
-
<div class="method-description">
|
220
|
+
</li>
|
221
|
+
</ul>
|
270
222
|
<p><a class="source-toggle" href="#"
|
271
|
-
onclick="toggleCode('
|
272
|
-
<div class="method-source-code" id="
|
223
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
224
|
+
<div class="method-source-code" id="M000003-source">
|
273
225
|
<pre>
|
274
|
-
<span class="ruby-comment cmt"># File lib/assembla.rb, line
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
226
|
+
<span class="ruby-comment cmt"># File lib/assembla.rb, line 51</span>
|
227
|
+
51: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find</span>(<span class="ruby-identifier">args</span>)
|
228
|
+
52: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
229
|
+
53: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">find_id</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:id</span>]) <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:id</span>])
|
230
|
+
54: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">find_with_status</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:status</span>]) <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:status</span>])
|
231
|
+
55: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">find_with_summary</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:summary</span>]) <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:summary</span>])
|
232
|
+
56: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">find_assigned_to</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:assigned_to</span>]) <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:assigned_to</span>])
|
233
|
+
57: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>
|
234
|
+
58: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">find_assigned_and_with_status</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:assigned_to</span>], <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:status</span>]) <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:status</span>] <span class="ruby-operator">&&</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:assigned_to</span>])
|
235
|
+
59: <span class="ruby-keyword kw">end</span>
|
236
|
+
60: <span class="ruby-keyword kw">end</span>
|
279
237
|
</pre>
|
280
238
|
</div>
|
281
239
|
</div>
|
282
240
|
</div>
|
283
241
|
|
284
|
-
<div id="method-
|
285
|
-
<a name="
|
242
|
+
<div id="method-M000004" class="method-detail">
|
243
|
+
<a name="M000004"></a>
|
286
244
|
|
287
245
|
<div class="method-heading">
|
288
|
-
<a href="#
|
246
|
+
<a href="#M000004" class="method-signature">
|
289
247
|
<span class="method-name">print</span><span class="method-args">(tickets)</span>
|
290
248
|
</a>
|
291
249
|
</div>
|
292
250
|
|
293
251
|
<div class="method-description">
|
252
|
+
<p>
|
253
|
+
Prints the <a href="AssEmBlr.html#M000002">tickets</a> to STDOUT
|
254
|
+
</p>
|
294
255
|
<p><a class="source-toggle" href="#"
|
295
|
-
onclick="toggleCode('
|
296
|
-
<div class="method-source-code" id="
|
297
|
-
<pre>
|
298
|
-
<span class="ruby-comment cmt"># File lib/assembla.rb, line 66</span>
|
299
|
-
66: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print</span>(<span class="ruby-identifier">tickets</span>)
|
300
|
-
67: <span class="ruby-identifier">puts_title_line</span>
|
301
|
-
68: <span class="ruby-identifier">tickets</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">to_s</span> }
|
302
|
-
69: <span class="ruby-keyword kw">end</span>
|
303
|
-
</pre>
|
304
|
-
</div>
|
305
|
-
</div>
|
306
|
-
</div>
|
307
|
-
|
308
|
-
<div id="method-M000003" class="method-detail">
|
309
|
-
<a name="M000003"></a>
|
310
|
-
|
311
|
-
<div class="method-heading">
|
312
|
-
<a href="#M000003" class="method-signature">
|
313
|
-
<span class="method-name">print_tickets</span><span class="method-args">()</span>
|
314
|
-
</a>
|
315
|
-
</div>
|
316
|
-
|
317
|
-
<div class="method-description">
|
318
|
-
<p><a class="source-toggle" href="#"
|
319
|
-
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
320
|
-
<div class="method-source-code" id="M000003-source">
|
256
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
257
|
+
<div class="method-source-code" id="M000004-source">
|
321
258
|
<pre>
|
322
|
-
<span class="ruby-comment cmt"># File lib/assembla.rb, line
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
46: <span class="ruby-keyword kw">end</span>
|
328
|
-
47: <span class="ruby-keyword kw">end</span>
|
259
|
+
<span class="ruby-comment cmt"># File lib/assembla.rb, line 86</span>
|
260
|
+
86: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print</span>(<span class="ruby-identifier">tickets</span>)
|
261
|
+
87: <span class="ruby-identifier">puts_title_line</span>
|
262
|
+
88: <span class="ruby-identifier">tickets</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">to_s</span> }
|
263
|
+
89: <span class="ruby-keyword kw">end</span>
|
329
264
|
</pre>
|
330
265
|
</div>
|
331
266
|
</div>
|
@@ -349,45 +284,49 @@ in your Assembla space
|
|
349
284
|
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
350
285
|
<div class="method-source-code" id="M000002-source">
|
351
286
|
<pre>
|
352
|
-
<span class="ruby-comment cmt"># File lib/assembla.rb, line
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
287
|
+
<span class="ruby-comment cmt"># File lib/assembla.rb, line 39</span>
|
288
|
+
39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tickets</span>
|
289
|
+
40: <span class="ruby-identifier">all</span> = <span class="ruby-constant">All</span>.<span class="ruby-identifier">new</span>
|
290
|
+
41: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parsed</span> = <span class="ruby-identifier">all</span>.<span class="ruby-identifier">evaluate</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">page</span>)
|
291
|
+
42: <span class="ruby-keyword kw">end</span>
|
357
292
|
</pre>
|
358
293
|
</div>
|
359
294
|
</div>
|
360
295
|
</div>
|
361
296
|
|
362
|
-
<div id="method-
|
363
|
-
<a name="
|
297
|
+
<div id="method-M000005" class="method-detail">
|
298
|
+
<a name="M000005"></a>
|
364
299
|
|
365
300
|
<div class="method-heading">
|
366
|
-
<a href="#
|
367
|
-
<span class="method-name">
|
301
|
+
<a href="#M000005" class="method-signature">
|
302
|
+
<span class="method-name">update_tickets_status</span><span class="method-args">(id, status)</span>
|
368
303
|
</a>
|
369
304
|
</div>
|
370
305
|
|
371
306
|
<div class="method-description">
|
372
307
|
<p>
|
373
|
-
|
308
|
+
This method uses Assembla‘s Ticket REST API <a
|
309
|
+
href="http://www.assembla.com/wiki/show/breakoutdocs/Ticket_REST_API">www.assembla.com/wiki/show/breakoutdocs/Ticket_REST_API</a>
|
310
|
+
to change <a href="AssEmBlr.html#M000002">tickets</a> status. It returns
|
311
|
+
text of http response from Aseembla server.
|
374
312
|
</p>
|
375
313
|
<p><a class="source-toggle" href="#"
|
376
|
-
onclick="toggleCode('
|
377
|
-
<div class="method-source-code" id="
|
314
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
315
|
+
<div class="method-source-code" id="M000005-source">
|
378
316
|
<pre>
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
317
|
+
<span class="ruby-comment cmt"># File lib/assembla.rb, line 115</span>
|
318
|
+
115: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_tickets_status</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">status</span>)
|
319
|
+
116: <span class="ruby-identifier">status_number</span> = <span class="ruby-identifier">get_id_from_status</span>(<span class="ruby-identifier">status</span>)
|
320
|
+
117: <span class="ruby-identifier">space</span> = <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/https:\/\/www\.assembla.com(.+)/</span>, <span class="ruby-value str">'\1'</span>)
|
321
|
+
118: <span class="ruby-identifier">url</span> = <span class="ruby-identifier">space</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">id</span>.<span class="ruby-identifier">to_s</span>
|
322
|
+
119: <span class="ruby-identifier">request</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Put</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">initheader</span> = {<span class="ruby-value str">'Content-Type'</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'application/xml'</span>, <span class="ruby-value str">'Accept'</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'application/xml'</span>})
|
323
|
+
120: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span> = <span class="ruby-node">"<ticket><status type='integer'>#{status_number}</status></ticket>"</span>
|
324
|
+
121: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">basic_auth</span> <span class="ruby-ivar">@user</span>, <span class="ruby-ivar">@password</span>
|
325
|
+
122: <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value str">"www.assembla.com"</span>, <span class="ruby-value">80</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
|
326
|
+
123: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">request</span>)
|
327
|
+
124: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">response</span>
|
328
|
+
125: <span class="ruby-keyword kw">end</span>
|
329
|
+
126: <span class="ruby-keyword kw">end</span>
|
391
330
|
</pre>
|
392
331
|
</div>
|
393
332
|
</div>
|
data/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Mon, 15 Mar 2010 19:24:30 +0100
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Mon Mar 15 19:18:21 +0100 2010</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -71,8 +71,7 @@
|
|
71
71
|
<div id="description">
|
72
72
|
<p>
|
73
73
|
This program allows you to use command line to perform your typical
|
74
|
-
assembla.com tasks.
|
75
|
-
reasign them or create new ones
|
74
|
+
assembla.com tasks.
|
76
75
|
</p>
|
77
76
|
<table>
|
78
77
|
<tr><td valign="top">Author:</td><td>Ignacy Moryc (<a href="mailto:imoryc@gmail.com">imoryc@gmail.com</a>)
|
@@ -82,9 +81,6 @@ reasign them or create new ones
|
|
82
81
|
|
83
82
|
</td></tr>
|
84
83
|
</table>
|
85
|
-
<p>
|
86
|
-
This is the main program class
|
87
|
-
</p>
|
88
84
|
|
89
85
|
</div>
|
90
86
|
|
@@ -96,7 +92,6 @@ This is the main program class
|
|
96
92
|
net/http
|
97
93
|
rubygems
|
98
94
|
hpricot
|
99
|
-
patron
|
100
95
|
</div>
|
101
96
|
</div>
|
102
97
|
|
data/rdoc/fr_method_index.html
CHANGED
@@ -20,15 +20,11 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/AssEmBlr.html#
|
24
|
-
<a href="classes/AssEmBlr.html#M000008">find_id (AssEmBlr)</a><br />
|
25
|
-
<a href="classes/AssEmBlr.html#M000005">find_my_active_tickets (AssEmBlr)</a><br />
|
26
|
-
<a href="classes/AssEmBlr.html#M000006">find_with_status (AssEmBlr)</a><br />
|
23
|
+
<a href="classes/AssEmBlr.html#M000003">find (AssEmBlr)</a><br />
|
27
24
|
<a href="classes/AssEmBlr.html#M000001">new (AssEmBlr)</a><br />
|
28
|
-
<a href="classes/AssEmBlr.html#
|
29
|
-
<a href="classes/AssEmBlr.html#M000003">print_tickets (AssEmBlr)</a><br />
|
25
|
+
<a href="classes/AssEmBlr.html#M000004">print (AssEmBlr)</a><br />
|
30
26
|
<a href="classes/AssEmBlr.html#M000002">tickets (AssEmBlr)</a><br />
|
31
|
-
<a href="classes/AssEmBlr.html#
|
27
|
+
<a href="classes/AssEmBlr.html#M000005">update_tickets_status (AssEmBlr)</a><br />
|
32
28
|
</div>
|
33
29
|
</div>
|
34
30
|
</body>
|
data/spec/assembla_spec.rb
CHANGED
@@ -15,22 +15,49 @@ describe AssEmBlr do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
it "should find status number code properly" do
|
19
|
+
@assem.send(:get_id_from_status, "Fixed").should eql(3)
|
20
|
+
@assem.send(:get_id_from_status, "Invalid").should eql(2)
|
21
|
+
end
|
22
|
+
|
23
|
+
context "searching for tickets" do
|
24
|
+
it "should use 'Assiged To' filter" do
|
25
|
+
mine = @assem.find({:assigned_to => "Above & Beyond"})
|
21
26
|
mine.length.should eql(2)
|
22
27
|
end
|
23
|
-
|
24
|
-
#TODO find_id should return only one element
|
28
|
+
|
25
29
|
it "should filter tickets by id" do
|
26
|
-
with_id = @assem.
|
27
|
-
with_id.
|
30
|
+
with_id = @assem.find({:id => 841})
|
31
|
+
with_id.summary.should match /Fix tab order/
|
28
32
|
end
|
29
33
|
|
30
34
|
it "should filter tickets by status" do
|
31
|
-
test = @assem.
|
35
|
+
test = @assem.find({:status => "Test"})
|
32
36
|
test.length.should eql(2)
|
33
37
|
end
|
34
|
-
|
38
|
+
|
39
|
+
it "should filter tickets by summary text" do
|
40
|
+
se = @assem.find({:summary => "else"})
|
41
|
+
se.first.summary.should match /Somethign else/
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with multiple filters " do
|
45
|
+
# see => find_assigned_or_with_status description
|
46
|
+
# it "should filter tickets with status or assigned user" do
|
47
|
+
# a = @assem.find_assigned_or_with_status("Armin Van B", "Test")
|
48
|
+
# a.count.should eql(5)
|
49
|
+
# end
|
50
|
+
|
51
|
+
it "should filter tickets with status and assigned user" do
|
52
|
+
a = @assem.find_assigned_and_with_status("Armin Van B", "Test")
|
53
|
+
a.count.should eql(1)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should find tickets with status AND assigned user" do
|
57
|
+
a = @assem.find({:assigned_to => "Armin Van B", :status => "Test"})
|
58
|
+
a.count.should eql(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
35
62
|
end
|
36
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assembla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignacy Moryc
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-15 00:00:00 +01:00
|
13
13
|
default_executable: ass
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- README.textile
|
36
36
|
- Rakefile
|
37
37
|
- VERSION
|
38
|
+
- a2smbla-0.3.0.gem
|
38
39
|
- assembla.gemspec
|
39
40
|
- bin/ass
|
40
41
|
- config_default.yml
|