namecase 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,14 @@
1
1
  = NameCase CHANGELOG
2
2
 
3
+ == 1.1.0
4
+
5
+ * New Features:
6
+ * NameCase() function returns a namecased string
7
+ * NameCase.nc methind returns a namecased string
8
+
9
+ * Bug Fixes:
10
+ * Not using chars method, was breaking 1.8.7
11
+
3
12
  == 1.0.2
4
13
 
5
14
  * Updating NameCase to work with the new Edge Rails ActiveSupport::Multibye
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ LICENSE.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/namecase.rb
7
+ test/test_namecase.rb
data/README.txt CHANGED
@@ -2,24 +2,16 @@
2
2
 
3
3
  http://namecase.rubyforge.org/
4
4
 
5
- Version 1.0.2 - 2006/10/24
6
-
7
5
  == DESCRIPTION
8
6
 
9
7
  NameCase is a Ruby implementation of Lingua::EN::NameCase, a library for
10
8
  converting strings to be properly cased. This is good for converting
11
9
  denormalized data to human friendly data.
12
10
 
13
- Original version by Mark Summerfield <http://search.cpan.org/~summer/>
14
- Ruby port by Aaron Patterson <aaronp@rubyforge.org>
15
-
16
11
  * Example Usage
17
12
 
18
- NameCase is a subclass of Ruby's +String+, and can be used similarly:
19
-
20
- string = NameCase.new( string )
21
- puts string.nc
22
- puts string.nc!
13
+ NameCase("RON BURGUNDY") # => Ron Burgundy
14
+ NameCase("MCDONALDS") # => McDonalds
23
15
 
24
16
  * Acknowledgements
25
17
 
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'hoe'
3
+ require './lib/namecase.rb'
4
+
5
+ Hoe.new('namecase', NameCase::VERSION) do |p|
6
+ p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
7
+ end
@@ -1,18 +1,17 @@
1
- require 'version'
2
-
3
1
  class NameCase < String
2
+ VERSION = '1.1.0'
3
+
4
+ class << self
5
+ def nc string
6
+ new(string).nc
7
+ end
8
+ end
4
9
 
5
10
  # Returns a new +String+ with the contents properly namecased
6
11
  def nc
7
- if respond_to?(:chars)
8
- localstring = chars.downcase.to_s
9
- localstring.gsub!(/\b\w/) { |first| first.chars.upcase }
10
- localstring.gsub!(/\'\w\b/) { |c| c.chars.downcase } # Lowercase 's
11
- else
12
- localstring = downcase
13
- localstring.gsub!(/\b\w/) { |first| first.upcase }
14
- localstring.gsub!(/\'\w\b/) { |c| c.downcase } # Lowercase 's
15
- end
12
+ localstring = downcase
13
+ localstring.gsub!(/\b\w/) { |first| first.upcase }
14
+ localstring.gsub!(/\'\w\b/) { |c| c.downcase } # Lowercase 's
16
15
 
17
16
  if localstring =~ /\bMac[A-Za-z]{2,}[^aciozj]\b/ or localstring =~ /\bMc/
18
17
  localstring.gsub!(/\b(Ma?c)([A-Za-z]+)/) { |match| $1 + $2.capitalize }
@@ -59,3 +58,7 @@ class NameCase < String
59
58
  self.gsub!(self, self.nc)
60
59
  end
61
60
  end
61
+
62
+ def NameCase string
63
+ NameCase.new(string).nc
64
+ end
@@ -33,6 +33,8 @@ class TestNameCase < Test::Unit::TestCase
33
33
  @proper_names.each do |name|
34
34
  nc_name = NameCase.new(name)
35
35
  assert_equal(name, nc_name.downcase.nc)
36
+ assert_equal(name, NameCase.nc(name))
37
+ assert_equal(name, NameCase(name))
36
38
  end
37
39
  end
38
40
 
@@ -44,14 +46,10 @@ class TestNameCase < Test::Unit::TestCase
44
46
  end
45
47
 
46
48
  def test_namecase_multibyte
47
- String.class_eval { define_method(:chars) { self } }
48
-
49
49
  $KCODE = 'u'
50
50
 
51
51
  proper_cased = 'Iñtërnâtiônàlizætiøn'
52
52
  nc_name = NameCase.new(proper_cased)
53
- assert_equal(proper_cased, nc_name.downcase.nc!)
54
-
55
- String.class_eval { undef_method :chars }
53
+ assert_equal(proper_cased, nc_name.downcase.nc)
56
54
  end
57
55
  end
metadata CHANGED
@@ -1,61 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: namecase
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.0.2
7
- date: 2006-11-04 00:00:00 -08:00
8
- summary: "NameCase is a Ruby implementation of Lingua::EN::NameCase, a library for
9
- converting strings to be properly cased."
10
- require_paths:
11
- - lib
12
- - test
13
- email: aaronp@rubyforge.org
14
- homepage: http://namecase.rubyforge.org/
15
- rubyforge_project: namecase
16
- description: "NameCase is a Ruby implementation of Lingua::EN::NameCase, a library for
17
- converting strings to be properly cased. This is good for converting
18
- denormalized data to human friendly data."
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Patterson
19
8
  autorequire:
20
- default_executable:
21
9
  bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-05 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.7.0
24
+ version:
25
+ description: "NameCase is a Ruby implementation of Lingua::EN::NameCase, a library for converting strings to be properly cased. This is good for converting denormalized data to human friendly data. * Example Usage NameCase(\"RON BURGUNDY\") # => Ron Burgundy NameCase(\"MCDONALDS\") # => McDonalds * Acknowledgements This library is a port of the Perl library, and owes most of its functionality to the Perl version by Mark Summerfield. Any bugs in the Ruby port are my fault. * Author Original Version: Copyright (c) Mark Summerfield 1998-2002. <summer@perlpress.com> All Rights Reserved Ruby Version: Copyright (c) Aaron Patterson 2006 * License NameCase is distributed under the GPL license. Please see the LICENSE file."
26
+ email:
27
+ - aaronp@rubyforge.org
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ - LICENSE.txt
35
+ - Manifest.txt
36
+ - README.txt
37
+ files:
38
+ - History.txt
39
+ - LICENSE.txt
40
+ - Manifest.txt
41
+ - README.txt
42
+ - Rakefile
43
+ - lib/namecase.rb
44
+ - test/test_namecase.rb
22
45
  has_rdoc: true
23
- required_ruby_version: !ruby/object:Gem::Version::Requirement
46
+ homepage: " http://namecase.rubyforge.org/"
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --main
50
+ - README.txt
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
24
54
  requirements:
25
- -
26
- - ">"
27
- - !ruby/object:Gem::Version
28
- version: 0.0.0
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
29
58
  version:
30
- platform: ruby
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project: namecase
68
+ rubygems_version: 1.2.0
31
69
  signing_key:
32
- cert_chain:
33
- post_install_message:
34
- authors:
35
- - Aaron Patterson
36
- files:
37
- - README.txt
38
- - CHANGELOG.txt
39
- - LICENSE.txt
40
- - lib/namecase.rb
41
- - lib/version.rb
70
+ specification_version: 2
71
+ summary: NameCase is a Ruby implementation of Lingua::EN::NameCase, a library for converting strings to be properly cased
42
72
  test_files:
43
- - test/test_all.rb
44
- - test/test_namecase.rb
45
- - test/test_all.rb
46
- rdoc_options: []
47
- extra_rdoc_files: []
48
- executables: []
49
- extensions: []
50
- requirements: []
51
- dependencies:
52
- - !ruby/object:Gem::Dependency
53
- name: hoe
54
- version_requirement:
55
- version_requirements: !ruby/object:Gem::Version::Requirement
56
- requirements:
57
- -
58
- - ">="
59
- - !ruby/object:Gem::Version
60
- version: 1.1.2
61
- version:
73
+ - test/test_namecase.rb
@@ -1,3 +0,0 @@
1
- class NameCase < String
2
- Version = '1.0.2'
3
- end
@@ -1,2 +0,0 @@
1
- require 'test/unit'
2
- require 'test_namecase'