Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

renamed gem using @drbrain's conventions : http://blog.segment7.net/a…

  • Loading branch information...
commit fcc35ee98d2c550827bbed91b1ed696ada9b3083 1 parent e7bf061
@veganstraightedge authored
View
6 CHANGELOG.rdoc
@@ -1,3 +1,9 @@
+=== 1.0.3 / 2010-11-16
+
+* 1 minor enhancement
+
+ * Changed named from newbase60 to new_base_60
+
=== 1.0.2 / 2010-06-21
* 2 minor enhancement
View
4 Manifest.txt
@@ -3,5 +3,5 @@ CHANGELOG.rdoc
Manifest.txt
README.rdoc
Rakefile
-lib/newbase60.rb
-test/test_newbase60.rb
+lib/new_base_60.rb
+test/test_new_base_60.rb
View
14 README.rdoc
@@ -1,6 +1,6 @@
-= newbase60
+= new_base_60
-* http://github.com/veganstraightedge/NewBase60
+* http://github.com/veganstraightedge/New_base_60
== DESCRIPTION:
@@ -10,7 +10,7 @@ Cuts out ambiguous characters like:
* I : capital I (looks like a 1 : one)
* O : capital O (looks like a 0 : zero)
-Based on work done by Tantek Çelik : http://tantek.pbworks.com/NewBase60
+Based on work done by Tantek Çelik : http://tantek.pbworks.com/New_base_60
== FEATURES/PROBLEMS:
@@ -22,8 +22,8 @@ Based on work done by Tantek Çelik : http://tantek.pbworks.com/NewBase60
How to use:
- require "newbase60"
- n = Newbase60.new("464")# => #<Newbase60:0x1011ea468 @base_60="464">
+ require "new_base_60"
+ n = New_base_60.new("464")# => #<New_base_60:0x1011ea468 @base_60="464">
puts n.to_i # => 14764
puts n.to_i.to_sxg # => "464"
puts n.to_date # => #<Date: 4910703/2,0,2299161>
@@ -32,7 +32,7 @@ How to use:
== INSTALL:
-* sudo gem install newbase60
+* sudo gem install new_base_60
== CREDITS:
@@ -40,7 +40,7 @@ How to use:
* Ruby Port : Shane Becker
* Lotsa Cleanup : John Barnette
-* sudo gem install newbase60
+* sudo gem install new_base_60
== LICENSE:
View
2  Rakefile
@@ -1,7 +1,7 @@
require 'rubygems'
require 'hoe'
-Hoe.spec 'newbase60' do
+Hoe.spec 'new_base_60' do
developer('Shane Becker', 'veganstraightedge@example.com')
self.extra_rdoc_files = Dir["*.rdoc"]
View
19 lib/newbase60.rb → lib/new_base_60.rb
@@ -1,7 +1,7 @@
require "date"
require "time"
-class Newbase60
+class New_base_60
VERSION = '1.0.2'
VOCABULARY = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz"
@@ -41,7 +41,7 @@ def to_i
def to_date
# HACK this is smelly
# days since epoch * seconds * minutes * hours + timezone
- time = Time.at(Newbase60.new(@base_60).to_i *
+ time = Time.at(New_base_60.new(@base_60).to_i *
60 * 60 * 24 + Time.now.gmtoff.abs)
Date.parse(time.strftime("%Y/%m/%d"))
@@ -49,9 +49,7 @@ def to_date
end
class Integer
-
- # Converts a base 10 integer into a NewBase60 string.
-
+ # Converts a base 10 integer into a New_base_60 string.
def to_sxg
return "" if zero?
@@ -60,16 +58,15 @@ def to_sxg
while num > 0 do
mod = num % 60
- sxg = "#{Newbase60::VOCABULARY[mod,1]}#{sxg}"
+ sxg = "#{New_base_60::VOCABULARY[mod,1]}#{sxg}"
num = (num - mod) / 60
end
sxg
end
- # Converts a base 10 integer into a NewBase60 string, padding with
- # leading zeroes.
-
+ # Converts a base 10 integer into a New_base_60 string,
+ # padding with leading zeroes.
def to_sxgf(padding)
num = self
@@ -88,9 +85,7 @@ def to_sxgf(padding)
end
class Date
-
- # Converts into a NewBase60 string.
-
+ # Converts into a New_base_60 string.
def to_sxg
(self - Date.parse("1970/01/01")).to_i.to_sxg
end
View
29 test/test_new_base_60.rb
@@ -0,0 +1,29 @@
+require "test/unit"
+require "new_base_60"
+
+class TestNew_base_60 < Test::Unit::TestCase
+ def test_base60_to_base10
+ assert_equal New_base_60.new("464").to_i, 14764
+ assert_not_equal New_base_60.new("464").to_i, 12345
+ end
+
+ def test_base60_to_date
+ assert_equal New_base_60.new("464").to_date, Date.parse("2010/06/04")
+ assert_not_equal New_base_60.new("464").to_date, Date.parse("2010/06/05")
+ end
+
+ def test_date_to_base60
+ assert_equal Date.parse("2010/06/04").to_sxg, New_base_60.new("464").to_s
+ assert_not_equal Date.parse("2010/06/05").to_sxg, New_base_60.new("464")
+ end
+
+ def test_base10_to_base60
+ assert_equal 14764.to_sxg, "464"
+ assert_not_equal 12345.to_sxg, "464"
+ end
+
+ def test_base10_to_base60_with_leading_zeroes
+ assert_equal 14764.to_sxgf(9), "000000464"
+ assert_not_equal 12345.to_sxgf(9), "000000464"
+ end
+end
View
29 test/test_newbase60.rb
@@ -1,29 +0,0 @@
-require "test/unit"
-require "newbase60"
-
-class TestNewbase60 < Test::Unit::TestCase
- def test_base60_to_base10
- assert_equal Newbase60.new("464").to_i, 14764
- assert_not_equal Newbase60.new("464").to_i, 12345
- end
-
- def test_base60_to_date
- assert_equal Newbase60.new("464").to_date, Date.parse("2010/06/04")
- assert_not_equal Newbase60.new("464").to_date, Date.parse("2010/06/05")
- end
-
- def test_date_to_base60
- assert_equal Date.parse("2010/06/04").to_sxg, Newbase60.new("464").to_s
- assert_not_equal Date.parse("2010/06/05").to_sxg, Newbase60.new("464")
- end
-
- def test_base10_to_base60
- assert_equal 14764.to_sxg, "464"
- assert_not_equal 12345.to_sxg, "464"
- end
-
- def test_base10_to_base60_with_leading_zeroes
- assert_equal 14764.to_sxgf(9), "000000464"
- assert_not_equal 12345.to_sxgf(9), "000000464"
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.