gom-filesystem-adapter 0.1.0 → 0.2.0
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 +4 -0
 - data/lib/gom/storage/filesystem.rb +1 -0
 - data/lib/gom/storage/filesystem/adapter.rb +16 -13
 - data/lib/gom/storage/filesystem/collection.rb +18 -0
 - data/lib/gom/storage/filesystem/collection/fetcher.rb +32 -0
 - data/lib/gom/storage/filesystem/loader.rb +20 -19
 - data/spec/gom/storage/filesystem/adapter_spec.rb +51 -14
 - data/spec/gom/storage/filesystem/collection/fetcher_spec.rb +24 -0
 - data/spec/gom/storage/filesystem/loader_spec.rb +13 -16
 - data/spec/storage.configuration +6 -3
 - metadata +9 -5
 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -42,6 +42,10 @@ A fetch of that book would look like: 
     | 
|
| 
       42 
42 
     | 
    
         
             
            The fetched object would have the instance variable <tt>@pages</tt> set to <tt>1253</tt> and <tt>@author</tt> would
         
     | 
| 
       43 
43 
     | 
    
         
             
            point to an object of the class <tt>Author</tt> with the id <tt>author_1</tt>.
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
      
 45 
     | 
    
         
            +
            == Views
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            This adapter currently supports class views. For documentation see http://github.com/phifty/gom.
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
       45 
49 
     | 
    
         
             
            == Development
         
     | 
| 
       46 
50 
     | 
    
         | 
| 
       47 
51 
     | 
    
         
             
            Development has been done test-driven and the code follows at most the Clean Code paradigms. Code smells has been
         
     | 
| 
         @@ -6,6 +6,7 @@ module GOM 
     | 
|
| 
       6 
6 
     | 
    
         
             
                module Filesystem
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  autoload :Adapter, File.join(File.dirname(__FILE__), "filesystem", "adapter")
         
     | 
| 
      
 9 
     | 
    
         
            +
                  autoload :Collection, File.join(File.dirname(__FILE__), "filesystem", "collection")
         
     | 
| 
       9 
10 
     | 
    
         
             
                  autoload :Loader, File.join(File.dirname(__FILE__), "filesystem", "loader")
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
                end
         
     | 
| 
         @@ -8,33 +8,36 @@ module GOM 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  # The filesystem storage adapter
         
     | 
| 
       9 
9 
     | 
    
         
             
                  class Adapter < GOM::Storage::Adapter
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                    def initialize(configuration)
         
     | 
| 
       12 
     | 
    
         
            -
                      super configuration
         
     | 
| 
       13 
     | 
    
         
            -
                    end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
11 
     | 
    
         
             
                    def setup
         
     | 
| 
       16 
     | 
    
         
            -
                       
     | 
| 
      
 12 
     | 
    
         
            +
                      load_drafts
         
     | 
| 
       17 
13 
     | 
    
         
             
                    end
         
     | 
| 
       18 
14 
     | 
    
         | 
| 
       19 
15 
     | 
    
         
             
                    def fetch(id)
         
     | 
| 
       20 
     | 
    
         
            -
                      @ 
     | 
| 
      
 16 
     | 
    
         
            +
                      @drafts[id]
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    def store(*arguments)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      read_only_error
         
     | 
| 
       21 
21 
     | 
    
         
             
                    end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
                    def  
     | 
| 
       24 
     | 
    
         
            -
                      read_only_error 
     | 
| 
      
 23 
     | 
    
         
            +
                    def remove(*arguments)
         
     | 
| 
      
 24 
     | 
    
         
            +
                      read_only_error
         
     | 
| 
       25 
25 
     | 
    
         
             
                    end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                    def  
     | 
| 
       28 
     | 
    
         
            -
                       
     | 
| 
      
 27 
     | 
    
         
            +
                    def collection(view_name, options = { })
         
     | 
| 
      
 28 
     | 
    
         
            +
                      view = configuration.views[view_name.to_sym]
         
     | 
| 
      
 29 
     | 
    
         
            +
                      raise ViewNotFoundError, "there are no view with the name #{view_name}" unless view
         
     | 
| 
      
 30 
     | 
    
         
            +
                      fetcher = Collection::Fetcher.new @drafts, view
         
     | 
| 
      
 31 
     | 
    
         
            +
                      GOM::Object::Collection.new fetcher
         
     | 
| 
       29 
32 
     | 
    
         
             
                    end
         
     | 
| 
       30 
33 
     | 
    
         | 
| 
       31 
34 
     | 
    
         
             
                    private
         
     | 
| 
       32 
35 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                    def  
     | 
| 
       34 
     | 
    
         
            -
                      @ 
     | 
| 
      
 36 
     | 
    
         
            +
                    def load_drafts
         
     | 
| 
      
 37 
     | 
    
         
            +
                      @drafts = GOM::Storage::Filesystem::Loader.new(configuration[:directory]).drafts
         
     | 
| 
       35 
38 
     | 
    
         
             
                    end
         
     | 
| 
       36 
39 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                    def read_only_error 
     | 
| 
      
 40 
     | 
    
         
            +
                    def read_only_error
         
     | 
| 
       38 
41 
     | 
    
         
             
                      raise GOM::Storage::ReadOnlyError, "The adapter doesn't provide write methods"
         
     | 
| 
       39 
42 
     | 
    
         
             
                    end
         
     | 
| 
       40 
43 
     | 
    
         | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            module GOM
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              module Storage
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                module Filesystem
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  module Collection
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    # A class collection fetcher for the filesystem adapter.
         
     | 
| 
      
 11 
     | 
    
         
            +
                    class Fetcher
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                      attr_accessor :drafts
         
     | 
| 
      
 14 
     | 
    
         
            +
                      attr_accessor :view
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                      def initialize(drafts, view)
         
     | 
| 
      
 17 
     | 
    
         
            +
                        @drafts, @view = drafts, view
         
     | 
| 
      
 18 
     | 
    
         
            +
                      end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                      def drafts
         
     | 
| 
      
 21 
     | 
    
         
            +
                        @drafts.values.select{ |draft| draft.class_name == @view.class_name }
         
     | 
| 
      
 22 
     | 
    
         
            +
                      end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -13,18 +13,17 @@ module GOM 
     | 
|
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                    def initialize(directory)
         
     | 
| 
       15 
15 
     | 
    
         
             
                      @directory = directory
         
     | 
| 
       16 
     | 
    
         
            -
                      @data = { }
         
     | 
| 
       17 
16 
     | 
    
         
             
                    end
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                    def  
     | 
| 
      
 18 
     | 
    
         
            +
                    def drafts
         
     | 
| 
      
 19 
     | 
    
         
            +
                      @drafts = { }
         
     | 
| 
       20 
20 
     | 
    
         
             
                      load_yml_files
         
     | 
| 
       21 
     | 
    
         
            -
                      @ 
     | 
| 
      
 21 
     | 
    
         
            +
                      @drafts
         
     | 
| 
       22 
22 
     | 
    
         
             
                    end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                    private
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                    def load_yml_files
         
     | 
| 
       27 
     | 
    
         
            -
                      @data = { }
         
     | 
| 
       28 
27 
     | 
    
         
             
                      Dir[File.join(@directory, "*.yml")].each do |filename|
         
     | 
| 
       29 
28 
     | 
    
         
             
                        load_yml_file filename
         
     | 
| 
       30 
29 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -37,43 +36,45 @@ module GOM 
     | 
|
| 
       37 
36 
     | 
    
         | 
| 
       38 
37 
     | 
    
         
             
                    def load_file_hash(classname, file_hash)
         
     | 
| 
       39 
38 
     | 
    
         
             
                      file_hash.each do |id, hash|
         
     | 
| 
       40 
     | 
    
         
            -
                        @ 
     | 
| 
      
 39 
     | 
    
         
            +
                        @drafts[id] = Builder.new(classname, hash).draft
         
     | 
| 
       41 
40 
     | 
    
         
             
                      end
         
     | 
| 
       42 
41 
     | 
    
         
             
                    end
         
     | 
| 
       43 
42 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
                    # Builds  
     | 
| 
      
 43 
     | 
    
         
            +
                    # Builds a draft out of the file hashes.
         
     | 
| 
       45 
44 
     | 
    
         
             
                    class Builder
         
     | 
| 
       46 
45 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
                       
     | 
| 
      
 46 
     | 
    
         
            +
                      def initialize(class_name, hash)
         
     | 
| 
      
 47 
     | 
    
         
            +
                        @class_name, @hash = class_name, hash
         
     | 
| 
      
 48 
     | 
    
         
            +
                      end
         
     | 
| 
       48 
49 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
                      def  
     | 
| 
       50 
     | 
    
         
            -
                        @ 
     | 
| 
       51 
     | 
    
         
            -
                         
     | 
| 
       52 
     | 
    
         
            -
                         
     | 
| 
       53 
     | 
    
         
            -
                         
     | 
| 
       54 
     | 
    
         
            -
                         
     | 
| 
      
 50 
     | 
    
         
            +
                      def draft
         
     | 
| 
      
 51 
     | 
    
         
            +
                        @draft = GOM::Object::Draft.new
         
     | 
| 
      
 52 
     | 
    
         
            +
                        set_class_name
         
     | 
| 
      
 53 
     | 
    
         
            +
                        set_properties
         
     | 
| 
      
 54 
     | 
    
         
            +
                        set_relations
         
     | 
| 
      
 55 
     | 
    
         
            +
                        @draft
         
     | 
| 
       55 
56 
     | 
    
         
             
                      end
         
     | 
| 
       56 
57 
     | 
    
         | 
| 
       57 
58 
     | 
    
         
             
                      private
         
     | 
| 
       58 
59 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                      def  
     | 
| 
       60 
     | 
    
         
            -
                        @ 
     | 
| 
      
 60 
     | 
    
         
            +
                      def set_class_name
         
     | 
| 
      
 61 
     | 
    
         
            +
                        @draft.class_name = @class_name
         
     | 
| 
       61 
62 
     | 
    
         
             
                      end
         
     | 
| 
       62 
63 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
                      def  
     | 
| 
      
 64 
     | 
    
         
            +
                      def set_properties
         
     | 
| 
       64 
65 
     | 
    
         
             
                        properties = { }
         
     | 
| 
       65 
66 
     | 
    
         
             
                        (@hash["properties"] || { }).each do |key, value|
         
     | 
| 
       66 
67 
     | 
    
         
             
                          properties[key] = value
         
     | 
| 
       67 
68 
     | 
    
         
             
                        end
         
     | 
| 
       68 
     | 
    
         
            -
                        @ 
     | 
| 
      
 69 
     | 
    
         
            +
                        @draft.properties = properties unless properties.empty?
         
     | 
| 
       69 
70 
     | 
    
         
             
                      end
         
     | 
| 
       70 
71 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
                      def  
     | 
| 
      
 72 
     | 
    
         
            +
                      def set_relations
         
     | 
| 
       72 
73 
     | 
    
         
             
                        relations = { }
         
     | 
| 
       73 
74 
     | 
    
         
             
                        (@hash["relations"] || { }).each do |key, value|
         
     | 
| 
       74 
75 
     | 
    
         
             
                          relations[key] = GOM::Object::Proxy.new GOM::Object::Id.new(value)
         
     | 
| 
       75 
76 
     | 
    
         
             
                        end
         
     | 
| 
       76 
     | 
    
         
            -
                        @ 
     | 
| 
      
 77 
     | 
    
         
            +
                        @draft.relations = relations unless relations.empty?
         
     | 
| 
       77 
78 
     | 
    
         
             
                      end
         
     | 
| 
       78 
79 
     | 
    
         | 
| 
       79 
80 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -3,18 +3,10 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "sp 
     | 
|
| 
       3 
3 
     | 
    
         
             
            describe GOM::Storage::Filesystem::Adapter do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              before :each do
         
     | 
| 
       6 
     | 
    
         
            -
                @ 
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  },
         
     | 
| 
       11 
     | 
    
         
            -
                  "object_2" => {
         
     | 
| 
       12 
     | 
    
         
            -
                    :class => "Object",
         
     | 
| 
       13 
     | 
    
         
            -
                    :properties => { :test => "another test value" }
         
     | 
| 
       14 
     | 
    
         
            -
                  }
         
     | 
| 
       15 
     | 
    
         
            -
                }
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                @loader = mock GOM::Storage::Filesystem::Loader, :data => @data
         
     | 
| 
      
 6 
     | 
    
         
            +
                @draft = mock GOM::Object::Draft
         
     | 
| 
      
 7 
     | 
    
         
            +
                @drafts = mock Hash, :[] => @draft
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                @loader = mock GOM::Storage::Filesystem::Loader, :drafts => @drafts
         
     | 
| 
       18 
10 
     | 
    
         
             
                GOM::Storage::Filesystem::Loader.stub(:new).and_return(@loader)
         
     | 
| 
       19 
11 
     | 
    
         | 
| 
       20 
12 
     | 
    
         
             
                @configuration = mock GOM::Storage::Configuration
         
     | 
| 
         @@ -34,7 +26,7 @@ describe GOM::Storage::Filesystem::Adapter do 
     | 
|
| 
       34 
26 
     | 
    
         
             
                end
         
     | 
| 
       35 
27 
     | 
    
         | 
| 
       36 
28 
     | 
    
         
             
                it "should load the data" do
         
     | 
| 
       37 
     | 
    
         
            -
                  @loader.should_receive(: 
     | 
| 
      
 29 
     | 
    
         
            +
                  @loader.should_receive(:drafts).and_return(@drafts)
         
     | 
| 
       38 
30 
     | 
    
         
             
                  @adapter.setup
         
     | 
| 
       39 
31 
     | 
    
         
             
                end
         
     | 
| 
       40 
32 
     | 
    
         | 
| 
         @@ -47,7 +39,7 @@ describe GOM::Storage::Filesystem::Adapter do 
     | 
|
| 
       47 
39 
     | 
    
         
             
                end
         
     | 
| 
       48 
40 
     | 
    
         | 
| 
       49 
41 
     | 
    
         
             
                it "should return the object hash" do
         
     | 
| 
       50 
     | 
    
         
            -
                  @adapter.fetch("object_1").should == @ 
     | 
| 
      
 42 
     | 
    
         
            +
                  @adapter.fetch("object_1").should == @draft
         
     | 
| 
       51 
43 
     | 
    
         
             
                end
         
     | 
| 
       52 
44 
     | 
    
         | 
| 
       53 
45 
     | 
    
         
             
              end
         
     | 
| 
         @@ -72,4 +64,49 @@ describe GOM::Storage::Filesystem::Adapter do 
     | 
|
| 
       72 
64 
     | 
    
         | 
| 
       73 
65 
     | 
    
         
             
              end
         
     | 
| 
       74 
66 
     | 
    
         | 
| 
      
 67 
     | 
    
         
            +
              describe "collection" do
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                before :each do
         
     | 
| 
      
 70 
     | 
    
         
            +
                  @adapter.setup
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                  @view = mock GOM::Storage::Configuration::View::Class
         
     | 
| 
      
 73 
     | 
    
         
            +
                  @views = mock Hash, :[] => @view
         
     | 
| 
      
 74 
     | 
    
         
            +
                  @configuration.stub(:views).and_return(@views)
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                  @fetcher = mock GOM::Storage::Filesystem::Collection::Fetcher
         
     | 
| 
      
 77 
     | 
    
         
            +
                  GOM::Storage::Filesystem::Collection::Fetcher.stub(:new).and_return(@fetcher)
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  @collection = mock GOM::Object::Collection
         
     | 
| 
      
 80 
     | 
    
         
            +
                  GOM::Object::Collection.stub(:new).and_return(@collection)
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                it "should select the right view" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                  @views.should_receive(:[]).with(:test_object_class_view).and_return(@view)
         
     | 
| 
      
 85 
     | 
    
         
            +
                  @adapter.collection "test_object_class_view"
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                it "should raise a #{described_class::ViewNotFoundError} if view name if invalid" do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  @views.stub(:[]).and_return(nil)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  lambda do
         
     | 
| 
      
 91 
     | 
    
         
            +
                    @adapter.collection :test_object_class_view
         
     | 
| 
      
 92 
     | 
    
         
            +
                  end.should raise_error(described_class::ViewNotFoundError)
         
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                it "should initialize the collection fetcher" do
         
     | 
| 
      
 96 
     | 
    
         
            +
                  GOM::Storage::Filesystem::Collection::Fetcher.should_receive(:new).with(@drafts, @view).and_return(@fetcher)
         
     | 
| 
      
 97 
     | 
    
         
            +
                  @adapter.collection :test_object_class_view
         
     | 
| 
      
 98 
     | 
    
         
            +
                end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                it "should initialize the collection" do
         
     | 
| 
      
 101 
     | 
    
         
            +
                  GOM::Object::Collection.should_receive(:new).and_return(@collection)
         
     | 
| 
      
 102 
     | 
    
         
            +
                  @adapter.collection :test_object_class_view
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                it "should return the collection" do
         
     | 
| 
      
 106 
     | 
    
         
            +
                  collection = @adapter.collection :test_object_class_view
         
     | 
| 
      
 107 
     | 
    
         
            +
                  collection.should == @collection
         
     | 
| 
      
 108 
     | 
    
         
            +
                end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
       75 
112 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "..", "spec_helper"))
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe GOM::Storage::Filesystem::Collection::Fetcher do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              before :each do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @draft_one = mock GOM::Object::Draft, :class_name => "Object"
         
     | 
| 
      
 7 
     | 
    
         
            +
                @draft_two = mock GOM::Object::Draft, :class_name => "Test"
         
     | 
| 
      
 8 
     | 
    
         
            +
                @drafts = mock Hash, :values => [ @draft_one, @draft_two ]
         
     | 
| 
      
 9 
     | 
    
         
            +
                @view = mock GOM::Storage::Configuration::View::Class, :class_name => "Object"
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                @fetcher = described_class.new @drafts, @view
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              describe "drafts" do
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                it "should return an array with a selection of drafts" do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  drafts = @fetcher.drafts
         
     | 
| 
      
 18 
     | 
    
         
            +
                  drafts.should include(@draft_one)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  drafts.should_not include(@draft_two)
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -15,7 +15,7 @@ describe GOM::Storage::Filesystem::Loader do 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
              end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
              describe " 
     | 
| 
      
 18 
     | 
    
         
            +
              describe "drafts" do
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                before :each do
         
     | 
| 
       21 
21 
     | 
    
         
             
                  @filename = "directory/Object.yml"
         
     | 
| 
         @@ -45,31 +45,28 @@ describe GOM::Storage::Filesystem::Loader do 
     | 
|
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
                it "should searches all .yml file in the directory" do
         
     | 
| 
       47 
47 
     | 
    
         
             
                  Dir.should_receive(:[]).with("directory/*.yml").and_return(@filenames)
         
     | 
| 
       48 
     | 
    
         
            -
                  @loader. 
     | 
| 
      
 48 
     | 
    
         
            +
                  @loader.drafts
         
     | 
| 
       49 
49 
     | 
    
         
             
                end
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
51 
     | 
    
         
             
                it "should load the files" do
         
     | 
| 
       52 
52 
     | 
    
         
             
                  YAML.should_receive(:load_file).with(@filename).and_return(@file_hash)
         
     | 
| 
       53 
     | 
    
         
            -
                  @loader. 
     | 
| 
      
 53 
     | 
    
         
            +
                  @loader.drafts
         
     | 
| 
       54 
54 
     | 
    
         
             
                end
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
       56 
56 
     | 
    
         
             
                it "should create object proxies for relations" do
         
     | 
| 
       57 
57 
     | 
    
         
             
                  GOM::Object::Proxy.should_receive(:new).with(GOM::Object::Id.new("test_storage:object_2")).and_return(@proxy)
         
     | 
| 
       58 
     | 
    
         
            -
                  @loader. 
     | 
| 
      
 58 
     | 
    
         
            +
                  @loader.drafts
         
     | 
| 
       59 
59 
     | 
    
         
             
                end
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                it "should convert the file hash into  
     | 
| 
       62 
     | 
    
         
            -
                  @loader. 
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                      :properties => { "test" => "another test value" }
         
     | 
| 
       71 
     | 
    
         
            -
                    }
         
     | 
| 
       72 
     | 
    
         
            -
                  }
         
     | 
| 
      
 61 
     | 
    
         
            +
                it "should convert the file hash into drafts" do
         
     | 
| 
      
 62 
     | 
    
         
            +
                  draft_one = @loader.drafts["object_1"]
         
     | 
| 
      
 63 
     | 
    
         
            +
                  draft_one.class_name.should == "Object"
         
     | 
| 
      
 64 
     | 
    
         
            +
                  draft_one.properties.should == { "test" => "test value" }
         
     | 
| 
      
 65 
     | 
    
         
            +
                  draft_one.relations.should == { "related_object" => @proxy }
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                  draft_two = @loader.drafts["object_2"]
         
     | 
| 
      
 68 
     | 
    
         
            +
                  draft_two.class_name.should == "Object"
         
     | 
| 
      
 69 
     | 
    
         
            +
                  draft_two.properties.should == { "test" => "another test value" }
         
     | 
| 
       73 
70 
     | 
    
         
             
                end
         
     | 
| 
       74 
71 
     | 
    
         | 
| 
       75 
72 
     | 
    
         
             
              end
         
     | 
    
        data/spec/storage.configuration
    CHANGED
    
    | 
         @@ -1,5 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
2 
     | 
    
         
             
            test_storage:
         
     | 
| 
       3 
     | 
    
         
            -
              adapter: 
     | 
| 
       4 
     | 
    
         
            -
              directory: 
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
      
 3 
     | 
    
         
            +
              adapter:   filesystem
         
     | 
| 
      
 4 
     | 
    
         
            +
              directory: /home/phifty/projects/gom-filesystem-adapter/spec/acceptance/data
         
     | 
| 
      
 5 
     | 
    
         
            +
              views:
         
     | 
| 
      
 6 
     | 
    
         
            +
                test_object_class_view:
         
     | 
| 
      
 7 
     | 
    
         
            +
                  type: class
         
     | 
| 
      
 8 
     | 
    
         
            +
                  class: Object
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       4 
4 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
     | 
    
         
            -
              -  
     | 
| 
      
 7 
     | 
    
         
            +
              - 2
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - "Philipp Br\xC3\xBCll"
         
     | 
| 
         @@ -14,7 +14,7 @@ autorequire: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2010-12- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-12-20 00:00:00 +01:00
         
     | 
| 
       18 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -27,9 +27,9 @@ dependencies: 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       28 
28 
     | 
    
         
             
                    segments: 
         
     | 
| 
       29 
29 
     | 
    
         
             
                    - 0
         
     | 
| 
       30 
     | 
    
         
            -
                    -  
     | 
| 
      
 30 
     | 
    
         
            +
                    - 2
         
     | 
| 
       31 
31 
     | 
    
         
             
                    - 0
         
     | 
| 
       32 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 0.2.0
         
     | 
| 
       33 
33 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       34 
34 
     | 
    
         
             
              version_requirements: *id001
         
     | 
| 
       35 
35 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -73,9 +73,12 @@ files: 
     | 
|
| 
       73 
73 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       74 
74 
     | 
    
         
             
            - lib/gom/storage/filesystem/adapter.rb
         
     | 
| 
       75 
75 
     | 
    
         
             
            - lib/gom/storage/filesystem/loader.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
            - lib/gom/storage/filesystem/collection/fetcher.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            - lib/gom/storage/filesystem/collection.rb
         
     | 
| 
       76 
78 
     | 
    
         
             
            - lib/gom/storage/filesystem.rb
         
     | 
| 
       77 
79 
     | 
    
         
             
            - lib/gom/storage.rb
         
     | 
| 
       78 
80 
     | 
    
         
             
            - lib/filesystem.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
            - spec/gom/storage/filesystem/collection/fetcher_spec.rb
         
     | 
| 
       79 
82 
     | 
    
         
             
            - spec/gom/storage/filesystem/adapter_spec.rb
         
     | 
| 
       80 
83 
     | 
    
         
             
            - spec/gom/storage/filesystem/loader_spec.rb
         
     | 
| 
       81 
84 
     | 
    
         
             
            - spec/storage.configuration
         
     | 
| 
         @@ -115,6 +118,7 @@ signing_key: 
     | 
|
| 
       115 
118 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       116 
119 
     | 
    
         
             
            summary: Filesystem storage adapter for the General Object Mapper.
         
     | 
| 
       117 
120 
     | 
    
         
             
            test_files: 
         
     | 
| 
      
 121 
     | 
    
         
            +
            - spec/gom/storage/filesystem/collection/fetcher_spec.rb
         
     | 
| 
       118 
122 
     | 
    
         
             
            - spec/gom/storage/filesystem/adapter_spec.rb
         
     | 
| 
       119 
123 
     | 
    
         
             
            - spec/gom/storage/filesystem/loader_spec.rb
         
     | 
| 
       120 
124 
     | 
    
         
             
            - spec/acceptance/adapter_spec.rb
         
     |