marilyne 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +44 -13
- data/Rakefile +1 -1
- data/lib/generators/{marilyn → marilyne}/presenter_generator.rb +0 -0
- data/lib/generators/templates/presenter.rb +1 -1
- data/lib/marilyne/engine.rb +9 -0
- data/lib/{marilyn → marilyne}/helper.rb +9 -9
- data/lib/{marilyn → marilyne}/presenter.rb +3 -3
- data/lib/marilyne/version.rb +3 -0
- data/lib/marilyne.rb +5 -0
- data/lib/tasks/{marilyn_tasks.rake → marilyne_tasks.rake} +1 -1
- data/test/dummy/app/presenters/user_presenter.rb +1 -1
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +23 -23
- data/test/dummy/log/development.log +80 -326
- data/test/dummy/log/test.log +5 -134
- data/test/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212 +0 -0
- data/test/dummy/tmp/cache/assets/CAA/620/sprockets%2F87b209c0c9da28094a8d5581a21262c6 +0 -0
- data/test/dummy/tmp/cache/assets/{C75/2F0/sprockets%2F54de5b71312225e0b690248b38409a6d → CAE/4F0/sprockets%2F5a6c412c047e2f38067eb473f2f73633} +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/B70/sprockets%2F4050a4e5062ab95c9f32e9b6940821ea +0 -0
- data/test/dummy/tmp/cache/assets/{D67/8C0/sprockets%2Fa5ec1263c53956c2fe2ed2604e3abf55 → CEB/6A0/sprockets%2F00e940e713bb2d76f9e40f697d9155a9} +0 -0
- data/test/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/test/dummy/tmp/cache/assets/{E45/990/sprockets%2Fc270c04a7b0ebc7a13e6bddcc5e7bdc1 → D1A/6C0/sprockets%2Ffbf586c3b503b6c61f83909c81a3947d} +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D46/650/sprockets%2Ff56253b5f374fff1a33fbbc9881c9124 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/{DFB/320/sprockets%2F08fc5e1bf462fe1ac6f28c7e3eda4c33 → D54/C10/sprockets%2Fc90e3bf92f49ac56c874963ce48f117d} +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D67/B60/sprockets%2F5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/{marilyn_test.rb → marilyne_test.rb} +9 -9
- metadata +124 -121
- data/lib/marilyn/engine.rb +0 -9
- data/lib/marilyn/version.rb +0 -3
- data/lib/marilyn.rb +0 -5
- data/test/dummy/tmp/pids/server.pid +0 -1
data/README.md
CHANGED
@@ -1,47 +1,78 @@
|
|
1
|
-
#
|
1
|
+
# Marilyne [![Build Status](https://secure.travis-ci.org/alaibe/marilyne.png)][travis] [![Dependency Status](https://gemnasium.com/alaibe/marilyne.png)][gemnasium] [![Code Climate](https://codeclimate.com/badge.png)][codeclimate]
|
2
2
|
|
3
|
-
[travis]: http://travis-ci.org/alaibe/
|
4
|
-
[gemnasium]: https://gemnasium.com/alaibe/
|
5
|
-
[codeclimate]: https://codeclimate.com/github/alaibe/
|
3
|
+
[travis]: http://travis-ci.org/alaibe/marilyne
|
4
|
+
[gemnasium]: https://gemnasium.com/alaibe/marilyne
|
5
|
+
[codeclimate]: https://codeclimate.com/github/alaibe/marilyne
|
6
6
|
|
7
|
-
|
7
|
+
Marilyne is a Gem which allows you to use presenter patten easily into your rails project
|
8
8
|
|
9
9
|
## Resources
|
10
10
|
Bugs
|
11
11
|
|
12
|
-
* http://github.com/alaibe/
|
12
|
+
* http://github.com/alaibe/marilyne/issues
|
13
13
|
|
14
14
|
Development
|
15
15
|
|
16
|
-
* http://github.com/alaibe/
|
16
|
+
* http://github.com/alaibe/marilyne
|
17
17
|
|
18
18
|
Testing
|
19
19
|
|
20
|
-
* http://travis-ci.org/alaibe/
|
20
|
+
* http://travis-ci.org/alaibe/marilyne
|
21
21
|
|
22
22
|
Source
|
23
23
|
|
24
|
-
* git://github.com/alaibe/
|
24
|
+
* git://github.com/alaibe/marilyne.git
|
25
25
|
|
26
26
|
## Install
|
27
27
|
|
28
28
|
Add this to your Gemfile
|
29
29
|
``` ruby
|
30
|
-
gem '
|
30
|
+
gem 'marilyne'
|
31
31
|
```
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
35
35
|
You must generate your presenter
|
36
36
|
``` ruby
|
37
|
-
rails g
|
37
|
+
rails g marilyne:presenter base # => app/presenters/base_presenter.rb
|
38
38
|
```
|
39
39
|
|
40
40
|
And in your view you can call
|
41
41
|
``` ruby
|
42
|
-
<%= presenter_for('template', object: @
|
42
|
+
<%= presenter_for('template', object: @base) %>
|
43
|
+
```
|
44
|
+
|
45
|
+
## Exemple
|
46
|
+
|
47
|
+
Basic usage:
|
48
|
+
``` ruby
|
49
|
+
presenter_for('base')
|
50
|
+
# => render partial: 'base', object: BasePresenter.new(template, Base.new)
|
51
|
+
```
|
52
|
+
|
53
|
+
It's possible to specify the object you want present:
|
54
|
+
``` ruby
|
55
|
+
presenter_for('base', object: @object)
|
56
|
+
# => render partial: 'base', object: BasePresenter.new(template, @object)
|
57
|
+
```
|
58
|
+
|
59
|
+
or multiple object
|
60
|
+
``` ruby
|
61
|
+
presenter_for('base', objects: [@object, @other_object])
|
62
|
+
# => render partial: 'base', object: BasePresenter.new(template, @object, @other_object)
|
63
|
+
```
|
64
|
+
|
65
|
+
A block can also be passed and the the render will be call only if block is true
|
66
|
+
``` ruby
|
67
|
+
presenter_for('base', object: @object) { |object| object.ok? }
|
68
|
+
```
|
69
|
+
|
70
|
+
Finally, it's also possible to pass a presenter in options
|
71
|
+
``` ruby
|
72
|
+
presenter_for('base', presenter: 'MySpecificPresenter', object: @object)
|
73
|
+
# => render partial: 'base', object: MySpecificPresenter.new(template, @object)
|
43
74
|
```
|
44
75
|
|
45
76
|
## Contributors
|
46
77
|
|
47
|
-
*Anthony Laibe
|
78
|
+
*Anthony Laibe
|
data/Rakefile
CHANGED
File without changes
|
@@ -1,2 +1,2 @@
|
|
1
|
-
class <%= presenter_name.singularize.camelize %>Presenter <
|
1
|
+
class <%= presenter_name.singularize.camelize %>Presenter < Marilyne::Presenter
|
2
2
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Marilyne
|
2
2
|
# = Presenter Helper
|
3
3
|
module Helper
|
4
4
|
|
@@ -6,12 +6,12 @@ module Marilyn
|
|
6
6
|
# ==== Examples
|
7
7
|
# presenter_for('base')
|
8
8
|
# # => render partial: 'base', object: BasePresenter.new(Base.new)
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# You can specify the object you want present:
|
11
11
|
#
|
12
12
|
# presenter_for('base', object: @object)
|
13
13
|
# # => render partial: 'base', object: BasePresenter.new(@object)
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# or multiple object
|
16
16
|
#
|
17
17
|
# presenter_for('base', objects: [@object, @other_object])
|
@@ -27,15 +27,15 @@ module Marilyn
|
|
27
27
|
# * <tt>:presenter</tt> - Specifies the presenter you want use
|
28
28
|
def presenter_for(template, options = {})
|
29
29
|
presenter_string = options[:presenter] || "#{template.camelize}Presenter"
|
30
|
-
|
31
|
-
object = extract_objects template, options[:object], options[:objects]
|
32
|
-
presenter = presenter_string.constantize.new self, *object
|
33
|
-
|
30
|
+
|
31
|
+
object = extract_objects template, options[:object], options[:objects]
|
32
|
+
presenter = presenter_string.to_s.constantize.new self, *object
|
33
|
+
|
34
34
|
if block_given?
|
35
35
|
return unless yield object
|
36
36
|
end
|
37
37
|
|
38
|
-
render partial: template, object: presenter
|
38
|
+
render partial: template, object: presenter
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
@@ -47,4 +47,4 @@ module Marilyn
|
|
47
47
|
base_name.camelize.constantize.new
|
48
48
|
end
|
49
49
|
end
|
50
|
-
end
|
50
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Marilyne
|
2
2
|
# == Base presenter
|
3
3
|
class Presenter
|
4
4
|
|
@@ -9,7 +9,7 @@ module Marilyn
|
|
9
9
|
# * <tt>:objects</tt> - All presented objects
|
10
10
|
def initialize(template, *objects)
|
11
11
|
@template = template
|
12
|
-
objects.length == 1 ? @object = objects.first : @objects = objects
|
12
|
+
objects.length == 1 ? @object = objects.first : @objects = objects
|
13
13
|
end
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
data/lib/marilyne.rb
ADDED
Binary file
|
data/test/dummy/db/schema.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# This file is auto-generated from the current state of the database. Instead
|
3
|
-
# of editing this file, please use the migrations feature of Active Record to
|
4
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
-
#
|
6
|
-
# Note that this schema.rb definition is the authoritative source for your
|
7
|
-
# database schema. If you need to create the application database on another
|
8
|
-
# system, you should be using db:schema:load, not running all the migrations
|
9
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
-
#
|
12
|
-
# It's strongly recommended to check this file into your version control system.
|
13
|
-
|
14
|
-
ActiveRecord::Schema.define(:version => 20120818172022) do
|
15
|
-
|
16
|
-
create_table "users", :force => true do |t|
|
17
|
-
t.string "first_name"
|
18
|
-
t.string "last_name"
|
19
|
-
t.datetime "created_at", :null => false
|
20
|
-
t.datetime "updated_at", :null => false
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20120818172022) do
|
15
|
+
|
16
|
+
create_table "users", :force => true do |t|
|
17
|
+
t.string "first_name"
|
18
|
+
t.string "last_name"
|
19
|
+
t.datetime "created_at", :null => false
|
20
|
+
t.datetime "updated_at", :null => false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|