Module: VV::FileMethods::ClassMethods
- Defined in:
- lib/vv/file_methods.rb
Instance Method Summary collapse
- #file ⇒ Object
- #file_directory ⇒ Object
- #pwd ⇒ Object
- #repo_directory(missing_throws_exception: true) ⇒ Object
- #separator ⇒ Object
- #vv_included? ⇒ Boolean
- #vv_readlines(*args, **kwargs) ⇒ Object
- #vv_split(string) ⇒ Object
Instance Method Details
#file ⇒ Object
66 67 68 |
# File 'lib/vv/file_methods.rb', line 66 def file caller_locations[0].path end |
#file_directory ⇒ Object
62 63 64 |
# File 'lib/vv/file_methods.rb', line 62 def file_directory File.(File.dirname(caller_locations[0].path)) end |
#pwd ⇒ Object
70 71 72 |
# File 'lib/vv/file_methods.rb', line 70 def pwd File.(Dir.pwd) end |
#repo_directory(missing_throws_exception: true) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vv/file_methods.rb', line 36 def repo_directory missing_throws_exception: true _path = caller_locations(1)[0].path _file_directory = File.(File.dirname(_path)) directory_fragments = File.vv_split _file_directory while directory_fragments.any? current_directory = File.join directory_fragments supported_source_control_directories = %w(.git .hg) supported_source_control_directories .each do | directory | full_path = File.join current_directory, directory path_exists = File.directory? full_path return current_directory if path_exists end directory_fragments.pop end return unless missing_throws_exception fail "No repository detected" end |
#separator ⇒ Object
74 75 76 |
# File 'lib/vv/file_methods.rb', line 74 def separator File::SEPARATOR end |
#vv_included? ⇒ Boolean
22 23 24 |
# File 'lib/vv/file_methods.rb', line 22 def vv_included? true end |
#vv_readlines(*args, **kwargs) ⇒ Object
26 27 28 |
# File 'lib/vv/file_methods.rb', line 26 def vv_readlines *args, **kwargs File.readlines(*args, **kwargs).map!(&:chomp) end |
#vv_split(string) ⇒ Object
30 31 32 33 34 |
# File 'lib/vv/file_methods.rb', line 30 def vv_split string response = string.split(File::SEPARATOR) response[0] = File::SEPARATOR if response.first.blank? response end |