assembla 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,17 @@ user: USERNAME
11
11
  password: PASSWORD
12
12
  me: MEANING_THE_PERSON_TO_WHOM_THE_TICKETS_ARE_ASSIGNED
13
13
 
14
+ bc.. Usage: ass [options]
15
+ -a, --all Print your active and new tickets
16
+ -i, --id ID Get ticket with id = ID
17
+ -s, --status STATUS Find tickets with given status
18
+ -t, --to TO Assigned to TO, example: ass -t "John Doe"
19
+ --toandstatus DATA Assigned to TO and with STATUS, call like this: ass --toandstatus "Name Surname"__New
20
+ -u, --updateStatus DATA Change tickets status, call like this: ass -u ID__NEW_STATUS
21
+ -d, --updateDescription DATA Change tickets descriptino. Exmple ass -d ID__"New description text"
22
+ -v, --version Get version
23
+ -h, --help Display this information
24
+
14
25
  h2. INSTALATION
15
26
 
16
27
  p{background:#888}. gem install a2smbla
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 1.0.0
Binary file
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{assembla}
8
- s.version = "0.8.0"
8
+ s.version = "1.0.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-03-15}
12
+ s.date = %q{2010-03-27}
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}
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  "Rakefile",
24
24
  "VERSION",
25
25
  "a2smbla-0.3.0.gem",
26
+ "assembla-0.8.0.gem",
26
27
  "assembla.gemspec",
27
28
  "bin/ass",
28
29
  "config_default.yml",
@@ -46,7 +47,7 @@ Gem::Specification.new do |s|
46
47
  s.homepage = %q{http://github.com/ignacy/assembla}
47
48
  s.rdoc_options = ["--charset=UTF-8"]
48
49
  s.require_paths = ["lib"]
49
- s.rubygems_version = %q{1.3.5}
50
+ s.rubygems_version = %q{1.3.6}
50
51
  s.summary = %q{Command line access to assembla}
51
52
  s.test_files = [
52
53
  "spec/assembla_spec.rb"
data/bin/ass CHANGED
@@ -3,6 +3,61 @@
3
3
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
4
 
5
5
  require 'assembla'
6
+ require 'optparse'
6
7
 
8
+ options = {}
7
9
  @assem = AssEmBlr.new
8
- @assem.print(@assem.find_my_active_tickets)
10
+
11
+ OptionParser.new do |opts|
12
+ opts.banner = "Usage: ass [options]"
13
+
14
+ opts.on("-a", "--all", "Print your active and new tickets") do |a|
15
+ options[:all] = a
16
+ @assem.print(@assem.find_my_active_tickets)
17
+ end
18
+
19
+ opts.on("-i", "--id ID", "Get ticket with id = ID") do |id|
20
+ idid = @assem.find({:id => id.to_i})
21
+ puts idid.details
22
+ end
23
+
24
+
25
+ opts.on("-s", "--status STATUS", "Find tickets with given status") do |status|
26
+ options[:status] = status
27
+ with_id = @assem.find({:status => options[:status]})
28
+ @assem.print(with_id)
29
+ end
30
+
31
+
32
+ opts.on( '-t', '--to TO', 'Assigned to TO, example: ass -t "John Doe" ') do |to|
33
+ @assem.print(@assem.find({:assigned_to => to}))
34
+ end
35
+
36
+ opts.on("--toandstatus DATA", 'Assigned to TO and with STATUS, call like this: ass --toandstatus "Name Surname"__New ') do |data|
37
+ to, status = data.split(/__/)
38
+ @assem.print(@assem.find({:assigned_to => to, :status => status}))
39
+ end
40
+
41
+ opts.on("-u", "--updateStatus DATA", 'Change tickets status, call like this: ass -u ID__NEW_STATUS') do |data|
42
+ id, status = data.split(/__/)
43
+ @assem.update_tickets_status(id, status)
44
+ end
45
+
46
+ opts.on("-d", "--updateDescription DATA", 'Change tickets descriptino. Exmple ass -d ID__"New description text"') do |data|
47
+ id, description = data.split(/__/)
48
+ @assem.update_tickets_description(id, description)
49
+ end
50
+
51
+ opts.on("-v", "--version", "Get version") do |v|
52
+ options[:verbose] = v
53
+ puts "Assembla version 0.8.0"
54
+ end
55
+
56
+ opts.on( '-h', '--help', 'Display this information' ) do
57
+ puts opts
58
+ exit
59
+ end
60
+
61
+
62
+ end.parse!
63
+
@@ -65,11 +65,10 @@ class AssEmBlr
65
65
  end
66
66
 
67
67
  def find_my_active_tickets #:nodoc:
68
- ass = find_assigned_to(@me)
69
- new = find_with_status("New")
70
- test = find_with_status("Test")
71
- accepted = find_with_status("Accepted")
72
- ((accepted + new + ass) - test).uniq
68
+ ass = self.find({ :assigned_to => @me, :status => "New"})
69
+ test = self.find({ :assigned_to => @me, :status => "Test"})
70
+ accepted = self.find({ :assigned_to => @me, :status => "Accepted"})
71
+ ((accepted + ass) - test)
73
72
  end
74
73
 
75
74
  def find_with_status(status = "New") #:nodoc:
@@ -90,7 +89,7 @@ class AssEmBlr
90
89
 
91
90
  def find_id(id) #:nodoc:
92
91
  result = Id.new
93
- result.evaluate(self.parsed, id).first
92
+ result.evaluate(self.parsed, id)
94
93
  end
95
94
 
96
95
  # This function uses OR condition for search
@@ -113,19 +112,34 @@ class AssEmBlr
113
112
  # to change tickets status.
114
113
  # It returns text of http response from Aseembla server.
115
114
  def update_tickets_status(id, status)
116
- status_number = get_id_from_status(status)
115
+ request = prepare_request(id)
116
+ request.body = "<ticket><status type='integer'>#{get_id_from_status(status)}</status></ticket>"
117
+ send_request(request)
118
+ end
119
+
120
+
121
+ def update_tickets_description(id, description)
122
+ request = prepare_request(id)
123
+ request.body = "<ticket><description>#{description}</description></ticket>"
124
+ send_request(request)
125
+ end
126
+
127
+ private
128
+
129
+ def prepare_request(id)
117
130
  space = @url.gsub(/https:\/\/www\.assembla.com(.+)/, '\1')
118
131
  url = space + '/' + id.to_s
119
132
  request = Net::HTTP::Put.new(url, initheader = {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'})
120
- request.body = "<ticket><status type='integer'>#{status_number}</status></ticket>"
121
- request.basic_auth @user, @password
133
+ end
134
+
135
+ def send_request(request)
136
+ request.basic_auth @user, @password
122
137
  Net::HTTP.start("www.assembla.com", 80 ) do |http|
123
138
  response = http.request(request)
124
- puts response
139
+ puts "Response code #{response.code}"
140
+ puts response.body
125
141
  end
126
142
  end
127
-
128
- private
129
143
 
130
144
  def get_id_from_status(s) #:nodoc:
131
145
  statuses = { "New" => 0,
@@ -41,9 +41,7 @@ end
41
41
  class Id < Expression
42
42
  # Searches tickets by id
43
43
  def evaluate(tickets, id)
44
- returning result = [] do
45
- tickets.each { |t| result.push(t) if t.id == id }
46
- end
44
+ tickets.detect { |t| t.id == id }
47
45
  end
48
46
  end
49
47
 
@@ -21,5 +21,19 @@ class Ticket
21
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
+
25
+ def details
26
+ details = <<DETAILS
27
+ Id: #{self.id}
28
+ Status: #{self.status.to_s}
29
+ AssignedTo: #{self.assigned_to}
30
+ -----------------------------------------------
31
+ Sumary: #{self.summary}
32
+ -----------------------------------------------
33
+ DETAILS
34
+
35
+
36
+ end
37
+
24
38
 
25
39
  end
@@ -90,6 +90,7 @@
90
90
  <a href="#M000001">new</a>&nbsp;&nbsp;
91
91
  <a href="#M000004">print</a>&nbsp;&nbsp;
92
92
  <a href="#M000002">tickets</a>&nbsp;&nbsp;
93
+ <a href="#M000006">update_tickets_description</a>&nbsp;&nbsp;
93
94
  <a href="#M000005">update_tickets_status</a>&nbsp;&nbsp;
94
95
  </div>
95
96
  </div>
@@ -256,11 +257,11 @@ Prints the <a href="AssEmBlr.html#M000002">tickets</a> to STDOUT
256
257
  onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
257
258
  <div class="method-source-code" id="M000004-source">
258
259
  <pre>
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>
260
+ <span class="ruby-comment cmt"># File lib/assembla.rb, line 85</span>
261
+ 85: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print</span>(<span class="ruby-identifier">tickets</span>)
262
+ 86: <span class="ruby-identifier">puts_title_line</span>
263
+ 87: <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> }
264
+ 88: <span class="ruby-keyword kw">end</span>
264
265
  </pre>
265
266
  </div>
266
267
  </div>
@@ -294,6 +295,31 @@ in your Assembla space
294
295
  </div>
295
296
  </div>
296
297
 
298
+ <div id="method-M000006" class="method-detail">
299
+ <a name="M000006"></a>
300
+
301
+ <div class="method-heading">
302
+ <a href="#M000006" class="method-signature">
303
+ <span class="method-name">update_tickets_description</span><span class="method-args">(id, description)</span>
304
+ </a>
305
+ </div>
306
+
307
+ <div class="method-description">
308
+ <p><a class="source-toggle" href="#"
309
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
310
+ <div class="method-source-code" id="M000006-source">
311
+ <pre>
312
+ <span class="ruby-comment cmt"># File lib/assembla.rb, line 121</span>
313
+ 121: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_tickets_description</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">description</span>)
314
+ 122: <span class="ruby-identifier">request</span> = <span class="ruby-identifier">prepare_request</span>(<span class="ruby-identifier">id</span>)
315
+ 123: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span> = <span class="ruby-node">&quot;&lt;ticket&gt;&lt;description&gt;#{description}&lt;/description&gt;&lt;/ticket&gt;&quot;</span>
316
+ 124: <span class="ruby-identifier">send_request</span>(<span class="ruby-identifier">request</span>)
317
+ 125: <span class="ruby-keyword kw">end</span>
318
+ </pre>
319
+ </div>
320
+ </div>
321
+ </div>
322
+
297
323
  <div id="method-M000005" class="method-detail">
298
324
  <a name="M000005"></a>
299
325
 
@@ -314,19 +340,12 @@ text of http response from Aseembla server.
314
340
  onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
315
341
  <div class="method-source-code" id="M000005-source">
316
342
  <pre>
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">&gt;</span> <span class="ruby-value str">'application/xml'</span>, <span class="ruby-value str">'Accept'</span> =<span class="ruby-operator">&gt;</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">&quot;&lt;ticket&gt;&lt;status type='integer'&gt;#{status_number}&lt;/status&gt;&lt;/ticket&gt;&quot;</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">&quot;www.assembla.com&quot;</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>
343
+ <span class="ruby-comment cmt"># File lib/assembla.rb, line 114</span>
344
+ 114: <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>)
345
+ 115: <span class="ruby-identifier">request</span> = <span class="ruby-identifier">prepare_request</span>(<span class="ruby-identifier">id</span>)
346
+ 116: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span> = <span class="ruby-node">&quot;&lt;ticket&gt;&lt;status type='integer'&gt;#{get_id_from_status(status)}&lt;/status&gt;&lt;/ticket&gt;&quot;</span>
347
+ 117: <span class="ruby-identifier">send_request</span>(<span class="ruby-identifier">request</span>)
348
+ 118: <span class="ruby-keyword kw">end</span>
330
349
  </pre>
331
350
  </div>
332
351
  </div>
@@ -1 +1 @@
1
- Mon, 15 Mar 2010 19:24:30 +0100
1
+ Sat, 27 Mar 2010 13:26:45 +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>Sat Feb 13 13:16:26 +0100 2010</td>
59
+ <td>Sat Mar 27 13:26:18 +0100 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -95,6 +95,20 @@ user: USERNAME password: PASSWORD me:
95
95
  MEANING_THE_PERSON_TO_WHOM_THE_TICKETS_ARE_ASSIGNED
96
96
  </p>
97
97
  <p>
98
+ bc.. Usage: ass [options]
99
+ </p>
100
+ <pre>
101
+ -a, --all Print your active and new tickets
102
+ -i, --id ID Get ticket with id = ID
103
+ -s, --status STATUS Find tickets with given status
104
+ -t, --to TO Assigned to TO, example: ass -t &quot;John Doe&quot;
105
+ --toandstatus DATA Assigned to TO and with STATUS, call like this: ass --toandstatus &quot;Name Surname&quot;__New
106
+ -u, --updateStatus DATA Change tickets status, call like this: ass -u ID__NEW_STATUS
107
+ -d, --updateDescription DATA Change tickets descriptino. Exmple ass -d ID__&quot;New description text&quot;
108
+ -v, --version Get version
109
+ -h, --help Display this information
110
+ </pre>
111
+ <p>
98
112
  h2. INSTALATION
99
113
  </p>
100
114
  <p>
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Mon Mar 15 19:18:21 +0100 2010</td>
59
+ <td>Sat Mar 27 13:15:49 +0100 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -24,6 +24,7 @@
24
24
  <a href="classes/AssEmBlr.html#M000001">new (AssEmBlr)</a><br />
25
25
  <a href="classes/AssEmBlr.html#M000004">print (AssEmBlr)</a><br />
26
26
  <a href="classes/AssEmBlr.html#M000002">tickets (AssEmBlr)</a><br />
27
+ <a href="classes/AssEmBlr.html#M000006">update_tickets_description (AssEmBlr)</a><br />
27
28
  <a href="classes/AssEmBlr.html#M000005">update_tickets_status (AssEmBlr)</a><br />
28
29
  </div>
29
30
  </div>
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assembla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Ignacy Moryc
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-15 00:00:00 +01:00
17
+ date: 2010-03-27 00:00:00 +01:00
13
18
  default_executable: ass
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: hpricot
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 8
30
+ - 1
23
31
  version: 0.8.1
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description: This gem provides access to assembla tickets. It supports listing, creating and modyfing functionality
26
35
  email: imoryc@gmail.com
27
36
  executables:
@@ -36,6 +45,7 @@ files:
36
45
  - Rakefile
37
46
  - VERSION
38
47
  - a2smbla-0.3.0.gem
48
+ - assembla-0.8.0.gem
39
49
  - assembla.gemspec
40
50
  - bin/ass
41
51
  - config_default.yml
@@ -68,18 +78,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
78
  requirements:
69
79
  - - ">="
70
80
  - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
71
83
  version: "0"
72
- version:
73
84
  required_rubygems_version: !ruby/object:Gem::Requirement
74
85
  requirements:
75
86
  - - ">="
76
87
  - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
77
90
  version: "0"
78
- version:
79
91
  requirements: []
80
92
 
81
93
  rubyforge_project:
82
- rubygems_version: 1.3.5
94
+ rubygems_version: 1.3.6
83
95
  signing_key:
84
96
  specification_version: 3
85
97
  summary: Command line access to assembla