maxim-lighthouse_cli 1.1.0 → 1.2.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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -6,12 +6,21 @@ module LighthouseCLI
6
6
  end
7
7
 
8
8
  def list(which = "next")
9
- tickets = case which
9
+ case which
10
10
  when 'next'
11
- fetch_tickets("responsible:me milestone:#{next_milestone.title} state:open sort:priority")
11
+ puts "Milestone: #{fetch_next_milestone.title}"
12
+ tickets = fetch_tickets("responsible:me milestone:#{fetch_next_milestone.title} state:open sort:priority")
13
+ display_tickets tickets
14
+ else
15
+ milestones = fetch_milestones_by_title(which)
16
+ milestones.each do |ms|
17
+ puts "Milestone: #{ms.title}"
18
+ tickets = fetch_tickets("responsible:me milestone:#{ms.title} state:open sort:priority")
19
+ display_tickets tickets
20
+ puts "\n"
21
+ sleep 1
22
+ end
12
23
  end
13
-
14
- display_tickets tickets
15
24
  end
16
25
 
17
26
  def resolve(id)
@@ -41,6 +50,17 @@ module LighthouseCLI
41
50
  puts " #{ticket.body}" unless ticket.body.blank?
42
51
  puts " #{ticket.tags.join(', ')}" unless ticket.tags.blank?
43
52
  end
53
+
54
+ def ms(which = "future")
55
+ milestones = case which
56
+ when 'all'
57
+ fetch_all_milestones
58
+ when 'future'
59
+ fetch_future_milestones
60
+ end
61
+
62
+ display_milestones milestones
63
+ end
44
64
 
45
65
  def help
46
66
  puts <<-TEXT
@@ -48,9 +68,12 @@ module LighthouseCLI
48
68
  help
49
69
  Show this text.
50
70
 
51
- list
52
- List all assigned tickets from upcoming milestone.
53
-
71
+ list [milestone_name]
72
+ List all assigned tickets from next upcoming milestone (by default). Otherwise, list all tickets in all milestones matching milestone name.
73
+
74
+ ms [all]
75
+ List future milestones (by default). List all milestones when option "all" provided.
76
+
54
77
  show 50
55
78
  Show details for ticket with given id.
56
79
 
@@ -23,14 +23,38 @@ module LighthouseCLI
23
23
  {:params => {:q => str, :project_id => @project.id}}
24
24
  end
25
25
 
26
- def next_milestone
27
- @next_milestone ||= @project.milestones.find_all{|m| m.due_on > Time.now}.min{|a,b| a.due_on <=> b.due_on}
26
+ def fetch_next_milestone
27
+ @next_milestone ||= fetch_future_milestones.min{|a,b| a.due_on <=> b.due_on}
28
+ end
29
+
30
+ def fetch_future_milestones
31
+ @future_milestones ||= fetch_all_milestones.find_all{|m| m.due_on > Time.now}
32
+ end
33
+
34
+ def fetch_all_milestones
35
+ @all_milestones ||= @project.milestones.sort{|a,b| b.due_on <=> a.due_on}
36
+ end
37
+
38
+ def fetch_milestones_by_title(title)
39
+ fetch_all_milestones.select{|m| m.title =~ /#{title}/i}
28
40
  end
29
41
 
30
42
  def display_tickets(tickets)
31
43
  puts AutoTable.render tickets, :fields => [:number, :title], :max_width => width
32
44
  end
33
45
 
46
+ def display_milestones(milestones)
47
+ puts AutoTable.render milestones, :fields => [:title, :tickets_count, :open_tickets_count, :due_on],
48
+ :headers => { :due_on => "due",
49
+ :title => "title",
50
+ :tickets_count => "tickets",
51
+ :open_tickets_count => "open"},
52
+ :filters => {
53
+ :due_on => [:strftime, "%m/%d/%Y"]
54
+ },
55
+ :max_width => width
56
+ end
57
+
34
58
  def width
35
59
  `stty size`.split.map { |x| x.to_i }.reverse.second
36
60
  rescue
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lighthouse_cli}
8
- s.version = "1.1.0"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Maxim Chernyak"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maxim-lighthouse_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Chernyak
@@ -66,6 +66,7 @@ files:
66
66
  - vendor/lighthouse-api/lib/lighthouse/console.rb
67
67
  has_rdoc: false
68
68
  homepage: http://github.com/maxim/lighthouse_cli
69
+ licenses:
69
70
  post_install_message:
70
71
  rdoc_options:
71
72
  - --charset=UTF-8
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  requirements: []
87
88
 
88
89
  rubyforge_project:
89
- rubygems_version: 1.2.0
90
+ rubygems_version: 1.3.5
90
91
  signing_key:
91
92
  specification_version: 3
92
93
  summary: A quick command line interface to lighthouse.