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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a791cf6c6b8217cc5cd4535f56b915c40d797881
4
- data.tar.gz: a22158208a9b31417b0e860fd4fb655d2f2789fc
3
+ metadata.gz: eaede2b47cdb4a9ee894f0fd26292c7c54379676
4
+ data.tar.gz: bb215367b79908f5d8778762bd876d9360dccde7
5
5
  SHA512:
6
- metadata.gz: 65b53dc35b2d1ee74acf7163be98abe10296706e40d6ab8467ff8ef833e34a4ddaca432d1951400bda6c5e5672839779849ebc15a361fa5e03cc49fee2dd68dc
7
- data.tar.gz: f9cb8c51759b32506b76e17daaa08211cf37107df5f186cc73a2814af1af8da4874d229ebc625b5e94b373368b2a11fa46888bd240780d30802f118bc5d82acd
6
+ metadata.gz: 4cef4cd287cc97265f164979f5f598860596bae89dd631293f00fedc0774728022ebc4fb0925abab9bd826e3eb4919ae9b64a017250bd53c40f89eb68b1a40c7
7
+ data.tar.gz: f6d464149a62894c98cbcf4d6e2b779c18d8f2f9571d16d247a060aa237c698551d9d303baf4da11ce0e390fd2ca4248ad4f3ae75cee45187347d1a6643ca354
@@ -2,5 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 1.9.3
5
- - ruby-head
6
5
  script: "bundle exec rake test"
@@ -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 Corey, 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.)
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
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'rake/testtask'
3
3
 
4
+ task :default => [:test]
5
+
4
6
  Rake::TestTask.new do |t|
5
7
  t.libs << 'test'
6
8
  t.pattern = "test/*_test.rb"
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
- methods_owned_by_klass.select{ |m| (words_in_method(m.to_s) & potential_objects).size > 0 }
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
- common_words = find_common_words_in(hash_of_words_used_in_methods)
21
- words_used_more_than_twice(common_words)
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
- methods_owned_by_klass.inject({}) do |hash, method|
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
- end
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
- all_instance_methods_of_klass.select{ |method| method_is_owned_by_klass? method }
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.new.method(method).owner == self.klass
59
+ self.klass.instance_method(method).owner == self.klass
54
60
  end
55
61
 
56
62
  def all_instance_methods_of_klass
@@ -1,3 +1,3 @@
1
1
  module LatentObjectDetector
2
- VERSION = "0.0.2"
2
+ VERSION = '0.0.3'
3
3
  end
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.2
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: 2013-09-03 00:00:00.000000000 Z
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