exhibit 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/exhibit/version.rb +1 -1
- data/lib/generators/exhibit/USAGE +17 -19
- data/lib/generators/exhibit/presenter_generator.rb +11 -66
- data/lib/generators/exhibit/templates/presenter.rb +3 -3
- data/lib/generators/rspec/presenter_generator.rb +9 -0
- data/lib/generators/{exhibit → rspec}/templates/presenter_spec.rb +4 -4
- data/lib/generators/shoulda/presenter_generator.rb +9 -0
- data/lib/generators/{exhibit → shoulda}/templates/presenter_test.rb +3 -3
- data/lib/generators/test_unit/presenter_generator.rb +9 -0
- data/lib/generators/test_unit/templates/presenter_test.rb +4 -0
- metadata +10 -6
data/lib/exhibit/version.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
|
-
Available generators:
|
2
|
-
exhibit:presenter
|
3
|
-
Options:
|
4
|
-
--
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
This will create:
|
19
|
-
config/initializers/exhibit_presenter.rb
|
1
|
+
Available generators:
|
2
|
+
exhibit:presenter
|
3
|
+
Options:
|
4
|
+
--skip_namespace
|
5
|
+
|
6
|
+
exhibit:base
|
7
|
+
|
8
|
+
Examples:
|
9
|
+
rails g exhibit:presenter User
|
10
|
+
This will create:
|
11
|
+
app/presenters
|
12
|
+
app/presenters/user_presenter.rb
|
13
|
+
spec/presenters/user_presenter_spec.rb
|
14
|
+
|
15
|
+
rails g exhibit:base
|
16
|
+
This will create:
|
17
|
+
config/initializers/exhibit_presenter.rb
|
@@ -1,66 +1,11 @@
|
|
1
|
-
module Exhibit
|
2
|
-
class PresenterGenerator < Rails::Generators::
|
3
|
-
source_root File.expand_path('../templates', __FILE__)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def create_tests
|
14
|
-
if test_framework == :rspec
|
15
|
-
template "presenter_spec.rb", "spec/presenters/#{file_name}_spec.rb"
|
16
|
-
else
|
17
|
-
template "presenter_test.rb", "test/unit/presenters/#{file_name}_test.rb"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def file_name
|
24
|
-
"#{singular_name}_presenter"
|
25
|
-
end
|
26
|
-
|
27
|
-
def singular_name
|
28
|
-
if options[:no_namespace]
|
29
|
-
presenter_name.underscore.split('/').last
|
30
|
-
else
|
31
|
-
presenter_name.underscore
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def class_name
|
36
|
-
singular_name.camelize
|
37
|
-
end
|
38
|
-
|
39
|
-
def exhibit_name
|
40
|
-
if options[:no_namespace]
|
41
|
-
presenter_name.underscore.split('/').last
|
42
|
-
else
|
43
|
-
presenter_name.underscore.gsub('/', '_')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_framework
|
48
|
-
return @test_framework if defined?(@test_framework)
|
49
|
-
if options.testunit?
|
50
|
-
return @test_framework = :testunit
|
51
|
-
elsif options.rspec?
|
52
|
-
return @test_framework = :rspec
|
53
|
-
else
|
54
|
-
return @test_framework = default_test_framework
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def default_test_framework
|
59
|
-
File.exist?(destination_path("spec")) ? :rspec : :testunit
|
60
|
-
end
|
61
|
-
|
62
|
-
def destination_path(path)
|
63
|
-
File.join(destination_root, path)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
1
|
+
module Exhibit
|
2
|
+
class PresenterGenerator < Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
hook_for :test_framework
|
6
|
+
|
7
|
+
def create_presenter
|
8
|
+
template "presenter.rb", "app/presenters/#{file_name}_presenter.rb"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class <%= class_name %>Presenter < Exhibit::Presenter
|
2
|
-
exhibit :<%=
|
3
|
-
end
|
1
|
+
class <%= class_name %>Presenter < Exhibit::Presenter
|
2
|
+
exhibit :<%= singular_name %>
|
3
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Rspec
|
2
|
+
class PresenterGenerator < ::Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def create_test_file
|
6
|
+
template 'presenter_spec.rb', File.join('spec/presenters', "#{singular_name}_presenter_spec.rb")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe <%= class_name %>Presenter do
|
4
|
-
include ActionView::TestCase::Behavior
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe <%= class_name %>Presenter do
|
4
|
+
include ActionView::TestCase::Behavior
|
5
5
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Shoulda
|
2
|
+
class PresenterGenerator < ::Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def create_test_file
|
6
|
+
template 'presenter_test.rb', File.join('test/unit/presenters', "#{singular_name}_presenter_test.rb")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class <%= class_name %>PresenterTest < ActionView::TestCase
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class <%= class_name %>PresenterTest < ActionView::TestCase
|
4
4
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module TestUnit
|
2
|
+
class PresenterGenerator < ::Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def create_test_file
|
6
|
+
template 'presenter_test.rb', File.join('test/unit/presenters', "#{singular_name}_presenter_test.rb")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robin Brouwer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-07-18 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,9 +50,13 @@ files:
|
|
50
50
|
- lib/generators/exhibit/presenter_generator.rb
|
51
51
|
- lib/generators/exhibit/templates/exhibit_presenter.rb
|
52
52
|
- lib/generators/exhibit/templates/presenter.rb
|
53
|
-
- lib/generators/exhibit/templates/presenter_spec.rb
|
54
|
-
- lib/generators/exhibit/templates/presenter_test.rb
|
55
53
|
- lib/generators/exhibit/USAGE
|
54
|
+
- lib/generators/rspec/presenter_generator.rb
|
55
|
+
- lib/generators/rspec/templates/presenter_spec.rb
|
56
|
+
- lib/generators/shoulda/presenter_generator.rb
|
57
|
+
- lib/generators/shoulda/templates/presenter_test.rb
|
58
|
+
- lib/generators/test_unit/presenter_generator.rb
|
59
|
+
- lib/generators/test_unit/templates/presenter_test.rb
|
56
60
|
- lib/tasks/exhibit_tasks.rake
|
57
61
|
- MIT-LICENSE
|
58
62
|
- Rakefile
|