Class: FilenameFormatter
- Inherits:
-
Object
- Object
- FilenameFormatter
- Defined in:
- lib/filename_formatter.rb
Constant Summary collapse
- CODERSDOJO_WORKSPACE =
".codersdojo"
- RESULT_FILE =
"result.txt"
- INFO_FILE =
"info.yml"
- STATE_DIR_PREFIX =
"state_"
- DIR_SEPARATOR =
'/'
Class Method Summary collapse
Instance Method Summary collapse
- #concat_path(path, item) ⇒ Object
- #info_file(state_dir) ⇒ Object
- #result_file(state_dir) ⇒ Object
- #session_dir(session_id) ⇒ Object
- #source_file_in_state_dir?(file) ⇒ Boolean
- #state_dir(session_id, step) ⇒ Object
- #state_file(state_dir, file) ⇒ Object
- #step_number_from_state_dir(state_dir) ⇒ Object
Class Method Details
.codersdojo_workspace ⇒ Object
15 16 17 |
# File 'lib/filename_formatter.rb', line 15 def self.codersdojo_workspace CODERSDOJO_WORKSPACE end |
.state_dir_prefix ⇒ Object
11 12 13 |
# File 'lib/filename_formatter.rb', line 11 def self.state_dir_prefix STATE_DIR_PREFIX end |
Instance Method Details
#concat_path(path, item) ⇒ Object
49 50 51 52 |
# File 'lib/filename_formatter.rb', line 49 def concat_path path, item separator = path.end_with?(DIR_SEPARATOR) ? '' : DIR_SEPARATOR "#{path}#{separator}#{item}" end |
#info_file(state_dir) ⇒ Object
28 29 30 |
# File 'lib/filename_formatter.rb', line 28 def info_file state_dir state_file state_dir, INFO_FILE end |
#result_file(state_dir) ⇒ Object
24 25 26 |
# File 'lib/filename_formatter.rb', line 24 def result_file state_dir state_file state_dir, RESULT_FILE end |
#session_dir(session_id) ⇒ Object
45 46 47 |
# File 'lib/filename_formatter.rb', line 45 def session_dir session_id concat_path CODERSDOJO_WORKSPACE, session_id end |
#source_file_in_state_dir?(file) ⇒ Boolean
19 20 21 22 |
# File 'lib/filename_formatter.rb', line 19 def source_file_in_state_dir? file file = Filename.new(file).extract_last_path_item.to_s file != '..' and file != '.' and file != INFO_FILE and file != RESULT_FILE end |
#state_dir(session_id, step) ⇒ Object
36 37 38 39 |
# File 'lib/filename_formatter.rb', line 36 def state_dir session_id, step session_directory = session_dir session_id concat_path session_directory, "#{STATE_DIR_PREFIX}#{step}" end |
#state_file(state_dir, file) ⇒ Object
32 33 34 |
# File 'lib/filename_formatter.rb', line 32 def state_file state_dir, file concat_path state_dir, file end |
#step_number_from_state_dir(state_dir) ⇒ Object
41 42 43 |
# File 'lib/filename_formatter.rb', line 41 def step_number_from_state_dir state_dir state_dir.delete(STATE_DIR_PREFIX).to_i end |