ptf 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,83 +0,0 @@
1
- module Ptf
2
- module Utilities
3
- module FileSystem
4
- class << self
5
-
6
- def file_exist?(filepath)
7
- File.file?(filepath)
8
- end
9
-
10
- def config
11
- @config = Ptf::Config.get_config if @config.nil?
12
-
13
- @config
14
- end
15
-
16
- def file_permission
17
- @config[:file_permission]
18
- end
19
-
20
- def base_dir
21
- config[:base_dir]
22
- end
23
-
24
- def id_counter_file
25
- File.join(base_dir, config[:task_counter_file])
26
- end
27
-
28
- def id_counter_starting_content
29
- config[:id_counter_start]
30
- end
31
-
32
- def group_list_file
33
- File.join(base_dir, config[:group_list_file])
34
- end
35
-
36
- def metadata_dir
37
- File.join(base_dir, config[:task_metadata_dir])
38
- end
39
-
40
- def metadata_open_dir
41
- File.join(metadata_dir, config[:in_progress_dir])
42
- end
43
-
44
- def metadata_closed_dir
45
- File.join(metadata_dir, config[:completed_dir])
46
- end
47
-
48
- def data_dir
49
- File.join(base_dir, config[:task_data_dir])
50
- end
51
-
52
- def tmp_dir
53
- File.join(base_dir, config[:tmp_dir])
54
- end
55
-
56
- def id_exist?(id)
57
- next_id = File.read(id_counter_file).to_i
58
-
59
- (id < next_id && id > 0)
60
- end
61
-
62
- def find_file(id, open = true)
63
- raise ArgumentError, "No task with id #{id} exists." unless id_exist?(id)
64
-
65
- search_dir = (open ? metadata_open_dir : metadata_closed_dir)
66
- groups = Ptf::Data::Group.all_groups
67
-
68
- groups.each do |g|
69
- dir = File.join(search_dir, g.name)
70
- possible_id_file = File.join(dir, id.to_s)
71
-
72
- if file_exist?(possible_id_file)
73
- return possible_id_file
74
- end
75
- end
76
-
77
- nil
78
- end
79
-
80
- end
81
- end
82
- end
83
- end