lib/sugar-high/file.rb in sugar-high-0.5.5 vs lib/sugar-high/file.rb in sugar-high-0.6.0
- old
+ new
@@ -1,47 +1,46 @@
require 'sugar-high/blank'
require 'sugar-high/arguments'
require 'sugar-high/path'
require 'sugar-high/regexp'
require 'sugar-high/string'
-require 'sugar-high/file_mutate'
require 'sugar-high/file_ext'
-class File
+class File
include SugarHigh::FileExt
- extend SugarHigh::FileExt::ClassMethods
+ extend SugarHigh::FileExt::ClassMethods
end
class Symbol
def as_filename
self.to_s.underscore
end
-
+
def valid_file_command?
[:read, :remove, :delete].include? self
end
-
+
def file
as_filename.file
- end
-end
+ end
+end
class NilClass
def valid_file_command?
false
end
-end
+end
class Array
def file_names ext = '*'
self.map{|a| a.gsub( /(.*)\//, '').gsub(/\.#{Regexp.escape(ext.to_s)}/, '')}
end
end
class String
def as_filename
- self.underscore
+ self.underscore
end
def valid_file_command?
self.to_sym.valid_file_command?
end
@@ -55,13 +54,13 @@
return ::Dir.new(self) if ::File.directory?(self)
raise "No file found at #{self}"
end
def new_file
- begin
+ begin
file
rescue
- File.open(self, 'w')
+ File.open(self, 'w')
end
end
end