lib/arli/actions/dir_name.rb in arli-1.0.0 vs lib/arli/actions/dir_name.rb in arli-1.0.1

- old
+ new

@@ -14,11 +14,10 @@ description 'Auto-detects the canonical library folder name' attr_accessor :sources, :headers def execute - find_source_files # so "dir" is the 'Adafruit_Unified_Sensor' # but we found header Adafruit_Sensor we should # rename the folder @@ -31,17 +30,28 @@ if_only_one(sources) || if_header_a_substring(headers) set_canonical_dir!(candidate) end + + if if_no(sources) && if_have(headers) + library.headers_only = true + end end private def set_canonical_dir!(canonical_dir) if canonical_dir && canonical_dir != dir - mv(dir, canonical_dir) + # if they are match case insensitively, we may be + # on a mac where these are considered the same + if dir =~ /^#{canonical_dir}$/i + mv(dir, canonical_dir + '.temp') + mv(canonical_dir + '.temp', canonical_dir) + else + mv(dir, canonical_dir) + end library.canonical_dir = canonical_dir else library.canonical_dir = dir end print_target_dir(library.canonical_dir, 'installed to') @@ -53,9 +63,17 @@ def if_only_one(file_names) if file_names.size == 1 && file_names.first != dir file_names.first end + end + + def if_no(file_names) + file_names.nil? || file_names.empty? + end + + def if_have(file_names) + file_names && !file_names.empty? end def find_source_files Dir.chdir(dir) do self.sources = files_with_extension('**.{cpp,c}')