Skip to content

Commit

Permalink
Merge 3a2f349 into 367a61c
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed May 2, 2013
2 parents 367a61c + 3a2f349 commit 732b4a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/kagami
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

require File.join(File.dirname(__FILE__), "../lib/kagami")
require_relative "../lib/kagami"

program = File.basename($PROGRAM_NAME)
USAGE = <<-EOD
Expand Down
4 changes: 2 additions & 2 deletions lib/kagami.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "kagami/version"
require_relative "kagami/version"

module Kagami
class << self
Expand All @@ -16,7 +16,7 @@ def reversed(line)
end

def readable(line)
return line.gsub(/(\w+(:? \w+)*)/){|s| s.reverse}
return line.gsub(/[.!?]?[\w']+(?: ,?[\w']+)*/){|s| s.reverse}
end

def convert(line)
Expand Down
21 changes: 20 additions & 1 deletion test/test_kagami.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
rescue LoadError
# ignore error for old ruby
end
require 'kagami'
require_relative '../lib/kagami'

describe "Kagami" do
ONE_LINE_DATA = "The internet >>> Ruby >>>> Java and you"
Expand All @@ -22,6 +22,15 @@
+--------+ +-------+ ||
||
EOD
MOO_DATA = <<-'EOD'
(__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
...."Have you mooed today?"...
EOD

it ".max_width" do
Kagami.max_width(ONE_LINE_DATA).must_equal 39
Expand Down Expand Up @@ -74,5 +83,15 @@
|| +-------+ +--------+
||
EOD
Kagami.convert("Are you crazy? Yes, I'm crazy! Whoops.").must_equal "Whoops. Yes, I'm crazy! Are you crazy?"
Kagami.convert(MOO_DATA).must_equal <<-'EOD'.chomp
)__(
)oo(
/\------/
|| | /
\/---\/ *
~~ ~~
..."Have you mooed today?"....
EOD
end
end

0 comments on commit 732b4a1

Please sign in to comment.