Commit 13f85251 authored by Coraline Ehmke's avatar Coraline Ehmke

Don’t scan loose class methods. Closes #1

parent a8ca7e95
......@@ -6,9 +6,12 @@ module Snuffle
attr_accessor :element, :neighbors, :line_numbers
def self.from(nodes)
cohorts = Element::Hash.materialize(nodes.hashes.to_a).inject([]) do |cohorts, element|
nodes = nodes.non_sends.hashes
cohorts = Element::Hash.materialize(nodes.to_a).inject([]) do |cohorts, element|
cohort = Cohort.new(element: element, line_numbers: element.node.line_numbers )
cohorts << cohort if cohort.values.count > 1 && cohort.near_neighbors.count > 0
if cohort.values.count > 1 && cohort.near_neighbors.count > 0
cohorts << cohort
end
cohorts
end
end
......
......@@ -8,8 +8,8 @@ class Snuffle::LatentObject
STOPWORDS = [
"the", "be", "to", "of", "and", "a", "in", "that", "have", "I", "it", "for",
"not", "on", "with", "he", "as", "you", "do", "at", "this", "but", "his",
"by", "from", "they", "we", "say", "her", "she", "or", "an", "will", "my",
"one", "all", "would", "there", "their", "what", "so", "up", "out", "if",
"by", "from", "they", "we", "say", "her", "she", "or", "an", "will", "my", "are",
"one", "all", "would", "there", "their", "what", "so", "up", "out", "if", "is",
"about", "who", "get", "which", "go", "me", "when", "make", "can", "like",
"time", "no", "just", "him", "know", "take", "into", "else", "other", "again",
"your", "good", "some", "could", "them", "see", "other", "than", "then",
......
......@@ -12,11 +12,16 @@ module Snuffle
scope :with_parent, lambda{|parent_id| where(parent_id: parent_id) }
scope :hashes, {type: :hash}
scope :methods, {is_method: true}
scope :non_sends, {is_send: false}
def self.nil
new(type: :nil)
end
def self.not_a(type)
select{|node| node.type != type}
end
def initialize(*args, &block)
@id = SecureRandom.uuid
super
......@@ -38,6 +43,10 @@ module Snuffle
self.type == :def || self.type == :defs
end
def is_send
self.type == :send
end
def inspect
{
id: self.id,
......
module Snuffle
VERSION = "0.11.1"
VERSION = "0.12.0"
end
......@@ -4,9 +4,17 @@ class Customer
attr_accessor :customer_id, :customer_name, :company_name
attr_accessor :street_address_1, :street_address_2
attr_accessor :city, :state, :postal_code
attr_accessor :fred
MY_CONSTANT = "TheOtherZachIsThePrimaryZach"
def who_is_fred
{
:status => 'friend',
:name => self.fred
}
end
def my_condition
puts "MAGIC" if true == false
end
......
require 'snuffle'
def source_file
@source_file ||= Snuffle::SourceFile.new(path_to_file: "spec/fixtures/latent_object_fixture.rb")
@source_file ||= Snuffle::SourceFile.new(path_to_file: "spec/fixtures/program_3.rb")
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment