Module: Shard::ShardDirectory
Instance Method Summary collapse
-
#create_shard_dir(ref) ⇒ Object
# Module Methods # #.
- #directory(ref) ⇒ Object
- #file_path(ref, filename, options = {}) ⇒ Object
- #find_file_path(ref, filename, options = {}) ⇒ Object
- #find_file_paths(ref, *filenames) ⇒ Object
- #root_path ⇒ Object
- #shard_dir_exists?(ref) ⇒ Boolean
Instance Method Details
#create_shard_dir(ref) ⇒ Object
# Module Methods #
#
11 12 13 14 15 16 17 |
# File 'lib/shard/shard_directory.rb', line 11 def create_shard_dir(ref) dir = directory(ref) unless shard_dir_exists?(ref) FileUtils.mkpath(dir) end end |
#directory(ref) ⇒ Object
23 24 25 |
# File 'lib/shard/shard_directory.rb', line 23 def directory(ref) File.join(root_path, ref.user, ref.name, ref.version) end |
#file_path(ref, filename, options = {}) ⇒ Object
31 32 33 |
# File 'lib/shard/shard_directory.rb', line 31 def file_path(ref, filename, = {}) File.join( directory(ref), filename ) end |
#find_file_path(ref, filename, options = {}) ⇒ Object
35 36 37 |
# File 'lib/shard/shard_directory.rb', line 35 def find_file_path(ref, filename, = {}) find_file_paths(ref, filename).first end |
#find_file_paths(ref, *filenames) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/shard/shard_directory.rb', line 39 def find_file_paths(ref, *filenames) full_names = filenames.map do |filename| File.join( directory(ref), filename) end Dir[ *full_names ] end |
#root_path ⇒ Object
27 28 29 |
# File 'lib/shard/shard_directory.rb', line 27 def root_path File.join(Dir.home, '.shard') end |
#shard_dir_exists?(ref) ⇒ Boolean
19 20 21 |
# File 'lib/shard/shard_directory.rb', line 19 def shard_dir_exists?(ref) Dir.exists? directory(ref) end |