Sha256: b1853ed20a7f21cffc47b604494ceb119262aea1799140a231445babad000281

Contents?: true

Size: 1.71 KB

Versions: 18

Compression:

Stored size: 1.71 KB

Contents

module Redcar
  class Project
    module Adapters
      class Local
        def touch(new_file_path)
          FileUtils.touch(new_file_path)
        end
        
        def mkdir(new_dir_path)
          FileUtils.mkdir(new_dir_path)
        end
        
        def mv(path, new_path)
          FileUtils.mv(path, new_path)
        end
        
        def file?(path)
          File.file?(path)
        end
        
        def directory?(path)
          File.directory?(path)
        end
        
        def empty_directory?(path)
          Dir.glob("#{path}/*", File::FNM_DOTMATCH).length <= 2
        end
        
        def fetch_contents(path, force=false)
          Dir.glob("#{path}/*", File::FNM_DOTMATCH).map do |fn|
            is_dir = directory?(fn)
            hash = {
              :fullname => fn,
              :type => (is_dir ? :dir : :file),
            }
            if is_dir
              hash[:empty] = empty_directory?(fn)
            end
            hash
          end
        end

        def load(file)
          File.open(file, 'rb') do |f|; f.read; end
        end

        def save(file, contents)
          File.open(file, "wb") {|f| f.print contents }
        end
        
        def mtime(file)
          File.stat(file).mtime
        end
        
        def exists?(file)
          File.exists?(file)
        end
        
        def delete(file)
          FileUtils.rm_rf(file)
        end
        
        def load_contents(file)
          File.open(file, 'rb') do |f|; f.read; end
        end
        
        def save_contents(file)
          File.open(file, "wb") {|f| f.print contents }
        end
        
        def refresh_operation(tree)
          yield
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
redcar-0.7 plugins/project/lib/project/adapters/local.rb
redcar-0.6.1 plugins/project/lib/project/adapters/local.rb
redcar-0.6 plugins/project/lib/project/adapters/local.rb
redcar-0.6.1dev plugins/project/lib/project/adapters/local.rb
redcar-0.5.1 plugins/project/lib/project/adapters/local.rb
redcar-0.5 plugins/project/lib/project/adapters/local.rb
redcar-0.5.6dev plugins/project/lib/project/adapters/local.rb
redcar-0.5.5dev plugins/project/lib/project/adapters/local.rb
redcar-0.5.4dev plugins/project/lib/project/adapters/local.rb
redcar-0.5.3dev plugins/project/lib/project/adapters/local.rb
redcar-0.5.2dev plugins/project/lib/project/adapters/local.rb
redcar-0.5.1dev plugins/project/lib/project/adapters/local.rb
redcar-0.4.1 plugins/project/lib/project/adapters/local.rb
redcar-0.4 plugins/project/lib/project/adapters/local.rb
redcar-0.3.10.1dev plugins/project/lib/project/adapters/local.rb
redcar-0.3.10.0dev plugins/project/lib/project/adapters/local.rb
redcar-0.3.9 plugins/project/lib/project/adapters/local.rb
redcar-0.3.9.0dev plugins/project/lib/project/adapters/local.rb