new_base_60 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.0.4 / 2011-02-15
2
+
3
+ * 1 minor enhancement
4
+
5
+ * Changed class name from new_base_60 to NewBase60
6
+
1
7
  === 1.0.3 / 2010-11-16
2
8
 
3
9
  * 1 minor enhancement
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = new_base_60
2
2
 
3
- * http://github.com/veganstraightedge/New_base_60
3
+ * http://github.com/veganstraightedge/new_base_60
4
4
 
5
5
  == DESCRIPTION:
6
6
 
@@ -23,7 +23,7 @@ Based on work done by Tantek Çelik : http://tantek.pbworks.com/New_base_60
23
23
  How to use:
24
24
 
25
25
  require "new_base_60"
26
- n = New_base_60.new("464")# => #<New_base_60:0x1011ea468 @base_60="464">
26
+ n = NewBase60.new("464")# => #<NewBase60:0x1011ea468 @base_60="464">
27
27
  puts n.to_i # => 14764
28
28
  puts n.to_i.to_sxg # => "464"
29
29
  puts n.to_date # => #<Date: 4910703/2,0,2299161>
@@ -40,8 +40,6 @@ How to use:
40
40
  * Ruby Port : Shane Becker
41
41
  * Lotsa Cleanup : John Barnette
42
42
 
43
- * sudo gem install new_base_60
44
-
45
43
  == LICENSE:
46
44
 
47
45
  PUBLIC DOMAIN.
data/lib/new_base_60.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require "date"
2
2
  require "time"
3
3
 
4
- class New_base_60
5
- VERSION = '1.0.3'
4
+ class NewBase60
5
+ VERSION = '1.0.4'
6
6
  VOCABULARY = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz"
7
7
 
8
8
  def initialize(base_60)
@@ -41,7 +41,7 @@ class New_base_60
41
41
  def to_date
42
42
  # HACK this is smelly
43
43
  # days since epoch * seconds * minutes * hours + timezone
44
- time = Time.at(New_base_60.new(@base_60).to_i *
44
+ time = Time.at(NewBase60.new(@base_60).to_i *
45
45
  60 * 60 * 24 + Time.now.gmtoff.abs)
46
46
 
47
47
  Date.parse(time.strftime("%Y/%m/%d"))
@@ -49,7 +49,7 @@ class New_base_60
49
49
  end
50
50
 
51
51
  class Integer
52
- # Converts a base 10 integer into a New_base_60 string.
52
+ # Converts a base 10 integer into a NewBase60 string.
53
53
  def to_sxg
54
54
  return "" if zero?
55
55
 
@@ -58,14 +58,14 @@ class Integer
58
58
 
59
59
  while num > 0 do
60
60
  mod = num % 60
61
- sxg = "#{New_base_60::VOCABULARY[mod,1]}#{sxg}"
61
+ sxg = "#{NewBase60::VOCABULARY[mod,1]}#{sxg}"
62
62
  num = (num - mod) / 60
63
63
  end
64
64
 
65
65
  sxg
66
66
  end
67
67
 
68
- # Converts a base 10 integer into a New_base_60 string,
68
+ # Converts a base 10 integer into a NewBase60 string,
69
69
  # padding with leading zeroes.
70
70
  def to_sxgf(padding)
71
71
  num = self
@@ -85,7 +85,7 @@ class Integer
85
85
  end
86
86
 
87
87
  class Date
88
- # Converts into a New_base_60 string.
88
+ # Converts into a NewBase60 string.
89
89
  def to_sxg
90
90
  (self - Date.parse("1970/01/01")).to_i.to_sxg
91
91
  end
@@ -1,20 +1,20 @@
1
1
  require "test/unit"
2
2
  require "new_base_60"
3
3
 
4
- class TestNew_base_60 < Test::Unit::TestCase
4
+ class TestNewBase60 < Test::Unit::TestCase
5
5
  def test_base60_to_base10
6
- assert_equal New_base_60.new("464").to_i, 14764
7
- assert_not_equal New_base_60.new("464").to_i, 12345
6
+ assert_equal NewBase60.new("464").to_i, 14764
7
+ assert_not_equal NewBase60.new("464").to_i, 12345
8
8
  end
9
9
 
10
10
  def test_base60_to_date
11
- assert_equal New_base_60.new("464").to_date, Date.parse("2010/06/04")
12
- assert_not_equal New_base_60.new("464").to_date, Date.parse("2010/06/05")
11
+ assert_equal NewBase60.new("464").to_date, Date.parse("2010/06/04")
12
+ assert_not_equal NewBase60.new("464").to_date, Date.parse("2010/06/05")
13
13
  end
14
14
 
15
15
  def test_date_to_base60
16
- assert_equal Date.parse("2010/06/04").to_sxg, New_base_60.new("464").to_s
17
- assert_not_equal Date.parse("2010/06/05").to_sxg, New_base_60.new("464")
16
+ assert_equal Date.parse("2010/06/04").to_sxg, NewBase60.new("464").to_s
17
+ assert_not_equal Date.parse("2010/06/05").to_sxg, NewBase60.new("464")
18
18
  end
19
19
 
20
20
  def test_base10_to_base60
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: new_base_60
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease: false
4
+ hash: 31
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 3
10
- version: 1.0.3
9
+ - 4
10
+ version: 1.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shane Becker
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-16 00:00:00 -08:00
18
+ date: 2011-02-15 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 21
29
+ hash: 41
30
30
  segments:
31
31
  - 2
32
- - 6
32
+ - 9
33
33
  - 1
34
- version: 2.6.1
34
+ version: 2.9.1
35
35
  type: :development
36
36
  version_requirements: *id001
37
37
  description: "Handy Conversion Sexagesimal (base 60) for Short URLs\n\
@@ -58,8 +58,9 @@ files:
58
58
  - Rakefile
59
59
  - lib/new_base_60.rb
60
60
  - test/test_new_base_60.rb
61
+ - .gemtest
61
62
  has_rdoc: true
62
- homepage: http://github.com/veganstraightedge/New_base_60
63
+ homepage: http://github.com/veganstraightedge/new_base_60
63
64
  licenses: []
64
65
 
65
66
  post_install_message:
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  requirements: []
90
91
 
91
92
  rubyforge_project: new_base_60
92
- rubygems_version: 1.3.7
93
+ rubygems_version: 1.5.2
93
94
  signing_key:
94
95
  specification_version: 3
95
96
  summary: "Handy Conversion Sexagesimal (base 60) for Short URLs Cuts out ambiguous characters like: * l : lowercase l (looks like a 1 : one) * I : capital I (looks like a 1 : one) * O : capital O (looks like a 0 : zero) Based on work done by Tantek \xC3\x87elik : http://tantek.pbworks.com/New_base_60"