| |   |
| 8 | 8 | require 'kipling/scanner' |
| 9 | 9 | require 'kipling/reader' |
| 10 | 10 | require 'kipling/command_line' |
| 11 | |
| 12 | module 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 |
| 33 | end |
| toggle raw diff |
--- a/lib/kipling.rb
+++ b/lib/kipling.rb
@@ -8,3 +8,26 @@ require 'kipling/renderer'
require 'kipling/scanner'
require 'kipling/reader'
require 'kipling/command_line'
+
+module Kipling
+ class << self
+ attr_accessor :card_dir
+
+ def file_system
+ @file_system ||= Scanner::FileSystem.new(card_dir)
+ end
+
+ def scm
+ @scm ||= Scanner::Git.new('.', card_dir)
+ end
+
+ # Returns an array [Time, [Kipling::Card]]
+ #
+ # TODO: If +rev+ is passed, the snapshot is taken from the SCM.
+ def snapshot(rev=nil)
+ after = Time.utc(1980)
+ before = Time.utc(2030)
+ file_system.timeline(after, before).points[0]
+ end
+ end
+end
|
| |   |
| 6 | 6 | module KiplingWeb::Controllers |
| 7 | 7 | class Index < R '/' |
| 8 | 8 | 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] |
| 15 | 10 | @card_view = Kipling::CardView.new(cards, :attribute => 'state') |
| 16 | 11 | render :index |
| 17 | 12 | end |
| … | … | |
| 16 | 16 | module KiplingWeb::Views |
| 17 | 17 | def index |
| 18 | 18 | 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 |
| 20 | 37 | end |
| 21 | 38 | end |
| toggle raw diff |
--- a/lib/kipling/camping/kipling_web.rb
+++ b/lib/kipling/camping/kipling_web.rb
@@ -6,12 +6,7 @@ Camping.goes :KiplingWeb
module KiplingWeb::Controllers
class Index < R '/'
def get
- @scanner = Kipling::Scanner::Git.new('.', 'stories/stories')
- after = Time.now - 4*24*3600
- before = Time.now
- @timeline = scanner.timeline(after, before)
- points = timeline.points[0]
- cards = points[1]
+ cards = Kipling.snapshot[1]
@card_view = Kipling::CardView.new(cards, :attribute => 'state')
render :index
end
@@ -21,6 +16,23 @@ end
module KiplingWeb::Views
def index
h1 'Cards'
- 'hallo'
+ table do
+ tr do
+ @card_view.card_groups.each do |card_group|
+ th card_group.attribute_value
+ end
+ end
+ tr do
+ @card_view.card_groups.each do |card_group|
+ td do
+ ul do
+ card_group.cards.each do |card|
+ li card.name
+ end
+ end
+ end
+ end
+ end
+ end
end
end |
| |   |
| 8 | 8 | class CommandLine < CmdParse::CommandParser |
| 9 | 9 | def initialize |
| 10 | 10 | super(true,true) |
| 11 | load_prefs |
| 11 | 12 | self.program_name = "kipling" |
| 12 | 13 | self.program_version = Kipling::VERSION.split('.') |
| 13 | 14 | |
| … | … | |
| 16 | 16 | @glob = 'stories/**/*.story' |
| 17 | 17 | |
| 18 | 18 | 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 } |
| 22 | 19 | end |
| 23 | 20 | |
| 24 | 21 | add_command(CmdParse::HelpCommand.new) |
| … | … | |
| 29 | 29 | add_command(Commands::ServerCommand.new) |
| 30 | 30 | end |
| 31 | 31 | |
| 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 |
| 37 | 38 | end |
| 38 | 39 | end |
| 39 | | |
| 40 | | def timeline(after, before) |
| 41 | | scanner.timeline(after, before) |
| 42 | | end |
| 43 | 40 | end |
| 44 | 41 | end |
| toggle raw diff |
--- a/lib/kipling/command_line.rb
+++ b/lib/kipling/command_line.rb
@@ -8,6 +8,7 @@ module Kipling
class CommandLine < CmdParse::CommandParser
def initialize
super(true,true)
+ load_prefs
self.program_name = "kipling"
self.program_version = Kipling::VERSION.split('.')
@@ -15,9 +16,6 @@ module Kipling
@glob = 'stories/**/*.story'
self.options = CmdParse::OptionParserWrapper.new do |opt|
- opt.separator "Global options:"
- opt.on("--verbose", "Be verbose when outputting info") {|t| $verbose = true }
- opt.on("--scanner=SCANNER", "What scanner to use. Valid values are git or file") {|v| @scanner = v }
end
add_command(CmdParse::HelpCommand.new)
@@ -31,16 +29,13 @@ module Kipling
add_command(Commands::ServerCommand.new)
end
- def scanner
- if @scanner == 'file'
- scanner = Scanner::FileSystem.new(@glob)
- else
- scanner = Scanner::Git.new('.', 'stories/stories')
+ def load_prefs
+ begin
+ load '.kipling'
+ rescue MissingSourceFile
+ STDERR.puts "There is no .kipling file here. Please create one."
+ exit 1
end
end
-
- def timeline(after, before)
- scanner.timeline(after, before)
- end
end
end |
| |   |
| 10 | 10 | |
| 11 | 11 | @format = 'ascii' |
| 12 | 12 | @attribute = 'state' |
| 13 | | @n = 0 |
| 14 | 13 | @sum = nil |
| 15 | 14 | self.options = CmdParse::OptionParserWrapper.new do |opt| |
| 16 | 15 | opt.on("--format=X", "How to output format. Valid types are ascii or html") {|f| @format = f } |
| … | … | |
| 20 | 20 | end |
| 21 | 21 | |
| 22 | 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] |
| 23 | points = Kipling.snapshot |
| 27 | 24 | cards = points[1] |
| 28 | 25 | card_view = CardView.new(cards, :attribute => @attribute, :sum => @sum) |
| 29 | 26 | renderer_class = {'ascii' => Renderer::Snapshot::Ascii, 'html' => Renderer::Snapshot::Html}[@format] |
| toggle raw diff |
--- a/lib/kipling/commands/snapshot_command.rb
+++ b/lib/kipling/commands/snapshot_command.rb
@@ -10,7 +10,6 @@ module Kipling
@format = 'ascii'
@attribute = 'state'
- @n = 0
@sum = nil
self.options = CmdParse::OptionParserWrapper.new do |opt|
opt.on("--format=X", "How to output format. Valid types are ascii or html") {|f| @format = f }
@@ -21,10 +20,7 @@ module Kipling
end
def execute(args)
- after = Time.now - 4*24*3600
- before = Time.now
- timeline = super_command.super_command.timeline(after, before)
- points = timeline.points[@n]
+ points = Kipling.snapshot
cards = points[1]
card_view = CardView.new(cards, :attribute => @attribute, :sum => @sum)
renderer_class = {'ascii' => Renderer::Snapshot::Ascii, 'html' => Renderer::Snapshot::Html}[@format] |
| |   |
| 44 | 44 | end |
| 45 | 45 | |
| 46 | 46 | def execute(args) |
| 47 | | after = Time.now - 4*24*3600 |
| 47 | after = Time.now - 14*24*3600 |
| 48 | 48 | before = Time.now |
| 49 | | timeline = super_command.super_command.timeline(after, before) |
| 49 | timeline = Kipling.scm.timeline(after, before) |
| 50 | 50 | timeline.render(renderer, @y_attribute, @grouping_attribute, grouping_values) |
| 51 | 51 | end |
| 52 | 52 | end |
| toggle raw diff |
--- a/lib/kipling/commands/timeline_command.rb
+++ b/lib/kipling/commands/timeline_command.rb
@@ -44,9 +44,9 @@ module Kipling
end
def execute(args)
- after = Time.now - 4*24*3600
+ after = Time.now - 14*24*3600
before = Time.now
- timeline = super_command.super_command.timeline(after, before)
+ timeline = Kipling.scm.timeline(after, before)
timeline.render(renderer, @y_attribute, @grouping_attribute, grouping_values)
end
end |
| |   |
| 13 | 13 | timeline = Timeline.new(after, before) |
| 14 | 14 | |
| 15 | 15 | # 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| |
| 17 | 18 | timeline.add(commit.author_date) do |
| 18 | 19 | tree = subtree(commit) |
| 19 | 20 | unless tree.nil? |
| toggle raw diff |
--- a/lib/kipling/scanner/git.rb
+++ b/lib/kipling/scanner/git.rb
@@ -13,7 +13,8 @@ module Kipling
timeline = Timeline.new(after, before)
# TODO: Make git-ruby support until
- @repo.log.since(after).each do |commit|
+ # TODO: since doesn't work. I have emailed Scott Chacon about it
+ @repo.log(100).each do |commit|
timeline.add(commit.author_date) do
tree = subtree(commit)
unless tree.nil? |