Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fui: Add support for .mm files. #24

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 0.4.1 (Next)

* Your contribution here.
* [#24](https://github.com/dblock/fui/pull/24): Support .mm files - [@shachlan](https://github.com/Shachlan).

### 0.4.0 (5/14/2016)

Expand Down
2 changes: 1 addition & 1 deletion lib/fui/finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def references(&block)
end
Find.find(path) do |path|
next unless File.ftype(path) == 'file'
if ['.m', '.h', '.pch'].include?(File.extname(path))
if ['.m', '.mm', '.h', '.pch'].include?(File.extname(path))
process_code references, path, &block
elsif ['.storyboard', '.xib'].include?(File.extname(path))
process_xml references, path, &block
Expand Down
6 changes: 6 additions & 0 deletions spec/fixtures/mm/main.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import "used_class.h"

- void main()
{

}
8 changes: 8 additions & 0 deletions spec/fixtures/mm/unused_class.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// UnusedClass.h
// FUI
//

@interface UnusedClass

@end
10 changes: 10 additions & 0 deletions spec/fixtures/mm/unused_class.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// UnusedClass.mm
// FUI
//

#import "unused_class.h"

@implementation UnusedClass

@end
10 changes: 10 additions & 0 deletions spec/fixtures/mm/used_class.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// ImageView.h
// FUI
//

#import <UIKit/UIKit.h>

@interface ImageView
- (NSString *)fooForBar;
@end
14 changes: 14 additions & 0 deletions spec/fixtures/mm/used_class.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

//
// UsedClass.mm
// FUI
//

#import "used_class.h"

@implementation UsedClass
- (NSString *)fooForBar
{

}
@end
33 changes: 33 additions & 0 deletions spec/fui/finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,39 @@
end
end
end
context 'included from a .mm file' do
before :each do
@fixtures_dir = File.expand_path(File.join(__FILE__, '../../fixtures/mm'))
end
describe '#find' do
it 'finds all files for which the block yields true' do
files = Fui::Finder.send(:find, @fixtures_dir) do |file|
File.extname(file) == '.h'
end
expect(files.sort).to eq Dir["#{@fixtures_dir}/*.h"].sort
end
end
describe '#headers' do
it 'finds all headers' do
finder = Fui::Finder.new(@fixtures_dir)
expect(finder.headers.map(&:filename).sort).to eq(['unused_class.h', 'used_class.h'])
end
end
describe '#references' do
it 'maps references' do
finder = Fui::Finder.new(@fixtures_dir)
expect(finder.references.size).to eq(2)
expect(Hash[finder.references.map { |k, v| [k.filename, v.count] }]).to eq('unused_class.h' => 0,
'used_class.h' => 1)
end
end
describe '#unsed_references' do
it 'finds unused references' do
finder = Fui::Finder.new(@fixtures_dir)
expect(Hash[finder.unused_references.map { |k, v| [k.filename, v.count] }]).to eq('unused_class.h' => 0)
end
end
end
context 'included from a .pch file' do
before :each do
@fixtures_dir = File.expand_path(File.join(__FILE__, '../../fixtures/pch'))
Expand Down