chrislloyd-fancypath 0.5.6 → 0.5.7
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/Rakefile +1 -1
- data/lib/fancypath.rb +8 -0
- data/spec/fancypath_spec.rb +21 -0
- metadata +2 -2
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/fancypath.rb
    CHANGED
    
    | @@ -107,6 +107,14 @@ class Fancypath < Pathname | |
| 107 107 | 
             
                super.reject { |c| c.basename.to_s =~ /^\./ }
         | 
| 108 108 | 
             
              end
         | 
| 109 109 |  | 
| 110 | 
            +
              # only takes sym atm
         | 
| 111 | 
            +
              def select(arg)
         | 
| 112 | 
            +
                case arg
         | 
| 113 | 
            +
                when Symbol ; Dir["#{self}/*.#{arg}"].map { |p| self.class.new(p) }
         | 
| 114 | 
            +
                else ; Dir["#{self}/#{arg}"].map { |p| self.class.new(p) }
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
              end
         | 
| 117 | 
            +
              
         | 
| 110 118 | 
             
              def inspect
         | 
| 111 119 | 
             
                super.sub('Pathname','Fancypath')
         | 
| 112 120 | 
             
              end
         | 
    
        data/spec/fancypath_spec.rb
    CHANGED
    
    | @@ -107,6 +107,27 @@ describe '#has_extension?' do | |
| 107 107 |  | 
| 108 108 | 
             
            end
         | 
| 109 109 |  | 
| 110 | 
            +
            describe '#select' do
         | 
| 111 | 
            +
              
         | 
| 112 | 
            +
              example 'with symbol' do
         | 
| 113 | 
            +
                @dir.create_dir
         | 
| 114 | 
            +
                %W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
         | 
| 115 | 
            +
                
         | 
| 116 | 
            +
                @dir.select(:jpg).should == [@dir/'a.jpg', @dir/'b.jpg']
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
              
         | 
| 119 | 
            +
              example 'with glob' do
         | 
| 120 | 
            +
                @dir.create_dir
         | 
| 121 | 
            +
                %W(a.jpg b.jpg c.gif).each { |f| (@dir/f).touch }
         | 
| 122 | 
            +
                
         | 
| 123 | 
            +
                @dir.select("*.jpg").should == [@dir/'a.jpg', @dir/'b.jpg']
         | 
| 124 | 
            +
              end
         | 
| 125 | 
            +
              
         | 
| 126 | 
            +
              # todo: with regex
         | 
| 127 | 
            +
              # todo: with block
         | 
| 128 | 
            +
              
         | 
| 129 | 
            +
            end
         | 
| 130 | 
            +
             | 
| 110 131 | 
             
            end #/Fancypath
         | 
| 111 132 |  | 
| 112 133 | 
             
            describe "String#to_path" do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: chrislloyd-fancypath
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Myles Byrne
         | 
| @@ -10,7 +10,7 @@ autorequire: fancypath | |
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 12 |  | 
| 13 | 
            -
            date: 2009-02- | 
| 13 | 
            +
            date: 2009-02-17 00:00:00 -08:00
         | 
| 14 14 | 
             
            default_executable: 
         | 
| 15 15 | 
             
            dependencies: []
         | 
| 16 16 |  |