fierce 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aedff8993a377777fc09ce941eb0cbf8028b8e4e
4
- data.tar.gz: c183353ee1667ca03923c440edde27ec496c93bd
3
+ metadata.gz: 112381d66ad974af74f2c51860c0937b31f2474a
4
+ data.tar.gz: 84235a1fc6b60513295e7db8783f0627f07d5043
5
5
  SHA512:
6
- metadata.gz: 26b61ccc729797c468390278457f896a8fc7851665510d5e870ee0dec845173759e766fac7214daa6e5acb59811189cd1020e3107da850a89062be20eb96f803
7
- data.tar.gz: cdd47caeef578092e5bb001e91070849f8a5d9ec4f5228030624debd864522ded6e285374f962b0631c3ab56344a26e67fa68d469d20f86054b8b180947bc9e4
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 Presenters::Home::Index
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 Presenters::Home::Index
86
+ class Home::Index
87
87
  attr_reader :default_presenter
88
88
 
89
89
  def initialize(default_presenter)
@@ -1,15 +1,13 @@
1
- module Presenters
2
- module Home
3
- class Index
4
- def from_the_presenter
5
- 'Hello from the presenter'
6
- end
1
+ module Home
2
+ class Index
3
+ def from_the_presenter
4
+ 'Hello from the presenter'
5
+ end
7
6
 
8
- def partials
9
- {
10
- far_away: '/layouts/far_away'
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 Presenters
2
- module Home
3
- class Show
4
- attr_reader :view_model
1
+ module Home
2
+ class Show
3
+ attr_reader :view_model
5
4
 
6
- def initialize(view_model)
7
- @view_model = view_model
8
- end
5
+ def initialize(view_model)
6
+ @view_model = view_model
7
+ end
9
8
 
10
- def loop_count
11
- view_model.loop_it
12
- end
9
+ def loop_count
10
+ view_model.loop_it
11
+ end
13
12
 
14
- def loops
15
- (1..loop_count).to_a.map{|n| Looplet.new(n) }
16
- end
13
+ def loops
14
+ (1..loop_count).to_a.map{|n| Looplet.new(n) }
15
+ end
17
16
 
18
- class Looplet < Struct.new(:n)
19
- end
17
+ class Looplet < Struct.new(:n)
20
18
  end
21
19
  end
22
- end
20
+ end
@@ -1,19 +1,17 @@
1
- module Presenters
2
- module Layouts
3
- class Application
4
- attr_reader :view_model
1
+ module Layouts
2
+ class Application
3
+ attr_reader :view_model
5
4
 
6
- def initialize(view_model)
7
- @view_model = view_model
8
- end
5
+ def initialize(view_model)
6
+ @view_model = view_model
7
+ end
9
8
 
10
- def stylesheets
11
- view_model.stylesheet_link_tag('application', media: 'all')
12
- end
9
+ def stylesheets
10
+ view_model.stylesheet_link_tag('application', media: 'all')
11
+ end
13
12
 
14
- def javascripts
15
- view_model.javascript_include_tag('application')
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 found_base_path
14
- @found = Fierce.paths.map do |base_path|
15
- base_path if File.exist?(file_path(base_path))
16
- end.compact.first
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 found_base_path
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
- require file_path(found_base_path)
30
- path_to_classify.classify.constantize
24
+ "::#{path.classify}".constantize
31
25
  end
32
26
  end
33
27
  end
@@ -4,7 +4,7 @@ module Fierce
4
4
  Fierce.add_path (Rails.root.to_s + "/app/presenters") # default opinionation
5
5
 
6
6
  Fierce.paths.each do |path|
7
- app.config.autoload_paths << path
7
+ app.config.eager_load_paths << path
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Fierce
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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 == CustomPresenters::Home::Index
14
+ finder.perform.should == Home::Index
20
15
  end
21
16
  end
@@ -0,0 +1,7 @@
1
+ module Home
2
+ class Index
3
+ def from_custom_presenter
4
+ 'hello from the custom presenter'
5
+ end
6
+ end
7
+ 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.3
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-02 00:00:00.000000000 Z
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
@@ -1,9 +0,0 @@
1
- module CustomPresenters
2
- module Home
3
- class Index
4
- def from_custom_presenter
5
- 'hello from the custom presenter'
6
- end
7
- end
8
- end
9
- end