exhibit 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Exhibit is a simple gem to generate and work with presenters in Rails 3. It is based on the solution Ryan Bates created in [Railscasts Pro episode #287](http://railscasts.com/episodes/287-presenters-from-scratch).
4
4
 
5
- version 0.1.0
5
+ version 0.1.2
6
6
  Robin Brouwer
7
7
  45north
8
8
 
@@ -44,7 +44,14 @@ You can also use `delegate` to delegate methods to the User Model.
44
44
  delegate :email, :to => :user
45
45
  end
46
46
 
47
- But how can you use this presenter inside the View? It works the same as Ryan shows you in [Railscasts Pro episode #287](http://railscasts.com/episodes/287-presenters-from-scratch):
47
+ Want to add methods that can be used inside all of your presenters? Run the following command:
48
+
49
+ rails g exhibit:base
50
+
51
+ A new initializer will be created: config/initializers/exhibit_presenter.rb.
52
+ You can add methods to this class to extend it and use it inside all presenters.
53
+
54
+ But how can you actually use presenters inside the view? It works the same as Ryan shows you in [Railscasts Pro episode #287](http://railscasts.com/episodes/287-presenters-from-scratch):
48
55
 
49
56
  <% exhibit(@user) do |user| %>
50
57
  <p>
@@ -1,3 +1,3 @@
1
1
  module Exhibit
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,9 +1,13 @@
1
- Description:
2
- Generates a presenter for the exhibit gem.
1
+ Available generators:
2
+ exhibit:presenter
3
+ exhibit:base
3
4
 
4
- Example:
5
- rails generate presenter User
6
-
7
- This will create:
8
- app/presenters
9
- app/presenters/user_presenter.rb
5
+ Examples:
6
+ rails g exhibit:presenter User
7
+ This will create:
8
+ app/presenters
9
+ app/presenters/user_presenter.rb
10
+
11
+ rails g exhibit:base
12
+ This will create:
13
+ config/initializers/exhibit_presenter.rb
@@ -0,0 +1,9 @@
1
+ module Exhibit
2
+ class BaseGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def copy_exhibit_presenter
6
+ copy_file "exhibit_presenter.rb", "config/initializers/exhibit_presenter.rb"
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,3 @@
1
- require 'rails/generators'
2
-
3
1
  module Exhibit
4
2
  class PresenterGenerator < Rails::Generators::Base
5
3
  source_root File.expand_path('../templates', __FILE__)
@@ -0,0 +1,4 @@
1
+ class Exhibit::Presenter
2
+ # You can extend Exhibit::Presenter by changing this file.
3
+ # Remember to restart your server after changing it.
4
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exhibit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robin Brouwer
@@ -46,7 +46,9 @@ files:
46
46
  - lib/exhibit/presenter.rb
47
47
  - lib/exhibit/version.rb
48
48
  - lib/exhibit.rb
49
+ - lib/generators/exhibit/base_generator.rb
49
50
  - lib/generators/exhibit/presenter_generator.rb
51
+ - lib/generators/exhibit/templates/exhibit_presenter.rb
50
52
  - lib/generators/exhibit/templates/presenter
51
53
  - lib/generators/exhibit/USAGE
52
54
  - lib/tasks/exhibit_tasks.rake