memoized_inflectors 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +32 -0
- data/lib/memoized_inflectors/version.rb +3 -0
- data/lib/memoized_inflectors.rb +31 -0
- data/lib/tasks/memoized_inflectors_tasks.rake +4 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e239925a776420fdcb404d09ebcaa907faf1b494
|
4
|
+
data.tar.gz: a7101dd62be535f34c79bd4edd8d307c8ae13c93
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ed866e06bd9e3c445c47229fd4a575243f2658cba5cd29b494161ada6de0931167c41b96f5bb53098c284fa6620f33b5ae6b4742260de9c80b16ba8e1383c86
|
7
|
+
data.tar.gz: 7fe0daceb5232494175916c7fd54ec6ce98bd43a9f3ea2064557b3f533d90c89702e555518bcd753274eb38e0477aa52ed659a3d8290eaf1e531842c38ca6afb
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 Andrew Ogzewalla
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'MemoizedInflectors'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "active_support"
|
2
|
+
require "active_support/inflector"
|
3
|
+
require "active_support/core_ext/string"
|
4
|
+
|
5
|
+
module MemoizedInflectors
|
6
|
+
INFLECTOR_METHODS = [
|
7
|
+
:camelize, :classify, :constantize, :dasherize, :deconstantize, :demodulize, :foreign_key,
|
8
|
+
:humanize, :inflections, :ordinal, :ordinalize, :parameterize, :pluralize, :safe_constantize,
|
9
|
+
:singularize, :tableize, :titleize, :transliterate, :underscore
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
def self.prepended(klass)
|
13
|
+
klass.class_eval do
|
14
|
+
@memoized_inflectors = {}
|
15
|
+
INFLECTOR_METHODS.each do |inflector_name|
|
16
|
+
unless instance_variable_get("@#{ inflector_name }")
|
17
|
+
@memoized_inflectors[inflector_name] = instance_variable_set("@#{ inflector_name }", {})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
INFLECTOR_METHODS.each do |inflector_name|
|
24
|
+
define_method inflector_name do
|
25
|
+
memoized_inflections = self.class.instance_variable_get("@#{ inflector_name }")
|
26
|
+
memoized_inflections.has_key?(self) ? memoized_inflections[self] : memoized_inflections[self] = super()
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
String.send(:prepend, MemoizedInflectors)
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: memoized_inflectors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Ogzewalla
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
description: |
|
28
|
+
Memoizes inflected strings.
|
29
|
+
email:
|
30
|
+
- andyogzewalla@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- lib/memoized_inflectors/version.rb
|
36
|
+
- lib/memoized_inflectors.rb
|
37
|
+
- lib/tasks/memoized_inflectors_tasks.rake
|
38
|
+
- MIT-LICENSE
|
39
|
+
- Rakefile
|
40
|
+
homepage: https://github.com/WizardOfOgz/memoized_inflectors
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.0.4
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Memoizes inflected strings.
|
64
|
+
test_files: []
|