Skip to content

Commit

Permalink
Lotus => Hanami
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Jan 19, 2016
1 parent b7f6095 commit 802db2d
Show file tree
Hide file tree
Showing 92 changed files with 1,200 additions and 1,213 deletions.
22 changes: 4 additions & 18 deletions .travis.yml
Expand Up @@ -7,23 +7,9 @@ script:
- 'bundle install'
- 'bundle exec rake test:coverage'
rvm:
- 2.0.0
- 2.1.0
- 2.1.1
- 2.1.2
- 2.1.3
- 2.1.4
- 2.1.5
- 2.1.6
- 2.1.7
- 2.1.8
- 2.2.0
- 2.2.1
- 2.2.2
- 2.2.3
- 2.2.4
- 2.3.0
- rbx-2
- 2.2
- 2.3
- ruby-head
- jruby-9000
- jruby-head

Expand All @@ -32,5 +18,5 @@ addons:

matrix:
allow_failures:
- rvm: rbx-2
- rvm: ruby-head
- rvm: jruby-head
38 changes: 19 additions & 19 deletions CHANGELOG.md
@@ -1,20 +1,20 @@
# Lotus::Model
A persistence layer for Lotus
# Hanami::Model
A persistence layer for Hanami

## v0.5.2 - 2016-01-19
### Changed
- [Sean Collins] Improved error message for `Lotus::Model::Adapters::NoAdapterError`
- [Sean Collins] Improved error message for `Hanami::Model::Adapters::NoAdapterError`

### Fixed
- [Kyle Chong & Trung Lê] Catch Sequel exceptions and re-raise as `Lotus::Model::Error`
- [Kyle Chong & Trung Lê] Catch Sequel exceptions and re-raise as `Hanami::Model::Error`

## v0.5.1 - 2016-01-12
### Added
- [Taylor Finnell] Let `Lotus::Model::Configuration#adapter` to accept arbitrary options (eg. `adapter type: :sql, uri: 'jdbc:...', after_connect: Proc.new { |connection| connection.auto_commit(true) }`)
- [Taylor Finnell] Let `Hanami::Model::Configuration#adapter` to accept arbitrary options (eg. `adapter type: :sql, uri: 'jdbc:...', after_connect: Proc.new { |connection| connection.auto_commit(true) }`)

### Changed
- [Andrey Deryabin] Improved `Entity#inspect`
- [Karim Tarek] Introduced `Lotus::Model::Error` and let all the framework exceptions to inherit from it.
- [Karim Tarek] Introduced `Hanami::Model::Error` and let all the framework exceptions to inherit from it.

### Fixed
- [Luca Guidi] Improved error message when trying to use a repository without mapping the corresponding collections
Expand Down Expand Up @@ -53,9 +53,9 @@ A persistence layer for Lotus

## v0.3.1 - 2015-05-15
### Added
- [Dmitry Tymchuk] Dirty tracking for entities (via `Lotus::Entity::DirtyTracking` module to include)
- [Dmitry Tymchuk] Dirty tracking for entities (via `Hanami::Entity::DirtyTracking` module to include)
- [My Mai] Automatic update of timestamps when an entity is persisted.
- [Peter Berkenbosch] Introduced `Lotus::Repository#execute`, to execute raw query/commands against database (eg. `BookRepository.execute "SELECT * FROM users"` or `BookRepository.execute "UPDATE users SET admin = 'f'"`)
- [Peter Berkenbosch] Introduced `Hanami::Repository#execute`, to execute raw query/commands against database (eg. `BookRepository.execute "SELECT * FROM users"` or `BookRepository.execute "UPDATE users SET admin = 'f'"`)
- [Guilherme Franco] Memory and File System adapters now accept a block for `where`, `or`, `and` conditions (eg `where { age > 33 }`).

### Fixed
Expand All @@ -67,13 +67,13 @@ A persistence layer for Lotus

### Fixed
- [Alfonso Uceda Pompa] Don't send unwanted null values to the database, while coercing entities
- [Jan Lelis] Do not define top-level `Boolean`, because it is already defined by `lotus-utils`
- [Jan Lelis] Do not define top-level `Boolean`, because it is already defined by `hanami-utils`
- [Vsevolod Romashov] Fix entity class resolving in `Coercer#from_record`
- [Jason Harrelson] Add file and line to `instance_eval` in `Coercer` to make backtrace more usable

## v0.2.4 - 2015-02-20
### Fixed
- [Luca Guidi] When duplicate the framework don't copy over the original `Lotus::Model` configuration
- [Luca Guidi] When duplicate the framework don't copy over the original `Hanami::Model` configuration

## v0.2.3 - 2015-02-13
### Added
Expand All @@ -88,7 +88,7 @@ A persistence layer for Lotus

## v0.2.1 - 2015-01-12
### Added
- [Luca Guidi] Compatibility between Lotus::Entity and Lotus::Validations
- [Luca Guidi] Compatibility between Hanami::Entity and Hanami::Validations

## v0.2.0 - 2014-12-23
### Added
Expand All @@ -97,17 +97,17 @@ A persistence layer for Lotus
- [Trung Lê] Introduced `Entity#update` for bulk update of attributes
- [Luca Guidi] Improved error when try to use a repository which wasn't configured or when the framework wasn't loaded yet
- [Trung Lê] Introduced `Entity#to_h`
- [Trung Lê] Introduced `Lotus::Model.duplicate`
- [Trung Lê] Made `Lotus::Mapper` lazy
- [Trung Lê] Introduced `Hanami::Model.duplicate`
- [Trung Lê] Made `Hanami::Mapper` lazy
- [Trung Lê] Introduced thread safe autoloading for adapters
- [Felipe Sere] Add support for `Symbol` coercion
- [Celso Fernandes] Add support for `BigDecimal` coercion
- [Trung Lê] Introduced `Lotus::Model.load!` as entry point for loading
- [Trung Lê] Introduced `Hanami::Model.load!` as entry point for loading
- [Trung Lê] Introduced `Mapper#repository` as DSL to associate a repository to a collection
- [Trung Lê & Tao Guo] Introduced `Configuration#mapping` as DSL to configure the mapping
- [Coen Wessels] Allow `where`, `exclude` and `or` to accept blocks
- [Trung Lê & Tao Guo] Introduced `Configuration#adapter` as DSL to configure the adapter
- [Trung Lê] Introduced `Lotus::Model::Configuration`
- [Trung Lê] Introduced `Hanami::Model::Configuration`

### Changed
- [Trung Lê] Changed `Entity.attributes=` to `Entity.attributes`
Expand All @@ -121,21 +121,21 @@ A persistence layer for Lotus

## v0.1.2 - 2014-06-26
### Fixed
- [Stanislav Spiridonov] Ensure to require `'lotus/model/mapping/coercions'`
- [Stanislav Spiridonov] Ensure to require `'hanami/model/mapping/coercions'`
- [Krzysztof Zalewski] `Entity` defines `#id` accessor by default


## v0.1.1 - 2014-06-23
### Added
- [Luca Guidi] Introduced `Lotus::Model::Mapping::Coercions` in order to decouple from `Lotus::Utils::Kernel`
- [Luca Guidi] Introduced `Hanami::Model::Mapping::Coercions` in order to decouple from `Hanami::Utils::Kernel`
- [Luca Guidi] Official support for Ruby 2.1

## v0.1.0 - 2014-04-23
### Added
- [Luca Guidi] Allow to inject coercer into mapper
- [Luca Guidi] Introduced database mapping
- [Luca Guidi] Introduced `Lotus::Entity`
- [Luca Guidi] Introduced `Hanami::Entity`
- [Luca Guidi] Introduced SQL adapter
- [Luca Guidi] Introduced memory adapter
[Luca Guidi] Introduced adapters for repositories
- [Luca Guidi] Introduced `Lotus::Repository`
- [Luca Guidi] Introduced `Hanami::Repository`
30 changes: 15 additions & 15 deletions EXAMPLE.md
@@ -1,6 +1,6 @@
# Lotus::Model
# Hanami::Model

This is a guide that helps you to get started with [**Lotus::Model**](https://github.com/lotus/model).
This is a guide that helps you to get started with [**Hanami::Model**](https://github.com/hanami/model).
You can find the full code source [here](https://gist.github.com/jodosha/11211048).

## Gems
Expand All @@ -11,7 +11,7 @@ First of all, we need to setup a `Gemfile`.
source 'https://rubygems.org'

gem 'sqlite3'
gem 'lotus-model'
gem 'hanami-model'
```

Then we can fetch the dependencies with `bundle install`.
Expand All @@ -20,16 +20,16 @@ Then we can fetch the dependencies with `bundle install`.

<a name="connection-url"></a>

**Lotus::Model** doesn't have migrations.
**Hanami::Model** doesn't have migrations.
For this example we will use [Sequel](http://sequel.jeremyevans.net).
We create the database first.
Then we create two tables: `authors` and `articles`.

```ruby
require 'bundler/setup'
require 'sqlite3'
require 'lotus/model'
require 'lotus/model/adapters/sql_adapter'
require 'hanami/model'
require 'hanami/model/adapters/sql_adapter'

connection_uri = "sqlite://#{ __dir__ }/test.db"

Expand All @@ -52,7 +52,7 @@ end
## Entities

We have two entities in our application: `Author` and `Article`.
`Author` is a `Struct`, Lotus::Model can persist it.
`Author` is a `Struct`, Hanami::Model can persist it.
`Article` has a small API concerning its publishing process.

```ruby
Expand All @@ -63,7 +63,7 @@ Author = Struct.new(:id, :name) do
end

class Article
include Lotus::Entity
include Hanami::Entity
attributes :author_id, :title, :comments_count, :published # id is implicit

def published?
Expand All @@ -82,11 +82,11 @@ In order to persist and query the entities above, we define two corresponding re

```ruby
class AuthorRepository
include Lotus::Repository
include Hanami::Repository
end

class ArticleRepository
include Lotus::Repository
include Hanami::Repository

def self.most_recent_by_author(author, limit = 8)
query do
Expand Down Expand Up @@ -127,7 +127,7 @@ end
## Loading

```ruby
Lotus::Model.configure do
Hanami::Model.configure do
adapter type: :sql, uri: connection_uri

mapping do
Expand Down Expand Up @@ -162,10 +162,10 @@ author = Author.new(name: 'Luca')
AuthorRepository.create(author)

articles = [
Article.new(title: 'Announcing Lotus', author_id: author.id, comments_count: 123, published: true),
Article.new(title: 'Introducing Lotus::Router', author_id: author.id, comments_count: 63, published: true),
Article.new(title: 'Introducing Lotus::Controller', author_id: author.id, comments_count: 82, published: true),
Article.new(title: 'Introducing Lotus::Model', author_id: author.id)
Article.new(title: 'Announcing Hanami', author_id: author.id, comments_count: 123, published: true),
Article.new(title: 'Introducing Hanami::Router', author_id: author.id, comments_count: 63, published: true),
Article.new(title: 'Introducing Hanami::Controller', author_id: author.id, comments_count: 82, published: true),
Article.new(title: 'Introducing Hanami::Model', author_id: author.id)
]

articles.each do |article|
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -6,8 +6,8 @@ unless ENV['TRAVIS']
gem 'yard', require: false
end

gem 'lotus-utils', '~> 0.6', require: false, github: 'lotus/utils', branch: '0.6.x'
gem 'lotus-validations', '~> 0.4', require: false, github: 'lotus/validations', branch: '0.4.x'
gem 'hanami-utils', '~> 0.7', require: false, github: 'hanami/utils', branch: '0.7.x'
gem 'hanami-validations', '~> 0.5', require: false, github: 'hanami/validations', branch: '0.5.x'

platforms :ruby do
gem 'sqlite3', require: false
Expand Down

0 comments on commit 802db2d

Please sign in to comment.