Commit 193bddc95b40422b619c1ccac9079e289906cfa4

more moving files around

Commit diff

bin/kipling

 
11require 'rubygems'
22require 'kipling'
33
4Kipling::Commands::KiplingParser.new.parse
4Kipling::CommandLine.new.parse
toggle raw diff

lib/kipling.rb

 
77require 'kipling/renderer'
88require 'kipling/scanner'
99require 'kipling/reader'
10require 'kipling/commands'
10require 'kipling/command_line'
toggle raw diff

lib/kipling/command_line.rb

 
1require 'cmdparse'
2
3module Kipling
4 # Various command line commands
5 module Commands
6 end
7
8 class CommandLine < CmdParse::CommandParser
9 def initialize
10 super(true,true)
11 self.program_name = "kipling"
12 self.program_version = Kipling::VERSION.split('.')
13
14 @scanner = 'git'
15 @glob = 'stories/**/*.story'
16
17 self.options = CmdParse::OptionParserWrapper.new do |opt|
18 opt.separator "Global options:"
19 opt.on("--verbose", "Be verbose when outputting info") {|t| $verbose = true }
20 opt.on("--scanner=SCANNER", "What scanner to use. Valid values are git or file") {|v| @scanner = v }
21 end
22
23 add_command(CmdParse::HelpCommand.new)
24 add_command(CmdParse::VersionCommand.new)
25
26 require 'kipling/commands/snapshot_command'
27 require 'kipling/commands/timeline_command'
28 require 'kipling/commands/server_command'
29 add_command(Commands::SnapshotCommand.new)
30 add_command(Commands::TimelineCommand.new)
31 add_command(Commands::ServerCommand.new)
32 end
33
34 def scanner
35 if @scanner == 'file'
36 scanner = Scanner::FileSystem.new(@glob)
37 else
38 scanner = Scanner::Git.new('.', 'stories/stories')
39 end
40 end
41
42 def timeline(after, before)
43 scanner.timeline(after, before)
44 end
45 end
46end
toggle raw diff

lib/kipling/commands.rb

 
0require 'kipling/commands/kipling_parser'
1require 'kipling/commands/view_command'
2require 'kipling/commands/timeline_command'
3require 'kipling/commands/server_command'
4
5module Kipling
6 # Various command line commands
7 module Commands
8 end
9end
toggle raw diff

lib/kipling/commands/kipling_parser.rb

 
0require 'cmdparse'
1
2module Kipling
3 module Commands
4 class KiplingParser < CmdParse::CommandParser
5 def initialize
6 super(true,true)
7 self.program_name = "kipling"
8 self.program_version = Kipling::VERSION.split('.')
9
10 @scanner = 'git'
11 @glob = 'stories/**/*.story'
12
13 self.options = CmdParse::OptionParserWrapper.new do |opt|
14 opt.separator "Global options:"
15 opt.on("--verbose", "Be verbose when outputting info") {|t| $verbose = true }
16 opt.on("--scanner=SCANNER", "What scanner to use. Valid values are git or file") {|v| @scanner = v }
17 end
18
19 add_command(CmdParse::HelpCommand.new)
20 add_command(CmdParse::VersionCommand.new)
21 add_command(ViewCommand.new)
22 add_command(TimelineCommand.new)
23 add_command(ServerCommand.new)
24 end
25
26 def scanner
27 if @scanner == 'file'
28 scanner = Scanner::FileSystem.new(@glob)
29 else
30 scanner = Scanner::Git.new('.', 'stories/stories')
31 end
32 end
33
34 def timeline(after, before)
35 scanner.timeline(after, before)
36 end
37 end
38 end
39end
toggle raw diff

lib/kipling/commands/snapshot_command.rb

 
1require 'cmdparse'
2
3module Kipling
4 module Commands
5 class SnapshotCommand < CmdParse::Command
6 def initialize
7 super('snapshot', false)
8 self.short_desc = "Print a snapshot of cards"
9 self.description = "This command prints a snapshot of cards in a grid, typically used in XP or Scrum projects"
10
11 @format = 'ascii'
12 @attribute = 'state'
13 @n = 0
14 @sum = nil
15 self.options = CmdParse::OptionParserWrapper.new do |opt|
16 opt.on("--format=X", "How to output format. Valid types are ascii or html") {|f| @format = f }
17 opt.on("--group=X", "Name of card attribute cards will be grouped by") {|g| @attribute = g }
18 opt.on("--n=X", "What point in time") {|p| @p = p.to_i }
19 opt.on("--sum=x", "Add sum") {|s| @sum = s }
20 end
21 end
22
23 def execute(args)
24 after = Time.now - 4*24*3600
25 before = Time.now
26 timeline = super_command.super_command.timeline(after, before)
27 points = timeline.points[@n]
28 cards = points[1]
29 card_view = CardView.new(cards, :attribute => @attribute, :sum => @sum)
30 renderer_class = {'ascii' => Renderer::Snapshot::Ascii, 'html' => Renderer::Snapshot::Html}[@format]
31 renderer = renderer_class.new(card_view)
32 renderer.render(STDOUT)
33 end
34 end
35 end
36end
toggle raw diff

lib/kipling/commands/view_command.rb

 
0require 'cmdparse'
1
2module Kipling
3 module Commands
4 class ViewCommand < CmdParse::Command
5 def initialize
6 super('view', false)
7 self.short_desc = "Print a view of cards"
8 self.description = "This command prints cards in a grid, typically used in XP or Scrum projects"
9
10 @format = 'txt'
11 @attribute = 'state'
12 @n = 0
13 @sum = nil
14 self.options = CmdParse::OptionParserWrapper.new do |opt|
15 opt.on("--format=X", "How to output format") {|f| @format = f }
16 opt.on("--group=X", "Name of card attribute cards will be grouped by") {|g| @attribute = g }
17 opt.on("--n=X", "What point in time") {|p| @p = p.to_i }
18 opt.on("--sum=x", "Add sum") {|s| @sum = s }
19 end
20 end
21
22 def execute(args)
23 after = Time.now - 4*24*3600
24 before = Time.now
25 timeline = super_command.super_command.timeline(after, before)
26 points = timeline.points[@n]
27 cards = points[1]
28 card_view = CardView.new(cards, :attribute => @attribute, :sum => @sum)
29 renderer_class = {'txt' => ConsoleRenderer, 'html' => HtmlRenderer}[@format]
30 renderer = renderer_class.new(card_view)
31 renderer.render(STDOUT)
32 end
33 end
34 end
35end
toggle raw diff