fierce 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/integration_spec/dummy/app/presenters/home/index.rb +10 -12
- data/integration_spec/dummy/app/presenters/home/show.rb +14 -16
- data/integration_spec/dummy/app/presenters/layouts/application.rb +12 -14
- data/lib/fierce/presenter_finder.rb +6 -12
- data/lib/fierce/railtie.rb +1 -1
- data/lib/fierce/version.rb +1 -1
- data/spec/master_of_ceremonies_spec.rb +1 -1
- data/spec/presenter_finder_spec.rb +2 -7
- data/spec/support/custom_presenters/home/index.rb +7 -0
- metadata +4 -4
- data/spec/custom_presenters/home/index.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 112381d66ad974af74f2c51860c0937b31f2474a
|
4
|
+
data.tar.gz: 84235a1fc6b60513295e7db8783f0627f07d5043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f9bd36ef756350d352099a5a22ced37d49dfd0b60a992b1a7409e5d44fb2faa744258bcef4bd756dbf0e78c31b9b410fd1439164a32ce4df7e64f506977cc1f
|
7
|
+
data.tar.gz: cc30aaee4b887019cd15b6d165068e6e9eb940a702b26d3eb8f64bff01d2d3f6b4cae28cd82d71c9b5ba05b49d3bf2b2fe0d148b2b4a60e07c7a0b8f98216b16
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ And a helper somewhere that has this logic:
|
|
51
51
|
|
52
52
|
And a presenter with a little something too:
|
53
53
|
|
54
|
-
class
|
54
|
+
class Home::Index
|
55
55
|
def from_your_presenters
|
56
56
|
"Use your presenters. It is a pure Ruby class of your own. Mixins and inheritance just work. One presenter per view. Go!"
|
57
57
|
end
|
@@ -83,7 +83,7 @@ Classes that initialize with a single argument will be passed a default presente
|
|
83
83
|
|
84
84
|
Given the setup previously described, helpers, controllers and all:
|
85
85
|
|
86
|
-
class
|
86
|
+
class Home::Index
|
87
87
|
attr_reader :default_presenter
|
88
88
|
|
89
89
|
def initialize(default_presenter)
|
@@ -1,15 +1,13 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
1
|
+
module Home
|
2
|
+
class Index
|
3
|
+
def from_the_presenter
|
4
|
+
'Hello from the presenter'
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
7
|
+
def partials
|
8
|
+
{
|
9
|
+
far_away: '/layouts/far_away'
|
10
|
+
}
|
13
11
|
end
|
14
12
|
end
|
15
|
-
end
|
13
|
+
end
|
@@ -1,22 +1,20 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
attr_reader :view_model
|
1
|
+
module Home
|
2
|
+
class Show
|
3
|
+
attr_reader :view_model
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def initialize(view_model)
|
6
|
+
@view_model = view_model
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def loop_count
|
10
|
+
view_model.loop_it
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def loops
|
14
|
+
(1..loop_count).to_a.map{|n| Looplet.new(n) }
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
end
|
17
|
+
class Looplet < Struct.new(:n)
|
20
18
|
end
|
21
19
|
end
|
22
|
-
end
|
20
|
+
end
|
@@ -1,19 +1,17 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
attr_reader :view_model
|
1
|
+
module Layouts
|
2
|
+
class Application
|
3
|
+
attr_reader :view_model
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def initialize(view_model)
|
6
|
+
@view_model = view_model
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def stylesheets
|
10
|
+
view_model.stylesheet_link_tag('application', media: 'all')
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
13
|
+
def javascripts
|
14
|
+
view_model.javascript_include_tag('application')
|
17
15
|
end
|
18
16
|
end
|
19
|
-
end
|
17
|
+
end
|
@@ -10,24 +10,18 @@ module Fierce
|
|
10
10
|
"#{base_path}/#{path}.rb"
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
end
|
13
|
+
def found?
|
14
|
+
Fierce.paths.any? do |base_path|
|
15
|
+
File.exist?(file_path(base_path))
|
16
|
+
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def perform
|
20
|
-
presenter_class if
|
21
|
-
end
|
22
|
-
|
23
|
-
def path_to_classify
|
24
|
-
top_module = found_base_path.split('/').last
|
25
|
-
"#{top_module}/#{path}"
|
20
|
+
presenter_class if found?
|
26
21
|
end
|
27
22
|
|
28
23
|
def presenter_class
|
29
|
-
|
30
|
-
path_to_classify.classify.constantize
|
24
|
+
"::#{path.classify}".constantize
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
data/lib/fierce/railtie.rb
CHANGED
data/lib/fierce/version.rb
CHANGED
@@ -23,7 +23,7 @@ describe Fierce::MasterOfCeremonies do
|
|
23
23
|
|
24
24
|
before do
|
25
25
|
Rails.stub(:root).and_return(File.dirname(__FILE__))
|
26
|
-
Fierce.add_path(File.dirname(__FILE__) + "/custom_presenters")
|
26
|
+
Fierce.add_path(File.dirname(__FILE__) + "/support/custom_presenters")
|
27
27
|
end
|
28
28
|
|
29
29
|
describe '#render' do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Fierce::PresenterFinder do
|
4
|
-
let(:fixture_presenter_path) { File.dirname(__FILE__) + "/custom_presenters" }
|
4
|
+
let(:fixture_presenter_path) { File.dirname(__FILE__) + "/support/custom_presenters" }
|
5
5
|
|
6
6
|
before do
|
7
7
|
Fierce.clear_paths
|
@@ -10,12 +10,7 @@ describe Fierce::PresenterFinder do
|
|
10
10
|
|
11
11
|
let(:finder) { Fierce::PresenterFinder.new('home/index') }
|
12
12
|
|
13
|
-
it "requires the file" do
|
14
|
-
finder.perform
|
15
|
-
defined?(CustomPresenters).should be_true
|
16
|
-
end
|
17
|
-
|
18
13
|
it "return the class" do
|
19
|
-
finder.perform.should ==
|
14
|
+
finder.perform.should == Home::Index
|
20
15
|
end
|
21
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fierce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kane Baccigalupi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mustache
|
@@ -181,11 +181,11 @@ files:
|
|
181
181
|
- lib/fierce/version.rb
|
182
182
|
- lib/fierce/view_model.rb
|
183
183
|
- spec/config_spec.rb
|
184
|
-
- spec/custom_presenters/home/index.rb
|
185
184
|
- spec/delegate_generator/controller_spec.rb
|
186
185
|
- spec/master_of_ceremonies_spec.rb
|
187
186
|
- spec/presenter_finder_spec.rb
|
188
187
|
- spec/spec_helper.rb
|
188
|
+
- spec/support/custom_presenters/home/index.rb
|
189
189
|
- spec/support/stubs.rb
|
190
190
|
- spec/support/view_model_spec.rb
|
191
191
|
- spec/view_model_spec.rb
|
@@ -215,11 +215,11 @@ specification_version: 4
|
|
215
215
|
summary: Fierce, opinionate view logic for Rails
|
216
216
|
test_files:
|
217
217
|
- spec/config_spec.rb
|
218
|
-
- spec/custom_presenters/home/index.rb
|
219
218
|
- spec/delegate_generator/controller_spec.rb
|
220
219
|
- spec/master_of_ceremonies_spec.rb
|
221
220
|
- spec/presenter_finder_spec.rb
|
222
221
|
- spec/spec_helper.rb
|
222
|
+
- spec/support/custom_presenters/home/index.rb
|
223
223
|
- spec/support/stubs.rb
|
224
224
|
- spec/support/view_model_spec.rb
|
225
225
|
- spec/view_model_spec.rb
|