README.md in melodiest-0.2.1 vs README.md in melodiest-0.3.0
- old
+ new
@@ -1,8 +1,8 @@
# Melodiest
-Melodiest is [Sinatra](http://www.sinatrarb.com/) application boilerplate. It provides generator and useful modules for developing application.
+Melodiest is [Sinatra](http://www.sinatrarb.com/) application boilerplate. It provides generator and contains minimalist configuration to develop application with Sinatra.
### Installation
```ruby
@@ -14,62 +14,95 @@
```ruby
gem 'melodiest'
```
### How to Use
-#### Command
-generate app in current directory
+generate app in current directory without database
```
melodiest -n my_app
```
-generate app in target directory
+generate app in target directory without database
```
-melodiest -n my_app -d target/dir
+melodiest -n my_app -t target/dir
```
+generate app in current directory with database. `-d` option will generate app with `Sequel` orm and PostgreSQL adapter.
+```
+melodiest -n my_app -d
+```
-#### Example Code
+### Melodiest::Application
Because Melodiest is already required Sinatra, you don't have to require 'sinatra' anymore, just require 'melodiest'.
`Melodiest::Application` is subclass from `Sinatra::Application` and by default is using configuration from `Melodiest::Setting.setup` method.
```ruby
# my_app.rb
-require 'melodiest/auth/http'
-
class App < Melodiest::Application
- configure do
- # Load up database and such
+ setup 'this_is_secret_for_encrypted_cookie'
+ ...
+end
+```
+### Example Usage
+This example assume that PostgreSQL is already running and .
+ 1. run `melodiest -n my_app -d`
+ 2. cd `my_app`
+ 3. run `bundle install`
+ 4. create `config/database.yml` and configure your database setting
+ 5. create file `db/migrations/001_create_artists.rb` and put the following code:
+```ruby
+Sequel.migration do
+ up do
+ create_table(:artists) do
+ primary_key :id
+ String :name, :null=>false
+ end
end
- helpers Melodiest::Auth::Http
+ down do
+ drop_table(:artists)
+ end
end
-
-# app/routes/my_routes.rb
-
-get "/" do
- "hello world!"
+```
+ 6. run `rake db:migrate`
+ 7. create file `app/models/Artist.rb` and put the following code:
+```ruby
+class Artist < Sequel::Model
end
+```
+ 8. create file `app/routes/artists.rb` and put the following code:
+```ruby
+class MyApp
+ get '/' do
+ "hello world!"
+ end
-get "/protected" do
- authorized! "myhttpauthusername", "myhttpauthpassword"
- "welcome!"
+ get '/artists' do
+ # for example purpose :)
+ artist = Artist.new
+ artist.name = 'Melody'
+ artist.save
+
+ @artists = Artist.all
+ erb :"artists/index"
+ end
end
-
```
-#### Run the server
+ 9. create file `app/views/artists/index.erb` and put the following code:
+```erb
+<h1>List of Artist</h1>
+<% @artists.each do |artist| %>
+ <li><%= artist.name %></li>
+<% end %>
```
-bundle exec rackup
-```
+ 10. run the server `bundle exec rackup`
+ 11. open url `localhost:9292/artists`
### Default Configuration
* `Sinatra::Reloader` in development environment only
- * See [melodiest/config.yml](https://github.com/kuntoaji/melodiest/blob/master/lib/melodiest/config.yml)
-
-### Modules
-
-Available modules from Melodiest
-
- * `Melodiest::Auth::Http`
+ * `Rack::Session::EncryptedCookie`
+ * `Rack::Csrf`
+ * `Sequel` ORM
+ * `sequel_pg` as PostgreSQL adapter