flay 2.3.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +6 -0
- data/lib/flay.rb +16 -5
- data/test/test_flay.rb +41 -0
- metadata +10 -10
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/lib/flay.rb
CHANGED
@@ -15,7 +15,7 @@ class File
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class Flay
|
18
|
-
VERSION = "2.
|
18
|
+
VERSION = "2.4.0" # :nodoc:
|
19
19
|
|
20
20
|
##
|
21
21
|
# Returns the default options.
|
@@ -165,8 +165,6 @@ class Flay
|
|
165
165
|
self.masses = {}
|
166
166
|
self.total = 0
|
167
167
|
self.mass_threshold = @option[:mass]
|
168
|
-
|
169
|
-
require 'ruby2ruby' if @option[:diff]
|
170
168
|
end
|
171
169
|
|
172
170
|
##
|
@@ -488,11 +486,24 @@ class Flay
|
|
488
486
|
|
489
487
|
if option[:diff] then
|
490
488
|
puts
|
491
|
-
|
492
|
-
|
489
|
+
sources = nodes.map do |s|
|
490
|
+
msg = "sexp_to_#{File.extname(s.file).sub(/./, '')}"
|
491
|
+
self.respond_to?(msg) ? self.send(msg, s) : sexp_to_rb(s)
|
492
|
+
end
|
493
|
+
puts n_way_diff(*sources)
|
493
494
|
end
|
494
495
|
end
|
495
496
|
end
|
497
|
+
|
498
|
+
def sexp_to_rb sexp
|
499
|
+
begin
|
500
|
+
require 'ruby2ruby'
|
501
|
+
rescue LoadError
|
502
|
+
return 'ruby2ruby is required for diff'
|
503
|
+
end
|
504
|
+
@r2r ||= Ruby2Ruby.new
|
505
|
+
@r2r.process sexp.deep_clone
|
506
|
+
end
|
496
507
|
end
|
497
508
|
|
498
509
|
class String
|
data/test/test_flay.rb
CHANGED
@@ -287,6 +287,47 @@ class TestSexp < Minitest::Test
|
|
287
287
|
assert_equal exp, out.gsub(/\d+/, "N").gsub(/^ {3}$/, "")
|
288
288
|
end
|
289
289
|
|
290
|
+
def test_report_diff_plugin_converter
|
291
|
+
# make sure we run through options parser
|
292
|
+
$*.clear
|
293
|
+
$* << "-d"
|
294
|
+
$* << "--mass=1"
|
295
|
+
$* << "-v"
|
296
|
+
|
297
|
+
opts = nil
|
298
|
+
capture_io do # ignored
|
299
|
+
opts = Flay.parse_options
|
300
|
+
end
|
301
|
+
|
302
|
+
flay = Flay.new opts
|
303
|
+
|
304
|
+
flay.process_sexp DOG_AND_CAT.deep_clone
|
305
|
+
flay.analyze
|
306
|
+
|
307
|
+
# (string) does not have extension, maps to :sexp_to_
|
308
|
+
Flay.send(:define_method, :sexp_to_){|s| "source code #{s.line}"}
|
309
|
+
|
310
|
+
out, err = capture_io do
|
311
|
+
flay.report nil
|
312
|
+
end
|
313
|
+
|
314
|
+
Flay.send(:remove_method, :sexp_to_)
|
315
|
+
|
316
|
+
exp = <<-END.gsub(/\d+/, "N").gsub(/^ {6}/, "")
|
317
|
+
Total score (lower is better) = 16
|
318
|
+
|
319
|
+
1) Similar code found in :class (mass = 16)
|
320
|
+
A: (string):1
|
321
|
+
B: (string):6
|
322
|
+
|
323
|
+
A: source code 1
|
324
|
+
B: source code 6
|
325
|
+
END
|
326
|
+
|
327
|
+
assert_equal '', err
|
328
|
+
assert_equal exp, out.gsub(/\d+/, "N").gsub(/^ {3}$/, "")
|
329
|
+
end
|
330
|
+
|
290
331
|
def test_n_way_diff
|
291
332
|
dog_and_cat = ["##\n# I am a dog.\n\nclass Dog\n def x\n return \"Hello\"\n end\nend",
|
292
333
|
"##\n# I\n#\n# am\n# a\n# cat.\n\nclass Cat\n def y\n return \"Hello\"\n end\nend"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 2.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2013-07-
|
39
|
+
date: 2013-07-24 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sexp_processor
|
@@ -106,11 +106,11 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
hash:
|
109
|
+
hash: 9
|
110
110
|
segments:
|
111
111
|
- 3
|
112
|
-
-
|
113
|
-
version: "3.
|
112
|
+
- 7
|
113
|
+
version: "3.7"
|
114
114
|
type: :development
|
115
115
|
version_requirements: *id005
|
116
116
|
description: |-
|
@@ -140,8 +140,8 @@ files:
|
|
140
140
|
- test/test_flay.rb
|
141
141
|
- .gemtest
|
142
142
|
homepage: http://ruby.sadi.st/
|
143
|
-
licenses:
|
144
|
-
|
143
|
+
licenses:
|
144
|
+
- MIT
|
145
145
|
post_install_message:
|
146
146
|
rdoc_options:
|
147
147
|
- --main
|
metadata.gz.sig
CHANGED
Binary file
|