taco_it 1.4.2 → 1.5.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/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.2'
15
+ program :version, '1.5.0'
16
16
  program :description, 'simple command line issue tracking'
17
17
 
18
18
  command :init do |c|
data/lib/taco/cli.rb CHANGED
@@ -1,62 +1,83 @@
1
1
  require 'taco/issue'
2
2
  require 'taco/taco'
3
3
  require 'taco/tacorc'
4
+ require 'taco/taco_profile'
5
+
6
+ # FIXME: this file should be named taco_cli.rb
4
7
 
5
8
  class TacoCLI
6
9
  RETRY_NAME = '.taco_retry.txt'
7
10
 
8
11
  TACORC_NAME = '.tacorc'
12
+ TACO_PROFILE_NAME = '.taco_profile'
9
13
  INDEX_ERB_NAME = '.index.html.erb'
10
14
 
11
15
  DEFAULT_TACORC_NAME = 'tacorc'
16
+ DEFAULT_TACO_PROFILE_NAME = 'taco_profile'
12
17
  DEFAULT_INDEX_ERB_NAME = 'index.html.erb'
13
- DEFAULTS_HOME = File.realpath(File.join(File.dirname(__FILE__), 'defaults/'))
14
18
 
19
+ DEFAULTS_HOME = File.realpath(File.join(File.dirname(__FILE__), 'defaults/'))
20
+
15
21
  def initialize
16
22
  @taco = Taco.new
17
23
 
18
24
  @retry_path = File.join(@taco.home, RETRY_NAME)
19
25
 
20
26
  @tacorc_path = File.join(@taco.home, TACORC_NAME)
27
+ @taco_profile_path = File.join(@taco.home, TACO_PROFILE_NAME)
21
28
  @index_erb_path = File.join(@taco.home, INDEX_ERB_NAME)
22
-
29
+
30
+ # FIXME: do this elsewhere. pass in an initialized TacoRc object
31
+ #
23
32
  if File.exist? @tacorc_path
24
33
  rc = TacoRc.new @tacorc_path
25
34
  rc.update_schema! Issue
26
35
  end
36
+
37
+ # FIXME: do this elsewhere. pass in an initialized TacoProfile object
38
+ #
39
+ if File.exist? @taco_profile_path
40
+ profile_text = open(@taco_profile_path) { |f| f.read }
41
+ end
42
+
43
+ @profile = TacoProfile.new profile_text
27
44
  end
28
45
 
29
46
  def init!
30
47
  out = @taco.init!
31
48
 
32
49
  FileUtils.copy(File.join(DEFAULTS_HOME, DEFAULT_TACORC_NAME), @tacorc_path)
50
+ FileUtils.copy(File.join(DEFAULTS_HOME, DEFAULT_TACO_PROFILE_NAME), @taco_profile_path)
51
+
33
52
  FileUtils.copy(File.join(DEFAULTS_HOME, DEFAULT_INDEX_ERB_NAME), @index_erb_path)
34
53
 
35
- out + "\nPlease edit the config file at #{@tacorc_path}"
54
+ out + "\nPlease edit the config files at:\n #{@tacorc_path}\n #{@taco_profile_path}"
36
55
  end
37
56
 
38
57
  def list(args, opts)
39
- the_list = @taco.list(:short_ids => true, :filters => args)
58
+ filters = args.size > 0 ? args : @profile.filters
59
+
60
+ the_list = @taco.list :filters => filters
40
61
 
41
62
  if opts[:sort]
42
63
  attrs = opts[:sort].split(',').map(&:to_s)
64
+ else
65
+ attrs = @profile.sort_order
66
+ end
43
67
 
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
68
+ the_list.sort! do |issue_a, issue_b|
69
+ order = 0
70
+
71
+ attrs.take_while do |attr|
72
+ order = issue_a.send(attr) <=> issue_b.send(attr)
73
+ order == 0
55
74
  end
75
+
76
+ order
56
77
  end
57
78
 
58
- the_list.map! do |issue, short_id|
59
- "#{short_id} : #{issue.priority} : #{issue.summary}"
79
+ the_list.map! do |issue|
80
+ @profile.columns.map { |col| issue.send(col) }.join(' : ')
60
81
  end
61
82
 
62
83
  return "Found no issues." unless the_list.size > 0
@@ -0,0 +1,14 @@
1
+ # comment, followed by a blank line (don't panic)
2
+
3
+ # uncomment/edit to change the default sort order for 'taco list'
4
+ #
5
+ # sort: priority,status,owner
6
+
7
+ # uncomment/edit to change the default filter for 'taco list'
8
+ #
9
+ # filter: kind:open owner:mike
10
+
11
+ # uncomment/edit to change the default columns for 'taco list'
12
+ #
13
+
14
+ #columns: short_id,priority,owner,status,summary
data/lib/taco/taco.rb CHANGED
@@ -86,17 +86,18 @@ class Taco
86
86
 
87
87
  raise Issue::Invalid.new("Issue ID does not match filename: #{issue.id} != #{id}") unless issue.id == id
88
88
 
89
- short_id = 8.upto(id.size).each do |n|
90
- short_id = id[0...n]
91
- break short_id unless ids.count { |i| i.include? short_id } > 1
89
+ the_short_id = 8.upto(id.size).each do |n|
90
+ the_short_id = id[0...n]
91
+ break the_short_id unless ids.count { |i| i.include? the_short_id } > 1
92
92
  end
93
+
94
+ # because the length of the short_id is determinable only within the context of a group of issues
95
+ # (because it must long enough to be unique), we can only define it on Issue in the context of a group
96
+ #
97
+ issue.instance_eval "def short_id; #{the_short_id.inspect}; end"
93
98
 
94
- if opts[:short_ids]
95
- [ issue, short_id ]
96
- else
97
- issue
98
- end
99
- end.reject(&:nil?).sort_by { |thing| opts[:short_ids] ? thing[0] : thing}
99
+ issue
100
+ end.reject(&:nil?).sort
100
101
  end
101
102
  end
102
103
 
@@ -0,0 +1,33 @@
1
+ # ~/.taco_profile configures per-user interactions with taco
2
+ # a default .taco_profile exists at .taco/.taco_profile
3
+ # contrast with .taco/.tacorc
4
+
5
+ class TacoProfile
6
+ attr_reader :sort_order, :filters, :columns
7
+
8
+ def initialize(text)
9
+ text ||= ''
10
+
11
+ # FIXME: this is way too coupled to Issue
12
+ #
13
+ @sort_order = [ :created_at, :id ]
14
+ @columns = [ :short_id, :priority, :summary ]
15
+ @filters = []
16
+
17
+ text.lines.each_with_index do |line, index|
18
+ next if line =~ /^#/ || line =~ /^\s*$/
19
+
20
+ key, value = line.split(':', 2).map(&:strip)
21
+ case key
22
+ when 'sort'
23
+ @sort_order = value.split(',').map(&:to_sym)
24
+ when 'filters'
25
+ @filters = value.split(/\s/)
26
+ when 'columns'
27
+ @columns = value.split(',').map(&:to_sym)
28
+ else
29
+ raise ArgumentError.new("Parse error on line #{index+1}")
30
+ end
31
+ end
32
+ end
33
+ end
data/lib/taco/tacorc.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # .taco/.tacorc describes properties of the taco repository
2
+ # contrast with ~/.taco_profile
3
+
1
4
  class TacoRc
2
5
  class ParseError < Exception; end
3
6
 
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.2
4
+ version: 1.5.0
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-31 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
@@ -41,8 +41,10 @@ files:
41
41
  - lib/taco/issue.rb
42
42
  - lib/taco/schema.rb
43
43
  - lib/taco/taco.rb
44
+ - lib/taco/taco_profile.rb
44
45
  - lib/taco/tacorc.rb
45
46
  - lib/taco/defaults/index.html.erb
47
+ - lib/taco/defaults/taco_profile
46
48
  - lib/taco/defaults/tacorc
47
49
  - bin/taco
48
50
  homepage: http://github.com/mikepartelow/taco