r_decorator 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +8 -0
- data/MIT-LICENSE +20 -0
- data/README.md +27 -0
- data/Rakefile +12 -0
- data/gemfiles/Gemfile-rails.3.0.x +8 -0
- data/gemfiles/Gemfile-rails.3.1.x +8 -0
- data/lib/generators/decorator/decorator_generator.rb +39 -0
- data/lib/generators/decorator/templates/decorator.rb +33 -0
- data/lib/generators/resource_override.rb +12 -0
- data/lib/generators/rspec/decorator_generator.rb +9 -0
- data/lib/generators/rspec/templates/decorator_spec.rb +4 -0
- data/lib/generators/test_unit/decorator_generator.rb +9 -0
- data/lib/generators/test_unit/templates/decorator_test.rb +4 -0
- data/lib/r_decorator/base.rb +77 -0
- data/lib/r_decorator/railtie.rb +12 -0
- data/lib/r_decorator/version.rb +3 -0
- data/lib/r_decorator/view_context.rb +23 -0
- data/lib/r_decorator.rb +3 -0
- data/r_decortator.gemspec +20 -0
- data/spec/fake_app/authors/index.html.erb +16 -0
- data/spec/fake_app/authors/show.html.erb +2 -0
- data/spec/fake_app/books/_book.html.erb +2 -0
- data/spec/fake_app/books/_book_locals.html.erb +2 -0
- data/spec/fake_app/books/show.html.erb +2 -0
- data/spec/fake_app/fake_app.rb +94 -0
- data/spec/features/action_view_helpers_spec.rb +17 -0
- data/spec/features/controller_ivar_spec.rb +29 -0
- data/spec/features/decorator_spec.rb +39 -0
- data/spec/features/partial_spec.rb +31 -0
- data/spec/spec_helper.rb +23 -0
- metadata +89 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Takuya Fujii
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# RDecorator
|
2
|
+
|
3
|
+
A readable and simple view helper for Rails 3.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
class Person < ActiveRecord::Base
|
7
|
+
def say
|
8
|
+
"Hey!"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class PersonDecorator < RDecorator::Base
|
13
|
+
def say
|
14
|
+
origin.say * 3
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
person = Person.new
|
19
|
+
person.say # == "Hey!"
|
20
|
+
person.decorated.say # == "Hey!Hey!Hey!"
|
21
|
+
|
22
|
+
## Notice
|
23
|
+
+ Most code of lib/rdecorator/view_context.rb and rspec files was copied from https://github.com/amatsuda/active_decorator.
|
24
|
+
Copyright (c) 2011 Akira Matsuda under MIT-LICENSE.
|
25
|
+
|
26
|
+
+ lig/generators/* was copied from https://github.com/drapergem/draper under MIT-LICENSE.
|
27
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require 'rspec/core'
|
7
|
+
require 'rspec/core/rake_task'
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => :spec
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generators
|
3
|
+
class DecoratorGenerator < NamedBase
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
check_class_collision :suffix => "Decorator"
|
6
|
+
|
7
|
+
class_option :parent, :type => :string, :desc => "The parent class for the generated decorator"
|
8
|
+
|
9
|
+
desc <<DESC
|
10
|
+
Description:
|
11
|
+
Stubs out a decorator class in app/decorators directory.
|
12
|
+
|
13
|
+
Examples:
|
14
|
+
`rails g decorator book`
|
15
|
+
|
16
|
+
This creates:
|
17
|
+
app/decorators/book_decorator.rb
|
18
|
+
DESC
|
19
|
+
|
20
|
+
def create_decorator_file
|
21
|
+
template 'decorator.rb', File.join('app/decorators', class_path, "#{file_name}_decorator.rb")
|
22
|
+
end
|
23
|
+
|
24
|
+
hook_for :test_framework
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def parent_class_name
|
29
|
+
if options[:parent]
|
30
|
+
options[:parent]
|
31
|
+
elsif defined?(ApplicationDecorator)
|
32
|
+
"ApplicationDecorator"
|
33
|
+
else
|
34
|
+
"RDecorator::Decorator"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
class <%= class_name %>Decorator < <%= parent_class_name %>
|
3
|
+
|
4
|
+
# Accessing Helpers
|
5
|
+
# You can access any helper via a proxy
|
6
|
+
#
|
7
|
+
# Normal Usage: helpers.number_to_currency(2)
|
8
|
+
# Abbreviated : h.number_to_currency(2)
|
9
|
+
#
|
10
|
+
# Or, optionally enable "lazy helpers" by including this module:
|
11
|
+
# include Draper::LazyHelpers
|
12
|
+
# Then use the helpers with no proxy:
|
13
|
+
# number_to_currency(2)
|
14
|
+
|
15
|
+
# Defining an Interface
|
16
|
+
# Control access to the wrapped subject's methods using one of the following:
|
17
|
+
#
|
18
|
+
# To allow only the listed methods (whitelist):
|
19
|
+
# allows :method1, :method2
|
20
|
+
#
|
21
|
+
# To allow everything except the listed methods (blacklist):
|
22
|
+
# denies :method1, :method2
|
23
|
+
|
24
|
+
# Presentation Methods
|
25
|
+
# Define your own instance methods, even overriding accessors
|
26
|
+
# generated by ActiveRecord:
|
27
|
+
#
|
28
|
+
# def created_at
|
29
|
+
# h.content_tag :span, attributes["created_at"].strftime("%a %m/%d/%y"),
|
30
|
+
# :class => 'timestamp'
|
31
|
+
# end
|
32
|
+
end
|
33
|
+
<% end -%>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Rspec
|
2
|
+
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def create_spec_file
|
6
|
+
template 'decorator_spec.rb', File.join('spec/decorators', class_path, "#{singular_name}_decorator_spec.rb")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module TestUnit
|
2
|
+
class DecoratorGenerator < ::Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def create_test_file
|
6
|
+
template 'decorator_test.rb', File.join('test/decorators', class_path, "#{singular_name}_decorator_test.rb")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module RDecorator
|
2
|
+
class Base
|
3
|
+
attr_reader :origin, :options
|
4
|
+
|
5
|
+
def initialize(obj, options={})
|
6
|
+
@origin = obj
|
7
|
+
@context = options.delete(:context)
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(method, *args, &block)
|
12
|
+
begin
|
13
|
+
origin.__send__(method, *args, &block)
|
14
|
+
rescue NoMethodError, NameError
|
15
|
+
context.__send__(method, *args, &block)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def respond_to?(*args)
|
20
|
+
super || origin.respond_to?(*args) || context.respond_to?(*args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.decorate_for(*args)
|
24
|
+
args.map{|target| decorate!(target, self) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.inherited(klass)
|
28
|
+
# TODO: skipping auto decoration if the subclass has defined so.
|
29
|
+
target = klass.name.sub(/Decorator$/,"")
|
30
|
+
klass.__send__( :decorate!, target, true )
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.decorating_classes
|
34
|
+
@_classes ||= []
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def context
|
40
|
+
@context ||= RDecorator::ViewContext.current
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.decorate!(target, ignore_missing = false)
|
44
|
+
klass = target_to_class(target,ignore_missing)
|
45
|
+
return nil unless klass
|
46
|
+
|
47
|
+
unless decorating_classes.include?(klass)
|
48
|
+
klass.class_eval <<-STR
|
49
|
+
def decorated(options={})
|
50
|
+
@_decorator ||= #{self.name}.new(self, options)
|
51
|
+
end
|
52
|
+
alias_method :deco, :decorated
|
53
|
+
STR
|
54
|
+
decorating_classes << klass
|
55
|
+
end
|
56
|
+
klass
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.target_to_class(target, ignore_missing = false)
|
60
|
+
case target
|
61
|
+
when String, Symbol
|
62
|
+
if ignore_missing
|
63
|
+
klass = target.to_s.camelize.safe_constantize
|
64
|
+
return nil if klass == nil
|
65
|
+
else
|
66
|
+
klass = target.to_s.camelize.constantize
|
67
|
+
end
|
68
|
+
else
|
69
|
+
klass = target
|
70
|
+
end
|
71
|
+
raise "Invalid target for decoration(#{self}): #{klass}" unless klass.is_a?(Class)
|
72
|
+
klass
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'r_decorator/view_context'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module RDecorator
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
initializer 'r_decorator' do
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
ActionController::Base.send :include, RDecorator::ViewContext::Filter
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RDecorator
|
2
|
+
module ViewContext
|
3
|
+
class << self
|
4
|
+
def current
|
5
|
+
Thread.current[:view_context]
|
6
|
+
end
|
7
|
+
|
8
|
+
def current=(view_context)
|
9
|
+
Thread.current[:view_context] = view_context
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Filter
|
14
|
+
extend ActiveSupport::Concern
|
15
|
+
|
16
|
+
included do
|
17
|
+
before_filter do |controller|
|
18
|
+
RDecorator::ViewContext.current = controller.view_context
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/r_decorator.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "r_decorator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "r_decorator"
|
7
|
+
s.version = RDecorator::VERSION
|
8
|
+
s.authors = ["Takuya Fujii"]
|
9
|
+
s.email = ["takuya327@gmail.com"]
|
10
|
+
s.homepage = 'https://github.com/takuya327/r_decorator'
|
11
|
+
s.summary = %q{A readable and simple view helper for Rails 3}
|
12
|
+
s.description = %q{A readable and simple view helper for Rails 3}
|
13
|
+
|
14
|
+
s.rubyforge_project = "r_decorator"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% @authors.each do |author| %>
|
2
|
+
<%= author.deco.name %>
|
3
|
+
<%= author.deco.reverse_name %>
|
4
|
+
|
5
|
+
<% if params[:partial] == 'collection' %>
|
6
|
+
<%= render author.books %>
|
7
|
+
<% elsif params[:partial] == 'locals' %>
|
8
|
+
<% author.books.each do |book| %>
|
9
|
+
<%= render :partial => 'books/book_locals', :locals => {:b => book} %>
|
10
|
+
<% end %>
|
11
|
+
<% else %>
|
12
|
+
<% author.books.each do |book| %>
|
13
|
+
<%= render book %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'action_controller/railtie'
|
3
|
+
require 'action_view/railtie'
|
4
|
+
|
5
|
+
# config
|
6
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
7
|
+
|
8
|
+
module RDecoratorTestApp
|
9
|
+
class Application < Rails::Application
|
10
|
+
config.secret_token = '"confusion" will be my epitaph.'
|
11
|
+
config.session_store :cookie_store, :key => '_myapp_session'
|
12
|
+
config.active_support.deprecation = :log
|
13
|
+
end
|
14
|
+
end
|
15
|
+
RDecoratorTestApp::Application.initialize!
|
16
|
+
|
17
|
+
# routes
|
18
|
+
RDecoratorTestApp::Application.routes.draw do
|
19
|
+
resources :authors, :only => [:index, :show] do
|
20
|
+
resources :books, :only => :show
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# models
|
25
|
+
class Author < ActiveRecord::Base
|
26
|
+
has_many :books
|
27
|
+
end
|
28
|
+
class Book < ActiveRecord::Base
|
29
|
+
belongs_to :author
|
30
|
+
end
|
31
|
+
|
32
|
+
# helpers
|
33
|
+
module ApplicationHelper; end
|
34
|
+
|
35
|
+
# decorators
|
36
|
+
class ApplicationDecorator < RDecorator::Base
|
37
|
+
end
|
38
|
+
class AuthorDecorator < ApplicationDecorator
|
39
|
+
def reverse_name
|
40
|
+
name.reverse
|
41
|
+
end
|
42
|
+
|
43
|
+
def capitalized_name
|
44
|
+
name.capitalize
|
45
|
+
end
|
46
|
+
end
|
47
|
+
class BookDecorator < ApplicationDecorator
|
48
|
+
def reverse_title
|
49
|
+
title.reverse
|
50
|
+
end
|
51
|
+
|
52
|
+
def upcased_title
|
53
|
+
title.upcase
|
54
|
+
end
|
55
|
+
|
56
|
+
def link
|
57
|
+
link_to title, "#{request.protocol}#{request.host_with_port}/assets/sample.png"
|
58
|
+
end
|
59
|
+
|
60
|
+
def cover_image
|
61
|
+
image_tag 'cover.png'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# controllers
|
66
|
+
class ApplicationController < ActionController::Base
|
67
|
+
self.append_view_path File.dirname(__FILE__)
|
68
|
+
end
|
69
|
+
class AuthorsController < ApplicationController
|
70
|
+
def index
|
71
|
+
if params[:variable_type] == 'array'
|
72
|
+
@authors = Author.all
|
73
|
+
else
|
74
|
+
@authors = Author.scoped
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def show
|
79
|
+
@author = Author.find params[:id]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
class BooksController < ApplicationController
|
83
|
+
def show
|
84
|
+
@book = Author.find(params[:author_id]).books.find(params[:id])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# migrations
|
89
|
+
class CreateAllTables < ActiveRecord::Migration
|
90
|
+
def self.up
|
91
|
+
create_table(:authors) {|t| t.string :name}
|
92
|
+
create_table(:books) {|t| t.string :title; t.references :author}
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'fallback to helpers' do
|
4
|
+
background do
|
5
|
+
aamine = Author.create! :name => 'aamine'
|
6
|
+
@rhg = aamine.books.create! :title => 'RHG'
|
7
|
+
end
|
8
|
+
|
9
|
+
scenario 'invoking action_view helper methods' do
|
10
|
+
visit "/authors/#{@rhg.author.id}/books/#{@rhg.id}"
|
11
|
+
puts "page: #{page.html}"
|
12
|
+
within 'a' do
|
13
|
+
page.should have_content 'RHG'
|
14
|
+
end
|
15
|
+
page.should have_css('img')
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'decorating controller ivar' do
|
4
|
+
background do
|
5
|
+
@matz = Author.create! :name => 'matz'
|
6
|
+
Author.create! :name => 'takahashim'
|
7
|
+
end
|
8
|
+
after do
|
9
|
+
Author.delete_all
|
10
|
+
end
|
11
|
+
|
12
|
+
scenario 'decorating a model object in ivar' do
|
13
|
+
visit "/authors/#{@matz.id}"
|
14
|
+
page.should have_content 'matz'
|
15
|
+
page.should have_content 'matz'.capitalize
|
16
|
+
end
|
17
|
+
|
18
|
+
scenario 'decorating model scope in ivar' do
|
19
|
+
visit '/authors'
|
20
|
+
page.should have_content 'takahashim'
|
21
|
+
page.should have_content 'takahashim'.reverse
|
22
|
+
end
|
23
|
+
|
24
|
+
scenario "decorating models' array in ivar" do
|
25
|
+
visit '/authors?variable_type=array'
|
26
|
+
page.should have_content 'takahashim'
|
27
|
+
page.should have_content 'takahashim'.reverse
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "Definition" do
|
4
|
+
class Foo
|
5
|
+
def say
|
6
|
+
"Hey!"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class FooDecorator < RDecorator::Base
|
11
|
+
def say
|
12
|
+
origin.say * 3
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class This
|
17
|
+
def say
|
18
|
+
"Yeah!"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class ThatDecorator < RDecorator::Base
|
23
|
+
decorate_for :this
|
24
|
+
def say
|
25
|
+
origin.say * 3
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
scenario "Auto decoration by class-name" do
|
30
|
+
foo = Foo.new
|
31
|
+
foo.decorated.say.should eq "Hey!Hey!Hey!"
|
32
|
+
end
|
33
|
+
|
34
|
+
scenario "using 'decorate_for'" do
|
35
|
+
this = This.new
|
36
|
+
this.decorated.say.should eq "Yeah!Yeah!Yeah!"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'decorating partial object' do
|
4
|
+
background do
|
5
|
+
Author.create! :name => 'aamine'
|
6
|
+
nari = Author.create! :name => 'nari'
|
7
|
+
nari.books.create! :title => 'the gc book'
|
8
|
+
end
|
9
|
+
after do
|
10
|
+
Book.delete_all
|
11
|
+
Author.delete_all
|
12
|
+
end
|
13
|
+
|
14
|
+
scenario 'decorating implicit @object' do
|
15
|
+
visit '/authors'
|
16
|
+
page.should have_content 'the gc book'
|
17
|
+
page.should have_content 'the gc book'.reverse
|
18
|
+
end
|
19
|
+
|
20
|
+
scenario 'decorating implicit @collection' do
|
21
|
+
visit '/authors?partial=collection'
|
22
|
+
page.should have_content 'the gc book'
|
23
|
+
page.should have_content 'the gc book'.reverse
|
24
|
+
end
|
25
|
+
|
26
|
+
scenario 'decorating objects in @locals' do
|
27
|
+
visit '/authors?partial=locals'
|
28
|
+
page.should have_content 'the gc book'
|
29
|
+
page.should have_content 'the gc book'.upcase
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
# load Rails first
|
4
|
+
require 'rails'
|
5
|
+
require 'r_decorator'
|
6
|
+
# needs to load the app before loading rspec/rails => capybara
|
7
|
+
require 'fake_app/fake_app'
|
8
|
+
require 'rspec/rails'
|
9
|
+
require 'capybara/rspec'
|
10
|
+
|
11
|
+
# Requires supporting files with custom matchers and macros, etc,
|
12
|
+
# in ./support/ and its subdirectories.
|
13
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.before :all do
|
17
|
+
CreateAllTables.up unless ActiveRecord::Base.connection.table_exists? 'authors'
|
18
|
+
end
|
19
|
+
config.before :each do
|
20
|
+
Book.delete_all
|
21
|
+
Author.delete_all
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: r_decorator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Takuya Fujii
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-16 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A readable and simple view helper for Rails 3
|
15
|
+
email:
|
16
|
+
- takuya327@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- .rspec
|
23
|
+
- .travis.yml
|
24
|
+
- Gemfile
|
25
|
+
- MIT-LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- gemfiles/Gemfile-rails.3.0.x
|
29
|
+
- gemfiles/Gemfile-rails.3.1.x
|
30
|
+
- lib/generators/decorator/decorator_generator.rb
|
31
|
+
- lib/generators/decorator/templates/decorator.rb
|
32
|
+
- lib/generators/resource_override.rb
|
33
|
+
- lib/generators/rspec/decorator_generator.rb
|
34
|
+
- lib/generators/rspec/templates/decorator_spec.rb
|
35
|
+
- lib/generators/test_unit/decorator_generator.rb
|
36
|
+
- lib/generators/test_unit/templates/decorator_test.rb
|
37
|
+
- lib/r_decorator.rb
|
38
|
+
- lib/r_decorator/base.rb
|
39
|
+
- lib/r_decorator/railtie.rb
|
40
|
+
- lib/r_decorator/version.rb
|
41
|
+
- lib/r_decorator/view_context.rb
|
42
|
+
- r_decortator.gemspec
|
43
|
+
- spec/fake_app/authors/index.html.erb
|
44
|
+
- spec/fake_app/authors/show.html.erb
|
45
|
+
- spec/fake_app/books/_book.html.erb
|
46
|
+
- spec/fake_app/books/_book_locals.html.erb
|
47
|
+
- spec/fake_app/books/show.html.erb
|
48
|
+
- spec/fake_app/fake_app.rb
|
49
|
+
- spec/features/action_view_helpers_spec.rb
|
50
|
+
- spec/features/controller_ivar_spec.rb
|
51
|
+
- spec/features/decorator_spec.rb
|
52
|
+
- spec/features/partial_spec.rb
|
53
|
+
- spec/spec_helper.rb
|
54
|
+
homepage: https://github.com/takuya327/r_decorator
|
55
|
+
licenses: []
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project: r_decorator
|
74
|
+
rubygems_version: 1.8.24
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: A readable and simple view helper for Rails 3
|
78
|
+
test_files:
|
79
|
+
- spec/fake_app/authors/index.html.erb
|
80
|
+
- spec/fake_app/authors/show.html.erb
|
81
|
+
- spec/fake_app/books/_book.html.erb
|
82
|
+
- spec/fake_app/books/_book_locals.html.erb
|
83
|
+
- spec/fake_app/books/show.html.erb
|
84
|
+
- spec/fake_app/fake_app.rb
|
85
|
+
- spec/features/action_view_helpers_spec.rb
|
86
|
+
- spec/features/controller_ivar_spec.rb
|
87
|
+
- spec/features/decorator_spec.rb
|
88
|
+
- spec/features/partial_spec.rb
|
89
|
+
- spec/spec_helper.rb
|