taco_it 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/taco +6 -2
  2. data/lib/taco/cli.rb +22 -2
  3. data/lib/taco/taco.rb +1 -1
  4. metadata +2 -2
data/bin/taco CHANGED
@@ -12,7 +12,7 @@ end
12
12
  require 'commander/import'
13
13
 
14
14
  program :name, 'taco'
15
- program :version, '1.4.1'
15
+ program :version, '1.4.2'
16
16
  program :description, 'simple command line issue tracking'
17
17
 
18
18
  command :init do |c|
@@ -36,13 +36,17 @@ command :list do |c|
36
36
  c.summary = 'list all issues in the repository'
37
37
  c.description = 'List all taco Issues in the current repository'
38
38
 
39
+ c.option '--sort STRING', String, 'sort results by the given attributes'
40
+
41
+ c.example 'Sort Issues by Priority, Owner, and Kind', 'taco list --sort priority,owner,kind'
42
+
39
43
  c.action do |args, options|
40
44
  begin
41
45
  # FIXME: merge this kind of thing into commander: tell it how many arguments we expect.
42
46
  unless args.all? { |arg| arg =~ /\w+:\w+/ }
43
47
  raise ArgumentError.new("Unexpected arguments: #{args.join(', ')}")
44
48
  end
45
- puts cli.list args
49
+ puts cli.list args, :sort => options.sort
46
50
  rescue Exception => e
47
51
  puts "Error: #{e}"
48
52
  exit 1
data/lib/taco/cli.rb CHANGED
@@ -35,10 +35,30 @@ class TacoCLI
35
35
  out + "\nPlease edit the config file at #{@tacorc_path}"
36
36
  end
37
37
 
38
- def list(args)
39
- the_list = @taco.list(:short_ids => true, :filters => args).map do |issue, short_id|
38
+ def list(args, opts)
39
+ the_list = @taco.list(:short_ids => true, :filters => args)
40
+
41
+ if opts[:sort]
42
+ attrs = opts[:sort].split(',').map(&:to_s)
43
+
44
+ the_list.sort! do |lhs, rhs|
45
+ issue_a, issue_b = lhs[0], rhs[0]
46
+
47
+ order = 0
48
+
49
+ attrs.take_while do |attr|
50
+ order = issue_a.send(attr) <=> issue_b.send(attr)
51
+ order == 0
52
+ end
53
+
54
+ order
55
+ end
56
+ end
57
+
58
+ the_list.map! do |issue, short_id|
40
59
  "#{short_id} : #{issue.priority} : #{issue.summary}"
41
60
  end
61
+
42
62
  return "Found no issues." unless the_list.size > 0
43
63
  the_list.join("\n")
44
64
  end
data/lib/taco/taco.rb CHANGED
@@ -67,7 +67,7 @@ class Taco
67
67
  filter_match = if opts.fetch(:filters, []).size > 0
68
68
  conditions = opts[:filters].map do |filter|
69
69
  attr, val = filter.split(':')
70
- %Q|i.send("#{attr}").to_s == "#{val}"|
70
+ %Q|i.send("#{attr}").to_s.downcase == "#{val.downcase}"|
71
71
  end.join ' && '
72
72
 
73
73
  # FIXME: eval-ing user input? madness!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taco_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-30 00:00:00.000000000 Z
12
+ date: 2013-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander