pluralize 0.1 → 0.2.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.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/.yardoc ADDED
Binary file
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 [name of plugin creator]
1
+ Copyright (c) 2009 Marcin Ciunelis
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,10 +1,20 @@
1
- = Pluralize - Better pluralization
1
+ == Pluralize - Better pluralization for non-english languages
2
2
 
3
- http://www.unicode.org/cldr/data/charts/supplemental/language_plural_rules.html
3
+ Languages vary in how they handle plurals of nouns or unit expressions ("hours", "meters", and so on). Some languages have two forms, like English; some languages have only a single form; and some languages have multiple forms.
4
4
 
5
- = Usage
5
+ Read more at: http://www.unicode.org/cldr/data/charts/supplemental/language_plural_rules.html
6
6
 
7
- === Configuration
7
+ == Installation
8
+
9
+ The gem is hosted on gemcutter, so if you haven’t already, add it as a gem source:
10
+
11
+ sudo gem sources -a http://gemcutter.org/
12
+
13
+ Then install the Formtastic gem:
14
+
15
+ sudo gem install pluralize
16
+
17
+ == Configuration
8
18
 
9
19
  ActiveSupport::Inflector.inflections do |inflect|
10
20
  inflect.proc :pl, lambda{|count, singular, inflections|
@@ -18,7 +28,7 @@ http://www.unicode.org/cldr/data/charts/supplemental/language_plural_rules.html
18
28
  }
19
29
 
20
30
  inflect.plural "chleb", :few => "chleby", :other => "chlebów", :proc => :pl
21
- inflect.plural "szklanka", :few => "szklanki", :other => "szklanek" # will user first defined proc
31
+ inflect.plural "szklanka", :few => "szklanki", :other => "szklanek" # use first defined proc
22
32
  inflect.plural "one potatoe",
23
33
  :two => "two potatoes",
24
34
  :three => "three potatoes",
@@ -41,5 +51,26 @@ http://www.unicode.org/cldr/data/charts/supplemental/language_plural_rules.html
41
51
  }
42
52
  end
43
53
 
54
+ == Usage
55
+
56
+ ActiveSupport::Inflector.pluralize("chleb", 1) # => chleb
57
+ ActiveSupport::Inflector.pluralize("chleb", 2) # => chleby
58
+ "chleb".pluralize # => chleby
59
+ ActiveSupport::Inflector.pluralize("chleb", 5) # => chlebów
60
+ ActiveSupport::Inflector.pluralize("one potatoe", 7) # => seven potatoes
61
+ ActiveSupport::Inflector.pluralize("one potatoe", 10) # => more!
62
+
63
+ # for other words it behaves like before
64
+ ActiveSupport::Inflector.pluralize("word") # => words
65
+ ActiveSupport::Inflector.pluralize("octopus") # => octopi
66
+ "person".pluralize # => people
67
+
68
+ #in your views
69
+
70
+ <%= pluralize(3, "chleb") %> # => chleby
71
+
72
+ == Author
73
+
74
+ Marcin Ciunelis marcin.ciunelis@gmail.com
44
75
 
45
76
  Copyright (c) 2009 G-Forces Polska, released under the MIT license
data/Rakefile CHANGED
@@ -1,38 +1,77 @@
1
+ require 'rubygems'
1
2
  require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
3
 
5
- desc 'Default: run unit tests.'
6
- task :default => :test
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "pluralize"
8
+ gem.summary = "Better pluralization for non-english languages"
9
+ gem.email = "marcin.ciunelis@gmail.com"
10
+ gem.homepage = "http://github.com/gforces/pluralize"
11
+ gem.authors = ["Marcin Ciunelis"]
12
+ gem.add_development_dependency "bacon", ">= 0"
13
+ gem.add_development_dependency "yard", ">= 0"
14
+ gem.add_development_dependency "activesupport", ">= 0"
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
+ end
7
20
 
8
- desc 'Test the pluralize plugin.'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
12
- t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:spec) do |spec|
23
+ spec.libs << 'lib' << 'spec'
24
+ spec.pattern = 'spec/**/*_spec.rb'
25
+ spec.verbose = true
14
26
  end
15
27
 
16
- desc 'Generate documentation for the pluralize plugin.'
17
- Rake::RDocTask.new(:rdoc) do |rdoc|
18
- rdoc.rdoc_dir = 'rdoc'
19
- rdoc.title = 'Pluralize'
20
- rdoc.options << '--line-numbers' << '--inline-source'
21
- rdoc.rdoc_files.include('README')
22
- rdoc.rdoc_files.include('lib/**/*.rb')
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |spec|
31
+ spec.libs << 'spec'
32
+ spec.pattern = 'spec/**/*_spec.rb'
33
+ spec.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
23
39
  end
24
40
 
41
+ task :spec => :check_dependencies
42
+
25
43
  begin
26
- require 'jeweler'
27
- Jeweler::Tasks.new do |gemspec|
28
- gemspec.name = "pluralize"
29
- gemspec.summary = "Language Plural Rules implementation"
30
- gemspec.email = "marcin.ciunelis@gmail.com"
31
- gemspec.homepage = "http://github.com/gforces/pluralize"
32
- gemspec.authors = ["Marcin Ciunelis"]
33
- gemspec.version = "0.1"
44
+ require 'reek/rake_task'
45
+ Reek::RakeTask.new do |t|
46
+ t.fail_on_error = true
47
+ t.verbose = false
48
+ t.source_files = 'lib/**/*.rb'
49
+ end
50
+ rescue LoadError
51
+ task :reek do
52
+ abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
53
+ end
54
+ end
55
+
56
+ begin
57
+ require 'roodi'
58
+ require 'roodi_task'
59
+ RoodiTask.new do |t|
60
+ t.verbose = false
34
61
  end
35
- Jeweler::GemcutterTasks.new
36
62
  rescue LoadError
37
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
63
+ task :roodi do
64
+ abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
65
+ end
66
+ end
67
+
68
+ task :default => :spec
69
+
70
+ begin
71
+ require 'yard'
72
+ YARD::Rake::YardocTask.new
73
+ rescue LoadError
74
+ task :yardoc do
75
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
76
+ end
38
77
  end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -1,3 +1,4 @@
1
+ require 'activesupport'
1
2
  require 'pluralize/active_support/inflector'
2
3
  require 'pluralize/action_view/helpers/text_helper'
3
4
  require 'pluralize/config/inflections'
@@ -11,8 +11,8 @@ module ActiveSupport
11
11
  if result == rule
12
12
  if replacement.has_key?(:proc) && replacement[:proc].is_a?(Proc)
13
13
  proc = replacement[:proc]
14
- elsif replacement.has_key?(:proc) && inflections.procs[replacement.has_key?(:proc).to_sym].is_a?(Proc)
15
- proc = inflections.procs[replacement.has_key?(:proc).to_sym]
14
+ elsif replacement.has_key?(:proc) && inflections.procs[replacement[:proc].to_sym].is_a?(Proc)
15
+ proc = inflections.procs[replacement[:proc].to_sym]
16
16
  elsif inflections.default_proc.is_a?(Proc)
17
17
  proc = inflections.default_proc
18
18
  end
@@ -32,10 +32,6 @@ module ActiveSupport
32
32
  class Inflections
33
33
  attr_reader :procs
34
34
 
35
- # def initialize
36
- # @plurals, @singulars, @uncountables, @humans, @procs = [], [], [], [], {}
37
- # end
38
-
39
35
  def proc(locale, proc)
40
36
  @procs = {} if @procs.nil?
41
37
  @procs[locale.to_sym] = proc
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{pluralize}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Marcin Ciunelis"]
12
+ s.date = %q{2009-10-29}
13
+ s.email = %q{marcin.ciunelis@gmail.com}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ ".yardoc",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/pluralize.rb",
27
+ "lib/pluralize/action_view/helpers/text_helper.rb",
28
+ "lib/pluralize/active_support/inflector.rb",
29
+ "lib/pluralize/config/inflections.rb",
30
+ "pluralize.gemspec",
31
+ "spec/config/inflections.rb",
32
+ "spec/pluralize_spec.rb",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/gforces/pluralize}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.5}
39
+ s.summary = %q{Better pluralization for non-english languages}
40
+ s.test_files = [
41
+ "spec/config/inflections.rb",
42
+ "spec/pluralize_spec.rb",
43
+ "spec/spec_helper.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<bacon>, [">= 0"])
52
+ s.add_development_dependency(%q<yard>, [">= 0"])
53
+ s.add_development_dependency(%q<activesupport>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<bacon>, [">= 0"])
56
+ s.add_dependency(%q<yard>, [">= 0"])
57
+ s.add_dependency(%q<activesupport>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<bacon>, [">= 0"])
61
+ s.add_dependency(%q<yard>, [">= 0"])
62
+ s.add_dependency(%q<activesupport>, [">= 0"])
63
+ end
64
+ end
65
+
@@ -10,7 +10,7 @@ ActiveSupport::Inflector.inflections do |inflect|
10
10
  }
11
11
 
12
12
  inflect.plural "chleb", :few => "chleby", :other => "chlebów", :proc => :pl
13
- inflect.plural "szklanka", :few => "szklanki", :other => "szklanek" # will user first defined proc
13
+ inflect.plural "szklanka", :few => "szklanki", :other => "szklanek" # use first defined proc
14
14
  inflect.plural "one potatoe",
15
15
  :two => "two potatoes",
16
16
  :three => "three potatoes",
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Pluralize" do
4
+ it "should pluralize polish word \"chleb\"" do
5
+ {
6
+ 0 => 'chlebów',
7
+ 1 => 'chleb',
8
+ 2 => 'chleby',
9
+ 3 => 'chleby',
10
+ 4 => 'chleby',
11
+ 5 => 'chlebów',
12
+ 6 => 'chlebów',
13
+ 11 => 'chlebów',
14
+ 22 => 'chleby',
15
+ 221 => 'chlebów'
16
+ }.each do |count, plural_form|
17
+ ActiveSupport::Inflector.pluralize("chleb", count).should.equal plural_form
18
+ end
19
+ end
20
+ it "should pluralize polish word \"szklanka\"" do
21
+ {
22
+ 0 => 'szklanek',
23
+ 1 => 'szklanka',
24
+ 2 => 'szklanki',
25
+ 3 => 'szklanki',
26
+ 4 => 'szklanki',
27
+ 5 => 'szklanek',
28
+ 6 => 'szklanek',
29
+ 11 => 'szklanek',
30
+ 22 => 'szklanki',
31
+ 221 => 'szklanek'
32
+ }.each do |count, plural_form|
33
+ ActiveSupport::Inflector.pluralize("szklanka", count).should.equal plural_form
34
+ end
35
+ end
36
+ it "should pluralize english word \"word\"" do
37
+ {
38
+ 0 => 'words',
39
+ 1 => 'words',
40
+ 2 => 'words',
41
+ 3 => 'words',
42
+ 4 => 'words',
43
+ 5 => 'words',
44
+ 6 => 'words',
45
+ 11 => 'words',
46
+ 22 => 'words',
47
+ 221 => 'words',
48
+ nil => 'words'
49
+ }.each do |count, plural_form|
50
+ ActiveSupport::Inflector.pluralize("word", count).should.equal plural_form
51
+ end
52
+ ActiveSupport::Inflector.pluralize("octopus").should.equal "octopi"
53
+ ActiveSupport::Inflector.pluralize("person").should.equal "people"
54
+ end
55
+
56
+ it "should pluralize strings" do
57
+ "chleb".pluralize.should.equal "chleby"
58
+ "chleb".pluralize(10).should.equal "chlebów"
59
+ end
60
+
61
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bacon'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ require 'pluralize'
7
+ require 'config/inflections'
8
+
9
+ Bacon.summary_on_exit
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluralize
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Ciunelis
@@ -9,10 +9,39 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-27 00:00:00 +01:00
12
+ date: 2009-10-29 00:00:00 +01:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bacon
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
+ - !ruby/object:Gem::Dependency
26
+ name: yard
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: activesupport
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
16
45
  description:
17
46
  email: marcin.ciunelis@gmail.com
18
47
  executables: []
@@ -20,22 +49,24 @@ executables: []
20
49
  extensions: []
21
50
 
22
51
  extra_rdoc_files:
52
+ - LICENSE
23
53
  - README.rdoc
24
54
  files:
25
- - MIT-LICENSE
55
+ - .document
56
+ - .gitignore
57
+ - .yardoc
58
+ - LICENSE
26
59
  - README.rdoc
27
60
  - Rakefile
28
- - init.rb
29
- - install.rb
61
+ - VERSION
30
62
  - lib/pluralize.rb
31
63
  - lib/pluralize/action_view/helpers/text_helper.rb
32
64
  - lib/pluralize/active_support/inflector.rb
33
65
  - lib/pluralize/config/inflections.rb
34
- - tasks/pluralize_tasks.rake
35
- - test/config/inflections.rb
36
- - test/pluralize_test.rb
37
- - test/test_helper.rb
38
- - uninstall.rb
66
+ - pluralize.gemspec
67
+ - spec/config/inflections.rb
68
+ - spec/pluralize_spec.rb
69
+ - spec/spec_helper.rb
39
70
  has_rdoc: true
40
71
  homepage: http://github.com/gforces/pluralize
41
72
  licenses: []
@@ -63,8 +94,8 @@ rubyforge_project:
63
94
  rubygems_version: 1.3.5
64
95
  signing_key:
65
96
  specification_version: 3
66
- summary: Language Plural Rules implementation
97
+ summary: Better pluralization for non-english languages
67
98
  test_files:
68
- - test/config/inflections.rb
69
- - test/pluralize_test.rb
70
- - test/test_helper.rb
99
+ - spec/config/inflections.rb
100
+ - spec/pluralize_spec.rb
101
+ - spec/spec_helper.rb
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'pluralize'
data/install.rb DELETED
@@ -1 +0,0 @@
1
- # Install hook code here
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :pluralize do
3
- # # Task goes here
4
- # end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PluralizeTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,3 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_support/test_case'
@@ -1 +0,0 @@
1
- # Uninstall hook code here