flay 2.7.0 → 2.8.0

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: f1c0f1551528a45340225c5bd74349a396bba865
4
- data.tar.gz: 8f2fcda92e948267073c31a4aa3cbddc044cd83e
3
+ metadata.gz: 83938e425e7da6168fc862af2d5ecaa7f8c3cfc4
4
+ data.tar.gz: 0cecc5f44a897b0695ac0f638aee67535dedcff7
5
5
  SHA512:
6
- metadata.gz: a81499c489c9d49cf066a4feef7bf5bb834850b74623de8539ee4dea339b543d3afe52097546f35888038a0637be4da32704b000b45b91dbadfd541ba9bf46fb
7
- data.tar.gz: 4c96b08538b1b54866df0ca31a17e5963233fd2965f1f6c8a4ad9cf0792eceadf3ec428b4a8a8783a4a133194fab23dd82c2d7ad9284a6dbc25c395a667c0b6f
6
+ metadata.gz: 233071084997a9e3a585704098514fb245590987aa0ec9f8317e4defe0555c1196b83e6646e73eb9607f2b5923c94d608f88c8635494285a7a50f92b4fca4c05
7
+ data.tar.gz: ede337e5a5968d0d8097d2a14f1eb42d58ef63f9cbeccdeaee57ae23a4a54e50753dc445ba1fbd7c751ffae426b8ab2b771f21565ce4521b0ab648f04c3b26a5
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,14 @@
1
+ === 2.8.0 / 2016-05-16
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Switched to path_expander to deal with cmdline args. See path_expander for details.
6
+
7
+ * 2 bug fixes:
8
+
9
+ * Added dev deps and bundler plugin to make flavorjones happy. (flavorjones)
10
+ * Explictly require rake/tasklib in flay_task.rb. (jasonkarns)
11
+
1
12
  === 2.7.0 / 2016-01-21
2
13
 
3
14
  * 1 minor enhancement:
data/README.txt CHANGED
@@ -25,6 +25,10 @@ braces vs do/end, etc are all ignored. Making this totally rad.
25
25
  * Ships with .rb and .erb.
26
26
  * javascript and others will be available separately.
27
27
  * Includes FlayTask for Rakefiles.
28
+ * Uses path_expander, so you can use:
29
+ * dir_arg -- expand a directory automatically
30
+ * @file_of_args -- persist arguments in a file
31
+ * -path_to_subtract -- ignore intersecting subsets of files/directories
28
32
  * Skips files matched via patterns in .flayignore (subset format of .gitignore).
29
33
  * Totally rad.
30
34
 
@@ -86,6 +90,7 @@ braces vs do/end, etc are all ignored. Making this totally rad.
86
90
 
87
91
  * ruby_parser
88
92
  * sexp_processor
93
+ * path_expander
89
94
  * ruby2ruby -- soft dependency: only if you want to use --diff
90
95
 
91
96
  == INSTALL:
data/Rakefile CHANGED
@@ -7,10 +7,12 @@ Hoe::add_include_dirs("../../sexp_processor/dev/lib",
7
7
  "../../ruby_parser/dev/lib",
8
8
  "../../ruby2ruby/dev/lib",
9
9
  "../../ZenTest/dev/lib",
10
+ "../../path_expander/dev/lib",
10
11
  "lib")
11
12
 
12
13
  Hoe.plugin :seattlerb
13
14
  Hoe.plugin :isolate
15
+ Hoe.plugin :bundler
14
16
 
15
17
  Hoe.spec "flay" do
16
18
  developer "Ryan Davis", "ryand-ruby@zenspider.com"
@@ -19,6 +21,10 @@ Hoe.spec "flay" do
19
21
  dependency "sexp_processor", "~> 4.0"
20
22
  dependency "ruby_parser", "~> 3.0"
21
23
  dependency "erubis", "~> 2.7.0"
24
+ dependency "path_expander", "~> 1.0"
25
+
26
+ dependency "minitest", "~> 5.8.0", :dev
27
+ dependency "ruby2ruby", "~> 2.2.0", :dev
22
28
 
23
29
  self.flay_threshold = 250
24
30
  end
@@ -27,30 +33,14 @@ task :debug => :isolate do
27
33
  require "flay"
28
34
 
29
35
  file = ENV["F"]
30
- mass = ENV["M"]
31
- diff = ENV["D"]
32
- libr = ENV["L"]
33
- ver = ENV["V"]
34
-
35
- opts = Flay.parse_options
36
- opts[:mass] = mass.to_i if mass
37
- opts[:diff] = diff.to_i if diff
38
- opts[:liberal] = true if libr
39
- opts[:verbose] = true if ver
40
-
41
- flay = Flay.new opts
42
- flay.process(*Flay.expand_dirs_to_files(file))
43
- flay.report
44
- end
45
-
46
- task :run do
47
- file = ENV["F"]
48
- fuzz = ENV["Z"] && "-f #{ENV["Z"]}"
49
- mass = ENV["M"] && "-m #{ENV["M"]}"
50
- diff = ENV["D"] && "-d"
51
- libr = ENV["L"] && "-l"
36
+ fuzz = ENV["Z"] && ["-f", ENV["Z"]]
37
+ mass = ENV["M"] && ["-m", ENV["M"]]
38
+ diff = ENV["D"] && ["-d"]
39
+ libr = ENV["L"] && ["-l"]
40
+ ver = ENV["V"] && ["-v"]
52
41
 
53
- ruby "#{Hoe::RUBY_FLAGS} bin/flay #{mass} #{fuzz} #{diff} #{libr} #{file}"
42
+ flay = Flay.run [mass, fuzz, diff, libr, file, ver].flatten.compact
43
+ flay.report
54
44
  end
55
45
 
56
46
  # vim: syntax=ruby
data/bin/flay CHANGED
@@ -2,9 +2,4 @@
2
2
 
3
3
  require 'flay'
4
4
 
5
- flay = Flay.new Flay.parse_options
6
-
7
- files = Flay.filter_files Flay.expand_dirs_to_files(*ARGV)
8
-
9
- flay.process(*files)
10
- flay.report
5
+ Flay.run.report
@@ -4,6 +4,7 @@ require "optparse"
4
4
  require "rubygems"
5
5
  require "sexp_processor"
6
6
  require "ruby_parser"
7
+ require "path_expander"
7
8
  require "timeout"
8
9
 
9
10
  class File
@@ -15,7 +16,7 @@ class File
15
16
  end
16
17
 
17
18
  class Flay
18
- VERSION = "2.7.0" # :nodoc:
19
+ VERSION = "2.8.0" # :nodoc:
19
20
 
20
21
  class Item < Struct.new(:structural_hash, :name, :bonus, :mass, :locations)
21
22
  alias identical? bonus
@@ -25,6 +26,18 @@ class Flay
25
26
  alias fuzzy? fuzzy
26
27
  end
27
28
 
29
+ def self.run args = ARGV
30
+ extensions = ["rb"] + Flay.load_plugins
31
+ glob = "**/*.{#{extensions.join ","}}"
32
+
33
+ expander = PathExpander.new args, glob
34
+ files = expander.filter_files expander.process, DEFAULT_IGNORE
35
+
36
+ flay = Flay.new Flay.parse_options args
37
+ flay.process(*files)
38
+ flay
39
+ end
40
+
28
41
  ##
29
42
  # Returns the default options.
30
43
 
@@ -120,59 +133,9 @@ class Flay
120
133
  options
121
134
  end
122
135
 
123
- ##
124
- # Expands +*dirs+ to all files within that match ruby and rake extensions.
125
- # --
126
- # REFACTOR: from flog
127
-
128
- def self.expand_dirs_to_files *dirs
129
- extensions = ["rb"] + Flay.load_plugins
130
-
131
- dirs.flatten.map { |p|
132
- if File.directory? p then
133
- Dir[File.join(p, "**", "*.{#{extensions.join(",")}}")]
134
- else
135
- p
136
- end
137
- }.flatten.map { |s| s.sub(/^\.\//, "") } # strip "./" from paths
138
- end
139
-
140
136
  # so I can move this to flog wholesale
141
137
  DEFAULT_IGNORE = ".flayignore" # :nodoc:
142
138
 
143
- ##
144
- # A file filter mechanism similar to, but not as extensive as,
145
- # .gitignore files:
146
- #
147
- # + If a pattern does not contain a slash, it is treated as a shell glob.
148
- # + If a pattern ends in a slash, it matches on directories (and contents).
149
- # + Otherwise, it matches on relative paths.
150
- #
151
- # File.fnmatch is used throughout, so glob patterns work for all 3 types.
152
-
153
- def self.filter_files files, ignore = DEFAULT_IGNORE
154
- ignore_paths = if ignore.respond_to? :read then
155
- ignore.read
156
- elsif File.exists? ignore then
157
- File.read ignore
158
- end
159
-
160
- if ignore_paths then
161
- nonglobs, globs = ignore_paths.split("\n").partition { |p| p.include? "/" }
162
- dirs, ifiles = nonglobs.partition { |p| p.end_with? "/" }
163
- dirs = dirs.map { |s| s.chomp "/" }
164
-
165
- only_paths = File::FNM_PATHNAME
166
- files = files.reject { |f|
167
- dirs.any? { |i| File.fnmatch?(i, File.dirname(f), only_paths) } ||
168
- globs.any? { |i| File.fnmatch?(i, f) } ||
169
- ifiles.any? { |i| File.fnmatch?(i, f, only_paths) }
170
- }
171
- end
172
-
173
- files
174
- end
175
-
176
139
  ##
177
140
  # Loads all flay plugins. Files must be named "flay_*.rb".
178
141
 
@@ -1,3 +1,5 @@
1
+ require 'rake/tasklib'
2
+
1
3
  class FlayTask < Rake::TaskLib
2
4
  ##
3
5
  # The name of the task. Defaults to :flay
@@ -42,10 +44,7 @@ class FlayTask < Rake::TaskLib
42
44
  def define
43
45
  desc "Analyze for code duplication in: #{dirs.join(", ")}"
44
46
  task name do
45
- require "flay"
46
- flay = Flay.new
47
- files = Flay.filter_files Flay.expand_dirs_to_files dirs
48
- flay.process(*files)
47
+ flay = Flay.run
49
48
  flay.report if verbose
50
49
 
51
50
  raise "Flay total too high! #{flay.total} > #{threshold}" if
@@ -78,13 +78,9 @@ class FlayGauntlet < Gauntlet
78
78
  ############################################################
79
79
 
80
80
  def score_for dir
81
- # files = `find #{dir} -name \\*.rb | grep -v gen.*templ`.split(/\n/)
82
- flayer = Flay.new
83
-
84
81
  dirs = %w(app lib test spec).reject { |f| ! File.directory? f }
85
82
 
86
- flay = Flay.new
87
- flay.process(*Flay.expand_dirs_to_files(dirs))
83
+ flay = Flay.run dirs
88
84
  flay.total
89
85
  rescue Interrupt
90
86
  # let us break out
@@ -436,52 +436,4 @@ class TestSexp < Minitest::Test
436
436
 
437
437
  assert_equal exp, flay.n_way_diff(*dog_and_cat).gsub(/^ {3}$/, "")
438
438
  end
439
-
440
- def test_cls_expand_dirs_to_files
441
- Dir.mktmpdir do |dir|
442
- Dir.chdir dir do
443
- FileUtils.touch "dog_and_cat.rb"
444
-
445
- files = Flay.expand_dirs_to_files "."
446
- assert_equal %w[dog_and_cat.rb], files
447
- end
448
- end
449
- end
450
-
451
- def assert_filter_files exp, filter, files = %w[test/dog_and_cat.rb]
452
- ignore = StringIO.new filter
453
- act = Flay.filter_files files, ignore
454
- assert_equal exp, act
455
- end
456
-
457
- def test_cls_filter_files_dir
458
- assert_filter_files [], "test/"
459
- end
460
-
461
- def test_cls_filter_files_files
462
- assert_filter_files [], "test/*.rb"
463
-
464
- example = %w[test/file.rb test/sub/file.rb top/test/perf.rb]
465
-
466
- assert_filter_files example[1..-1], "test/*.rb", example
467
- end
468
-
469
- def test_cls_filter_files_glob
470
- assert_filter_files [], "test*"
471
- assert_filter_files [], "test*", ["test/lib/woot.rb"]
472
- assert_filter_files [], "*.rb"
473
- assert_filter_files [], "*dog*.rb"
474
- end
475
-
476
- def test_cls_filter_files_glob_miss
477
- miss = %w[test/dog_and_cat.rb]
478
- assert_filter_files miss, "test"
479
- assert_filter_files miss, "nope"
480
- end
481
-
482
- def test_expand_dirs_on_frozen_string
483
- s = "./foo"
484
- s.freeze
485
- assert_equal Flay.expand_dirs_to_files([s]), ["foo"]
486
- end
487
439
  end
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: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  qx3h45R1CAsObX0SQDIT+rRbQrtKz1GHIZTOFYvEJjUY1XmRTZupD3CJ8Q7sDqSy
30
30
  NLq5jm1fq6Y9Uolu3RJbmycf
31
31
  -----END CERTIFICATE-----
32
- date: 2016-01-21 00:00:00.000000000 Z
32
+ date: 2016-05-16 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -74,19 +74,19 @@ dependencies:
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.7.0
76
76
  - !ruby/object:Gem::Dependency
77
- name: minitest
77
+ name: path_expander
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: '5.8'
83
- type: :development
82
+ version: '1.0'
83
+ type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: '5.8'
89
+ version: '1.0'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: rdoc
92
92
  requirement: !ruby/object:Gem::Requirement
@@ -101,20 +101,48 @@ dependencies:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '4.0'
104
+ - !ruby/object:Gem::Dependency
105
+ name: minitest
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 5.8.0
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 5.8.0
118
+ - !ruby/object:Gem::Dependency
119
+ name: ruby2ruby
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 2.2.0
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 2.2.0
104
132
  - !ruby/object:Gem::Dependency
105
133
  name: hoe
106
134
  requirement: !ruby/object:Gem::Requirement
107
135
  requirements:
108
136
  - - ~>
109
137
  - !ruby/object:Gem::Version
110
- version: '3.14'
138
+ version: '3.15'
111
139
  type: :development
112
140
  prerelease: false
113
141
  version_requirements: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ~>
116
144
  - !ruby/object:Gem::Version
117
- version: '3.14'
145
+ version: '3.15'
118
146
  description: |-
119
147
  Flay analyzes code for structural similarities. Differences in literal
120
148
  values, variable, class, method names, whitespace, programming style,
metadata.gz.sig CHANGED
Binary file