Module: Ptf::FileSystem
- Defined in:
- lib/ptf/file_system.rb
Class Method Summary collapse
- .base_dir ⇒ Object
- .config ⇒ Object
- .data_dir ⇒ Object
- .file_exist?(filepath) ⇒ Boolean
- .file_permission ⇒ Object
- .find_file(id, open = true) ⇒ Object
- .group_list_file ⇒ Object
- .id_counter_file ⇒ Object
- .id_counter_starting_content ⇒ Object
- .id_exist?(id) ⇒ Boolean
- .metadata_closed_dir ⇒ Object
- .metadata_dir ⇒ Object
- .metadata_open_dir ⇒ Object
- .tmp_dir ⇒ Object
Class Method Details
.base_dir ⇒ Object
19 20 21 |
# File 'lib/ptf/file_system.rb', line 19 def base_dir config[:base_dir] end |
.config ⇒ Object
9 10 11 12 13 |
# File 'lib/ptf/file_system.rb', line 9 def config @config = Ptf::Config.get_config if @config.nil? @config end |
.data_dir ⇒ Object
47 48 49 |
# File 'lib/ptf/file_system.rb', line 47 def data_dir File.join(base_dir, config[:task_data_dir]) end |
.file_exist?(filepath) ⇒ Boolean
5 6 7 |
# File 'lib/ptf/file_system.rb', line 5 def file_exist?(filepath) File.file?(filepath) end |
.file_permission ⇒ Object
15 16 17 |
# File 'lib/ptf/file_system.rb', line 15 def @config[:file_permission] end |
.find_file(id, open = true) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ptf/file_system.rb', line 61 def find_file(id, open = true) raise ArgumentError, "No task with id #{id} exists." unless id_exist?(id) search_dir = (open ? : ) groups = Ptf::Group.all_groups groups.each do |g| dir = File.join(search_dir, g.name) possible_id_file = File.join(dir, id.to_s) if file_exist?(possible_id_file) return possible_id_file end end nil end |
.group_list_file ⇒ Object
31 32 33 |
# File 'lib/ptf/file_system.rb', line 31 def group_list_file File.join(base_dir, config[:group_list_file]) end |
.id_counter_file ⇒ Object
23 24 25 |
# File 'lib/ptf/file_system.rb', line 23 def id_counter_file File.join(base_dir, config[:task_counter_file]) end |
.id_counter_starting_content ⇒ Object
27 28 29 |
# File 'lib/ptf/file_system.rb', line 27 def id_counter_starting_content config[:id_counter_start] end |
.id_exist?(id) ⇒ Boolean
55 56 57 58 59 |
# File 'lib/ptf/file_system.rb', line 55 def id_exist?(id) next_id = File.read(id_counter_file).to_i (id < next_id && id > 0) end |
.metadata_closed_dir ⇒ Object
43 44 45 |
# File 'lib/ptf/file_system.rb', line 43 def File.join(, config[:completed_dir]) end |
.metadata_dir ⇒ Object
35 36 37 |
# File 'lib/ptf/file_system.rb', line 35 def File.join(base_dir, config[:task_metadata_dir]) end |
.metadata_open_dir ⇒ Object
39 40 41 |
# File 'lib/ptf/file_system.rb', line 39 def File.join(, config[:in_progress_dir]) end |
.tmp_dir ⇒ Object
51 52 53 |
# File 'lib/ptf/file_system.rb', line 51 def tmp_dir File.join(base_dir, config[:tmp_dir]) end |