flay 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,15 @@
1
+ === 1.2.1 / 2009-03-16
2
+
3
+ * 3 minor enhancements:
4
+
5
+ * Added gauntlet_flay.rb
6
+ * Cached value of plugins loaded.
7
+ * Refactored and separated analysis phase from process phase
8
+
9
+ * 1 bug fix:
10
+
11
+ * Added bin dir to default dirs list in FlayTask
12
+
1
13
  === 1.2.0 / 2009-03-09
2
14
 
3
15
  * 2 major enhancements:
data/Manifest.txt CHANGED
@@ -6,4 +6,5 @@ bin/flay
6
6
  lib/flay.rb
7
7
  lib/flay_erb.rb
8
8
  lib/flay_task.rb
9
+ lib/gauntlet_flay.rb
9
10
  test/test_flay.rb
data/Rakefile CHANGED
@@ -6,7 +6,11 @@ require 'hoe'
6
6
  Hoe::add_include_dirs("../../sexp_processor/dev/lib",
7
7
  "../../ruby_parser/dev/lib")
8
8
 
9
- require './lib/flay.rb'
9
+ begin
10
+ require 'flay'
11
+ rescue LoadError
12
+ load 'lib/flay.rb'
13
+ end
10
14
 
11
15
  Hoe.new('flay', Flay::VERSION) do |flay|
12
16
  flay.rubyforge_name = 'seattlerb'
data/lib/flay.rb CHANGED
@@ -11,7 +11,7 @@ require 'ruby_parser'
11
11
  abort "update rubygems to >= 1.3.1" unless Gem.respond_to? :find_files
12
12
 
13
13
  class Flay
14
- VERSION = '1.2.0'
14
+ VERSION = '1.2.1'
15
15
 
16
16
  def self.default_options
17
17
  {
@@ -71,17 +71,20 @@ class Flay
71
71
  end
72
72
 
73
73
  def self.load_plugins
74
- plugins = Gem.find_files("flay_*.rb").reject { |path| path =~ /flay_task/ }
75
-
76
- plugins.each do |plugin|
77
- begin
78
- load plugin
79
- rescue LoadError => e
80
- warn "error loading #{plugin.inspect}: #{e.message}. skipping..."
74
+ unless defined? @@plugins then
75
+ plugins = Gem.find_files("flay_*.rb").reject { |p| p =~ /flay_task/ }
76
+
77
+ plugins.each do |plugin|
78
+ begin
79
+ load plugin
80
+ rescue LoadError => e
81
+ warn "error loading #{plugin.inspect}: #{e.message}. skipping..."
82
+ end
81
83
  end
82
- end
83
84
 
84
- plugins.map { |f| File.basename(f, '.rb').sub(/^flay_/, '') }
85
+ @@plugins = plugins.map { |f| File.basename(f, '.rb').sub(/^flay_/, '') }
86
+ end
87
+ @@plugins
85
88
  end
86
89
 
87
90
  attr_accessor :mass_threshold, :total, :identical, :masses
@@ -99,7 +102,7 @@ class Flay
99
102
  require 'ruby2ruby' if @option[:verbose]
100
103
  end
101
104
 
102
- def process(*files)
105
+ def process(*files) # TODO: rename from process - should act as SexpProcessor
103
106
  files.each do |file|
104
107
  warn "Processing #{file}"
105
108
 
@@ -127,6 +130,10 @@ class Flay
127
130
 
128
131
  process_fuzzy_similarities if option[:fuzzy]
129
132
 
133
+ analyze
134
+ end
135
+
136
+ def analyze
130
137
  self.prune
131
138
 
132
139
  self.hashes.each do |hash,nodes|
data/lib/flay_task.rb CHANGED
@@ -6,7 +6,7 @@ class FlayTask < Rake::TaskLib
6
6
 
7
7
  def initialize name = :flay, threshold = 200, dirs = nil
8
8
  @name = name
9
- @dirs = dirs || %w(app lib test spec)
9
+ @dirs = dirs || %w(app bin lib spec test)
10
10
  @threshold = threshold
11
11
  @verbose = Rake.application.options.trace
12
12
 
@@ -24,7 +24,8 @@ class FlayTask < Rake::TaskLib
24
24
  flay.process(*Flay.expand_dirs_to_files(dirs))
25
25
  flay.report if verbose
26
26
 
27
- raise "Flay total too high! #{flay.total} > #{threshold}" if flay.total > threshold
27
+ raise "Flay total too high! #{flay.total} > #{threshold}" if
28
+ flay.total > threshold
28
29
  end
29
30
  self
30
31
  end
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/ruby -ws
2
+
3
+ $: << 'lib' << '../../ParseTree/dev/lib' << '../../flay/dev/lib'
4
+
5
+ $v ||= false # HACK
6
+
7
+ require 'rubygems'
8
+ require 'flay'
9
+
10
+ require 'gauntlet'
11
+ require 'pp'
12
+
13
+ class FlayGauntlet < Gauntlet
14
+ $owners = {}
15
+ $score_file = 'flay-scores.yml'
16
+ $misc_error = {:total => -1, :average => -1, :methods => {}}
17
+ $syntax_error = {:total => -2, :average => -2, :methods => {}}
18
+ $no_gem = {:total => -4, :average => -4, :methods => {}}
19
+
20
+ # copied straight from hoedown.rb
21
+ my_projects = %w[InlineFortran ParseTree RubyInline RubyToC
22
+ ZenHacks ZenTest bfts box_layout
23
+ change_class flay flog gauntlet heckle
24
+ hoe image_science miniunit minitest
25
+ minitest_tu_shim png ruby2ruby ruby_parser
26
+ rubyforge test-unit un vlad zenprofile
27
+ zentest]
28
+
29
+ MY_PROJECTS = Regexp.union(*my_projects)
30
+
31
+ def run name
32
+ warn name
33
+ self.data[name] = score_for '.'
34
+ self.dirty = true
35
+ end
36
+
37
+ def display_report max
38
+ good_data = {}
39
+ bad_count = 0
40
+ zero_count = 0
41
+
42
+ @data.each do |name, flay|
43
+ case
44
+ when flay < 0 then
45
+ bad_count += 1
46
+ when flay == 0 then
47
+ zero_count += 1
48
+ else
49
+ good_data[name] = flay
50
+ end
51
+ end
52
+
53
+ scores = good_data.values
54
+
55
+ # SWEET JESUS:
56
+ #
57
+ # without zeros:
58
+ # average flay: 1487.23 +/- 7800.16
59
+ # with zeros:
60
+ # average flay: 988.69 +/- 6398.45
61
+
62
+ puts "broken projects : %d" % bad_count
63
+ puts "great projects : %d" % zero_count
64
+ puts "bad projects : %d" % good_data.size
65
+ puts "average flay : %.2f +/- %.2f" % [scores.average, scores.stddev]
66
+
67
+ top = good_data.sort_by { |name,flay| -flay }.first max
68
+
69
+ puts
70
+ top.each_with_index do |(name, flay), i|
71
+ puts "%3d: %10.2f: %s" % [ i, flay, name ]
72
+ end
73
+ end
74
+
75
+ ############################################################
76
+ # OTHER
77
+ ############################################################
78
+
79
+ def score_for dir
80
+ # files = `find #{dir} -name \\*.rb | grep -v gen.*templ`.split(/\n/)
81
+ flayer = Flay.new
82
+
83
+ dirs = %w(app lib test spec).reject { |f| ! File.directory? f }
84
+
85
+ flay = Flay.new
86
+ flay.process(*Flay.expand_dirs_to_files(dirs))
87
+ flay.total
88
+ rescue Interrupt
89
+ # let us break out
90
+ rescue Exception
91
+ -1
92
+ end
93
+ end
94
+
95
+ max = (ARGV.shift || 10).to_i
96
+ filter = ARGV.shift
97
+ filter = Regexp.new filter if filter
98
+ flayer = FlayGauntlet.new
99
+ flayer.run_the_gauntlet filter
100
+ flayer.display_report max
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flay
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -30,7 +30,7 @@ cert_chain:
30
30
  FBHgymkyj/AOSqKRIpXPhjC6
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2009-03-09 00:00:00 -07:00
33
+ date: 2009-03-16 00:00:00 -07:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -61,7 +61,7 @@ dependencies:
61
61
  requirements:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: 1.10.0
64
+ version: 1.11.0
65
65
  version:
66
66
  description: Flay analyzes code for structural similarities. Differences in literal values, variable, class, method names, whitespace, programming style, braces vs do/end, etc are all ignored. Making this totally rad.
67
67
  email:
@@ -83,6 +83,7 @@ files:
83
83
  - lib/flay.rb
84
84
  - lib/flay_erb.rb
85
85
  - lib/flay_task.rb
86
+ - lib/gauntlet_flay.rb
86
87
  - test/test_flay.rb
87
88
  has_rdoc: true
88
89
  homepage: http://ruby.sadi.st/
metadata.gz.sig CHANGED
@@ -1 +1,3 @@
1
- �B�쑊 �u�4`. �,�*sO
1
+ ]|��4�H��i?��?�e���ݙV���7�`��T
2
+ ɏbѹܢ*��S��H���z3�4m��.3�`�?����8�J~NK�y!ڃ�+�� �����[��P$�/��ޅ�Nq7o�&�Y(m����FN��m�"��G�j� Q��2���v)��i}g�uCdFg9� ="��1�i=���P���e��
3
+ ��v�k��@Οs2��+�HUĚe�:0���� ��pF-*��Ȭ�խ�J\wj�*��n��