fancypath 0.3.0 → 0.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{README.rdoc → README} +1 -3
 - data/lib/fancypath.rb +91 -22
 - metadata +10 -14
 - data/Rakefile +0 -57
 - data/spec/fancypath_spec.rb +0 -75
 - data/spec/spec_helper.rb +0 -6
 
    
        data/{README.rdoc → README}
    RENAMED
    
    
    
        data/lib/fancypath.rb
    CHANGED
    
    | 
         @@ -1,78 +1,147 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'pathname'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            class Pathname
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              def to_fancypath
         
     | 
| 
       5 
6 
     | 
    
         
             
                Fancypath.new(self)
         
     | 
| 
       6 
7 
     | 
    
         
             
              end
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
              alias_method : 
     | 
| 
      
 9 
     | 
    
         
            +
              alias_method :to_path, :to_fancypath
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            end
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
            class String
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              def to_fancypath
         
     | 
| 
       14 
16 
     | 
    
         
             
                Fancypath.new(self)
         
     | 
| 
       15 
17 
     | 
    
         
             
              end
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              alias_method : 
     | 
| 
      
 19 
     | 
    
         
            +
              alias_method :to_path, :to_fancypath
         
     | 
| 
       18 
20 
     | 
    
         | 
| 
       19 
21 
     | 
    
         
             
            end
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
            class Fancypath < Pathname
         
     | 
| 
       22 
24 
     | 
    
         
             
              # methods are chainable and do what you think they do
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              alias_method :dir, :dirname
         
     | 
| 
      
 27 
     | 
    
         
            +
              alias_method :directory, :dirname
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              alias_method :expand, :expand_path
         
     | 
| 
      
 30 
     | 
    
         
            +
              alias_method :abs, :expand_path
         
     | 
| 
      
 31 
     | 
    
         
            +
              alias_method :absolute, :expand_path
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       24 
33 
     | 
    
         
             
              alias_method :exists?, :exist?
         
     | 
| 
       25 
34 
     | 
    
         
             
              alias_method :rename_to, :rename
         
     | 
| 
       26 
35 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
              def  
     | 
| 
       28 
     | 
    
         
            -
                 
     | 
| 
      
 36 
     | 
    
         
            +
              def join(path)
         
     | 
| 
      
 37 
     | 
    
         
            +
                super(path).to_path
         
     | 
| 
       29 
38 
     | 
    
         
             
              end
         
     | 
| 
       30 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
              alias_method :/, :join
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       31 
42 
     | 
    
         
             
              # make file
         
     | 
| 
       32 
43 
     | 
    
         
             
              def touch
         
     | 
| 
       33 
44 
     | 
    
         
             
                FileUtils.touch self.to_s
         
     | 
| 
       34 
     | 
    
         
            -
                self 
     | 
| 
      
 45 
     | 
    
         
            +
                self
         
     | 
| 
       35 
46 
     | 
    
         
             
              end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
               
     | 
| 
       38 
     | 
    
         
            -
              def create
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              def create_dir
         
     | 
| 
       39 
49 
     | 
    
         
             
                mkpath unless exist?
         
     | 
| 
       40 
     | 
    
         
            -
                self 
     | 
| 
      
 50 
     | 
    
         
            +
                self
         
     | 
| 
       41 
51 
     | 
    
         
             
              end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              alias_method :create, :create_dir
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       43 
55 
     | 
    
         
             
              def copy(dest)
         
     | 
| 
       44 
56 
     | 
    
         
             
                FileUtils.cp(self, dest)
         
     | 
| 
       45 
57 
     | 
    
         
             
                self
         
     | 
| 
       46 
58 
     | 
    
         
             
              end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              alias_method :cp, :copy
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
       48 
62 
     | 
    
         
             
              # file or dir
         
     | 
| 
       49 
63 
     | 
    
         
             
              def remove
         
     | 
| 
       50 
64 
     | 
    
         
             
                directory? ? rmtree : delete if exist?
         
     | 
| 
       51 
     | 
    
         
            -
                self 
     | 
| 
      
 65 
     | 
    
         
            +
                self
         
     | 
| 
       52 
66 
     | 
    
         
             
              end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              alias_method :rm, :remove
         
     | 
| 
       54 
69 
     | 
    
         
             
              def write(contents, mode='wb')
         
     | 
| 
       55 
70 
     | 
    
         
             
                dirname.create
         
     | 
| 
       56 
71 
     | 
    
         
             
                open(mode) { |f| f.write contents }
         
     | 
| 
       57 
     | 
    
         
            -
                self 
     | 
| 
      
 72 
     | 
    
         
            +
                self
         
     | 
| 
       58 
73 
     | 
    
         
             
              end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
       60 
75 
     | 
    
         
             
              def append(contents)
         
     | 
| 
       61 
76 
     | 
    
         
             
                write(contents,'a+')
         
     | 
| 
      
 77 
     | 
    
         
            +
                self
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              def move(dest)
         
     | 
| 
      
 81 
     | 
    
         
            +
                self.rename(dest)
         
     | 
| 
      
 82 
     | 
    
         
            +
                dest.to_path
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              def tail(bytes)
         
     | 
| 
      
 86 
     | 
    
         
            +
                return self.read if self.size < bytes
         
     | 
| 
      
 87 
     | 
    
         
            +
                open('r') do |f|
         
     | 
| 
      
 88 
     | 
    
         
            +
                  f.seek(-bytes, IO::SEEK_END)
         
     | 
| 
      
 89 
     | 
    
         
            +
                  f.read
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
              end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
              alias_method :mv, :move
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              def set_extension(ext)
         
     | 
| 
      
 96 
     | 
    
         
            +
                "#{without_extension}.#{ext}".to_path
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              alias_method :change_extension, :set_extension
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              def without_extension
         
     | 
| 
      
 102 
     | 
    
         
            +
                to_s[/^ (.+?) (\. ([^\.]+))? $/x, 1].to_path
         
     | 
| 
      
 103 
     | 
    
         
            +
              end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
              def has_extension?(ext)
         
     | 
| 
      
 106 
     | 
    
         
            +
                !!(self.to_s =~ /\.#{ext}$/)
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
              def parent
         
     | 
| 
      
 110 
     | 
    
         
            +
                super.to_path
         
     | 
| 
      
 111 
     | 
    
         
            +
              end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
              alias_method :all_children, :children
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
              def children
         
     | 
| 
      
 116 
     | 
    
         
            +
                super.reject { |c| c.basename.to_s =~ /^\./ }
         
     | 
| 
      
 117 
     | 
    
         
            +
              end
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              # only takes sym atm
         
     | 
| 
      
 120 
     | 
    
         
            +
              def select(*args)
         
     | 
| 
      
 121 
     | 
    
         
            +
                return args.map { |arg| select(arg) }.flatten.uniq if args.size > 1
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                case arg = args.first
         
     | 
| 
      
 124 
     | 
    
         
            +
                when Symbol
         
     | 
| 
      
 125 
     | 
    
         
            +
                  Dir["#{self}/*.#{arg}"].map { |p| self.class.new(p) }
         
     | 
| 
      
 126 
     | 
    
         
            +
                when Regexp
         
     | 
| 
      
 127 
     | 
    
         
            +
                  children.select { |child| child.to_s =~ arg }
         
     | 
| 
      
 128 
     | 
    
         
            +
                else
         
     | 
| 
      
 129 
     | 
    
         
            +
                  Dir["#{self}/#{arg}"].map { |p| self.class.new(p) }
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
       62 
131 
     | 
    
         
             
              end
         
     | 
| 
       63 
132 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
              def  
     | 
| 
       65 
     | 
    
         
            -
                children. 
     | 
| 
      
 133 
     | 
    
         
            +
              def empty?
         
     | 
| 
      
 134 
     | 
    
         
            +
                directory? ? children.size == 0 : self.size == 0
         
     | 
| 
       66 
135 
     | 
    
         
             
              end
         
     | 
| 
       67 
136 
     | 
    
         | 
| 
       68 
137 
     | 
    
         
             
              def inspect
         
     | 
| 
       69 
138 
     | 
    
         
             
                super.sub('Pathname','Fancypath')
         
     | 
| 
       70 
139 
     | 
    
         
             
              end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
       72 
141 
     | 
    
         
             
              def to_path
         
     | 
| 
       73 
142 
     | 
    
         
             
                self
         
     | 
| 
       74 
143 
     | 
    
         
             
              end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
       76 
145 
     | 
    
         
             
            end
         
     | 
| 
       77 
146 
     | 
    
         | 
| 
       78 
147 
     | 
    
         
             
            def Fancypath(path); Fancypath.new(path) end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,37 +1,33 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: fancypath
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.12
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Myles Byrne
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Chris Lloyd
         
     | 
| 
       9 
     | 
    
         
            -
            autorequire:  
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2009-07-12 00:00:00 +10:00
         
     | 
| 
       14 
14 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
            description: Extensions for the Pathname library.
         
     | 
| 
       18 
     | 
    
         
            -
            email: myles@ 
     | 
| 
      
 18 
     | 
    
         
            +
            email: myles@myles.id.au
         
     | 
| 
       19 
19 
     | 
    
         
             
            executables: []
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            extensions: []
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            extra_rdoc_files: 
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
            - LICENSE
         
     | 
| 
      
 23 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       26 
25 
     | 
    
         
             
            files: 
         
     | 
| 
       27 
26 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       28 
     | 
    
         
            -
            - README 
     | 
| 
       29 
     | 
    
         
            -
            - Rakefile
         
     | 
| 
      
 27 
     | 
    
         
            +
            - README
         
     | 
| 
       30 
28 
     | 
    
         
             
            - lib/fancypath.rb
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
            has_rdoc: true
         
     | 
| 
       34 
     | 
    
         
            -
            homepage: http://ducknewmedia.com/fancypath
         
     | 
| 
      
 29 
     | 
    
         
            +
            has_rdoc: false
         
     | 
| 
      
 30 
     | 
    
         
            +
            homepage: http://github.com/tred/fancypath/tree/master
         
     | 
| 
       35 
31 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       36 
32 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       37 
33 
     | 
    
         | 
| 
         @@ -51,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       51 
47 
     | 
    
         
             
              version: 
         
     | 
| 
       52 
48 
     | 
    
         
             
            requirements: []
         
     | 
| 
       53 
49 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
            rubyforge_project: 
         
     | 
| 
      
 50 
     | 
    
         
            +
            rubyforge_project: fancypath
         
     | 
| 
       55 
51 
     | 
    
         
             
            rubygems_version: 1.3.1
         
     | 
| 
       56 
52 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       57 
53 
     | 
    
         
             
            specification_version: 2
         
     | 
    
        data/Rakefile
    DELETED
    
    | 
         @@ -1,57 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'rake/gempackagetask'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'rubygems/specification'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'date'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'spec/rake/spectask'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            GEM = "fancypath"
         
     | 
| 
       8 
     | 
    
         
            -
            GEM_VERSION = "0.3.0"
         
     | 
| 
       9 
     | 
    
         
            -
            AUTHORS = ["Myles Byrne", "Chris Lloyd"]
         
     | 
| 
       10 
     | 
    
         
            -
            EMAIL = "myles@ducknewmedia.com"
         
     | 
| 
       11 
     | 
    
         
            -
            HOMEPAGE = "http://ducknewmedia.com/fancypath"
         
     | 
| 
       12 
     | 
    
         
            -
            SUMMARY = "Extensions for the Pathname library."
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            spec = Gem::Specification.new do |s|
         
     | 
| 
       15 
     | 
    
         
            -
              s.name = GEM
         
     | 
| 
       16 
     | 
    
         
            -
              s.version = GEM_VERSION
         
     | 
| 
       17 
     | 
    
         
            -
              s.platform = Gem::Platform::RUBY
         
     | 
| 
       18 
     | 
    
         
            -
              s.has_rdoc = true
         
     | 
| 
       19 
     | 
    
         
            -
              s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
         
     | 
| 
       20 
     | 
    
         
            -
              s.summary = SUMMARY
         
     | 
| 
       21 
     | 
    
         
            -
              s.description = s.summary
         
     | 
| 
       22 
     | 
    
         
            -
              s.authors = AUTHORS
         
     | 
| 
       23 
     | 
    
         
            -
              s.email = EMAIL
         
     | 
| 
       24 
     | 
    
         
            -
              s.homepage = HOMEPAGE
         
     | 
| 
       25 
     | 
    
         
            -
              
         
     | 
| 
       26 
     | 
    
         
            -
              # Uncomment this to add a dependency
         
     | 
| 
       27 
     | 
    
         
            -
              # s.add_dependency "foo"
         
     | 
| 
       28 
     | 
    
         
            -
              
         
     | 
| 
       29 
     | 
    
         
            -
              s.require_path = 'lib'
         
     | 
| 
       30 
     | 
    
         
            -
              s.autorequire = GEM
         
     | 
| 
       31 
     | 
    
         
            -
              s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
         
     | 
| 
       32 
     | 
    
         
            -
            end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            task :default => :spec
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            desc "Run specs"
         
     | 
| 
       37 
     | 
    
         
            -
            Spec::Rake::SpecTask.new do |t|
         
     | 
| 
       38 
     | 
    
         
            -
              t.spec_files = FileList['spec/**/*_spec.rb']
         
     | 
| 
       39 
     | 
    
         
            -
              t.spec_opts = %w(-fs --color)
         
     | 
| 
       40 
     | 
    
         
            -
            end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
            Rake::GemPackageTask.new(spec) do |pkg|
         
     | 
| 
       44 
     | 
    
         
            -
              pkg.gem_spec = spec
         
     | 
| 
       45 
     | 
    
         
            -
            end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
            desc "install the gem locally"
         
     | 
| 
       48 
     | 
    
         
            -
            task :install => [:package] do
         
     | 
| 
       49 
     | 
    
         
            -
              sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
         
     | 
| 
       50 
     | 
    
         
            -
            end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
            desc "create a gemspec file"
         
     | 
| 
       53 
     | 
    
         
            -
            task :make_spec do
         
     | 
| 
       54 
     | 
    
         
            -
              File.open("#{GEM}.gemspec", "w") do |file|
         
     | 
| 
       55 
     | 
    
         
            -
                file.puts spec.to_ruby
         
     | 
| 
       56 
     | 
    
         
            -
              end
         
     | 
| 
       57 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/fancypath_spec.rb
    DELETED
    
    | 
         @@ -1,75 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.dirname(__FILE__) + '/spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Fancypath do
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            before do
         
     | 
| 
       6 
     | 
    
         
            -
              TMP_DIR.rmtree if TMP_DIR.exist?
         
     | 
| 
       7 
     | 
    
         
            -
              TMP_DIR.mkpath
         
     | 
| 
       8 
     | 
    
         
            -
              @file = TMP_DIR.to_path/'testfile'
         
     | 
| 
       9 
     | 
    
         
            -
              @dir = TMP_DIR.to_path/'testdir'
         
     | 
| 
       10 
     | 
    
         
            -
            end
         
     | 
| 
       11 
     | 
    
         
            -
            after  { TMP_DIR.rmtree }
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            describe '#/' do
         
     | 
| 
       14 
     | 
    
         
            -
              
         
     | 
| 
       15 
     | 
    
         
            -
              it('returns a Fancypath') { (@dir/'somefile').class.should == Fancypath }  
         
     | 
| 
       16 
     | 
    
         
            -
              it('joins paths') { (@dir/'somefile').to_s.should =~ /\/somefile$/ }
         
     | 
| 
       17 
     | 
    
         
            -
              
         
     | 
| 
       18 
     | 
    
         
            -
            end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            describe '#touch', 'file does not exist' do
         
     | 
| 
       21 
     | 
    
         
            -
              
         
     | 
| 
       22 
     | 
    
         
            -
              it('returns self') { @file.touch.should == @file }  
         
     | 
| 
       23 
     | 
    
         
            -
              it('returns a Fancypath') { @file.touch.should be_instance_of(Fancypath) }
         
     | 
| 
       24 
     | 
    
         
            -
              it('creates file') { @file.touch.should be_file }
         
     | 
| 
       25 
     | 
    
         
            -
              
         
     | 
| 
       26 
     | 
    
         
            -
            end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            describe '#create', 'dir does not exist' do
         
     | 
| 
       29 
     | 
    
         
            -
              
         
     | 
| 
       30 
     | 
    
         
            -
              it('returns self') { @dir.create.should == @dir }
         
     | 
| 
       31 
     | 
    
         
            -
              it('returns a Fancypath') { @dir.create.should be_instance_of(Fancypath) }
         
     | 
| 
       32 
     | 
    
         
            -
              it('creates directory') { @dir.create.should be_directory }
         
     | 
| 
       33 
     | 
    
         
            -
              
         
     | 
| 
       34 
     | 
    
         
            -
            end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            describe '#remove' do
         
     | 
| 
       37 
     | 
    
         
            -
              
         
     | 
| 
       38 
     | 
    
         
            -
              it('returns self') { @file.remove.should == @file }
         
     | 
| 
       39 
     | 
    
         
            -
              it('returns a Fancypath') { @file.remove.should be_instance_of(Fancypath) }
         
     | 
| 
       40 
     | 
    
         
            -
              it('removes file') { @file.touch.remove.should_not exist }  
         
     | 
| 
       41 
     | 
    
         
            -
              it('removes directory') { @dir.create.remove.should_not exist }
         
     | 
| 
       42 
     | 
    
         
            -
              
         
     | 
| 
       43 
     | 
    
         
            -
            end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
            describe '#write' do
         
     | 
| 
       46 
     | 
    
         
            -
              
         
     | 
| 
       47 
     | 
    
         
            -
              it('returns self') { @file.write('').should == @file }
         
     | 
| 
       48 
     | 
    
         
            -
              it('returns a Fancypath') { @file.write('').should be_instance_of(Fancypath) }
         
     | 
| 
       49 
     | 
    
         
            -
              it('writes contents to file') { @file.write('test').read.should == 'test' }
         
     | 
| 
       50 
     | 
    
         
            -
              
         
     | 
| 
       51 
     | 
    
         
            -
            end
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
            describe '#copy' do
         
     | 
| 
       54 
     | 
    
         
            -
              
         
     | 
| 
       55 
     | 
    
         
            -
              before { @file.touch }
         
     | 
| 
       56 
     | 
    
         
            -
              it('returns a Fancypath') { @file.copy(TMP_DIR/'foo').should be_instance_of(Fancypath) }
         
     | 
| 
       57 
     | 
    
         
            -
              it('creates a new file') { @file.copy(TMP_DIR/'foo').should exist }
         
     | 
| 
       58 
     | 
    
         
            -
              it('keeps the original') { @file.copy(TMP_DIR/'foo'); @file.should exist }
         
     | 
| 
       59 
     | 
    
         
            -
              it('copies the contents') { @file.copy(TMP_DIR/'foo').read.should == @file.read }
         
     | 
| 
       60 
     | 
    
         
            -
              
         
     | 
| 
       61 
     | 
    
         
            -
            end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
            end #/Fancypath
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
            describe "String#to_path" do
         
     | 
| 
       66 
     | 
    
         
            -
              
         
     | 
| 
       67 
     | 
    
         
            -
              it('returns a Fancypath') { 'test'.to_path.should be_instance_of(Fancypath) }
         
     | 
| 
       68 
     | 
    
         
            -
              
         
     | 
| 
       69 
     | 
    
         
            -
            end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
            describe "Pathname#to_path" do
         
     | 
| 
       72 
     | 
    
         
            -
              
         
     | 
| 
       73 
     | 
    
         
            -
              it('returns a Fancypath') { Fancypath.new('/').to_path.should be_instance_of(Fancypath) }
         
     | 
| 
       74 
     | 
    
         
            -
              
         
     | 
| 
       75 
     | 
    
         
            -
            end
         
     |