taco_it 1.1.2 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/taco +39 -8
  2. data/lib/taco.rb +39 -8
  3. metadata +2 -2
data/bin/taco CHANGED
@@ -101,6 +101,9 @@ class Issue
101
101
  :kind => { :class => String, :required => true, :settable => true },
102
102
  :status => { :class => String, :required => true, :settable => true },
103
103
  :owner => { :class => String, :required => true, :settable => true },
104
+
105
+ :priority => { :class => Fixnum, :required => true, :settable => true },
106
+
104
107
  :description => { :class => String, :required => true, :settable => true },
105
108
  }
106
109
 
@@ -109,6 +112,7 @@ class Issue
109
112
  Summary : %{summary}
110
113
  Kind : %{kind}
111
114
  Status : %{status}
115
+ Priority : %{priority}
112
116
  Owner : %{owner}
113
117
 
114
118
  # Everything between the --- lines is Issue Description
@@ -158,6 +162,10 @@ EOT
158
162
  attrs.each do |attr, values|
159
163
  raise ArgumentError.new("Unknown Issue attributes: #{attr}") unless SCHEMA_ATTRIBUTES.include? attr
160
164
 
165
+ if SCHEMA_ATTRIBUTES[attr][:class] == Fixnum
166
+ values.map!(&:to_i)
167
+ end
168
+
161
169
  SCHEMA_ATTRIBUTES[attr][:allowed_values] = values
162
170
  end
163
171
  end
@@ -174,18 +182,36 @@ EOT
174
182
  case cfg[:class].to_s # can't case on cfg[:class], because class of cfg[:class] is always Class :-)
175
183
  when 'Time'
176
184
  unless attrs[attr].is_a?(String) || attrs[attr].is_a?(Time)
177
- raise ArgumentError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
185
+ raise TypeError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
178
186
  end
179
187
 
180
- t = attrs[attr].is_a?(String) ? Time.parse(attrs[attr]) : attrs[attr]
188
+ t = if attrs[attr].is_a?(String)
189
+ begin
190
+ Time.parse(attrs[attr])
191
+ rescue ArgumentError => e
192
+ raise TypeError.new(e.to_s)
193
+ end
194
+ else
195
+ attrs[attr]
196
+ end
181
197
  attrs[attr] = timescrub(t)
182
198
  when 'String'
183
199
  unless attrs[attr].is_a?(String)
184
- raise ArgumentError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
200
+ raise TypeError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
185
201
  end
186
202
 
187
203
  attrs[attr] && attrs[attr].strip!
188
- end
204
+ when 'Fixnum'
205
+ unless attrs[attr].is_a?(Fixnum) || attrs[attr].is_a?(String)
206
+ raise TypeError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
207
+ end
208
+
209
+ if attrs[attr].is_a?(String)
210
+ i = attrs[attr].to_i
211
+ raise TypeError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}") unless i.to_s == attrs[attr]
212
+ attrs[attr] = i
213
+ end
214
+ end
189
215
  end
190
216
 
191
217
  attrs
@@ -254,6 +280,7 @@ Updated At : #{date(updated_at)}
254
280
  Summary : #{summary}
255
281
  Kind : #{kind}
256
282
  Status : #{status}
283
+ Priority : #{priority}
257
284
  Owner : #{owner}
258
285
 
259
286
  ---
@@ -383,9 +410,9 @@ EOT
383
410
  raise Issue::Invalid.new("Empty string is not allowed for #{attr}")
384
411
  end
385
412
  end
386
- rescue Issue::Invalid
413
+ rescue Issue::Invalid => e
387
414
  return false unless opts[:raise]
388
- raise
415
+ raise e
389
416
  end
390
417
 
391
418
  true
@@ -565,11 +592,13 @@ class TacoCLI
565
592
  #
566
593
  Kind = Defect, Feature Request
567
594
  Status = Open, Closed
595
+ Priority = 1, 2, 3, 4, 5
568
596
 
569
597
  # Default values for Issue fields
570
598
  #
571
599
  DefaultKind = Defect
572
600
  DefaultStatus = Open
601
+ DefaultPriority = 3
573
602
  EOT
574
603
  RETRY_NAME = '.taco_retry.txt'
575
604
 
@@ -593,7 +622,9 @@ EOT
593
622
  end
594
623
 
595
624
  def list(args)
596
- the_list = @taco.list(:short_ids => true, :filters => args).map { |issue, short_id| "#{short_id} : #{issue.summary}" }
625
+ the_list = @taco.list(:short_ids => true, :filters => args).map do |issue, short_id|
626
+ "#{short_id} : #{issue.priority} : #{issue.summary}"
627
+ end
597
628
  return "Found no issues." unless the_list.size > 0
598
629
  the_list.join("\n")
599
630
  end
@@ -706,7 +737,7 @@ end
706
737
  require 'commander/import'
707
738
 
708
739
  program :name, 'taco'
709
- program :version, '1.1.2'
740
+ program :version, '1.1.4'
710
741
  program :description, 'simple command line issue tracking'
711
742
 
712
743
  command :init do |c|
data/lib/taco.rb CHANGED
@@ -101,6 +101,9 @@ class Issue
101
101
  :kind => { :class => String, :required => true, :settable => true },
102
102
  :status => { :class => String, :required => true, :settable => true },
103
103
  :owner => { :class => String, :required => true, :settable => true },
104
+
105
+ :priority => { :class => Fixnum, :required => true, :settable => true },
106
+
104
107
  :description => { :class => String, :required => true, :settable => true },
105
108
  }
106
109
 
@@ -109,6 +112,7 @@ class Issue
109
112
  Summary : %{summary}
110
113
  Kind : %{kind}
111
114
  Status : %{status}
115
+ Priority : %{priority}
112
116
  Owner : %{owner}
113
117
 
114
118
  # Everything between the --- lines is Issue Description
@@ -158,6 +162,10 @@ EOT
158
162
  attrs.each do |attr, values|
159
163
  raise ArgumentError.new("Unknown Issue attributes: #{attr}") unless SCHEMA_ATTRIBUTES.include? attr
160
164
 
165
+ if SCHEMA_ATTRIBUTES[attr][:class] == Fixnum
166
+ values.map!(&:to_i)
167
+ end
168
+
161
169
  SCHEMA_ATTRIBUTES[attr][:allowed_values] = values
162
170
  end
163
171
  end
@@ -174,18 +182,36 @@ EOT
174
182
  case cfg[:class].to_s # can't case on cfg[:class], because class of cfg[:class] is always Class :-)
175
183
  when 'Time'
176
184
  unless attrs[attr].is_a?(String) || attrs[attr].is_a?(Time)
177
- raise ArgumentError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
185
+ raise TypeError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
178
186
  end
179
187
 
180
- t = attrs[attr].is_a?(String) ? Time.parse(attrs[attr]) : attrs[attr]
188
+ t = if attrs[attr].is_a?(String)
189
+ begin
190
+ Time.parse(attrs[attr])
191
+ rescue ArgumentError => e
192
+ raise TypeError.new(e.to_s)
193
+ end
194
+ else
195
+ attrs[attr]
196
+ end
181
197
  attrs[attr] = timescrub(t)
182
198
  when 'String'
183
199
  unless attrs[attr].is_a?(String)
184
- raise ArgumentError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
200
+ raise TypeError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
185
201
  end
186
202
 
187
203
  attrs[attr] && attrs[attr].strip!
188
- end
204
+ when 'Fixnum'
205
+ unless attrs[attr].is_a?(Fixnum) || attrs[attr].is_a?(String)
206
+ raise TypeError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}")
207
+ end
208
+
209
+ if attrs[attr].is_a?(String)
210
+ i = attrs[attr].to_i
211
+ raise TypeError.new("#{attr} : expected type #{cfg[:class]}, got type #{attrs[attr].class}") unless i.to_s == attrs[attr]
212
+ attrs[attr] = i
213
+ end
214
+ end
189
215
  end
190
216
 
191
217
  attrs
@@ -254,6 +280,7 @@ Updated At : #{date(updated_at)}
254
280
  Summary : #{summary}
255
281
  Kind : #{kind}
256
282
  Status : #{status}
283
+ Priority : #{priority}
257
284
  Owner : #{owner}
258
285
 
259
286
  ---
@@ -383,9 +410,9 @@ EOT
383
410
  raise Issue::Invalid.new("Empty string is not allowed for #{attr}")
384
411
  end
385
412
  end
386
- rescue Issue::Invalid
413
+ rescue Issue::Invalid => e
387
414
  return false unless opts[:raise]
388
- raise
415
+ raise e
389
416
  end
390
417
 
391
418
  true
@@ -565,11 +592,13 @@ class TacoCLI
565
592
  #
566
593
  Kind = Defect, Feature Request
567
594
  Status = Open, Closed
595
+ Priority = 1, 2, 3, 4, 5
568
596
 
569
597
  # Default values for Issue fields
570
598
  #
571
599
  DefaultKind = Defect
572
600
  DefaultStatus = Open
601
+ DefaultPriority = 3
573
602
  EOT
574
603
  RETRY_NAME = '.taco_retry.txt'
575
604
 
@@ -593,7 +622,9 @@ EOT
593
622
  end
594
623
 
595
624
  def list(args)
596
- the_list = @taco.list(:short_ids => true, :filters => args).map { |issue, short_id| "#{short_id} : #{issue.summary}" }
625
+ the_list = @taco.list(:short_ids => true, :filters => args).map do |issue, short_id|
626
+ "#{short_id} : #{issue.priority} : #{issue.summary}"
627
+ end
597
628
  return "Found no issues." unless the_list.size > 0
598
629
  the_list.join("\n")
599
630
  end
@@ -706,7 +737,7 @@ end
706
737
  require 'commander/import'
707
738
 
708
739
  program :name, 'taco'
709
- program :version, '1.1.2'
740
+ program :version, '1.1.4'
710
741
  program :description, 'simple command line issue tracking'
711
742
 
712
743
  command :init do |c|
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.1.2
4
+ version: 1.1.4
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-25 00:00:00.000000000 Z
12
+ date: 2013-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander