Module: NameFileFinder
- Defined in:
- lib/teuton/utils/name_file_finder.rb
Class Method Summary collapse
-
.find_configfilename_from_directory(folder_path) ⇒ Object
Find project config filename from input folder path.
- .find_configfilenames_from_rb(script_path) ⇒ Object
-
.find_filenames_for(relprojectpath) ⇒ Object
Find project filenames from input project relative path.
-
.find_filenames_from_directory(folder_path) ⇒ Object
Find project filenames from input folder path.
- .find_filenames_from_rb(script_path) ⇒ Object
- .verbose(text) ⇒ Object
- .verboseln(text) ⇒ Object
Class Method Details
.find_configfilename_from_directory(folder_path) ⇒ Object
Find project config filename from input folder path
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/teuton/utils/name_file_finder.rb', line 45 def self.find_configfilename_from_directory(folder_path) # COMPLEX MODE: We use config.yaml by default app = Application.instance config_path = "" if app.["cpath"].nil? config_name = "config" # Config name file is introduced by cname arg option from teuton command config_name = app.["cname"] unless app.["cname"].nil? config_path = File.join(folder_path, "#{config_name}.json") unless File.exist? config_path config_path = File.join(folder_path, "#{config_name}.yaml") end else # Config path file is introduced by cpath arg option from teuton command config_path = app.["cpath"] end app.config_path = config_path end |
.find_configfilenames_from_rb(script_path) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/teuton/utils/name_file_finder.rb', line 82 def self.find_configfilenames_from_rb(script_path) # SIMPLE MODE: We use script_path as main RB file # This must be fullpath to DSL script file app = Application.instance config_path = "" if app.["cpath"].nil? config_name = File.basename(script_path, ".rb") # Config name file is introduced by cname arg option from teuton command config_name = app.["cname"] unless app.["cname"].nil? config_path = File.join(app.project_path, config_name + ".json") unless File.exist? config_path config_path = File.join(app.project_path, config_name + ".yaml") end else # Config path file is introduced by cpath arg option from teuton command config_path = app.["cpath"] end app.config_path = config_path end |
.find_filenames_for(relprojectpath) ⇒ Object
Find project filenames from input project relative path
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/teuton/utils/name_file_finder.rb', line 7 def self.find_filenames_for(relprojectpath) projectpath = File.absolute_path(relprojectpath) # Define: # script_path, must contain fullpath to DSL script file # config_path, must contain fullpath to YAML config file if File.directory?(projectpath) # COMPLEX MODE: We use start.rb as main RB file find_filenames_from_directory(projectpath) else # SIMPLE MODE: We use pathtofile as main RB file find_filenames_from_rb(projectpath) end true end |
.find_filenames_from_directory(folder_path) ⇒ Object
Find project filenames from input folder path
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/teuton/utils/name_file_finder.rb', line 26 def self.find_filenames_from_directory(folder_path) # COMPLEX MODE: We use start.rb as main RB file script_path = File.join(folder_path, "start.rb") unless File.exist? script_path warn Rainbow("[ERROR] File not found: #{script_path}").bright.red exit 1 end app = Application.instance app.project_path = folder_path app.script_path = script_path app.test_name = folder_path.split(File::SEPARATOR)[-1] find_configfilename_from_directory(folder_path) end |
.find_filenames_from_rb(script_path) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/teuton/utils/name_file_finder.rb', line 65 def self.find_filenames_from_rb(script_path) # SIMPLE MODE: We use script_path as main RB file # This must be fullpath to DSL script file if File.extname(script_path) != ".rb" warn Rainbow("[ERROR] .rb extension required!").bright.red warn Rainbow(" #{script_path}").white exit 1 end app = Application.instance app.project_path = File.dirname(script_path) app.script_path = script_path app.test_name = File.basename(script_path, ".rb") find_configfilenames_from_rb(script_path) end |
.verbose(text) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/teuton/utils/name_file_finder.rb', line 108 def self.verbose(text) return unless Application.instance.verbose return if Application.instance.["quiet"] print text end |
.verboseln(text) ⇒ Object
104 105 106 |
# File 'lib/teuton/utils/name_file_finder.rb', line 104 def self.verboseln(text) verbose(text + "\n") end |