fresnel 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/fresnel.gemspec CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  s.name = 'fresnel'
4
4
  s.summary = "Fresnel is a console manager to LighthouseApp.com using the official lighthouse api."
5
5
  s.description = s.summary
6
- s.version = '0.5.5'
7
- s.date = '2009-12-07'
6
+ s.version = '0.5.6'
7
+ s.date = '2009-12-08'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Gerard de Brieder", "Wes Oldenbeuving"]
10
10
  s.email = "smeevil@gmail.com"
@@ -1,6 +1,6 @@
1
1
  class InputDetector
2
2
  attr_accessor :question, :possible_answers, :collection, :answer
3
-
3
+
4
4
  def initialize(question,*answers)
5
5
  @question=question
6
6
  @possible_answers=Array.new
@@ -11,7 +11,16 @@ class InputDetector
11
11
  print question
12
12
  detect_answer
13
13
  end
14
-
14
+
15
+ def self.pretty_prompt(inputs, *extras)
16
+ lines = inputs.keys.sort_by(&:to_s).map do |key|
17
+ choices = inputs[key].sort.map {|state| '[%s]%s' % [state[0,1], state[1..-1]]}.join(", ")
18
+ "#{key.to_s.capitalize}: #{choices}"
19
+ end
20
+ prompt = lines.join(".\n") + ": "
21
+ new(prompt, *extras)
22
+ end
23
+
15
24
  def detect_answer
16
25
  loop do
17
26
  begin
@@ -22,6 +31,8 @@ class InputDetector
22
31
  end
23
32
  print str.chr
24
33
  if str == 13
34
+ puts
35
+ exit if collection.blank?
25
36
  possible_options = possible_answers.select{|option| option == collection}
26
37
  else
27
38
  self.collection+=str.chr
@@ -31,7 +42,7 @@ class InputDetector
31
42
  if str==3
32
43
  puts
33
44
  puts "exiting due to ^c"
34
- exit
45
+ exit
35
46
  end
36
47
  puts
37
48
  puts "Invalid choice: #{collection}, choises are #{possible_answers.inspect}"
@@ -41,14 +41,9 @@ class SetupWizard
41
41
  data=fresnel.projects(:object=>true)
42
42
  current_dir=File.expand_path(".").split("/").last
43
43
  fresnel.projects(:selectable=>true, :clear=>false, :setup=>true)
44
-
45
- project_id=ask("please select which project # resides here : ", Integer) do |q|
46
- q.validate = /^\d+$/
47
- q.below=data.size
48
- q.responses[:ask_on_error]="This project is # : "
49
- end
50
- config['project_id']=data[project_id].id
51
- puts "generated your config in #{fresnel.project_config_file}, going on with main program..."
52
- File.open(fresnel.project_config_file,'w+'){ |f| f.write(YAML::dump(config)) }
44
+ project_id=InputDetector.new("please select which project # resides here : ", 0...data.size).answer
45
+ config['project_id']=data[project_id].id
46
+ puts "generated your config in #{fresnel.project_config_file}, going on with main program..."
47
+ File.open(fresnel.project_config_file,'w+'){ |f| f.write(YAML::dump(config)) }
53
48
  end
54
49
  end
data/lib/fresnel.rb CHANGED
@@ -101,7 +101,7 @@ class Fresnel
101
101
  else
102
102
  puts(project_table)
103
103
  unless options[:setup]
104
- action=InputDetector.new("[q]uit, [c]reate or project #",(0..(projects_data.size-1)).to_a).answer
104
+ action=InputDetector.new("[q]uit, [c]reate or project #",(0...projects_data.size).to_a).answer
105
105
  puts "action is #{action.inspect}"
106
106
  case action
107
107
  when "c" then create_project
@@ -152,8 +152,11 @@ class Fresnel
152
152
  end
153
153
  end
154
154
  puts tickets_table
155
- action=InputDetector.new("[q]uit, [b]ins, [p]rojects, #{options[:all] ? "[u]nresolved" : "[a]ll"}, [c]reate or ticket #",tickets.map(&:number)).answer
155
+ action=InputDetector.new("[q]uit, [b]ins, [p]rojects, #{options[:all] ? "[u]nresolved" : "[a]ll"}, [c]reate , [r]efresh/[t]ickets or ticket # : ",tickets.map(&:number)).answer
156
156
  case action
157
+ when /t|r/ then
158
+ cache.clear(:name=>"fresnel_project_#{project_id}_tickets")
159
+ self.tickets
157
160
  when "b" then get_bins
158
161
  when "c" then create
159
162
  when "p" then projects(:selectable=>true)
@@ -165,7 +168,7 @@ class Fresnel
165
168
  end
166
169
  else
167
170
  puts Frame.new(:header=>"Notice",:body=>"no #{"unresolved " unless options[:all]}tickets #{"in bin #{options[:bin_name]}"}...")
168
- action=InputDetector.new("[q]uit, [b]ins, [p]rojects, [u]nresolved, [a]ll, [c]reate").answer
171
+ action=InputDetector.pretty_prompt(:actions => %w[quit bins projects unresolved all create]).answer
169
172
  case action
170
173
  when "b" then get_bins
171
174
  when "c" then create
@@ -194,7 +197,7 @@ class Fresnel
194
197
  end
195
198
  end
196
199
  puts bins_table
197
- bin_id=InputDetector.new("[q]uit or Bin #: ",(0..(bins.size-1)).to_a).answer
200
+ bin_id=InputDetector.new("[q]uit or Bin #: ",(0...bins.size).to_a).answer
198
201
  if bin_id=="q"
199
202
  exit(0)
200
203
  else
@@ -278,18 +281,22 @@ class Fresnel
278
281
  end
279
282
  end
280
283
  puts "Current state : #{ticket.versions.last.state}"
281
- action=InputDetector.new("[q]uit, [t]ickets, [b]ins, [c]omment, [a]ssign, [r]esolve, [s]elf, [o]pen, [h]old, [w]eb, [l]inks").answer
284
+ choices = {
285
+ :states => %w[open resolved invalid hold new],
286
+ :actions => %w[quit tickets bins comments assign self web links]
287
+ }
288
+ states = choices[:states]
289
+ action=InputDetector.pretty_prompt(choices).answer
282
290
  case action
283
291
  when "t" then tickets
284
292
  when "b" then get_bins
285
293
  when "c" then comment(number)
286
294
  when "a" then assign(:ticket=>number)
287
- when "r" then change_state(:ticket=>number,:state=>"resolved")
288
295
  when "s" then claim(:ticket=>number)
289
- when "o" then change_state(:ticket=>number,:state=>"open")
290
- when "h" then change_state(:ticket=>number,:state=>"hold")
291
296
  when "w" then open_browser_for_ticket(number)
292
297
  when "l" then links(number)
298
+ when *(states.map{|state| state[0,1]})
299
+ change_state(:ticket=>number,:state=>states.find{|state| state[0,1] == action})
293
300
  else
294
301
  exit(0)
295
302
  end
@@ -311,10 +318,7 @@ class Fresnel
311
318
  links.each_with_index{|link,i|t << [i,link]}
312
319
  end
313
320
  puts link_table
314
- pick=ask("open link # : ", Integer) do |q|
315
- q.below=links.size
316
- q.above=-1
317
- end
321
+ pick=InputDetector.new("open link # : ", (0...links.size).to_a).answer
318
322
  url=links[pick]
319
323
  url="http://#{url}" unless url=~/^http/
320
324
  `open '#{url}'`
@@ -326,6 +330,7 @@ class Fresnel
326
330
  puts "create comment for #{number}"
327
331
  ticket=get_ticket(number)
328
332
  File.open("/tmp/fresnel_ticket_#{number}_comment", "w+") do |f|
333
+ f.puts
329
334
  f.puts "# Please enter the comment for this ticket. Lines starting"
330
335
  f.puts "# with '#' will be ignored, and an empty message aborts the commit."
331
336
  `echo "q" | fresnel #{number}`.each{ |l| f.write "# #{l}" }
@@ -415,9 +420,6 @@ class Fresnel
415
420
  end
416
421
 
417
422
  def open_browser_for_ticket(number)
418
- #fast
419
- #`open "https://#{self.account}.lighthouseapp.com/projects/#{self.current_project_id}/tickets/#{number}"`
420
- #or save
421
423
  puts "opening ticket #{number}in browser"
422
424
  `open "#{get_ticket(number).url}"`
423
425
  show_ticket(number)
@@ -434,10 +436,8 @@ class Fresnel
434
436
  end
435
437
  end
436
438
  puts members_table
437
- pick=ask("Assign to # : ",Integer) do |q|
438
- q.above=-1
439
- q.below=members.count
440
- end
439
+ #here
440
+ pick=InputDetector.new("Assign to user # : ",((0..members.size)-1)).answer
441
441
  options[:user_id]=members[pick].user.id
442
442
  end
443
443
  ticket=get_ticket(options[:ticket])
@@ -449,6 +449,7 @@ class Fresnel
449
449
  else
450
450
  puts Frame.new(:header=>"Error",:body=>"assigning failed !")
451
451
  end
452
+ show_ticket(options[:ticket])
452
453
  end
453
454
 
454
455
  def claim(options)
@@ -459,6 +460,6 @@ class Fresnel
459
460
  else
460
461
  assign(:ticket=>options[:ticket],:user_id=>self.current_user_id)
461
462
  end
462
-
463
+ show_ticket(options[:ticket])
463
464
  end
464
465
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fresnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerard de Brieder
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-12-07 00:00:00 +01:00
13
+ date: 2009-12-08 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency