humanize 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
@@ -0,0 +1,18 @@
1
+ # Ordinali(z|s)e
2
+
3
+ From the creator who brought you the wildly popular [humanize](http://github.com/radar/humanize), comes ordinali(s|z)e!
4
+
5
+ # Install
6
+
7
+ sudo gem install ordinalize
8
+
9
+ # Usage
10
+
11
+ >> 1.ordinalize
12
+ => "first"
13
+
14
+ >> 1024.ordinalize
15
+ => "one thousand and twenty-fourth"
16
+
17
+ >> 1.ordinalise
18
+ => "first"
@@ -0,0 +1,71 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "humanize"
5
+ gem.summary = %Q{Generates long winded string versions of numbers}
6
+ gem.description = %Q{Generates long winded string versions of numbers}
7
+ gem.email = "radarlistener@gmail.com"
8
+ gem.homepage = "http://github.com/radar/"
9
+ gem.authors = ["Ryan Bigg"]
10
+ gem.add_development_dependency "rspec"
11
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
12
+ end
13
+ Jeweler::GemcutterTasks.new
14
+ rescue LoadError
15
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
16
+ end
17
+
18
+
19
+ begin
20
+ require 'spec'
21
+ rescue LoadError
22
+ require 'rubygems'
23
+ require 'spec'
24
+ end
25
+
26
+ require 'rake/rdoctask'
27
+ require 'spec/rake/spectask'
28
+ desc 'Default: run unit tests.'
29
+ task :default => :test
30
+
31
+ desc "Run the specs under spec"
32
+ Spec::Rake::SpecTask.new do |t|
33
+ t.spec_files = FileList['spec/**/*_spec.rb']
34
+ t.libs = %w(lib spec)
35
+ t.spec_opts << "-c"
36
+ t.ruby_opts << "-rubygems"
37
+ end
38
+
39
+ desc 'Generate documentation for the humanize plugin.'
40
+ Rake::RDocTask.new(:rdoc) do |rdoc|
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = 'ByStar'
43
+ rdoc.options << '--line-numbers' << '--inline-source'
44
+ rdoc.rdoc_files.include('README')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
47
+
48
+ task :bump => ["version:bump", :gemspec]
49
+
50
+ namespace :version do
51
+ task :read do
52
+ unless defined? GEM_VERSION
53
+ GEM_VERSION = File.read("VERSION")
54
+ end
55
+ end
56
+
57
+ task :bump => :read do
58
+ if ENV['VERSION']
59
+ GEM_VERSION.replace ENV['VERSION']
60
+ else
61
+ GEM_VERSION.sub!(/\d+$/) { |num| num.to_i + 1 }
62
+ end
63
+
64
+ File.open("VERSION", 'w') { |v| v.write GEM_VERSION }
65
+ end
66
+ end
67
+
68
+ task :release => :bump do
69
+ system %(git add VERSION *.gemspec && git commit -m "release v#{GEM_VERSION}")
70
+ system %(git tag -am "release v#{GEM_VERSION}" v#{GEM_VERSION})
71
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{humanize}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Bigg"]
12
+ s.date = %q{2009-12-26}
13
+ s.description = %q{Generates long winded string versions of numbers}
14
+ s.email = %q{radarlistener@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.markdown"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "README.markdown",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "humanize.gemspec",
25
+ "lib/ordinalize.rb",
26
+ "spec/ordinalize_spec.rb",
27
+ "spec/spec_helper.rb"
28
+ ]
29
+ s.homepage = %q{http://github.com/radar/}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.5}
33
+ s.summary = %q{Generates long winded string versions of numbers}
34
+ s.test_files = [
35
+ "spec/ordinalize_spec.rb",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+
39
+ if s.respond_to? :specification_version then
40
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
44
+ s.add_development_dependency(%q<rspec>, [">= 0"])
45
+ else
46
+ s.add_dependency(%q<rspec>, [">= 0"])
47
+ end
48
+ else
49
+ s.add_dependency(%q<rspec>, [">= 0"])
50
+ end
51
+ end
@@ -0,0 +1,49 @@
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError; end
4
+ require 'humanize'
5
+
6
+ module Ordinalize
7
+ def ordinalize
8
+ humanized = self.humanize
9
+ # 13-19
10
+ humanized += "th" if humanized =~ /teen$/
11
+
12
+ # 20, 30, 40, etc.
13
+ humanized.gsub!(/ty$/, 'tieth')
14
+
15
+ output = conversions[humanized] if conversions[humanized]
16
+ output ||= split if split != ""
17
+ output ||= humanized
18
+ end
19
+
20
+ alias_method :ordinalise, :ordinalize
21
+
22
+ def split
23
+ humanized = self.humanize
24
+ parts = humanized.split("-")
25
+ parts[-1] = conversions[parts.last]
26
+ parts.join("-")
27
+ end
28
+
29
+ def conversions
30
+ {
31
+ "one" => "first",
32
+ "two" => "second",
33
+ "three" => "third",
34
+ "four" => "fourth",
35
+ "five" => "fifth",
36
+ "six" => "sixth",
37
+ "seven" => "seventh",
38
+ "eight" => "eighth",
39
+ "nine" => "ninth",
40
+ "ten" => "tenth",
41
+ "eleven" => "eleventh",
42
+ "twelve" => "twelveth",
43
+ }
44
+ end
45
+ end
46
+
47
+ class Numeric
48
+ include Ordinalize
49
+ end
@@ -0,0 +1,44 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ordinalize" do
4
+ [
5
+ [1, "first"],
6
+ [2, "second"],
7
+ [3, "third"],
8
+ [4, "fourth"],
9
+ [5, "fifth"],
10
+ [6, "sixth"],
11
+ [7, "seventh"],
12
+ [8, "eighth"],
13
+ [9, "ninth"],
14
+ [10, "tenth"],
15
+ [11, "eleventh"],
16
+ [12, "twelveth"],
17
+ [13, "thirteenth"],
18
+ [14, "fourteenth"],
19
+ [15, "fifteenth"],
20
+ [16, "sixteenth"],
21
+ [17, "seventeenth"],
22
+ [18, "eighteenth"],
23
+ [19, "nineteenth"],
24
+ [20, "twentieth"],
25
+ [21, "twenty-first"],
26
+ [22, "twenty-second"],
27
+ [23, "twenty-third"],
28
+ [24, "twenty-fourth"],
29
+ [25, "twenty-fifth"],
30
+ [26, "twenty-sixth"],
31
+ [27, "twenty-seventh"],
32
+ [28, "twenty-eighth"],
33
+ [29, "twenty-ninth"],
34
+ [1024, "one thousand and twenty-fourth"]
35
+ ].each do |num, expected|
36
+ it "#{num} should be #{expected}" do
37
+ num.ordinalize.should eql(expected)
38
+ end
39
+ end
40
+
41
+ it "alternative spelling" do
42
+ 1.ordinalise.should eql("first")
43
+ end
44
+ end
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'ordinalize'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: humanize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Bigg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-26 00:00:00 +10:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Generates long winded string versions of numbers
26
+ email: radarlistener@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.markdown
33
+ files:
34
+ - .document
35
+ - .gitignore
36
+ - README.markdown
37
+ - Rakefile
38
+ - VERSION
39
+ - humanize.gemspec
40
+ - lib/ordinalize.rb
41
+ - spec/ordinalize_spec.rb
42
+ - spec/spec_helper.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/radar/
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --charset=UTF-8
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.5
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Generates long winded string versions of numbers
71
+ test_files:
72
+ - spec/ordinalize_spec.rb
73
+ - spec/spec_helper.rb