marilyne 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/README.md +44 -13
  2. data/Rakefile +1 -1
  3. data/lib/generators/{marilyn → marilyne}/presenter_generator.rb +0 -0
  4. data/lib/generators/templates/presenter.rb +1 -1
  5. data/lib/marilyne/engine.rb +9 -0
  6. data/lib/{marilyn → marilyne}/helper.rb +9 -9
  7. data/lib/{marilyn → marilyne}/presenter.rb +3 -3
  8. data/lib/marilyne/version.rb +3 -0
  9. data/lib/marilyne.rb +5 -0
  10. data/lib/tasks/{marilyn_tasks.rake → marilyne_tasks.rake} +1 -1
  11. data/test/dummy/app/presenters/user_presenter.rb +1 -1
  12. data/test/dummy/config/application.rb +1 -1
  13. data/test/dummy/db/development.sqlite3 +0 -0
  14. data/test/dummy/db/schema.rb +23 -23
  15. data/test/dummy/log/development.log +80 -326
  16. data/test/dummy/log/test.log +5 -134
  17. data/test/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212 +0 -0
  18. data/test/dummy/tmp/cache/assets/CAA/620/sprockets%2F87b209c0c9da28094a8d5581a21262c6 +0 -0
  19. data/test/dummy/tmp/cache/assets/{C75/2F0/sprockets%2F54de5b71312225e0b690248b38409a6d → CAE/4F0/sprockets%2F5a6c412c047e2f38067eb473f2f73633} +0 -0
  20. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  21. data/test/dummy/tmp/cache/assets/CD8/B70/sprockets%2F4050a4e5062ab95c9f32e9b6940821ea +0 -0
  22. data/test/dummy/tmp/cache/assets/{D67/8C0/sprockets%2Fa5ec1263c53956c2fe2ed2604e3abf55 → CEB/6A0/sprockets%2F00e940e713bb2d76f9e40f697d9155a9} +0 -0
  23. data/test/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2 +0 -0
  24. data/test/dummy/tmp/cache/assets/{E45/990/sprockets%2Fc270c04a7b0ebc7a13e6bddcc5e7bdc1 → D1A/6C0/sprockets%2Ffbf586c3b503b6c61f83909c81a3947d} +0 -0
  25. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  26. data/test/dummy/tmp/cache/assets/D46/650/sprockets%2Ff56253b5f374fff1a33fbbc9881c9124 +0 -0
  27. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  28. data/test/dummy/tmp/cache/assets/{DFB/320/sprockets%2F08fc5e1bf462fe1ac6f28c7e3eda4c33 → D54/C10/sprockets%2Fc90e3bf92f49ac56c874963ce48f117d} +0 -0
  29. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  30. data/test/dummy/tmp/cache/assets/D67/B60/sprockets%2F5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  31. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  32. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  33. data/test/{marilyn_test.rb → marilyne_test.rb} +9 -9
  34. metadata +124 -121
  35. data/lib/marilyn/engine.rb +0 -9
  36. data/lib/marilyn/version.rb +0 -3
  37. data/lib/marilyn.rb +0 -5
  38. data/test/dummy/tmp/pids/server.pid +0 -1
data/README.md CHANGED
@@ -1,47 +1,78 @@
1
- # Marilyn [![Build Status](https://secure.travis-ci.org/alaibe/marilyn.png)][travis] [![Dependency Status](https://gemnasium.com/alaibe/marilyn.png)][gemnasium] [![Code Climate](https://codeclimate.com/badge.png)][codeclimate]
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/marilyn
4
- [gemnasium]: https://gemnasium.com/alaibe/marilyn
5
- [codeclimate]: https://codeclimate.com/github/alaibe/marilyn
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
- Marilyn is a Gem which allows you to use presenter patten easily into your rails project
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/marilyn/issues
12
+ * http://github.com/alaibe/marilyne/issues
13
13
 
14
14
  Development
15
15
 
16
- * http://github.com/alaibe/marilyn
16
+ * http://github.com/alaibe/marilyne
17
17
 
18
18
  Testing
19
19
 
20
- * http://travis-ci.org/alaibe/marilyn
20
+ * http://travis-ci.org/alaibe/marilyne
21
21
 
22
22
  Source
23
23
 
24
- * git://github.com/alaibe/marilyn.git
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 'marilyn'
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 marilyn:presenter my_presenter
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: @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
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  RDoc::Task.new(:rdoc) do |rdoc|
16
16
  rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'Marilyn'
17
+ rdoc.title = 'Marilyne'
18
18
  rdoc.options << '--line-numbers'
19
19
  rdoc.rdoc_files.include('README.rdoc')
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -1,2 +1,2 @@
1
- class <%= presenter_name.singularize.camelize %>Presenter < Marilyn::Presenter
1
+ class <%= presenter_name.singularize.camelize %>Presenter < Marilyne::Presenter
2
2
  end
@@ -0,0 +1,9 @@
1
+ module Marilyne
2
+ class Engine < ::Rails::Engine
3
+ initializer 'marilyne.initialize' do
4
+ ActiveSupport.on_load(:action_view) do
5
+ include Marilyne::Helper
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,4 +1,4 @@
1
- module Marilyn
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 Marilyn
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
@@ -0,0 +1,3 @@
1
+ module Marilyne
2
+ VERSION = "1.0.1"
3
+ end
data/lib/marilyne.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "marilyne/helper"
2
+ require "marilyne/presenter"
3
+ require "marilyne/engine"
4
+ module Marilyne
5
+ end
@@ -1,4 +1,4 @@
1
1
  # desc "Explaining what the task does"
2
- # task :marilyn do
2
+ # task :marilyne do
3
3
  # # Task goes here
4
4
  # end
@@ -1,4 +1,4 @@
1
- class UserPresenter < Marilyn::Presenter
1
+ class UserPresenter < Marilyne::Presenter
2
2
 
3
3
  def first_name
4
4
  @object.first_name
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
3
3
  require 'rails/all'
4
4
 
5
5
  Bundler.require
6
- require "marilyn"
6
+ require "marilyne"
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
Binary file
@@ -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