i18n-inflector-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -0
- data/.rspec +1 -0
- data/.yardopts +10 -0
- data/ChangeLog +185 -0
- data/Gemfile +17 -0
- data/LGPL-LICENSE +169 -0
- data/Manifest.txt +23 -0
- data/README.rdoc +154 -0
- data/Rakefile +81 -0
- data/docs/COPYING +57 -0
- data/docs/HISTORY +13 -0
- data/docs/LEGAL +11 -0
- data/docs/LGPL-LICENSE +166 -0
- data/docs/TODO +3 -0
- data/docs/rdoc.css +20 -0
- data/i18n-inflector-rails.gemspec +35 -0
- data/init.rb +1 -0
- data/lib/i18n-inflector-rails.rb +25 -0
- data/lib/i18n-inflector-rails/errors.rb +23 -0
- data/lib/i18n-inflector-rails/inflector.rb +185 -0
- data/lib/i18n-inflector-rails/railtie.rb +27 -0
- data/lib/i18n-inflector-rails/version.rb +30 -0
- data/spec/inflector_spec.rb +201 -0
- data/spec/spec_helper.rb +2 -0
- metadata +260 -0
- metadata.gz.sig +0 -0
data/Rakefile
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "lib")
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler/setup'
|
8
|
+
|
9
|
+
require "rake"
|
10
|
+
require "rake/clean"
|
11
|
+
|
12
|
+
require "fileutils"
|
13
|
+
require "i18n-inflector"
|
14
|
+
|
15
|
+
require 'i18n-inflector-rails/version'
|
16
|
+
require 'hoe'
|
17
|
+
|
18
|
+
task :default => [:test]
|
19
|
+
|
20
|
+
desc "install by setup.rb"
|
21
|
+
task :install do
|
22
|
+
sh "sudo ruby setup.rb install"
|
23
|
+
end
|
24
|
+
|
25
|
+
### Gem
|
26
|
+
|
27
|
+
Hoe.plugin :bundler
|
28
|
+
Hoe.plugin :yard
|
29
|
+
|
30
|
+
Hoe.spec 'i18n-inflector-rails' do
|
31
|
+
developer I18n::Inflector::Rails::DEVELOPER, I18n::Inflector::Rails::EMAIL
|
32
|
+
|
33
|
+
self.version = I18n::Inflector::Rails::VERSION
|
34
|
+
self.rubyforge_name = I18n::Inflector::Rails::NAME
|
35
|
+
self.summary = I18n::Inflector::Rails::SUMMARY
|
36
|
+
self.description = I18n::Inflector::Rails::DESCRIPTION
|
37
|
+
self.url = I18n::Inflector::Rails::URL
|
38
|
+
|
39
|
+
self.remote_rdoc_dir = ''
|
40
|
+
self.rsync_args << '--chmod=a+rX'
|
41
|
+
self.readme_file = 'README.rdoc'
|
42
|
+
self.history_file = 'docs/HISTORY'
|
43
|
+
|
44
|
+
extra_deps << ['i18n-inflector', '~> 2.0.0'] <<
|
45
|
+
['railties', '~> 3.0.0'] <<
|
46
|
+
['actionpack', '~> 3.0.0']
|
47
|
+
extra_dev_deps << ['rspec', '>= 2.3.0'] <<
|
48
|
+
['yard', '>= 0.6.4'] <<
|
49
|
+
['bundler', '>= 1.0.7'] <<
|
50
|
+
['hoe-bundler', '>= 1.0.0'] <<
|
51
|
+
['hoe-yard', '>= 0.1.2']
|
52
|
+
end
|
53
|
+
|
54
|
+
task 'Manifest.txt' do
|
55
|
+
puts 'generating Manifest.txt from git'
|
56
|
+
sh %{git ls-files | grep -v gitignore > Manifest.txt}
|
57
|
+
sh %{git add Manifest.txt}
|
58
|
+
end
|
59
|
+
|
60
|
+
task 'ChangeLog' do
|
61
|
+
sh %{git log > ChangeLog}
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Fix documentation's file permissions"
|
65
|
+
task :docperm do
|
66
|
+
sh %{chmod -R a+rX doc}
|
67
|
+
end
|
68
|
+
|
69
|
+
### Sign & Publish
|
70
|
+
|
71
|
+
desc "Create signed tag in Git"
|
72
|
+
task :tag do
|
73
|
+
sh %{git tag -s v#{I18n::Inflector::Rails::VERSION} -m 'version #{I18n::Inflector::Rails::VERSION}'}
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "Create external GnuPG signature for Gem"
|
77
|
+
task :gemsign do
|
78
|
+
sh %{gpg -u #{I18n::Inflector::Rails::EMAIL} -ab pkg/#{I18n::Inflector::Rails::NAME}-#{I18n::Inflector::Rails::VERSION}.gem \
|
79
|
+
-o pkg/#{I18n::Inflector::Rails::NAME}-#{I18n::Inflector::Rails::VERSION}.gem.sig}
|
80
|
+
end
|
81
|
+
|
data/docs/COPYING
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
i18n-inflector-rails is copyrighted free software owned by Paweł Wilk (pw@gnu.org). The Owner of this software permits you to redistribute and/or modify the software under either the terms of the LGPL version 3 (see the file {file:LGPL-LICENSE LGPL-LICENSE}), or the conditions below ("Ruby License").
|
2
|
+
|
3
|
+
== 1.
|
4
|
+
|
5
|
+
You may make and give away verbatim copies of the source form of this software without restriction, provided that you retain ALL of the
|
6
|
+
original copyright notices and associated disclaimers.
|
7
|
+
|
8
|
+
== 2.
|
9
|
+
|
10
|
+
You may modify your copy of the software in any way, provided that you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said
|
13
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
14
|
+
the author to include your modifications in the software.
|
15
|
+
|
16
|
+
b) use the modified software only within your corporation or
|
17
|
+
organization.
|
18
|
+
|
19
|
+
c) give non-standard binaries non-standard names, with
|
20
|
+
instructions on where to get the original software distribution.
|
21
|
+
|
22
|
+
d) make other distribution arrangements with the Owner.
|
23
|
+
|
24
|
+
== 3.
|
25
|
+
|
26
|
+
You may distribute the software in object code or binary form, provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in a manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the Owner.
|
39
|
+
|
40
|
+
== 4.
|
41
|
+
|
42
|
+
You may modify and include parts of the software into any other software (possibly commercial), provided you comply with the terms in
|
43
|
+
Sections 1, 2, and 3 above. But some files in the distribution are not written by the Owner, so they may be made available to you
|
44
|
+
under different terms.
|
45
|
+
|
46
|
+
For the list of those files and their copying conditions, see the
|
47
|
+
file LEGAL.
|
48
|
+
|
49
|
+
== 5.
|
50
|
+
|
51
|
+
The scripts and library files supplied as input to or produced as output from the software do not automatically fall under the
|
52
|
+
copyright of the software, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this software.
|
53
|
+
|
54
|
+
== 6.
|
55
|
+
|
56
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
57
|
+
|
data/docs/HISTORY
ADDED
data/docs/LEGAL
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
LEGAL NOTICE INFORMATION
|
2
|
+
------------------------
|
3
|
+
|
4
|
+
i18n-inflector-rails is Copyright (C) 2011 by Paweł Wilk.
|
5
|
+
|
6
|
+
i18n-inflector-rails is copyrighted software owned by Paweł Wilk
|
7
|
+
(pw@gnu.org). You may redistribute and/or modify this
|
8
|
+
software as long as you comply with either the terms of the LGPL
|
9
|
+
(see the file {file:LGPL-LICENSE}),
|
10
|
+
or Ruby's license (see the file {file:COPYING}).
|
11
|
+
|
data/docs/LGPL-LICENSE
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
|
2
|
+
= GNU LESSER GENERAL PUBLIC LICENSE
|
3
|
+
Version 3, 29 June 2007
|
4
|
+
|
5
|
+
Copyright (C) 2007 Free Software Foundation, Inc. < http://fsf.org/ >
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
7
|
+
of this license document, but changing it is not allowed.
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
=== 0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
=== 1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
=== 2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
=== 3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
=== 4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
=== 5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
=== 6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
166
|
+
|
data/docs/TODO
ADDED
data/docs/rdoc.css
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
@import "rdoc_base.css";
|
2
|
+
|
3
|
+
#documentation > ul:first-of-type {
|
4
|
+
padding-bottom: 2em;
|
5
|
+
padding-top: 1.5em;
|
6
|
+
background-position: 20em 0%;
|
7
|
+
background-repeat: no-repeat;
|
8
|
+
}
|
9
|
+
|
10
|
+
#documentation .method-description > p:first-of-type + p {
|
11
|
+
margin-top: 0.5em;
|
12
|
+
}
|
13
|
+
|
14
|
+
#documentation .method-description > ul {
|
15
|
+
margin-left: 1.2em;
|
16
|
+
}
|
17
|
+
|
18
|
+
#documentation .method-description > p + ul {
|
19
|
+
margin-left: 1.8em;
|
20
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# This is just a helper file for those including directly from sources.
|
4
|
+
# Real building follows the instructions in the hoe section of Rakefile.
|
5
|
+
|
6
|
+
lib = File.expand_path('../lib/', __FILE__)
|
7
|
+
$:.unshift lib unless $:.include?(lib)
|
8
|
+
require 'i18n-inflector-rails/version'
|
9
|
+
|
10
|
+
Gem::Specification.new do |s|
|
11
|
+
s.name = I18n::Inflector::Rails::NAME
|
12
|
+
s.version = I18n::Inflector::Rails::VERSION
|
13
|
+
s.authors = [I18n::Inflector::Rails::DEVELOPER]
|
14
|
+
s.email = I18n::Inflector::Rails::EMAIL
|
15
|
+
s.homepage = I18n::Inflector::Rails::URL
|
16
|
+
s.summary = I18n::Inflector::Rails::SUMMARY
|
17
|
+
s.description = I18n::Inflector::Rails::DESCRIPTION
|
18
|
+
|
19
|
+
s.files = Dir.glob("{ci,lib,spec,docs}/**/**") + %w(init.rb Gemfile .rspec .yardopts README.rdoc LGPL-LICENSE ChangeLog Manifest.txt)
|
20
|
+
s.extra_rdoc_files = ["README.rdoc", "docs/HISTORY", "docs/LGPL-LICENSE", "docs/COPYING"]
|
21
|
+
s.rdoc_options = ["--main", "README.rdoc", "--charset=UTF-8"]
|
22
|
+
s.platform = Gem::Platform::RUBY
|
23
|
+
s.require_path = 'lib'
|
24
|
+
s.rubyforge_project = '[none]'
|
25
|
+
s.required_rubygems_version = '>= 1.3.5'
|
26
|
+
s.specification_version = 3
|
27
|
+
|
28
|
+
s.add_dependency 'i18n-inflector', '~> 2.0.0'
|
29
|
+
s.add_dependency 'railties', '~> 3.0.0'
|
30
|
+
s.add_dependency 'actionpack', '~> 3.0.0'
|
31
|
+
s.add_development_dependency 'rspec', '>= 2.3.0'
|
32
|
+
s.add_development_dependency 'yard', '>= 1.0.7'
|
33
|
+
s.add_development_dependency 'hoe-bundler', '>= 1.0.0'
|
34
|
+
s.add_development_dependency 'hoe-yard', '>= 0.1.2'
|
35
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'i18n-inflector-rails'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'i18n-inflector'
|
4
|
+
require 'i18n-inflector-rails/version'
|
5
|
+
require 'i18n-inflector-rails/errors'
|
6
|
+
require 'i18n-inflector-rails/inflector'
|
7
|
+
|
8
|
+
if defined? Rails::Engine
|
9
|
+
|
10
|
+
require 'i18n-inflector-rails/railtie'
|
11
|
+
|
12
|
+
else
|
13
|
+
|
14
|
+
require 'action_controller' if not defined? ActionController::Base
|
15
|
+
require 'action_view' if not defined? ActionView::Base
|
16
|
+
|
17
|
+
ActionController::Base.send(:extend, I18n::Inflector::Rails::ClassMethods)
|
18
|
+
ActionController::Base.send(:include, I18n::Inflector::Rails::InstanceMethods)
|
19
|
+
ActionController::Base.send(:include, I18n::Inflector::Rails::InflectedTranslate)
|
20
|
+
|
21
|
+
if ActionController::Base.respond_to?(:helper_method)
|
22
|
+
ActionController::Base.helper_method :translate
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Author:: Paweł Wilk (mailto:pw@gnu.org)
|
4
|
+
# Copyright:: (c) 2011 by Paweł Wilk
|
5
|
+
# License:: This program is licensed under the terms of {file:LGPL-LICENSE GNU Lesser General Public License} or {file:COPYING Ruby License}.
|
6
|
+
#
|
7
|
+
# This file contains error reporting classes for I18n::Backend::Inflector module.
|
8
|
+
|
9
|
+
module I18n
|
10
|
+
module Inflector
|
11
|
+
module Rails
|
12
|
+
|
13
|
+
class BadInflectionMethod < I18n::ArgumentError
|
14
|
+
attr_reader :assignment
|
15
|
+
def initialize(assignment)
|
16
|
+
@assignment = assignment
|
17
|
+
super "The given assignment is invalid: #{assignment}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|