deflect 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +25 -0
- data/Rakefile +2 -0
- data/deflect.gemspec +23 -0
- data/lib/deflect.rb +21 -0
- data/lib/deflect/railtie.rb +7 -0
- data/lib/deflect/version.rb +3 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b5f1c3cb0cfdb99819ae1ef5e96a200ad43f432
|
4
|
+
data.tar.gz: 59475a7bf8edb1c5121e8dd74ac1aa8078c24e78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46208ea651f55c3004b0b345c198cf7339721a56422a6218aab172e85e0c10923de84ca870b8a1e9cae38953a17d60df8ca35cefd6438d2e7893c50305c74a3e
|
7
|
+
data.tar.gz: ebeaea4d703e618f29b9cc0598b4f0e7cc51e6f1b70620d9050309f24374bc5491d459aa70332a5d8ac1ebc1832fcb6869055e5b1a4bce0227ad6314802508e2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
2
|
+
Version 2, December 2004
|
3
|
+
|
4
|
+
Copyright (C) 2015 James Dabbs <jamesdabbs@gmail.com>
|
5
|
+
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
7
|
+
copies of this license document, and changing it is allowed as long
|
8
|
+
as the name is changed.
|
9
|
+
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
12
|
+
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Deflect
|
2
|
+
|
3
|
+
Do you ever write `Users.all` when you meant `User.all`? Happened to me once.
|
4
|
+
|
5
|
+

|
6
|
+
|
7
|
+
```
|
8
|
+
[1] pry(main)> Users.all
|
9
|
+
NameError: uninitialized constant Users
|
10
|
+
from (pry):1:in `__pry__'
|
11
|
+
[2] pry(main)> require "deflect"
|
12
|
+
=> true
|
13
|
+
[3] pry(main)> Users.all
|
14
|
+
Did you mean `User`?
|
15
|
+
User Load (1.5ms) SELECT "users".* FROM "users"
|
16
|
+
=> [#<User:0x007fa7b808c980
|
17
|
+
id: 1,
|
18
|
+
...
|
19
|
+
```
|
20
|
+
|
21
|
+
## FAQ
|
22
|
+
|
23
|
+
*Is this a good idea?*
|
24
|
+
|
25
|
+
One could argue that it's no worse of an idea than constant autoloading in the first place.
|
data/Rakefile
ADDED
data/deflect.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'deflect/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "deflect"
|
8
|
+
spec.version = Deflect::VERSION
|
9
|
+
spec.authors = ["James Dabbs"]
|
10
|
+
spec.email = ["jamesdabbs@gmail.com"]
|
11
|
+
spec.summary = %q{Automatically fix mis-pluralized model names}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "http://github.com/jamesdabbs/deflect"
|
14
|
+
spec.license = "WTFPL"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
data/lib/deflect.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "deflect/version"
|
2
|
+
|
3
|
+
module Deflect
|
4
|
+
def self.patch_plural_constant_lookup!
|
5
|
+
ActiveSupport::Dependencies.define_singleton_method :load_missing_constant do |from_mod, const_name|
|
6
|
+
begin
|
7
|
+
super from_mod, const_name
|
8
|
+
rescue NameError => e
|
9
|
+
singular = const_name.to_s.singularize
|
10
|
+
if const_name.to_s == singular
|
11
|
+
raise
|
12
|
+
else
|
13
|
+
Rails.logger.debug "Did you mean `#{singular}`?"
|
14
|
+
from_mod.const_get singular
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
require "deflect/railtie" if defined? Rails
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deflect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Dabbs
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Automatically fix mis-pluralized model names
|
42
|
+
email:
|
43
|
+
- jamesdabbs@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- deflect.gemspec
|
54
|
+
- lib/deflect.rb
|
55
|
+
- lib/deflect/railtie.rb
|
56
|
+
- lib/deflect/version.rb
|
57
|
+
homepage: http://github.com/jamesdabbs/deflect
|
58
|
+
licenses:
|
59
|
+
- WTFPL
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.4.5
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Automatically fix mis-pluralized model names
|
81
|
+
test_files: []
|