Commit a714b4d92423330196408fcae37edcab674798dd

more camping

Commit diff

.gitignore

 
11coverage
2*.png
2*.png
3*.tmproj
toggle raw diff

.kipling

 
1Kipling.card_dir = 'stories/stories'
toggle raw diff

lib/kipling.rb

 
88require 'kipling/scanner'
99require 'kipling/reader'
1010require 'kipling/command_line'
11
12module Kipling
13 class << self
14 attr_accessor :card_dir
15
16 def file_system
17 @file_system ||= Scanner::FileSystem.new(card_dir)
18 end
19
20 def scm
21 @scm ||= Scanner::Git.new('.', card_dir)
22 end
23
24 # Returns an array [Time, [Kipling::Card]]
25 #
26 # TODO: If +rev+ is passed, the snapshot is taken from the SCM.
27 def snapshot(rev=nil)
28 after = Time.utc(1980)
29 before = Time.utc(2030)
30 file_system.timeline(after, before).points[0]
31 end
32 end
33end
toggle raw diff

lib/kipling/camping/kipling_web.rb

 
66module KiplingWeb::Controllers
77 class Index < R '/'
88 def get
9 @scanner = Kipling::Scanner::Git.new('.', 'stories/stories')
10 after = Time.now - 4*24*3600
11 before = Time.now
12 @timeline = scanner.timeline(after, before)
13 points = timeline.points[0]
14 cards = points[1]
9 cards = Kipling.snapshot[1]
1510 @card_view = Kipling::CardView.new(cards, :attribute => 'state')
1611 render :index
1712 end
1616module KiplingWeb::Views
1717 def index
1818 h1 'Cards'
19 'hallo'
19 table do
20 tr do
21 @card_view.card_groups.each do |card_group|
22 th card_group.attribute_value
23 end
24 end
25 tr do
26 @card_view.card_groups.each do |card_group|
27 td do
28 ul do
29 card_group.cards.each do |card|
30 li card.name
31 end
32 end
33 end
34 end
35 end
36 end
2037 end
2138end
toggle raw diff

lib/kipling/card_group.rb

 
1313 end
1414 end
1515
16 attr_reader :cards, :attribute_value
17
1618 def initialize(cards, attribute_value)
1719 @cards = cards.dup
1820 @attribute_value = attribute_value
toggle raw diff

lib/kipling/command_line.rb

 
88 class CommandLine < CmdParse::CommandParser
99 def initialize
1010 super(true,true)
11 load_prefs
1112 self.program_name = "kipling"
1213 self.program_version = Kipling::VERSION.split('.')
1314
1616 @glob = 'stories/**/*.story'
1717
1818 self.options = CmdParse::OptionParserWrapper.new do |opt|
19 opt.separator "Global options:"
20 opt.on("--verbose", "Be verbose when outputting info") {|t| $verbose = true }
21 opt.on("--scanner=SCANNER", "What scanner to use. Valid values are git or file") {|v| @scanner = v }
2219 end
2320
2421 add_command(CmdParse::HelpCommand.new)
2929 add_command(Commands::ServerCommand.new)
3030 end
3131
32 def scanner
33 if @scanner == 'file'
34 scanner = Scanner::FileSystem.new(@glob)
35 else
36 scanner = Scanner::Git.new('.', 'stories/stories')
32 def load_prefs
33 begin
34 load '.kipling'
35 rescue MissingSourceFile
36 STDERR.puts "There is no .kipling file here. Please create one."
37 exit 1
3738 end
3839 end
39
40 def timeline(after, before)
41 scanner.timeline(after, before)
42 end
4340 end
4441end
toggle raw diff

lib/kipling/commands/snapshot_command.rb

 
1010
1111 @format = 'ascii'
1212 @attribute = 'state'
13 @n = 0
1413 @sum = nil
1514 self.options = CmdParse::OptionParserWrapper.new do |opt|
1615 opt.on("--format=X", "How to output format. Valid types are ascii or html") {|f| @format = f }
2020 end
2121
2222 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]
23 points = Kipling.snapshot
2724 cards = points[1]
2825 card_view = CardView.new(cards, :attribute => @attribute, :sum => @sum)
2926 renderer_class = {'ascii' => Renderer::Snapshot::Ascii, 'html' => Renderer::Snapshot::Html}[@format]
toggle raw diff

lib/kipling/commands/timeline_command.rb

 
4444 end
4545
4646 def execute(args)
47 after = Time.now - 4*24*3600
47 after = Time.now - 14*24*3600
4848 before = Time.now
49 timeline = super_command.super_command.timeline(after, before)
49 timeline = Kipling.scm.timeline(after, before)
5050 timeline.render(renderer, @y_attribute, @grouping_attribute, grouping_values)
5151 end
5252 end
toggle raw diff

lib/kipling/scanner/file_system.rb

 
33module Kipling
44 module Scanner
55 class FileSystem
6 def initialize(glob, card_reader=Reader::Yaml.new)
7 @glob = glob
6 def initialize(dir, card_reader=Reader::Yaml.new)
7 @glob = "#{dir}/*"
88 @card_reader = card_reader
99 end
1010
toggle raw diff

lib/kipling/scanner/git.rb

 
1313 timeline = Timeline.new(after, before)
1414
1515 # TODO: Make git-ruby support until
16 @repo.log.since(after).each do |commit|
16 # TODO: since doesn't work. I have emailed Scott Chacon about it
17 @repo.log(100).each do |commit|
1718 timeline.add(commit.author_date) do
1819 tree = subtree(commit)
1920 unless tree.nil?
toggle raw diff