Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
From c5e49cdc44a1c884db421cd1af99e109ac607866 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Mislav=20Marohni=C4=87?= <mislav.marohnic@gmail.com> Date: Wed, 10 Sep 2008 22:32:10 +0200 Subject: [PATCH] support "_:;,." characters in ticket names --- lib/ticgit/ticket.rb | 8 +++++--- spec/base_spec.rb | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/ticgit/ticket.rb b/lib/ticgit/ticket.rb index 190a824..625cbf5 100644 --- a/lib/ticgit/ticket.rb +++ b/lib/ticgit/ticket.rb @@ -65,8 +65,10 @@ module TicGit def self.parse_ticket_name(name) - epoch, title, rand = name.split('_') - title = title.gsub('-', ' ') + unless name =~ /^([^_]+)_(.+)_([^_]+)$/ + raise "invalid ticket name #{name.inspect}" + end + epoch, title, rand = $1, $2.gsub('-', ' '), $3 return [title, Time.at(epoch.to_i)] end @@ -106,7 +108,7 @@ module TicGit end def self.clean_string(string) - string.downcase.gsub(/[^a-z0-9]+/i, '-') + string.downcase.gsub(/[^a-zA-Z0-9_:;,.]+/, '-') end def add_comment(comment) diff --git a/spec/base_spec.rb b/spec/base_spec.rb index 9ce6a06..34b82e0 100644 --- a/spec/base_spec.rb +++ b/spec/base_spec.rb @@ -25,6 +25,12 @@ describe TicGit::Base do list.first.should be_an_instance_of(TicGit::Ticket) list.size.should eql(2) end + + it "should be able to use more than just alphanumeric characters in title" do + id = @ticgit.ticket_new('under_scores do.ts,comma -- colon:semicolon;').ticket_id + ticket = @ticgit.ticket_list.find { |t| t.ticket_id == id } + ticket.title.should == 'under_scores do.ts,comma colon:semicolon;' + end it "should be able to change the state of a ticket" do tic = @ticgit.ticket_list.first @@ -76,7 +82,7 @@ describe TicGit::Base do tics = @ticgit.ticket_list(:state => 'resolved') tics.size.should eql(1) tics = @ticgit.ticket_list(:state => 'open') - tics.size.should eql(2) + tics.size.should eql(3) end it "should be able to save and recall filtered ticket lists" do -- 1.6.0
This paste will be private.
From the Design Piracy series on my blog: