flay 1.4.0 → 1.4.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.
- data.tar.gz.sig +4 -0
- data/History.txt +11 -0
- data/lib/flay.rb +8 -3
- data/lib/flay_erb.rb +7 -2
- data/test/test_flay.rb +21 -30
- metadata +100 -19
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 1.4.1 / 2010-09-01
|
2
|
+
|
3
|
+
* 2 minor enhancements:
|
4
|
+
|
5
|
+
* Added extra error handling for ERB flay to deal with tons of bad ERB
|
6
|
+
* Skip plugin if another version already loaded (eg local vs gem).
|
7
|
+
|
8
|
+
* 1 bug fix:
|
9
|
+
|
10
|
+
* Fixed all tests that were having problems on 1.9 due to unstable hashes
|
11
|
+
|
1
12
|
=== 1.4.0 / 2009-08-14
|
2
13
|
|
3
14
|
* 4 minor enhancements:
|
data/lib/flay.rb
CHANGED
@@ -9,7 +9,7 @@ require 'sexp_processor'
|
|
9
9
|
require 'ruby_parser'
|
10
10
|
|
11
11
|
class Flay
|
12
|
-
VERSION = '1.4.
|
12
|
+
VERSION = '1.4.1'
|
13
13
|
|
14
14
|
def self.default_options
|
15
15
|
{
|
@@ -85,17 +85,20 @@ class Flay
|
|
85
85
|
|
86
86
|
def self.load_plugins
|
87
87
|
unless defined? @@plugins then
|
88
|
+
@@plugins = []
|
89
|
+
|
88
90
|
plugins = Gem.find_files("flay_*.rb").reject { |p| p =~ /flay_task/ }
|
89
91
|
|
90
92
|
plugins.each do |plugin|
|
93
|
+
plugin_name = File.basename(plugin, '.rb').sub(/^flay_/, '')
|
94
|
+
next if @@plugins.include? plugin_name
|
91
95
|
begin
|
92
96
|
load plugin
|
97
|
+
@@plugins << plugin_name
|
93
98
|
rescue LoadError => e
|
94
99
|
warn "error loading #{plugin.inspect}: #{e.message}. skipping..."
|
95
100
|
end
|
96
101
|
end
|
97
|
-
|
98
|
-
@@plugins = plugins.map { |f| File.basename(f, '.rb').sub(/^flay_/, '') }
|
99
102
|
end
|
100
103
|
@@plugins
|
101
104
|
rescue
|
@@ -304,6 +307,7 @@ class Sexp
|
|
304
307
|
hashes
|
305
308
|
end
|
306
309
|
|
310
|
+
# REFACTOR: move to sexp.rb
|
307
311
|
def deep_each(&block)
|
308
312
|
self.each_sexp do |sexp|
|
309
313
|
block[sexp]
|
@@ -311,6 +315,7 @@ class Sexp
|
|
311
315
|
end
|
312
316
|
end
|
313
317
|
|
318
|
+
# REFACTOR: move to sexp.rb
|
314
319
|
def each_sexp
|
315
320
|
self.each do |sexp|
|
316
321
|
next unless Sexp === sexp
|
data/lib/flay_erb.rb
CHANGED
@@ -8,7 +8,12 @@ class Flay
|
|
8
8
|
def process_erb file
|
9
9
|
erb = File.read file
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
ruby = ERB.new(erb).src
|
12
|
+
begin
|
13
|
+
RubyParser.new.process(ruby, file)
|
14
|
+
rescue => e
|
15
|
+
warn ruby if option[:verbose]
|
16
|
+
raise e
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
data/test/test_flay.rb
CHANGED
@@ -5,22 +5,6 @@ require 'flay'
|
|
5
5
|
|
6
6
|
$: << "../../sexp_processor/dev/lib"
|
7
7
|
|
8
|
-
require 'pp' # TODO: remove
|
9
|
-
|
10
|
-
ON_1_9 = RUBY_VERSION =~ /1\.9/
|
11
|
-
SKIP_1_9 = true && ON_1_9 # HACK
|
12
|
-
|
13
|
-
class Symbol # for testing only, makes the tests concrete
|
14
|
-
def hash
|
15
|
-
to_s.hash
|
16
|
-
end
|
17
|
-
|
18
|
-
alias :crap :<=> if :blah.respond_to? :<=>
|
19
|
-
def <=> o
|
20
|
-
Symbol === o && self.to_s <=> o.to_s
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
8
|
class TestSexp < Test::Unit::TestCase
|
25
9
|
def setup
|
26
10
|
# a(1) { |c| d }
|
@@ -31,22 +15,29 @@ class TestSexp < Test::Unit::TestCase
|
|
31
15
|
end
|
32
16
|
|
33
17
|
def test_structural_hash
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
hash = 955256285
|
18
|
+
hash = s(:iter,
|
19
|
+
s(:call, s(:arglist, s(:lit))),
|
20
|
+
s(:lasgn),
|
21
|
+
s(:call, s(:arglist))).hash
|
40
22
|
|
41
|
-
assert_equal hash, s.structural_hash
|
42
|
-
assert_equal hash, @s.structural_hash
|
43
|
-
|
44
|
-
assert_equal hash, s.deep_clone.structural_hash, "copy deep clone"
|
45
|
-
end unless SKIP_1_9
|
23
|
+
assert_equal hash, @s.structural_hash
|
24
|
+
assert_equal hash, @s.deep_clone.structural_hash
|
25
|
+
end
|
46
26
|
|
47
27
|
def test_all_structural_subhashes
|
48
|
-
|
49
|
-
|
28
|
+
s = s(:iter,
|
29
|
+
s(:call, s(:arglist, s(:lit))),
|
30
|
+
s(:lasgn),
|
31
|
+
s(:call, s(:arglist)))
|
32
|
+
|
33
|
+
expected = [
|
34
|
+
s[1] .hash,
|
35
|
+
s[1][1] .hash,
|
36
|
+
s[1][1][1].hash,
|
37
|
+
s[2] .hash,
|
38
|
+
s[3] .hash,
|
39
|
+
s[3][1] .hash,
|
40
|
+
].sort
|
50
41
|
|
51
42
|
assert_equal expected, @s.all_structural_subhashes.sort.uniq
|
52
43
|
|
@@ -57,7 +48,7 @@ class TestSexp < Test::Unit::TestCase
|
|
57
48
|
end
|
58
49
|
|
59
50
|
assert_equal expected, x.sort.uniq
|
60
|
-
end
|
51
|
+
end
|
61
52
|
|
62
53
|
def test_process_sexp
|
63
54
|
flay = Flay.new
|
metadata
CHANGED
@@ -1,47 +1,122 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 5
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 4
|
9
|
+
- 1
|
10
|
+
version: 1.4.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Ryan Davis
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
|
-
cert_chain:
|
16
|
+
cert_chain:
|
17
|
+
- |
|
18
|
+
-----BEGIN CERTIFICATE-----
|
19
|
+
MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
|
20
|
+
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
21
|
+
GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
|
22
|
+
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
23
|
+
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
24
|
+
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
25
|
+
taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
|
26
|
+
oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
|
27
|
+
GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
|
28
|
+
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
29
|
+
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
30
|
+
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
|
31
|
+
AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m
|
32
|
+
vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/
|
33
|
+
w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0
|
34
|
+
l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl
|
35
|
+
n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T
|
36
|
+
FBHgymkyj/AOSqKRIpXPhjC6
|
37
|
+
-----END CERTIFICATE-----
|
11
38
|
|
12
|
-
date:
|
39
|
+
date: 2010-09-01 00:00:00 -07:00
|
13
40
|
default_executable:
|
14
41
|
dependencies:
|
15
42
|
- !ruby/object:Gem::Dependency
|
16
43
|
name: sexp_processor
|
17
|
-
|
18
|
-
|
19
|
-
|
44
|
+
prerelease: false
|
45
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
20
47
|
requirements:
|
21
48
|
- - ~>
|
22
49
|
- !ruby/object:Gem::Version
|
50
|
+
hash: 7
|
51
|
+
segments:
|
52
|
+
- 3
|
53
|
+
- 0
|
23
54
|
version: "3.0"
|
24
|
-
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: *id001
|
25
57
|
- !ruby/object:Gem::Dependency
|
26
58
|
name: ruby_parser
|
27
|
-
|
28
|
-
|
29
|
-
|
59
|
+
prerelease: false
|
60
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
30
62
|
requirements:
|
31
63
|
- - ~>
|
32
64
|
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 2
|
68
|
+
- 0
|
33
69
|
version: "2.0"
|
34
|
-
|
70
|
+
type: :runtime
|
71
|
+
version_requirements: *id002
|
35
72
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
73
|
+
name: rubyforge
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
hash: 7
|
81
|
+
segments:
|
82
|
+
- 2
|
83
|
+
- 0
|
84
|
+
- 4
|
85
|
+
version: 2.0.4
|
37
86
|
type: :development
|
38
|
-
|
39
|
-
|
87
|
+
version_requirements: *id003
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: minitest
|
90
|
+
prerelease: false
|
91
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 9
|
97
|
+
segments:
|
98
|
+
- 1
|
99
|
+
- 7
|
100
|
+
- 1
|
101
|
+
version: 1.7.1
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id004
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: hoe
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
40
109
|
requirements:
|
41
110
|
- - ">="
|
42
111
|
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
112
|
+
hash: 19
|
113
|
+
segments:
|
114
|
+
- 2
|
115
|
+
- 6
|
116
|
+
- 2
|
117
|
+
version: 2.6.2
|
118
|
+
type: :development
|
119
|
+
version_requirements: *id005
|
45
120
|
description: |-
|
46
121
|
Flay analyzes code for structural similarities. Differences in literal
|
47
122
|
values, variable, class, method names, whitespace, programming style,
|
@@ -78,21 +153,27 @@ rdoc_options:
|
|
78
153
|
require_paths:
|
79
154
|
- lib
|
80
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
81
157
|
requirements:
|
82
158
|
- - ">="
|
83
159
|
- !ruby/object:Gem::Version
|
160
|
+
hash: 3
|
161
|
+
segments:
|
162
|
+
- 0
|
84
163
|
version: "0"
|
85
|
-
version:
|
86
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
87
166
|
requirements:
|
88
167
|
- - ">="
|
89
168
|
- !ruby/object:Gem::Version
|
169
|
+
hash: 3
|
170
|
+
segments:
|
171
|
+
- 0
|
90
172
|
version: "0"
|
91
|
-
version:
|
92
173
|
requirements: []
|
93
174
|
|
94
175
|
rubyforge_project: seattlerb
|
95
|
-
rubygems_version: 1.3.
|
176
|
+
rubygems_version: 1.3.7
|
96
177
|
signing_key:
|
97
178
|
specification_version: 3
|
98
179
|
summary: Flay analyzes code for structural similarities
|
metadata.gz.sig
ADDED
Binary file
|