latent_object_detector 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CODE_OF_CONDUCT.md +12 -0
- data/README.md +2 -2
- data/Rakefile +2 -0
- data/TODO.md +3 -1
- data/lib/latent_object_detector.rb +13 -7
- data/lib/latent_object_detector/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaede2b47cdb4a9ee894f0fd26292c7c54379676
|
4
|
+
data.tar.gz: bb215367b79908f5d8778762bd876d9360dccde7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cef4cd287cc97265f164979f5f598860596bae89dd631293f00fedc0774728022ebc4fb0925abab9bd826e3eb4919ae9b64a017250bd53c40f89eb68b1a40c7
|
7
|
+
data.tar.gz: f6d464149a62894c98cbcf4d6e2b779c18d8f2f9571d16d247a060aa237c698551d9d303baf4da11ce0e390fd2ca4248ad4f3ae75cee45187347d1a6643ca354
|
data/.travis.yml
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
## Version 0.4
|
3
|
+
|
4
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
5
|
+
|
6
|
+
If any participant in this project has issues or takes exception with a contribution, they are obligated to provide constructive feedback and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
7
|
+
|
8
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
9
|
+
|
10
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
11
|
+
|
12
|
+
We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, ability or disability, ethnicity, religion, or level of experience.
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[<img src="https://secure.travis-ci.org/kerrizor/latent_object_detector.png" />](http://travis-ci.org/kerrizor/latent_object_detector)
|
4
4
|
|
5
|
-
Based on an original idea from
|
5
|
+
Based on an original idea from @bantik, this gem looks at the methods defined on an object and looks for repeated words contained in the method names, as this can sometimes illuminate latent objects, concepts, or relationships that don't currently exist in the code (but should.)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
```
|
23
|
-
d = LatentObjectDetector.for(User)
|
23
|
+
d = LatentObjectDetector::Detector.for(User)
|
24
24
|
d.potential_objects
|
25
25
|
=> ["password", "token", "remember"]
|
26
26
|
d.suspicious_methods
|
data/Rakefile
CHANGED
data/TODO.md
CHANGED
@@ -3,5 +3,7 @@ TODO
|
|
3
3
|
|
4
4
|
Next steps and ideas for more exploration
|
5
5
|
|
6
|
-
+ use stemming and Levenshtein distances to find non-exact matches
|
6
|
+
+ use stemming, Hamming, and/or Levenshtein distances to find non-exact matches
|
7
7
|
+ scan comments for matching words as well
|
8
|
+
+ create a report version of the output
|
9
|
+
+ scan across a series of classes and compare
|
@@ -13,12 +13,16 @@ module LatentObjectDetector
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def suspicious_methods
|
16
|
-
|
16
|
+
@suspicious_methods ||=
|
17
|
+
methods_owned_by_klass.select{ |m| (words_in_method(m.to_s) & potential_objects).size > 0 }
|
17
18
|
end
|
18
19
|
|
19
20
|
def potential_objects
|
20
|
-
|
21
|
-
|
21
|
+
@potential_objects ||=
|
22
|
+
begin
|
23
|
+
common_words = find_common_words_in(hash_of_words_used_in_methods)
|
24
|
+
words_used_more_than_twice(common_words)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
private
|
@@ -27,10 +31,11 @@ module LatentObjectDetector
|
|
27
31
|
end
|
28
32
|
|
29
33
|
def hash_of_words_used_in_methods
|
30
|
-
|
34
|
+
@hash_of_words_used_in_methods ||=
|
35
|
+
methods_owned_by_klass.inject({}) do |hash, method|
|
31
36
|
hash[method] = words_in_method(method)
|
32
37
|
hash
|
33
|
-
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
def find_common_words_in(hash_of_words = hash_of_words_used_in_methods)
|
@@ -46,11 +51,12 @@ module LatentObjectDetector
|
|
46
51
|
end
|
47
52
|
|
48
53
|
def methods_owned_by_klass
|
49
|
-
|
54
|
+
@methods_owned_by_klass ||=
|
55
|
+
all_instance_methods_of_klass.select{ |method| method_is_owned_by_klass? method }
|
50
56
|
end
|
51
57
|
|
52
58
|
def method_is_owned_by_klass?(method)
|
53
|
-
self.klass.
|
59
|
+
self.klass.instance_method(method).owner == self.klass
|
54
60
|
end
|
55
61
|
|
56
62
|
def all_instance_methods_of_klass
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latent_object_detector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Ehmke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -51,6 +51,7 @@ extra_rdoc_files: []
|
|
51
51
|
files:
|
52
52
|
- .gitignore
|
53
53
|
- .travis.yml
|
54
|
+
- CODE_OF_CONDUCT.md
|
54
55
|
- Gemfile
|
55
56
|
- LICENSE.txt
|
56
57
|
- README.md
|