Class: FileHelper
- Inherits:
-
Object
- Object
- FileHelper
- Defined in:
- lib/core_blur/util/file_helper.rb
Class Method Summary collapse
- .cp_rf_exclude_git(path1, path2) ⇒ Object
- .have_implementation_files(path) ⇒ Object
- .recursion_files(des_path, result_array) ⇒ Object
- .recursion_find(des_path, find, result_array) ⇒ Object
Class Method Details
.cp_rf_exclude_git(path1, path2) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/core_blur/util/file_helper.rb', line 4 def FileHelper.cp_rf_exclude_git(path1, path2) Dir.foreach(path2) do |file_name| if file_name == "." or file_name == ".." or file_name == ".git" next end sub_path = "#{path2}/#{file_name}" FileUtils.rm_rf(sub_path) end Dir.foreach(path1) do |file_name| if file_name == "." or file_name == ".." or file_name == ".git" next end sub_path = "#{path1}/#{file_name}" FileUtils.cp_r(sub_path, path2) end end |
.have_implementation_files(path) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/core_blur/util/file_helper.rb', line 51 def FileHelper.have_implementation_files(path) files = Dir[path] extends = %w[.m .mm .c .cc .cpp .swift] files.each do |file_path_str| extend_name = Pathname(file_path_str).extname if extends.include?(extend_name) return true end end false end |
.recursion_files(des_path, result_array) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/core_blur/util/file_helper.rb', line 36 def FileHelper.recursion_files(des_path, result_array) if not result_array or not result_array.is_a?(Array) return end if File.file?(des_path) result_array << des_path else Dir.foreach(des_path) { |file_name| sub_path = "#{des_path}/#{file_name}" unless file_name.start_with?(".") FileHelper.recursion_files(sub_path, result_array) end } end end |
.recursion_find(des_path, find, result_array) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/core_blur/util/file_helper.rb', line 20 def FileHelper.recursion_find(des_path, find, result_array) if not result_array or not result_array.is_a?(Array) return end find_path = "#{des_path}/#{find}" if File.exist?(find_path) result_array << find_path else Dir.foreach(des_path) { |file_name| sub_path = "#{des_path}/#{file_name}" if File.directory?(sub_path) and not file_name.start_with?(".") FileHelper.recursion_find(sub_path, find, result_array) end } end end |