summary refs log tree commit diff
path: root/lib/ballet/Commit.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-03-13 20:22:59 +0100
committerfranck cuny <franck@lumberjaph.net>2011-03-13 20:22:59 +0100
commit7d3095b4b9e487d0966ed7ac777d3f9783ce1c28 (patch)
treef474b6e8fafb4874cdb078f4fef56fc2ac6b30ef /lib/ballet/Commit.pm
parentlayout (diff)
downloadballet-7d3095b4b9e487d0966ed7ac777d3f9783ce1c28.tar.gz
css; twitter; commits; history
Signed-off-by: franck cuny <franck@lumberjaph.net>
Diffstat (limited to 'lib/ballet/Commit.pm')
-rw-r--r--lib/ballet/Commit.pm36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/ballet/Commit.pm b/lib/ballet/Commit.pm
new file mode 100644
index 0000000..2836714
--- /dev/null
+++ b/lib/ballet/Commit.pm
@@ -0,0 +1,36 @@
+package ballet::Commit;
+
+use Mouse::Role;
+
+sub create_commits {
+    my ( $self, $logs_lines ) = @_;
+
+    my @commits;
+
+    while (scalar @$logs_lines) {
+        my $id     = shift @$logs_lines;
+        my $author = shift @$logs_lines;
+        my $date   = shift @$logs_lines;
+
+        shift @$logs_lines;
+
+        my $msg      = shift @$logs_lines;
+        my $messages = [];
+
+        while ( length $msg > 0) {
+            push @$messages, $msg;
+            $msg = shift @$logs_lines;
+        }
+
+        push @commits,
+          {
+            id      => $id,
+            author  => $author,
+            date    => $date,
+            message => join( "\n", @$messages )
+          };
+    }
+    \@commits;
+}
+
+1;