fui 0.3.0 → 0.4.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: 95461cae3ee31c3d0a45fc8996d12f85e0af00ea
4
- data.tar.gz: 3f90ffa5af46eb689930f6029805cea8281efdd1
3
+ metadata.gz: f54323f18c553e3a577d2356ba9777601fe5b017
4
+ data.tar.gz: f5b31abaf34393e4c1db738f9a8e34695f8b6b67
5
5
  SHA512:
6
- metadata.gz: ee27ad841003c4f16beb828ffd048a539bc4039d565e57043895645eaf9e1fa167f7d3af8f5a2a4090bee95f8c6744bc9e73611a99d4f1f226495d936d9b4967
7
- data.tar.gz: ab689ab980e1e10f06798c3bc9626c06127397e1bf9dde263c8ae97a4139ce88b02f4bc4816d5ec3930b1d6e1f5b6c88c0ba339594aa529049b2069d02f1edf0
6
+ metadata.gz: 9d8924cbe968e7554f0cbeaacf6b8c16d29da0d35432bc3a4f571a20a767af8601b4bb28f5dd2dfe6a1f76dd7a0fbe2424e287651bc3591b5df44752a03dd6a8
7
+ data.tar.gz: 225407e9ee09173fbd0f0ddb5640b2243939b18c37fd926dc25ab2f3be72b25fb2c43161536216aa67012a39508c34f68ff5636c829f55505b52b17e2af9d67b
@@ -1,3 +1,11 @@
1
+ ### 0.4.1 (Next)
2
+
3
+ * Your contribution here.
4
+
5
+ ### 0.4.0 (5/14/2016)
6
+
7
+ * [#20](https://github.com/dblock/fui/pull/20): Added `-x`, `--ignorexib`, find unused classes referenced from its own XIB - [@Ezor](https://github.com/Ezor).
8
+
1
9
  ### 0.3.0 (2/7/2014)
2
10
 
3
11
  * [#5](https://github.com/dblock/fui/issues/5): Explicitly require Ruby 1.9.3 or later in .gemspec - [@paulyoung](https://github.com/paulyoung).
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Fui
2
2
  ==========
3
3
 
4
- [![Build Status](https://travis-ci.org/dblock/fui.png)](https://travis-ci.org/dblock/fui)
4
+ [![Build Status](https://travis-ci.org/dblock/fui.svg)](https://travis-ci.org/dblock/fui)
5
5
 
6
6
  Find unused Objective-C imports.
7
7
 
@@ -31,15 +31,27 @@ The `find` command lists all the files that contain unused imports and exits wit
31
31
  fui --path=~/source/project/Name find
32
32
  ```
33
33
 
34
+ #### Find Unused Classes in a Path Skipping Interface Builder (.xib) Files
35
+
36
+ ForRunning `fui` with `-x` (or `--ignorexib`) will, for example, mark `Foo.h` as unused when `Foo.xib` holds a reference to the `Foo` class and no other references to Foo.h exist.
37
+
38
+ ```
39
+ fui -x --path=~/source/project/Name find
40
+ ```
41
+
34
42
  #### Delete All Unused Class Files w/ Prompt
35
43
 
36
44
  ```
37
45
  fui --path=~/source/project/Name delete --perform --prompt
38
46
  ```
39
47
 
48
+ #### XCode Plugin
49
+
50
+ Use [xcfui](https://github.com/jcavar/xcfui) for integration with XCode.
51
+
40
52
  ## Contributing
41
53
 
42
- There're a [few known issues](https://github.com/dblock/fui/issues), notably around storyboards and .xib files. Please contribute! See [CONTRIBUTING](CONTRIBUTING.md).
54
+ There're [a few feature requests and known issues](https://github.com/dblock/fui/issues). Please contribute! See [CONTRIBUTING](CONTRIBUTING.md).
43
55
 
44
56
  ## Copyright and License
45
57
 
data/bin/fui CHANGED
@@ -4,26 +4,29 @@ require 'fui'
4
4
 
5
5
  include GLI::App
6
6
 
7
- program_desc 'Find unused imports in an Objective-C codebase'
7
+ program_desc 'Find unused imports in an Objective-C codebase.'
8
8
 
9
- flag [:p, :path], desc: 'Path to search', default_value: Dir.pwd
10
- switch [:v, :verbose], desc: 'Verbose', default_value: false
9
+ flag [:p, :path], desc: 'Path to search.', default_value: Dir.pwd
10
+ switch [:v, :verbose], desc: 'Produce verbose output.', default_value: false
11
+ switch [:x, :ignorexib], desc: 'Ignore interface builder (.xib) files.', default_value: false
11
12
 
12
13
  default_command :find
13
14
 
14
- pre do |global_options, command, options, args|
15
- $fui = Fui::Finder.new(global_options[:path])
15
+ pre do |global_options, _command, options, _args|
16
+ options = global_options.dup
17
+ path = options.delete(:path)
18
+ $fui = Fui::Finder.new(path, options)
16
19
  end
17
20
 
18
- desc "Find unused classes"
21
+ desc 'Find unused classes'
19
22
  long_desc "Note: fui's exit code will be the number of unused interfaces found."
20
23
  command :find do |c|
21
- c.action do |global_options, options, args|
24
+ c.action do |global_options, _options, _args|
22
25
  root = Pathname.new($fui.path)
23
- $fui.unused_references { |filename|
26
+ $fui.unused_references do |filename|
24
27
  relative_path = Pathname.new(filename).relative_path_from(root).to_s
25
28
  puts "Checking #{relative_path} ..." if global_options[:verbose]
26
- }.each do |k, v|
29
+ end.each do |k, _v|
27
30
  relative_path = Pathname.new(k.path).relative_path_from(root).to_s
28
31
  if global_options[:verbose]
29
32
  puts "Found #{relative_path}"
@@ -35,21 +38,20 @@ command :find do |c|
35
38
  end
36
39
  end
37
40
 
38
- desc "Delete header and implementation files of unused classes"
41
+ desc 'Delete header and implementation files of unused classes'
39
42
  command :delete do |c|
40
-
41
43
  c.switch [:t, :prompt], desc: 'Prompt on delete', default_value: true
42
- c.switch [:f, :perform], desc: 'Actually perform deletion', default_value: false, :negatable => false
44
+ c.switch [:f, :perform], desc: 'Actually perform deletion', default_value: false, negatable: false
43
45
 
44
- c.action do |global_options, options, args|
46
+ c.action do |global_options, options, _args|
45
47
  begin
46
- system("stty raw -echo")
48
+ system('stty raw -echo')
47
49
 
48
50
  root = Pathname.new($fui.path)
49
- $fui.unused_references { |filename|
51
+ $fui.unused_references do |filename|
50
52
  relative_path = Pathname.new(filename).relative_path_from(root).to_s
51
53
  puts "Checking #{relative_path} ..." if global_options[:verbose]
52
- }.each do |k, v|
54
+ end.each do |k, _v|
53
55
  relative_path = Pathname.new(k.path).relative_path_from(root).to_s
54
56
  if options[:prompt]
55
57
  print "Remove #{relative_path}(.m) [y/N] "
@@ -64,18 +66,17 @@ command :delete do |c|
64
66
  end
65
67
  File.delete(k.path) if options[:perform]
66
68
  impl_path = k.path.gsub(/\.h$/, '.m')
67
- if File.exists?(impl_path)
68
- relative_path = Pathname.new(impl_path).relative_path_from(root).to_s
69
- if global_options[:verbose]
70
- puts "Removing #{relative_path}#{options[:perform] ? '' : ' (simulation)'}\r\n"
71
- else
72
- puts "#{relative_path}#{options[:perform] ? '' : ' (simulation)'}\r\n"
73
- end
74
- File.delete(impl_path) if options[:perform]
69
+ next unless File.exist?(impl_path)
70
+ relative_path = Pathname.new(impl_path).relative_path_from(root).to_s
71
+ if global_options[:verbose]
72
+ puts "Removing #{relative_path}#{options[:perform] ? '' : ' (simulation)'}\r\n"
73
+ else
74
+ puts "#{relative_path}#{options[:perform] ? '' : ' (simulation)'}\r\n"
75
75
  end
76
+ File.delete(impl_path) if options[:perform]
76
77
  end
77
78
  ensure
78
- system("stty -raw echo")
79
+ system('stty -raw echo')
79
80
  end
80
81
  end
81
82
  end
@@ -1,10 +1,11 @@
1
1
  module Fui
2
2
  class Finder
3
- attr_reader :path
3
+ attr_reader :path, :options
4
4
 
5
- def initialize(path)
5
+ def initialize(path, options = {})
6
6
  @path = File.expand_path(path)
7
- raise Errno::ENOENT.new(path) unless Dir.exists?(@path)
7
+ @options = options
8
+ raise Errno::ENOENT, path unless Dir.exist?(@path)
8
9
  end
9
10
 
10
11
  def headers
@@ -18,10 +19,10 @@ module Fui
18
19
  references[header] = []
19
20
  end
20
21
  Find.find(path) do |path|
21
- next unless File.ftype(path) == "file"
22
- if [".m", ".h", ".pch"].include?(File.extname(path))
22
+ next unless File.ftype(path) == 'file'
23
+ if ['.m', '.h', '.pch'].include?(File.extname(path))
23
24
  process_code references, path, &block
24
- elsif [".storyboard", ".xib"].include?(File.extname(path))
25
+ elsif ['.storyboard', '.xib'].include?(File.extname(path))
25
26
  process_xml references, path, &block
26
27
  end
27
28
  end
@@ -30,21 +31,21 @@ module Fui
30
31
  end
31
32
 
32
33
  def unused_references(&block)
33
- @unused_references ||= references(&block).select { |k, v| v.count == 0 }
34
+ @unused_references ||= references(&block).select { |_k, v| v.count == 0 }
34
35
  end
35
36
 
36
37
  private
37
38
 
38
39
  # Find all files for which the block yields.
39
- def self.find(path, &block)
40
+ def self.find(path)
40
41
  results = []
41
- Find.find(path) { |fpath|
42
+ Find.find(path) do |fpath|
42
43
  results << fpath if yield fpath
43
- }
44
+ end
44
45
  results
45
46
  end
46
47
 
47
- def process_code(references, path, &block)
48
+ def process_code(references, path)
48
49
  File.open(path) do |file|
49
50
  yield path if block_given?
50
51
  filename = File.basename(path)
@@ -55,12 +56,12 @@ module Fui
55
56
  end
56
57
  end
57
58
 
58
- def process_xml(references, path, &block)
59
+ def process_xml(references, path)
59
60
  File.open(path) do |file|
60
61
  yield path if block_given?
61
62
  headers.each do |header|
62
63
  filename_without_extension = File.basename(path, File.extname(path))
63
- references[header] << path if File.read(file).include?("customClass=\"#{header.filename_without_extension}\"")
64
+ references[header] << path if (!options['ignorexib'] || filename_without_extension != header.filename_without_extension) && File.read(file).include?("customClass=\"#{header.filename_without_extension}\"")
64
65
  end
65
66
  end
66
67
  end
@@ -3,7 +3,7 @@ module Fui
3
3
  attr_accessor :filename, :filename_without_extension, :path
4
4
 
5
5
  def self.header?(path)
6
- File.extname(path) == ".h"
6
+ File.extname(path) == '.h'
7
7
  end
8
8
 
9
9
  def initialize(path)
@@ -1,3 +1,3 @@
1
1
  module Fui
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-07 00:00:00.000000000 Z
11
+ date: 2016-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description:
@@ -31,15 +31,15 @@ executables:
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - bin/fui
35
- - lib/fui/finder.rb
36
- - lib/fui/header.rb
37
- - lib/fui/version.rb
38
- - lib/fui.rb
39
34
  - CHANGELOG.md
40
35
  - CONTRIBUTING.md
41
36
  - LICENSE.md
42
37
  - README.md
38
+ - bin/fui
39
+ - lib/fui.rb
40
+ - lib/fui/finder.rb
41
+ - lib/fui/header.rb
42
+ - lib/fui/version.rb
43
43
  homepage: http://github.com/dblock/fui
44
44
  licenses:
45
45
  - MIT
@@ -50,17 +50,17 @@ require_paths:
50
50
  - lib
51
51
  required_ruby_version: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: 1.9.3
56
56
  required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - '>='
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 1.3.6
61
61
  requirements: []
62
62
  rubyforge_project:
63
- rubygems_version: 2.1.11
63
+ rubygems_version: 2.4.8
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: Find unused Objective-C imports.