Class: Pod::Command::Bin::ReverseImport
Instance Method Summary
collapse
#validate!
#binary_spec, #binary_spec_files, #binary_template_spec, #binary_template_spec_file, #binary_template_spec_files, #clear_binary_spec_file_if_needed, #code_spec, #code_spec_files, #create_binary_spec_file, #find_spec_file, #spec_files
#binary_source, #code_source, #sources_manager, #sources_option, #valid_sources
Constructor Details
Returns a new instance of ReverseImport.
12
13
14
15
16
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 12
def initialize(argv)
@current_path = argv.shift_argument || Dir.pwd
@framework_names = []
super
end
|
Instance Method Details
#child_dir ⇒ Object
46
47
48
49
50
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 46
def child_dir
dirs = Dir.entries(pod_folder_name)
dirs.reject!{ |d| File.directory?(d) }
dirs
end
|
#framework_name_reg ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 34
def framework_name_reg
@url_key_reg ||= begin
keys = @framework_names.join('|')
/#{keys}/
end
@url_key_reg
end
|
#get_all_frameworks ⇒ Object
29
30
31
32
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 29
def get_all_frameworks
folders = child_dir
folders.each { |name| @framework_names << name }
end
|
23
24
25
26
27
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 23
def
Dir.glob("#{@current_path}/**/*.{m,h,pch}").each do |f|
header_handler_file(f) unless f =~ /Pods/
end
end
|
#header_handler_file(f) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 56
def header_handler_file(f)
str = ''
File.readlines(f).each do |l|
if import_reg =~ l
ma = l.match(import_reg)
if framework_name_reg =~ ma[1]
str += "#import \"#{ma[2]}\"\n"
else
str += l.dup
end
else
str += l.dup
end
end
File.write(f, str)
end
|
#import_reg ⇒ Object
52
53
54
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 52
def import_reg
/#import\s*<(.*)\/(.*)>$/
end
|
#pod_folder_name ⇒ Object
42
43
44
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 42
def pod_folder_name
File.join(@current_path, 'MacauLife', 'CustomPods')
end
|
#run ⇒ Object
18
19
20
21
|
# File 'lib/cocoapods-lhj-bin/command/bin/reverse_import.rb', line 18
def run
get_all_frameworks
end
|