minimapper 0.0.3 → 0.0.4
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/.gitignore +0 -3
 - data/README.md +132 -45
 - data/lib/minimapper/entity/convert.rb +41 -0
 - data/lib/minimapper/entity.rb +9 -1
 - data/lib/minimapper/version.rb +1 -1
 - data/spec/support/shared_examples/mapper.rb +14 -14
 - data/unit/entity/convert_spec.rb +23 -0
 - data/unit/entity_spec.rb +20 -0
 - metadata +46 -67
 
    
        data/.gitignore
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -2,26 +2,36 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            # Minimapper
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## About
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ### Introduction
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            A minimalistic way of separating your models from ORMs like ActiveRecord that allows you to swap out your persistence layer for an in-memory implementation in tests or use different persistence for different models.
         
     | 
| 
       6 
10 
     | 
    
         | 
| 
       7 
11 
     | 
    
         
             
            If you're following good style you're probably already pushing all knowledge of your ORM down into your models or model-layer classes. This takes it a step further and let's you work with your models without depending on heavy frameworks like rails or needing a database.
         
     | 
| 
       8 
12 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            Minimapper is a partial [repository-pattern](http://martinfowler.com/eaaCatalog/repository.html) implementation (it implements repositories and data mappers but not  
     | 
| 
      
 13 
     | 
    
         
            +
            Minimapper is a partial [repository-pattern](http://martinfowler.com/eaaCatalog/repository.html) implementation (it implements repositories and data mappers but not criteria builders).
         
     | 
| 
       10 
14 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
            ### Only the most basic API
         
     | 
| 
       12 
16 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            This library only implements the most basic  
     | 
| 
      
 17 
     | 
    
         
            +
            This library only implements the most basic persistence API (mostly just CRUD). Any significant additions will be made into separate gems (with names like "minimapper-FOO").
         
     | 
| 
       14 
18 
     | 
    
         | 
| 
       15 
19 
     | 
    
         
             
            The reasons for this are:
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       16 
21 
     | 
    
         
             
            * You should be able to depend on the API
         
     | 
| 
       17 
22 
     | 
    
         
             
            * It should be possible to learn all it does in a short time
         
     | 
| 
       18 
23 
     | 
    
         
             
            * It should be simple to add an adapter for a new database
         
     | 
| 
       19 
24 
     | 
    
         
             
            * It should be simple to maintain minimapper
         
     | 
| 
       20 
25 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
            ### Compatibility
         
     | 
| 
       22 
27 
     | 
    
         | 
| 
       23 
28 
     | 
    
         
             
            This gem is tested against all major rubies in both 1.8 and 1.9, see [.travis.yml](https://github.com/joakimk/minimapper/blob/master/.travis.yml). For each ruby version, the SQL mappers are tested against SQLite3, PostgreSQL and MySQL.
         
     | 
| 
       24 
29 
     | 
    
         | 
| 
      
 30 
     | 
    
         
            +
            ### Early days
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            This is not quite intended for production use yet. It's a very small API that is well tested so you could use it in production apps, but there are still some problem areas that hasn't been well explored (for example, how to handle associations). It is probably better to use this than to roll your own project specific solution though.
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       25 
35 
     | 
    
         
             
            ## Installation
         
     | 
| 
       26 
36 
     | 
    
         | 
| 
       27 
37 
     | 
    
         
             
            Add this line to your application's Gemfile:
         
     | 
| 
         @@ -40,9 +50,12 @@ Please avoid installing directly from the github repository. Code will be pushed 
     | 
|
| 
       40 
50 
     | 
    
         | 
| 
       41 
51 
     | 
    
         
             
            ## Usage
         
     | 
| 
       42 
52 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 53 
     | 
    
         
            +
            ### Basics
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            You can use the mappers like this (**it's runnable, try copy and pasting it into a ruby file** or [use this gist](https://gist.github.com/3904952)):
         
     | 
| 
       44 
56 
     | 
    
         | 
| 
       45 
57 
     | 
    
         
             
            ``` ruby
         
     | 
| 
      
 58 
     | 
    
         
            +
            # minimapper_test.rb
         
     | 
| 
       46 
59 
     | 
    
         
             
            require "rubygems"
         
     | 
| 
       47 
60 
     | 
    
         
             
            require "minimapper"
         
     | 
| 
       48 
61 
     | 
    
         
             
            require "minimapper/entity"
         
     | 
| 
         @@ -56,35 +69,31 @@ end 
     | 
|
| 
       56 
69 
     | 
    
         
             
            class UserMapper < Minimapper::Memory
         
     | 
| 
       57 
70 
     | 
    
         
             
            end
         
     | 
| 
       58 
71 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 72 
     | 
    
         
            +
            ## Creating
         
     | 
| 
       60 
73 
     | 
    
         
             
            user = User.new(:name => "Joe")
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
      
 74 
     | 
    
         
            +
            user_mapper = UserMapper.new
         
     | 
| 
      
 75 
     | 
    
         
            +
            user_mapper.create(user)
         
     | 
| 
       63 
76 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
            user =  
     | 
| 
       66 
     | 
    
         
            -
            puts user.name             #  
     | 
| 
       67 
     | 
    
         
            -
            puts  
     | 
| 
      
 77 
     | 
    
         
            +
            ## Finding
         
     | 
| 
      
 78 
     | 
    
         
            +
            user = user_mapper.find(user.id)
         
     | 
| 
      
 79 
     | 
    
         
            +
            puts user.name             # => Joe
         
     | 
| 
      
 80 
     | 
    
         
            +
            puts user_mapper.first.name     # => Joe
         
     | 
| 
       68 
81 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
      
 82 
     | 
    
         
            +
            ## Updating
         
     | 
| 
       70 
83 
     | 
    
         
             
            user.name = "Joey"
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
            puts  
     | 
| 
      
 84 
     | 
    
         
            +
            user_mapper.update(user)
         
     | 
| 
      
 85 
     | 
    
         
            +
            puts user_mapper.first.name    # => Joey
         
     | 
| 
       73 
86 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
      
 87 
     | 
    
         
            +
            ## Deleting
         
     | 
| 
       75 
88 
     | 
    
         
             
            old_id = user.id
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
            user.id                   #  
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
            #  
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
            Or though a repository:
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
            ``` ruby
         
     | 
| 
      
 89 
     | 
    
         
            +
            user_mapper.delete(user)
         
     | 
| 
      
 90 
     | 
    
         
            +
            puts user.id                   # => nil
         
     | 
| 
      
 91 
     | 
    
         
            +
            puts user_mapper.find_by_id(old_id) # => nil
         
     | 
| 
      
 92 
     | 
    
         
            +
            # user_mapper.find(old_id)          # raises Minimapper::Common::CanNotFindEntity
         
     | 
| 
      
 93 
     | 
    
         
            +
            # user_mapper.delete_all
         
     | 
| 
      
 94 
     | 
    
         
            +
            # user_mapper.delete_by_id(1)
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            ## Using a repository
         
     | 
| 
       88 
97 
     | 
    
         
             
            require "minimapper/repository"
         
     | 
| 
       89 
98 
     | 
    
         | 
| 
       90 
99 
     | 
    
         
             
            repository = Minimapper::Repository.build({
         
     | 
| 
         @@ -94,10 +103,20 @@ repository = Minimapper::Repository.build({ 
     | 
|
| 
       94 
103 
     | 
    
         | 
| 
       95 
104 
     | 
    
         
             
            user = User.new(:name => "Joe")
         
     | 
| 
       96 
105 
     | 
    
         
             
            repository.users.create(user)
         
     | 
| 
       97 
     | 
    
         
            -
            puts repository.users.find(user.id).name #  
     | 
| 
      
 106 
     | 
    
         
            +
            puts repository.users.find(user.id).name # => Joe
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            ## Using ActiveModel validations
         
     | 
| 
      
 109 
     | 
    
         
            +
            user = User.new
         
     | 
| 
      
 110 
     | 
    
         
            +
            repository.users.create(user)
         
     | 
| 
      
 111 
     | 
    
         
            +
            puts repository.users.count    # => 0
         
     | 
| 
      
 112 
     | 
    
         
            +
            puts user.errors.full_messages # Name can't be blank
         
     | 
| 
       98 
113 
     | 
    
         
             
            ```
         
     | 
| 
       99 
114 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
      
 115 
     | 
    
         
            +
            ### ActiveRecord
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            This is not directly runnable like the previous example, it requires ActiveRecord, a database and a users table. Isn't it interesting how much you could do without those things in the previous example? :)
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            When you do need to use an ORM like ActiveRecord however, it now has the same API as your in-memory persistence (thanks to the [shared tests](https://github.com/joakimk/minimapper/blob/master/spec/support/shared_examples/mapper.rb) which define how a mapper is supposed to behave).
         
     | 
| 
       101 
120 
     | 
    
         | 
| 
       102 
121 
     | 
    
         
             
            ``` ruby
         
     | 
| 
       103 
122 
     | 
    
         
             
            require "minimapper/ar"
         
     | 
| 
         @@ -116,56 +135,124 @@ mapper = AR::UserMapper.new 
     | 
|
| 
       116 
135 
     | 
    
         
             
            mapper.create(user)
         
     | 
| 
       117 
136 
     | 
    
         
             
            ```
         
     | 
| 
       118 
137 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
      
 138 
     | 
    
         
            +
            ### Custom queries
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
            You can write custom queries like this:
         
     | 
| 
       120 
141 
     | 
    
         | 
| 
       121 
142 
     | 
    
         
             
            ``` ruby
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
      
 143 
     | 
    
         
            +
            # Memory implementation
         
     | 
| 
      
 144 
     | 
    
         
            +
            module Memory
         
     | 
| 
      
 145 
     | 
    
         
            +
              class ProjectMapper < Minimapper::Memory
         
     | 
| 
      
 146 
     | 
    
         
            +
                def waiting_for_review
         
     | 
| 
      
 147 
     | 
    
         
            +
                  all.find_all { |p| p.waiting_for_review }.sort_by(&:id).reverse
         
     | 
| 
      
 148 
     | 
    
         
            +
                end
         
     | 
| 
      
 149 
     | 
    
         
            +
              end
         
     | 
| 
      
 150 
     | 
    
         
            +
            end
         
     | 
| 
       123 
151 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 152 
     | 
    
         
            +
            # ActiveRecord implementation
         
     | 
| 
      
 153 
     | 
    
         
            +
            module AR
         
     | 
| 
      
 154 
     | 
    
         
            +
              class ProjectMapper < Minimapper::AR
         
     | 
| 
      
 155 
     | 
    
         
            +
                def waiting_for_review
         
     | 
| 
      
 156 
     | 
    
         
            +
                  record_klass.where(waiting_for_review: true).order("id DESC").map do |record|
         
     | 
| 
      
 157 
     | 
    
         
            +
                    entity_for(record)
         
     | 
| 
      
 158 
     | 
    
         
            +
                  end
         
     | 
| 
      
 159 
     | 
    
         
            +
                end
         
     | 
| 
      
 160 
     | 
    
         
            +
              end
         
     | 
| 
      
 161 
     | 
    
         
            +
            end
         
     | 
| 
      
 162 
     | 
    
         
            +
            ```
         
     | 
| 
       126 
163 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
      
 164 
     | 
    
         
            +
            And then use it like this:
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
            ``` ruby
         
     | 
| 
      
 167 
     | 
    
         
            +
            # repository = Minimapper::Repository.build(...)
         
     | 
| 
      
 168 
     | 
    
         
            +
            repository.projects.waiting_for_review.each do |project|
         
     | 
| 
      
 169 
     | 
    
         
            +
              puts project.name
         
     | 
| 
      
 170 
     | 
    
         
            +
            end
         
     | 
| 
       129 
171 
     | 
    
         
             
            ```
         
     | 
| 
       130 
172 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
      
 173 
     | 
    
         
            +
            It gets simpler to maintain if you use shared tests to test both implementations. For inspiration, see the [shared tests](https://github.com/joakimk/minimapper/blob/master/spec/support/shared_examples/mapper.rb) used to test minimapper.
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
            ### Typed attributes
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
            ``` ruby
         
     | 
| 
      
 178 
     | 
    
         
            +
            # Supported types: Integer, DateTime
         
     | 
| 
      
 179 
     | 
    
         
            +
            # TODO: Will probably not support more types, but instead provide a way to add custom conversions.
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
            class User < Minimapper::Entity
         
     | 
| 
      
 182 
     | 
    
         
            +
              attributes [ :profile_id, Integer ]
         
     | 
| 
      
 183 
     | 
    
         
            +
            end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
            User.new(:profile_id => "10").profile_id      # => 10
         
     | 
| 
      
 186 
     | 
    
         
            +
            User.new(:profile_id => " 10 ").profile_id    # => 10
         
     | 
| 
      
 187 
     | 
    
         
            +
            User.new(:profile_id => " ").profile_id       # => nil
         
     | 
| 
      
 188 
     | 
    
         
            +
            User.new(:profile_id => "foobar").profile_id  # => nil
         
     | 
| 
      
 189 
     | 
    
         
            +
            ```
         
     | 
| 
       132 
190 
     | 
    
         | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
      
 191 
     | 
    
         
            +
            ### Adding a new mapper
         
     | 
| 
       134 
192 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
      
 193 
     | 
    
         
            +
            If you where to add a [Mongoid](http://mongoid.org/en/mongoid/index.html) mapper:
         
     | 
| 
       136 
194 
     | 
    
         | 
| 
       137 
     | 
    
         
            -
            * 
     | 
| 
      
 195 
     | 
    
         
            +
            1. Start by copying *spec/ar_spec.rb* to *spec/mongoid_spec.rb* and adapt it for Mongoid.
         
     | 
| 
      
 196 
     | 
    
         
            +
            2. Add any setup code needed in *spec/support/database_setup.rb*.
         
     | 
| 
      
 197 
     | 
    
         
            +
            3. Get the [shared tests](https://github.com/joakimk/minimapper/blob/master/spec/support/shared_examples/mapper.rb) to pass for *spec/mongoid_spec.rb*.
         
     | 
| 
      
 198 
     | 
    
         
            +
            4. Ensure all other tests pass.
         
     | 
| 
      
 199 
     | 
    
         
            +
            5. Send a pull request.
         
     | 
| 
      
 200 
     | 
    
         
            +
            6. As soon as it can be made to work in travis in all ruby versions that apply (in Mongoid's case that is only the 1.9 rubies), I'll merge it in.
         
     | 
| 
       138 
201 
     | 
    
         | 
| 
       139 
202 
     | 
    
         
             
            ## Inspiration
         
     | 
| 
       140 
203 
     | 
    
         | 
| 
      
 204 
     | 
    
         
            +
            ### People
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
       141 
206 
     | 
    
         
             
            Jason Roelofs:
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
       142 
208 
     | 
    
         
             
            * [Designing a Rails App](http://jasonroelofs.com/2012/05/29/designing-a-rails-app-part-1/) (find the whole series of posts)
         
     | 
| 
       143 
209 
     | 
    
         | 
| 
       144 
210 
     | 
    
         
             
            Robert "Uncle Bob" Martin:
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
       145 
212 
     | 
    
         
             
            * [Architecture: The Lost Years](http://www.confreaks.com/videos/759-rubymidwest2011-keynote-architecture-the-lost-years)
         
     | 
| 
       146 
213 
     | 
    
         
             
            * [The Clean Architecture](http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html)
         
     | 
| 
       147 
214 
     | 
    
         | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
      
 215 
     | 
    
         
            +
            ### Apps
         
     | 
| 
       149 
216 
     | 
    
         | 
| 
       150 
217 
     | 
    
         
             
            * The deploy status app that minimapper was extracted from: [https://github.com/joakimk/deployer](https://github.com/joakimk/deployer)
         
     | 
| 
       151 
218 
     | 
    
         | 
| 
       152 
     | 
    
         
            -
            ##  
     | 
| 
      
 219 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
            ### Running the tests
         
     | 
| 
       153 
222 
     | 
    
         | 
| 
       154 
223 
     | 
    
         
             
            You need mysql and postgres installed (but they do not have to be running) to be able to run bundle. The sql-mapper tests use sqlite3 by default.
         
     | 
| 
       155 
224 
     | 
    
         | 
| 
       156 
225 
     | 
    
         
             
                bundle
         
     | 
| 
       157 
226 
     | 
    
         
             
                rake
         
     | 
| 
       158 
227 
     | 
    
         | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
      
 228 
     | 
    
         
            +
            ### Steps
         
     | 
| 
       160 
229 
     | 
    
         | 
| 
       161 
230 
     | 
    
         
             
            0. Read "Only the most basic API" above
         
     | 
| 
       162 
231 
     | 
    
         
             
            1. Fork it
         
     | 
| 
       163 
232 
     | 
    
         
             
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
       164 
233 
     | 
    
         
             
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
       165 
     | 
    
         
            -
            4. Don't forget to write  
     | 
| 
      
 234 
     | 
    
         
            +
            4. Don't forget to write tests
         
     | 
| 
       166 
235 
     | 
    
         
             
            5. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
       167 
236 
     | 
    
         
             
            6. Create new Pull Request
         
     | 
| 
       168 
237 
     | 
    
         | 
| 
      
 238 
     | 
    
         
            +
            ## Todo
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
            ### Next
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
            * Add some way to extend type conversions to keep that part of minimapper small.
         
     | 
| 
      
 243 
     | 
    
         
            +
            * Extract entity and model class lookup code from the ar-mapper and reuse it in the memory mapper.
         
     | 
| 
      
 244 
     | 
    
         
            +
            * Change the memory mapper to store entity attributes, not entity instances.
         
     | 
| 
      
 245 
     | 
    
         
            +
              - Unless this makes it difficult to handle associated data.
         
     | 
| 
      
 246 
     | 
    
         
            +
            * Make Minimapper::Entity a module so you won't have to inherit from it.
         
     | 
| 
      
 247 
     | 
    
         
            +
            * Make using Minimapper::Entity optional by providing shared examples of the behavior required by the mappers. Test the mappers with an object implementing only this behavior.
         
     | 
| 
      
 248 
     | 
    
         
            +
             
     | 
| 
      
 249 
     | 
    
         
            +
            ### Ideas
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
            I won't implement anything that isn't actually used. But here are some ideas for things that might make it into minimapper someday if there is a need for it.
         
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
      
 253 
     | 
    
         
            +
            * Provide a hook to convert attributes between entities and the backing models (when your entity attributes and db-schema isn't a one-to-one match).
         
     | 
| 
      
 254 
     | 
    
         
            +
            * Copy validation errors back from the mapper to the entity (for example if you do uniqueness validation in a backing ActiveRecord-model).
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
       169 
256 
     | 
    
         
             
            ## Credits and license
         
     | 
| 
       170 
257 
     | 
    
         | 
| 
       171 
258 
     | 
    
         
             
            By [Joakim Kolsjö](https://twitter.com/joakimk) under the MIT license:
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'active_support/core_ext'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Minimapper
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Entity
         
     | 
| 
      
 5 
     | 
    
         
            +
                class Convert
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def initialize(value)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    @value = value
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  def to(type)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    return if value.blank?
         
     | 
| 
      
 12 
     | 
    
         
            +
                    return value unless value.is_a?(String)
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                    case type.to_s
         
     | 
| 
      
 15 
     | 
    
         
            +
                    when "Integer"
         
     | 
| 
      
 16 
     | 
    
         
            +
                      to_integer
         
     | 
| 
      
 17 
     | 
    
         
            +
                    when "DateTime"
         
     | 
| 
      
 18 
     | 
    
         
            +
                      to_date_time
         
     | 
| 
      
 19 
     | 
    
         
            +
                    else
         
     | 
| 
      
 20 
     | 
    
         
            +
                      value
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  private
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  def to_integer
         
     | 
| 
      
 27 
     | 
    
         
            +
                    if value =~ /[0-9]/
         
     | 
| 
      
 28 
     | 
    
         
            +
                      value.to_i
         
     | 
| 
      
 29 
     | 
    
         
            +
                    else
         
     | 
| 
      
 30 
     | 
    
         
            +
                      nil
         
     | 
| 
      
 31 
     | 
    
         
            +
                    end
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def to_date_time
         
     | 
| 
      
 35 
     | 
    
         
            +
                    DateTime.parse(value) rescue nil
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                  attr_reader :value
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/minimapper/entity.rb
    CHANGED
    
    | 
         @@ -6,6 +6,7 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            #
         
     | 
| 
       7 
7 
     | 
    
         
             
            # This class also does some things needed for it to work well with rails.
         
     | 
| 
       8 
8 
     | 
    
         
             
            require 'informal'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'minimapper/entity/convert'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            module Minimapper
         
     | 
| 
       11 
12 
     | 
    
         
             
              class Entity
         
     | 
| 
         @@ -13,11 +14,18 @@ module Minimapper 
     | 
|
| 
       13 
14 
     | 
    
         | 
| 
       14 
15 
     | 
    
         
             
                def self.attributes(*list)
         
     | 
| 
       15 
16 
     | 
    
         
             
                  list.each do |attribute|
         
     | 
| 
      
 17 
     | 
    
         
            +
                    type = nil
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    if attribute.is_a?(Array)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      attribute, type = attribute
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       16 
23 
     | 
    
         
             
                    define_method(attribute) do
         
     | 
| 
       17 
24 
     | 
    
         
             
                      instance_variable_get("@#{attribute}")
         
     | 
| 
       18 
25 
     | 
    
         
             
                    end
         
     | 
| 
       19 
26 
     | 
    
         | 
| 
       20 
27 
     | 
    
         
             
                    define_method("#{attribute}=") do |value|
         
     | 
| 
      
 28 
     | 
    
         
            +
                      value = Convert.new(value).to(type)
         
     | 
| 
       21 
29 
     | 
    
         
             
                      instance_variable_set("@#{attribute}", value)
         
     | 
| 
       22 
30 
     | 
    
         
             
                      @attributes[attribute] = value
         
     | 
| 
       23 
31 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -37,7 +45,7 @@ module Minimapper 
     | 
|
| 
       37 
45 
     | 
    
         
             
                  id
         
     | 
| 
       38 
46 
     | 
    
         
             
                end
         
     | 
| 
       39 
47 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
                attributes :id, :created_at, :updated_at
         
     | 
| 
      
 48 
     | 
    
         
            +
                attributes [ :id, Integer ], [ :created_at, DateTime ], [ :updated_at, DateTime ]
         
     | 
| 
       41 
49 
     | 
    
         | 
| 
       42 
50 
     | 
    
         
             
                attr_reader :attributes
         
     | 
| 
       43 
51 
     | 
    
         
             
              end
         
     | 
    
        data/lib/minimapper/version.rb
    CHANGED
    
    
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            shared_examples :mapper do
         
     | 
| 
       2 
2 
     | 
    
         
             
              # expects repository and entity_klass to be defined
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              describe "create" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "#create" do
         
     | 
| 
       5 
5 
     | 
    
         
             
                it "sets an id on the entity" do
         
     | 
| 
       6 
6 
     | 
    
         
             
                  entity1 = build_valid_entity
         
     | 
| 
       7 
7 
     | 
    
         
             
                  entity1.id.should be_nil
         
     | 
| 
         @@ -32,7 +32,7 @@ shared_examples :mapper do 
     | 
|
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         
             
              end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
              describe "find" do
         
     | 
| 
      
 35 
     | 
    
         
            +
              describe "#find" do
         
     | 
| 
       36 
36 
     | 
    
         
             
                it "returns an entity matching the id" do
         
     | 
| 
       37 
37 
     | 
    
         
             
                  entity = build_valid_entity
         
     | 
| 
       38 
38 
     | 
    
         
             
                  repository.create(entity)
         
     | 
| 
         @@ -55,12 +55,12 @@ shared_examples :mapper do 
     | 
|
| 
       55 
55 
     | 
    
         
             
                  repository.find(entity.id).object_id.should_not == repository.find(entity.id).object_id
         
     | 
| 
       56 
56 
     | 
    
         
             
                end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
                it "fails when  
     | 
| 
      
 58 
     | 
    
         
            +
                it "fails when an entity can not be found" do
         
     | 
| 
       59 
59 
     | 
    
         
             
                  lambda { repository.find(-1) }.should raise_error(Minimapper::Common::CanNotFindEntity)
         
     | 
| 
       60 
60 
     | 
    
         
             
                end
         
     | 
| 
       61 
61 
     | 
    
         
             
              end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
              describe "find_by_id" do
         
     | 
| 
      
 63 
     | 
    
         
            +
              describe "#find_by_id" do
         
     | 
| 
       64 
64 
     | 
    
         
             
                it "returns an entity matching the id" do
         
     | 
| 
       65 
65 
     | 
    
         
             
                  entity = build_valid_entity
         
     | 
| 
       66 
66 
     | 
    
         
             
                  repository.create(entity)
         
     | 
| 
         @@ -83,12 +83,12 @@ shared_examples :mapper do 
     | 
|
| 
       83 
83 
     | 
    
         
             
                  repository.find_by_id(entity.id).object_id.should_not == repository.find_by_id(entity.id).object_id
         
     | 
| 
       84 
84 
     | 
    
         
             
                end
         
     | 
| 
       85 
85 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
                it "returns nil when  
     | 
| 
      
 86 
     | 
    
         
            +
                it "returns nil when an entity can not be found" do
         
     | 
| 
       87 
87 
     | 
    
         
             
                  repository.find_by_id(-1).should be_nil
         
     | 
| 
       88 
88 
     | 
    
         
             
                end
         
     | 
| 
       89 
89 
     | 
    
         
             
              end
         
     | 
| 
       90 
90 
     | 
    
         | 
| 
       91 
     | 
    
         
            -
              describe "all" do
         
     | 
| 
      
 91 
     | 
    
         
            +
              describe "#all" do
         
     | 
| 
       92 
92 
     | 
    
         
             
                it "returns all entities in undefined order" do
         
     | 
| 
       93 
93 
     | 
    
         
             
                  first_created_entity = build_valid_entity
         
     | 
| 
       94 
94 
     | 
    
         
             
                  second_created_entity = build_valid_entity
         
     | 
| 
         @@ -108,7 +108,7 @@ shared_examples :mapper do 
     | 
|
| 
       108 
108 
     | 
    
         
             
                end
         
     | 
| 
       109 
109 
     | 
    
         
             
              end
         
     | 
| 
       110 
110 
     | 
    
         | 
| 
       111 
     | 
    
         
            -
              describe "first" do
         
     | 
| 
      
 111 
     | 
    
         
            +
              describe "#first" do
         
     | 
| 
       112 
112 
     | 
    
         
             
                it "returns the first entity" do
         
     | 
| 
       113 
113 
     | 
    
         
             
                  first_created_entity = build_valid_entity
         
     | 
| 
       114 
114 
     | 
    
         
             
                  repository.create(first_created_entity)
         
     | 
| 
         @@ -129,7 +129,7 @@ shared_examples :mapper do 
     | 
|
| 
       129 
129 
     | 
    
         
             
                end
         
     | 
| 
       130 
130 
     | 
    
         
             
              end
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
       132 
     | 
    
         
            -
              describe "last" do
         
     | 
| 
      
 132 
     | 
    
         
            +
              describe "#last" do
         
     | 
| 
       133 
133 
     | 
    
         
             
                it "returns the last entity" do
         
     | 
| 
       134 
134 
     | 
    
         
             
                  last_created_entity = build_valid_entity
         
     | 
| 
       135 
135 
     | 
    
         
             
                  repository.create(build_valid_entity)
         
     | 
| 
         @@ -150,7 +150,7 @@ shared_examples :mapper do 
     | 
|
| 
       150 
150 
     | 
    
         
             
                end
         
     | 
| 
       151 
151 
     | 
    
         
             
              end
         
     | 
| 
       152 
152 
     | 
    
         | 
| 
       153 
     | 
    
         
            -
              describe "count" do
         
     | 
| 
      
 153 
     | 
    
         
            +
              describe "#count" do
         
     | 
| 
       154 
154 
     | 
    
         
             
                it "returns the number of entities" do
         
     | 
| 
       155 
155 
     | 
    
         
             
                  repository.create(build_valid_entity)
         
     | 
| 
       156 
156 
     | 
    
         
             
                  repository.create(build_valid_entity)
         
     | 
| 
         @@ -158,7 +158,7 @@ shared_examples :mapper do 
     | 
|
| 
       158 
158 
     | 
    
         
             
                end
         
     | 
| 
       159 
159 
     | 
    
         
             
              end
         
     | 
| 
       160 
160 
     | 
    
         | 
| 
       161 
     | 
    
         
            -
              describe "update" do
         
     | 
| 
      
 161 
     | 
    
         
            +
              describe "#update" do
         
     | 
| 
       162 
162 
     | 
    
         
             
                it "updates" do
         
     | 
| 
       163 
163 
     | 
    
         
             
                  entity = build_valid_entity
         
     | 
| 
       164 
164 
     | 
    
         
             
                  repository.create(entity)
         
     | 
| 
         @@ -199,7 +199,7 @@ shared_examples :mapper do 
     | 
|
| 
       199 
199 
     | 
    
         
             
                end
         
     | 
| 
       200 
200 
     | 
    
         
             
              end
         
     | 
| 
       201 
201 
     | 
    
         | 
| 
       202 
     | 
    
         
            -
              describe "delete" do
         
     | 
| 
      
 202 
     | 
    
         
            +
              describe "#delete" do
         
     | 
| 
       203 
203 
     | 
    
         
             
                it "removes the entity" do
         
     | 
| 
       204 
204 
     | 
    
         
             
                  entity = build_valid_entity
         
     | 
| 
       205 
205 
     | 
    
         
             
                  removed_entity_id = entity.id
         
     | 
| 
         @@ -229,7 +229,7 @@ shared_examples :mapper do 
     | 
|
| 
       229 
229 
     | 
    
         
             
                end
         
     | 
| 
       230 
230 
     | 
    
         
             
              end
         
     | 
| 
       231 
231 
     | 
    
         | 
| 
       232 
     | 
    
         
            -
              describe "delete_by_id" do
         
     | 
| 
      
 232 
     | 
    
         
            +
              describe "#delete_by_id" do
         
     | 
| 
       233 
233 
     | 
    
         
             
                it "removes the entity" do
         
     | 
| 
       234 
234 
     | 
    
         
             
                  entity = build_valid_entity
         
     | 
| 
       235 
235 
     | 
    
         
             
                  repository.create(entity)
         
     | 
| 
         @@ -239,12 +239,12 @@ shared_examples :mapper do 
     | 
|
| 
       239 
239 
     | 
    
         
             
                  repository.first.id.should_not == entity.id
         
     | 
| 
       240 
240 
     | 
    
         
             
                end
         
     | 
| 
       241 
241 
     | 
    
         | 
| 
       242 
     | 
    
         
            -
                it "fails when  
     | 
| 
      
 242 
     | 
    
         
            +
                it "fails when an entity can not be found" do
         
     | 
| 
       243 
243 
     | 
    
         
             
                  lambda { repository.delete_by_id(-1) }.should raise_error(Minimapper::Common::CanNotFindEntity)
         
     | 
| 
       244 
244 
     | 
    
         
             
                end
         
     | 
| 
       245 
245 
     | 
    
         
             
              end
         
     | 
| 
       246 
246 
     | 
    
         | 
| 
       247 
     | 
    
         
            -
              describe "delete_all" do
         
     | 
| 
      
 247 
     | 
    
         
            +
              describe "#delete_all" do
         
     | 
| 
       248 
248 
     | 
    
         
             
                it "empties the repository" do
         
     | 
| 
       249 
249 
     | 
    
         
             
                  repository.create(build_valid_entity)
         
     | 
| 
       250 
250 
     | 
    
         
             
                  repository.delete_all
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'minimapper/entity/convert'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Minimapper::Entity::Convert do
         
     | 
| 
      
 4 
     | 
    
         
            +
              it "converts strings into integers" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                described_class.new('10').to(Integer).should == 10
         
     | 
| 
      
 6 
     | 
    
         
            +
                described_class.new(' 10 ').to(Integer).should == 10
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              it "converts datetime strings into datetimes" do
         
     | 
| 
      
 10 
     | 
    
         
            +
                described_class.new('2012-01-01 20:57').to(DateTime).should == DateTime.new(2012, 01, 01, 20, 57)
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              it "make it nil when it can't convert" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                described_class.new(' ').to(Integer).should be_nil
         
     | 
| 
      
 15 
     | 
    
         
            +
                described_class.new(' ').to(DateTime).should be_nil
         
     | 
| 
      
 16 
     | 
    
         
            +
                described_class.new('garbage').to(Integer).should be_nil
         
     | 
| 
      
 17 
     | 
    
         
            +
                described_class.new('garbage').to(DateTime).should be_nil
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it "returns the value as-is when it does not know how to convert it" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                described_class.new('foobar').to(Kernel).should == 'foobar'
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
    
        data/unit/entity_spec.rb
    CHANGED
    
    | 
         @@ -13,6 +13,26 @@ describe Minimapper::Entity do 
     | 
|
| 
       13 
13 
     | 
    
         
             
                base.updated_at = time
         
     | 
| 
       14 
14 
     | 
    
         
             
                base.updated_at.should == time
         
     | 
| 
       15 
15 
     | 
    
         
             
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              it "converts typed attributes" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                base = described_class.new
         
     | 
| 
      
 19 
     | 
    
         
            +
                base.id = "10"
         
     | 
| 
      
 20 
     | 
    
         
            +
                base.id.should == 10
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            class TestUser < Minimapper::Entity
         
     | 
| 
      
 25 
     | 
    
         
            +
              attributes :name
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            describe Minimapper::Entity, "attributes without type" do
         
     | 
| 
      
 29 
     | 
    
         
            +
              it "can be set and get with anything" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                user = TestUser.new
         
     | 
| 
      
 31 
     | 
    
         
            +
                user.name = "Hello"
         
     | 
| 
      
 32 
     | 
    
         
            +
                user.name.should == "Hello"
         
     | 
| 
      
 33 
     | 
    
         
            +
                user.name = 5
         
     | 
| 
      
 34 
     | 
    
         
            +
                user.name.should == 5
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
       16 
36 
     | 
    
         
             
            end
         
     | 
| 
       17 
37 
     | 
    
         | 
| 
       18 
38 
     | 
    
         
             
            describe Minimapper::Entity, "attributes" do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,61 +1,46 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            --- !ruby/object:Gem::Specification 
     | 
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: minimapper
         
     | 
| 
       3 
     | 
    
         
            -
            version: !ruby/object:Gem::Version 
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.4
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
     | 
    
         
            -
              segments: 
         
     | 
| 
       7 
     | 
    
         
            -
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              - 3
         
     | 
| 
       10 
     | 
    
         
            -
              version: 0.0.3
         
     | 
| 
       11 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
     | 
    
         
            -
            authors: 
     | 
| 
       13 
     | 
    
         
            -
            -  
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Joakim Kolsjö
         
     | 
| 
       14 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       15 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            dependencies: 
         
     | 
| 
       21 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-11-02 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
       22 
15 
     | 
    
         
             
              name: informal
         
     | 
| 
       23 
     | 
    
         
            -
               
     | 
| 
       24 
     | 
    
         
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: &70301509547800 !ruby/object:Gem::Requirement
         
     | 
| 
       25 
17 
     | 
    
         
             
                none: false
         
     | 
| 
       26 
     | 
    
         
            -
                requirements: 
     | 
| 
       27 
     | 
    
         
            -
                - -  
     | 
| 
       28 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
       29 
     | 
    
         
            -
                     
     | 
| 
       30 
     | 
    
         
            -
                    segments: 
         
     | 
| 
       31 
     | 
    
         
            -
                    - 0
         
     | 
| 
       32 
     | 
    
         
            -
                    version: "0"
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       33 
22 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       34 
     | 
    
         
            -
              version_requirements: *id001
         
     | 
| 
       35 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       36 
     | 
    
         
            -
              name: rake
         
     | 
| 
       37 
23 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       38 
     | 
    
         
            -
               
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: *70301509547800
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 27 
     | 
    
         
            +
              requirement: &70301509545740 !ruby/object:Gem::Requirement
         
     | 
| 
       39 
28 
     | 
    
         
             
                none: false
         
     | 
| 
       40 
     | 
    
         
            -
                requirements: 
     | 
| 
       41 
     | 
    
         
            -
                - -  
     | 
| 
       42 
     | 
    
         
            -
                  - !ruby/object:Gem::Version 
     | 
| 
       43 
     | 
    
         
            -
                     
     | 
| 
       44 
     | 
    
         
            -
                    segments: 
         
     | 
| 
       45 
     | 
    
         
            -
                    - 0
         
     | 
| 
       46 
     | 
    
         
            -
                    version: "0"
         
     | 
| 
      
 29 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 30 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 31 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 32 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       47 
33 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       48 
     | 
    
         
            -
               
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 35 
     | 
    
         
            +
              version_requirements: *70301509545740
         
     | 
| 
      
 36 
     | 
    
         
            +
            description: A minimalistic way of separating your models from ORMs like ActiveRecord
         
     | 
| 
      
 37 
     | 
    
         
            +
              (by implementing the repository pattern)
         
     | 
| 
      
 38 
     | 
    
         
            +
            email:
         
     | 
| 
       51 
39 
     | 
    
         
             
            - joakim.kolsjo@gmail.com
         
     | 
| 
       52 
40 
     | 
    
         
             
            executables: []
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
41 
     | 
    
         
             
            extensions: []
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
42 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
            files: 
         
     | 
| 
      
 43 
     | 
    
         
            +
            files:
         
     | 
| 
       59 
44 
     | 
    
         
             
            - .gitignore
         
     | 
| 
       60 
45 
     | 
    
         
             
            - .rspec
         
     | 
| 
       61 
46 
     | 
    
         
             
            - .rvmrc
         
     | 
| 
         @@ -67,6 +52,7 @@ files: 
     | 
|
| 
       67 
52 
     | 
    
         
             
            - lib/minimapper/ar.rb
         
     | 
| 
       68 
53 
     | 
    
         
             
            - lib/minimapper/common.rb
         
     | 
| 
       69 
54 
     | 
    
         
             
            - lib/minimapper/entity.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/minimapper/entity/convert.rb
         
     | 
| 
       70 
56 
     | 
    
         
             
            - lib/minimapper/memory.rb
         
     | 
| 
       71 
57 
     | 
    
         
             
            - lib/minimapper/repository.rb
         
     | 
| 
       72 
58 
     | 
    
         
             
            - lib/minimapper/version.rb
         
     | 
| 
         @@ -77,46 +63,39 @@ files: 
     | 
|
| 
       77 
63 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       78 
64 
     | 
    
         
             
            - spec/support/database_setup.rb
         
     | 
| 
       79 
65 
     | 
    
         
             
            - spec/support/shared_examples/mapper.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
            - unit/entity/convert_spec.rb
         
     | 
| 
       80 
67 
     | 
    
         
             
            - unit/entity_spec.rb
         
     | 
| 
       81 
68 
     | 
    
         
             
            - unit/memory_spec.rb
         
     | 
| 
       82 
69 
     | 
    
         
             
            - unit/repository_spec.rb
         
     | 
| 
       83 
70 
     | 
    
         
             
            - unit/spec_helper.rb
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
            homepage: ""
         
     | 
| 
      
 71 
     | 
    
         
            +
            homepage: ''
         
     | 
| 
       86 
72 
     | 
    
         
             
            licenses: []
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
73 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       89 
74 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
            require_paths: 
         
     | 
| 
      
 75 
     | 
    
         
            +
            require_paths:
         
     | 
| 
       92 
76 
     | 
    
         
             
            - lib
         
     | 
| 
       93 
     | 
    
         
            -
            required_ruby_version: !ruby/object:Gem::Requirement 
     | 
| 
      
 77 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       94 
78 
     | 
    
         
             
              none: false
         
     | 
| 
       95 
     | 
    
         
            -
              requirements: 
     | 
| 
       96 
     | 
    
         
            -
              - -  
     | 
| 
       97 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       98 
     | 
    
         
            -
                   
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
                  - 0
         
     | 
| 
       101 
     | 
    
         
            -
                  version: "0"
         
     | 
| 
       102 
     | 
    
         
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 79 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 81 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 83 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       103 
84 
     | 
    
         
             
              none: false
         
     | 
| 
       104 
     | 
    
         
            -
              requirements: 
     | 
| 
       105 
     | 
    
         
            -
              - -  
     | 
| 
       106 
     | 
    
         
            -
                - !ruby/object:Gem::Version 
     | 
| 
       107 
     | 
    
         
            -
                   
     | 
| 
       108 
     | 
    
         
            -
                  segments: 
         
     | 
| 
       109 
     | 
    
         
            -
                  - 0
         
     | 
| 
       110 
     | 
    
         
            -
                  version: "0"
         
     | 
| 
      
 85 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 86 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 87 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 88 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       111 
89 
     | 
    
         
             
            requirements: []
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
90 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       114 
     | 
    
         
            -
            rubygems_version: 1.5 
     | 
| 
      
 91 
     | 
    
         
            +
            rubygems_version: 1.8.5
         
     | 
| 
       115 
92 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       116 
93 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       117 
     | 
    
         
            -
            summary: A minimalistic way of separating your models from ORMs like ActiveRecord 
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
      
 94 
     | 
    
         
            +
            summary: A minimalistic way of separating your models from ORMs like ActiveRecord
         
     | 
| 
      
 95 
     | 
    
         
            +
              (by implementing the repository pattern)
         
     | 
| 
      
 96 
     | 
    
         
            +
            test_files:
         
     | 
| 
       119 
97 
     | 
    
         
             
            - spec/ar_spec.rb
         
     | 
| 
       120 
98 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       121 
99 
     | 
    
         
             
            - spec/support/database_setup.rb
         
     | 
| 
       122 
100 
     | 
    
         
             
            - spec/support/shared_examples/mapper.rb
         
     | 
| 
      
 101 
     | 
    
         
            +
            has_rdoc: 
         
     |