Class: XmlFile
- Inherits:
-
Object
- Object
- XmlFile
- Defined in:
- lib/rest.rb
Constant Summary collapse
- @@include_dir =
""
Class Method Summary collapse
- .copy(file_name, output_dir) ⇒ Object
- .exist?(file_name) ⇒ Boolean
- .exists?(file_name) ⇒ Boolean
- .find_file(file_name) ⇒ Object
- .include_dir=(dir) ⇒ Object
Class Method Details
.copy(file_name, output_dir) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rest.rb', line 22 def XmlFile.copy file_name, output_dir dir_name = File.dirname( file_name ) if ( dir_name =~ /^\// ) puts STDERR, "Absolute file names aren't allowed as XML file names." + " (#{dir_name})"; return end if ( dir_name ) output_dir += "/" + dir_name end if ( dir_name && !dir_name.empty? && !File.exist?( dir_name ) ) `mkdir -p #{output_dir}` if ( $? != 0 ) puts STDERR, "Unable to create directory '#{dir_name}'" end end src_file = find_file( file_name ) unless File.absolute_path(output_dir) == File.absolute_path(File.split( src_file).first) # do not copy to itself FileUtils.cp( src_file, output_dir ) end end |
.exist?(file_name) ⇒ Boolean
14 15 16 |
# File 'lib/rest.rb', line 14 def XmlFile.exist? file_name exists? file_name end |
.exists?(file_name) ⇒ Boolean
18 19 20 |
# File 'lib/rest.rb', line 18 def XmlFile.exists? file_name find_file file_name end |
.find_file(file_name) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rest.rb', line 49 def XmlFile.find_file file_name if ( File.exists? file_name ) return file_name end if ( !@@include_dir.empty? ) file_name = @@include_dir + "/" + file_name if ( File.exists? file_name ) return file_name end end return nil end |
.include_dir=(dir) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/rest.rb', line 7 def XmlFile.include_dir= dir if !dir dir = "" end @@include_dir = dir end |