ordinalize_full 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad3aca4a46aa2509add50b4e3ccb3cc48c58059f
4
+ data.tar.gz: ff6d913c3efef11eb3f53fea9dea99fc553dedd5
5
+ SHA512:
6
+ metadata.gz: 6942fb0227b949b39f4882e74932c39d1b47c46e98d6e9e60afb5494a6af86d13ae27a1516b6af62e3cc2093389b66881cb1bd7cd427c7d770b34e9f5a9d3576
7
+ data.tar.gz: f05e00a98fc180c0ac7f5730ced2de96cccdbcce36904e5aa1f0e3f7e0ff2b6ba659eae7f7fda136d1aea8a8bc101d0c88c90edd8ddfd53008aee756fe77e79c
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1
5
+ notifications:
6
+ email:
7
+ on_success: always
8
+ on_failure: always
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ordinalize_full.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Cédric Félizard
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # OrdinalizeFull [![Build Status](https://travis-ci.org/infertux/ordinalize_full.svg?branch=master)](https://travis-ci.org/infertux/ordinalize_full) [![Dependency Status](https://gemnasium.com/infertux/ordinalize_full.svg)](https://gemnasium.com/infertux/ordinalize_full) [![Code Climate](https://codeclimate.com/github/infertux/ordinalize_full.png)](https://codeclimate.com/github/infertux/ordinalize_full)
2
+
3
+ Like Rails' [ordinalize](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-ordinalize) method but with the ability to return the ordinal string spelled out in full words such as _"first"_, _"second"_, _"third"_.
4
+
5
+ Features:
6
+
7
+ - i18n support
8
+ - doesn't monkey-patch
9
+ - easy to integrate with Rails but doesn't require Rails
10
+ - less than 25 lines of code
11
+
12
+ ## Usage
13
+
14
+ ### Monkey-patching `Integer` (like Rails does)
15
+
16
+ ```ruby
17
+ require "ordinalize_full/integer"
18
+
19
+ 42.ordinalize_in_full #=> "forty second"
20
+ 42.ordinalize_full #=> "forty second"
21
+ 42.ordinalize(in_full: true) #=> "forty second"
22
+
23
+ I18n.locale = :fr
24
+ 42.ordinalize_in_full #=> "quarante-deuxième"
25
+ ```
26
+
27
+ ### Without monkey-patching
28
+
29
+ ```ruby
30
+ require "ordinalize_full"
31
+
32
+ 42.ordinalize_in_full #=> NoMethodError: undefined method `ordinalize_in_full' for 42:Fixnum
33
+
34
+ class MyIntegerLikeClass; include OrdinalizeFull; def to_s; "42"; end; end #=> :to_s
35
+ MyIntegerLikeClass.new.ordinalize_in_full #=> "forty second"
36
+ ```
37
+
38
+ ## Limitations
39
+
40
+ - only works up to 100 (for now)
41
+ - locales only available in English and French (pull requests welcome!)
42
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.ruby_opts = "-w"
6
+ end
7
+
8
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ require "ordinalize_full"
2
+
3
+ class Integer
4
+ include OrdinalizeFull
5
+ end
6
+
@@ -0,0 +1,102 @@
1
+ en:
2
+ ordinalize_full:
3
+ n_1: first
4
+ n_2: second
5
+ n_3: third
6
+ n_4: fourth
7
+ n_5: fifth
8
+ n_6: sixth
9
+ n_7: seventh
10
+ n_8: eighth
11
+ n_9: ninth
12
+ n_10: tenth
13
+ n_11: eleventh
14
+ n_12: twelfth
15
+ n_13: thirteenth
16
+ n_14: fourteenth
17
+ n_15: fifteenth
18
+ n_16: sixteenth
19
+ n_17: seventeenth
20
+ n_18: eighteenth
21
+ n_19: nineteenth
22
+ n_20: twentieth
23
+ n_21: twenty first
24
+ n_22: twenty second
25
+ n_23: twenty third
26
+ n_24: twenty fourth
27
+ n_25: twenty fifth
28
+ n_26: twenty sixth
29
+ n_27: twenty seventh
30
+ n_28: twenty eighth
31
+ n_29: twenty ninth
32
+ n_30: thirtieth
33
+ n_31: thirty first
34
+ n_32: thirty second
35
+ n_33: thirty third
36
+ n_34: thirty fourth
37
+ n_35: thirty fifth
38
+ n_36: thirty sixth
39
+ n_37: thirty seventh
40
+ n_38: thirty eighth
41
+ n_39: thirty ninth
42
+ n_40: fortieth
43
+ n_41: forty first
44
+ n_42: forty second
45
+ n_43: forty third
46
+ n_44: forty fourth
47
+ n_45: forty fifth
48
+ n_46: forty sixth
49
+ n_47: forty seventh
50
+ n_48: forty eighth
51
+ n_49: forty ninth
52
+ n_50: fiftieth
53
+ n_51: fifty first
54
+ n_52: fifty second
55
+ n_53: fifty third
56
+ n_54: fifty fourth
57
+ n_55: fifty fifth
58
+ n_56: fifty sixth
59
+ n_57: fifty seventh
60
+ n_58: fifty eighth
61
+ n_59: fifty ninth
62
+ n_60: sixtieth
63
+ n_61: sixty first
64
+ n_62: sixty second
65
+ n_63: sixty third
66
+ n_64: sixty fourth
67
+ n_65: sixty fifth
68
+ n_66: sixty sixth
69
+ n_67: sixty seventh
70
+ n_68: sixty eighth
71
+ n_69: sixty ninth
72
+ n_70: seventieth
73
+ n_71: seventy first
74
+ n_72: seventy second
75
+ n_73: seventy third
76
+ n_74: seventy fourth
77
+ n_75: seventy fifth
78
+ n_76: seventy sixth
79
+ n_77: seventy seventh
80
+ n_78: seventy eighth
81
+ n_79: seventy ninth
82
+ n_80: eightieth
83
+ n_81: eighty first
84
+ n_82: eighty second
85
+ n_83: eighty third
86
+ n_84: eighty fourth
87
+ n_85: eighty fifth
88
+ n_86: eighty sixth
89
+ n_87: eighty seventh
90
+ n_88: eighty eighth
91
+ n_89: eighty ninth
92
+ n_90: ninetieth
93
+ n_91: ninety first
94
+ n_92: ninety second
95
+ n_93: ninety third
96
+ n_94: ninety fourth
97
+ n_95: ninety fifth
98
+ n_96: ninety sixth
99
+ n_97: ninety seventh
100
+ n_98: ninety eighth
101
+ n_99: ninety ninth
102
+ n_100: one hundredth
@@ -0,0 +1,102 @@
1
+ fr:
2
+ ordinalize_full:
3
+ n_1: premier
4
+ n_2: deuxième
5
+ n_3: troisième
6
+ n_4: quatrième
7
+ n_5: cinquième
8
+ n_6: sixième
9
+ n_7: septième
10
+ n_8: huitième
11
+ n_9: neuvième
12
+ n_10: dixième
13
+ n_11: onzième
14
+ n_12: douzième
15
+ n_13: treizième
16
+ n_14: quatorzième
17
+ n_15: quinzième
18
+ n_16: seizième
19
+ n_17: dix-septième
20
+ n_18: dix-huitième
21
+ n_19: dix-neuvième
22
+ n_20: vingtième
23
+ n_21: vingt-et-unième
24
+ n_22: vingt-deuxième
25
+ n_23: vingt-troisième
26
+ n_24: vingt-quatrième
27
+ n_25: vingt-cinquième
28
+ n_26: vingt-sixième
29
+ n_27: vingt-septième
30
+ n_28: vingt-huitième
31
+ n_29: vingt-neuvième
32
+ n_30: trentième
33
+ n_31: trente-et-unième
34
+ n_32: trente-deuxième
35
+ n_33: trente-troisième
36
+ n_34: trente-quatrième
37
+ n_35: trente-cinquième
38
+ n_36: trente-sixième
39
+ n_37: trente-septième
40
+ n_38: trente-huitième
41
+ n_39: trente-neuvième
42
+ n_40: quarantième
43
+ n_41: quarante-et-unième
44
+ n_42: quarante-deuxième
45
+ n_43: quarante-troisième
46
+ n_44: quarante-quatrième
47
+ n_45: quarante-cinquième
48
+ n_46: quarante-sixième
49
+ n_47: quarante-septième
50
+ n_48: quarante-huitième
51
+ n_49: quarante-neuvième
52
+ n_50: cinquantième
53
+ n_51: cinquante-et-unième
54
+ n_52: cinquante-deuxième
55
+ n_53: cinquante-troisième
56
+ n_54: cinquante-quatrième
57
+ n_55: cinquante-cinquième
58
+ n_56: cinquante-sixième
59
+ n_57: cinquante-septième
60
+ n_58: cinquante-huitième
61
+ n_59: cinquante-neuvième
62
+ n_60: soixantième
63
+ n_61: soixante-et-unième
64
+ n_62: soixante-deuxième
65
+ n_63: soixante-troisième
66
+ n_64: soixante-quatrième
67
+ n_65: soixante-cinquième
68
+ n_66: soixante-sixième
69
+ n_67: soixante-septième
70
+ n_68: soixante-huitième
71
+ n_69: soixante-neuvième
72
+ n_70: soixante-dixième
73
+ n_71: soixante-et-onzième
74
+ n_72: soixante-douzième
75
+ n_73: soixante-treizième
76
+ n_74: soixante-quatorzième
77
+ n_75: soixante-quinzième
78
+ n_76: soixante-seizième
79
+ n_77: soixante-dix-septième
80
+ n_78: soixante-dix-huitième
81
+ n_79: soixante-dix-neuvième
82
+ n_80: quatre-vingtième
83
+ n_81: quatre-vingt-unième
84
+ n_82: quatre-vingt-deuxième
85
+ n_83: quatre-vingt-troisième
86
+ n_84: quatre-vingt-quatrième
87
+ n_85: quatre-vingt-cinquième
88
+ n_86: quatre-vingt-sixième
89
+ n_87: quatre-vingt-septième
90
+ n_88: quatre-vingt-huitième
91
+ n_89: quatre-vingt-neuvième
92
+ n_90: quatre-vingt-dixième
93
+ n_91: quatre-vingt-onzième
94
+ n_92: quatre-vingt-douzième
95
+ n_93: quatre-vingt-treizième
96
+ n_94: quatre-vingt-quatorzième
97
+ n_95: quatre-vingt-quinzième
98
+ n_96: quatre-vingt-seizième
99
+ n_97: quatre-vingt-dix-septième
100
+ n_98: quatre-vingt-dix-huitième
101
+ n_99: quatre-vingt-dix-neuvième
102
+ n_100: centième
@@ -0,0 +1,21 @@
1
+ require "i18n"
2
+
3
+ module OrdinalizeFull
4
+ I18n.load_path << Dir[File.join(__dir__, "ordinalize_full/locales/*.yml")]
5
+
6
+ def ordinalize(in_full: false)
7
+ if in_full
8
+ self.ordinalize_in_full
9
+ else
10
+ require "active_support/inflector"
11
+ ActiveSupport::Inflector.ordinalize(self)
12
+ end
13
+ end
14
+
15
+ def ordinalize_in_full
16
+ I18n.t("ordinalize_full.n_#{self}")
17
+ end
18
+
19
+ alias_method :ordinalize_full, :ordinalize_in_full
20
+ end
21
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ordinalize_full"
7
+ spec.version = "1.0.0"
8
+ spec.authors = ["Cédric Félizard"]
9
+ spec.email = ["cedric@felizard.fr"]
10
+ spec.summary = %q{Turns a number into an ordinal string such as first, second, third or 1st, 2nd, 3rd.}
11
+ spec.description = spec.summary
12
+ spec.homepage = "https://github.com/infertux/ordinalize_full"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "i18n", "~> 0.5"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", "~> 3"
25
+ end
@@ -0,0 +1,22 @@
1
+ require "ordinalize_full/integer"
2
+
3
+ describe OrdinalizeFull do
4
+ describe "#ordinalize_in_full" do
5
+ context "with the default locale (:en)" do
6
+ specify { expect(1.ordinalize_in_full).to eq("first") }
7
+ specify { expect(42.ordinalize_in_full).to eq("forty second") }
8
+ end
9
+
10
+ context "with locale = :fr" do
11
+ before { I18n.locale = :fr }
12
+
13
+ specify { expect(1.ordinalize_in_full).to eq("premier") }
14
+ specify { expect(42.ordinalize_in_full).to eq("quarante-deuxième") }
15
+ end
16
+ end
17
+
18
+ describe "#ordinalize_full" do
19
+ specify { expect(1.ordinalize_full).to eq(1.ordinalize_in_full) }
20
+ end
21
+ end
22
+
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ordinalize_full
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Cédric Félizard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: i18n
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3'
69
+ description: Turns a number into an ordinal string such as first, second, third or
70
+ 1st, 2nd, 3rd.
71
+ email:
72
+ - cedric@felizard.fr
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/ordinalize_full.rb
84
+ - lib/ordinalize_full/integer.rb
85
+ - lib/ordinalize_full/locales/en.yml
86
+ - lib/ordinalize_full/locales/fr.yml
87
+ - ordinalize_full.gemspec
88
+ - spec/ordinalize_full_spec.rb
89
+ homepage: https://github.com/infertux/ordinalize_full
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Turns a number into an ordinal string such as first, second, third or 1st,
113
+ 2nd, 3rd.
114
+ test_files:
115
+ - spec/ordinalize_full_spec.rb