fresnel 0.5.8 → 0.5.9

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.8'
7
- s.date = '2009-12-11'
6
+ s.version = '0.5.9'
7
+ s.date = '2010-01-03'
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Gerard de Brieder", "Wes Oldenbeuving"]
10
10
  s.email = "smeevil@gmail.com"
@@ -381,6 +381,4 @@ module ActiveResource
381
381
  (Lighthouse.email || Lighthouse.password ? { 'Authorization' => 'Basic ' + ["#{Lighthouse.email}:#{Lighthouse.password}"].pack('m').delete("\r\n") } : {})
382
382
  end
383
383
  end
384
- end
385
-
386
-
384
+ end
@@ -31,8 +31,16 @@ class SetupWizard
31
31
  config['user_id']=ask("My lighthouse user_id is : ", Integer) do |q|
32
32
  q.default=user_id
33
33
  end
34
-
34
+
35
+ puts "What are your commonly used tags ?"
36
+ puts "Please write them down like : [l]ow [m]edium [h]igh awe[s]ome"
37
+ puts "When adding tags you can give something like : special s design h"
38
+ puts "this will be expanded to : special awesome design high"
39
+ tags=ask("Tags : ")
40
+ config['tags']=tags.split(" ")
41
+
35
42
  puts "generated your config in #{fresnel.global_config_file}, going on with main program..."
43
+ # TODO: Refactor GlobalConfig into its own object, responsible for loading and saving itself.
36
44
  File.open(fresnel.global_config_file,'w+'){ |f| f.write(YAML::dump(config)) }
37
45
  end
38
46
 
@@ -47,6 +55,7 @@ class SetupWizard
47
55
  else
48
56
  config['project_id']=data[project_id.to_i].id
49
57
  puts "generated your config in #{fresnel.project_config_file}, going on with main program..."
58
+ # TODO: Refactor ProjectConfig into its own object, responsible for loading and saving itself.
50
59
  File.open(fresnel.project_config_file,'w+'){ |f| f.write(YAML::dump(config)) }
51
60
  end
52
61
  end
@@ -9,6 +9,10 @@ class String
9
9
  end
10
10
 
11
11
  def scrape_urls
12
- scan(/(http|https)(:\/\/)([a-zA-Z0-9.\/_-]+)| (www\.[a-zA-Z0-9.\/_-]+)/).map{ |url| url.join}
12
+ scan(/(http|https)(:\/\/)([a-zA-Z0-9.\/_-]+\?[&=a-zA-Z0-9.\/_-]+)| (www\.[a-zA-Z0-9.\/_-]+)/).map{ |url| url.join}
13
+ end
14
+
15
+ def scrape_textmate_links
16
+ scan(/(\.?\/.*?\.rb:\d+):in/)
13
17
  end
14
18
  end
data/lib/fresnel.rb CHANGED
@@ -34,47 +34,56 @@ class Fresnel
34
34
  @app_description="A lighthouseapp console manager"
35
35
  @lighthouse=Lighthouse
36
36
  @cache=Cache.new
37
- Lighthouse.account, Lighthouse.token, @current_user_id = load_global_config
38
- @current_project_id=load_project_config
39
-
37
+ load_global_config
38
+ load_project_config
39
+ initialize_lighthouse
40
40
  end
41
41
 
42
42
  def load_global_config
43
- if File.exists? self.global_config_file
44
- config = YAML.load_file(self.global_config_file)
43
+ unless File.exists? self.global_config_file
44
+ puts Frame.new(:header=>"Notice",:body=>"global config not found at #{self.global_config_file}, starting wizard")
45
+ SetupWizard.global(self)
46
+ return load_global_config
47
+ end
45
48
 
46
- @@cache_timeout=config['cache_timeout'] if config.has_key?('cache_timeout')
47
- @@debug=config['debug'] if config.has_key?('debug')
48
- @@term_size=config['term_size'] if config.has_key?('term_size')
49
+ config = YAML.load_file(self.global_config_file)
49
50
 
50
- if config && config.class==Hash && config.has_key?('account') && config.has_key?('token') && config.has_key?('user_id')
51
- return [config['account'], config['token'], config['user_id']]
52
- else
53
- puts Frame.new(:header=>"Warning !",:body=>"global config did not validate , recreating")
54
- SetupWizard.global(self)
55
- load_global_config
56
- end
57
- else
58
- puts Frame.new(:header=>"Notice",:body=>"global config not found at #{self.global_config_file}, starting wizard")
51
+ @@cache_timeout=config['cache_timeout'] if config.has_key?('cache_timeout')
52
+ @@debug=config['debug'] if config.has_key?('debug')
53
+ @@term_size=config['term_size'] if config.has_key?('term_size')
54
+ @@tags=config['tags']
55
+ unless config && config.class==Hash && config.has_key?('account') && config.has_key?('token') && config.has_key?('user_id') && config.has_key?('tags')
56
+ puts Frame.new(:header=>"Warning !",:body=>"global config did not validate , recreating")
59
57
  SetupWizard.global(self)
60
- load_global_config
58
+ return load_global_config
61
59
  end
60
+
61
+ @lighthouse_account = config['account']
62
+ @lighthouse_token = config['token']
63
+ @current_user_id = config['user_id']
64
+ nil
65
+ end
66
+
67
+ def initialize_lighthouse
68
+ @lighthouse.account = @lighthouse_account
69
+ @lighthouse.token = @lighthouse_token
70
+ nil
62
71
  end
63
72
 
64
73
  def load_project_config
65
- if File.exists? self.project_config_file
66
- config = YAML.load_file(self.project_config_file)
67
- if config && config.class==Hash && config.has_key?('project_id')
68
- return config['project_id']
69
- else
70
- puts Frame.new(:header=>"Warning !",:body=>"project config found but project_id was not declared")
71
- load_project_config
72
- end
73
- else
74
+ unless File.exists? self.project_config_file
74
75
  puts Frame.new(:header=>"Notice",:body=>"project config not found at #{self.project_config_file}, starting wizard")
75
76
  SetupWizard.project(self)
76
- load_project_config
77
+ return load_project_config
78
+ end
79
+
80
+ config = YAML.load_file(self.project_config_file) || Hash.new
81
+ unless config['project_id']
82
+ puts Frame.new(:header=>"Warning !",:body=>"project config found but project_id was not declared")
83
+ return load_project_config
77
84
  end
85
+ @current_project_id = config['project_id']
86
+ nil
78
87
  end
79
88
 
80
89
  def account
@@ -100,7 +109,7 @@ class Fresnel
100
109
  license=InputDetector.new("License # : ",(0...LICENSES.size).to_a).answer
101
110
  license=LICENSES[license.to_i].first
102
111
  end
103
-
112
+
104
113
  puts "collected :"
105
114
  puts "#{name} : #{license}"
106
115
  project = Lighthouse::Project.new(:name => name)
@@ -157,6 +166,7 @@ class Fresnel
157
166
  system("clear")
158
167
  options[:all] ? print("Fetching all tickets#{" in bin #{options[:bin_name]}" if options[:bin_name].present?}...") : print("Fetching unresolved tickets#{" in bin #{options[:bin_name]}" if options[:bin_name].present?}...")
159
168
  STDOUT.flush
169
+ @current_project_id=options[:project_id]||self.current_project_id
160
170
  project_id=options[:project_id]||self.current_project_id
161
171
  tickets=options[:tickets]||cache.load(:name=>"fresnel_project_#{project_id}_tickets#{"_all" if options[:all]}", :action=>"Lighthouse::Ticket.find(:all, :params=>{:project_id=>#{project_id} #{",:q=>'not-state:closed'" unless options[:all]}})")
162
172
  puts " [done] - data is #{tickets.age}s old , max is #{@@cache_timeout}s"
@@ -295,7 +305,7 @@ class Fresnel
295
305
  ticket = get_ticket(number)
296
306
  puts Frame.new(
297
307
  :header=>[
298
- "Ticket ##{number} : #{ticket.title.chomp.truncate(55)}",
308
+ "Ticket ##{number} : #{ticket.title.chomp.truncate(@@term_size-5)}",
299
309
  "Date : #{DateParser.string(ticket.created_at.to_s)} by #{ticket.creator_name}",
300
310
  "Tags : #{ticket.tag}"
301
311
  ],
@@ -322,7 +332,7 @@ class Fresnel
322
332
  puts "Current state : #{ticket.versions.last.state}"
323
333
  choices = {
324
334
  :states => %w[open resolved invalid hold new],
325
- :actions => %w[quit tickets bins comments assign self web links]
335
+ :actions => %w[quit tickets bins comments assign self web links errors]
326
336
  }
327
337
  states = choices[:states]
328
338
  action=InputDetector.pretty_prompt(choices).answer
@@ -334,6 +344,7 @@ class Fresnel
334
344
  when "s" then claim(:ticket=>number)
335
345
  when "w" then open_browser_for_ticket(number)
336
346
  when "l" then links(number)
347
+ when "e" then errors(number)
337
348
  when *(states.map{|state| state[0,1]})
338
349
  change_state(:ticket=>number,:state=>states.find{|state| state[0,1] == action})
339
350
  else
@@ -365,6 +376,30 @@ class Fresnel
365
376
  show_ticket(number)
366
377
  end
367
378
 
379
+ def errors(number)
380
+ ticket = get_ticket(number)
381
+ errors = ticket.versions.map{ |version| version.body.to_s.scrape_textmate_links }.flatten
382
+ if errors.size == 0
383
+ puts "No errors found"
384
+ sleep 1
385
+ elsif errors.size == 1
386
+ error=errors.first
387
+ error=~/(.*?):(\d+)/
388
+ `mate -l #{$2} #{File.expand_path(".")}#{$1.gsub(/^\./,"")}`
389
+ else
390
+ error_table=table do |t|
391
+ t.headings=['#','error']
392
+ errors.each_with_index{|error,i|t << [i,error]}
393
+ end
394
+ puts error_table
395
+ pick=InputDetector.new("open error # : ", (0...errors.size).to_a).answer
396
+ error=errors[pick.to_i]
397
+ error=~/(.*?):(\d+)/
398
+ `mate -l #{$2} #{File.expand_path(".")}#{$1.gsub(/^\./,"")}`
399
+ end
400
+ show_ticket(number)
401
+ end
402
+
368
403
  def comment(number,state=nil)
369
404
  puts "create comment for #{number}"
370
405
  ticket=get_ticket(number)
@@ -413,16 +448,30 @@ class Fresnel
413
448
  body << l
414
449
  end
415
450
  body=body.to_s
416
- tags=ask("Tags : ")
451
+ tags=ask("Tags #{@@tags.join(",")} : ")
417
452
  tags=tags.split(" ")
453
+ expanded_tags=[]
454
+ tags.each do |tag|
455
+ match=false
456
+ if tag.length==1
457
+ @@tags.each do |predefined_tag|
458
+ if predefined_tag=~/\[#{tag}\]/
459
+ match=true
460
+ expanded_tags<<predefined_tag.gsub(/\[|\]/,"")
461
+ end
462
+ end
463
+ end
464
+ expanded_tags<<tag unless match
465
+ end
418
466
  end
467
+ puts "tags are #{expanded_tags.inspect}"
419
468
  puts "creating ticket..."
420
469
  ticket = Lighthouse::Ticket.new(
421
470
  :project_id=>self.current_project_id,
422
471
  :title=>title,
423
472
  :body=>body
424
473
  )
425
- ticket.tags=tags
474
+ ticket.tags=expanded_tags
426
475
  if ticket.save
427
476
  File.delete("/tmp/fresnel_new_ticket")
428
477
  show_ticket(ticket.number)
@@ -475,9 +524,8 @@ class Fresnel
475
524
  end
476
525
  end
477
526
  puts members_table
478
- #here
479
- pick=InputDetector.new("Assign to user # : ",((0..members.size)-1)).answer
480
- options[:user_id]=members[pick].user.id
527
+ pick=InputDetector.new("Assign to user # : ",((0...members.size).to_a)).answer
528
+ options[:user_id]=members[pick.to_i].user.id
481
529
  end
482
530
  ticket=get_ticket(options[:ticket])
483
531
  ticket.assigned_user_id=options[:user_id]
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.8
4
+ version: 0.5.9
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-11 00:00:00 +01:00
13
+ date: 2010-01-03 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency