Commits

Kaspar Schiess  committed bfc9b8f

+ Parses OS X zfs snapshots as well

  • Participants
  • Parent commits 809702b

Comments (0)

Files changed (3)

File Gemfile.lock

       diff-lcs (~> 1.1.2)
     rspec-mocks (2.6.0)
     sanitize (2.0.3)
-      nokogiri (< 1.6, >= 1.4.4)
+      nokogiri (>= 1.4.4, < 1.6)
     sdoc (0.3.11)
       json (>= 1.1.3)
       rdoc (~> 3)

File lib/snapshot_set.rb

     end
     
     def extract_timestamp(name)
-      if md=name.match(/(\d+)-(\d+)-(\d+)_(\d+)-(\d+)(.*)/)
+      if md=name.match(/(\d+)-(\d+)-(\d+)-(\d{2})(\d{2})(\d{2})(.*)/)
+        @time = Time.parse(md.captures.join) 
+      elsif md=name.match(/(\d+)-(\d+)-(\d+)_(\d+)-(\d+)(.*)/)
         @time = Time.parse(md.captures.join) 
       else
         @time = Time.parse(name)

File spec/unit/snapshot_set_spec.rb

       end 
     end
 
+    context "YYYY-MM-DD-HHMMSS" do
+      attr_reader :snapshot
+      before(:each) do
+        @snapshot = SnapshotSet::Snapshot.new('2012-02-15-213516')
+      end
+      
+      it "should have timestamp 15.2.2012 21:35:16" do
+        snapshot.time.should == Time.mktime(2012,2,15,21,35,16)
+      end
+    end
     context "YYYYMMDDstring" do
       attr_reader :snapshot
       before(:each) do