crumpet 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f931996638482bda209c63e1cf4d7ceec9632b1c
4
- data.tar.gz: aed1448bb8b7e4f2fe1b0eb7058be883ceb3744f
3
+ metadata.gz: 59d37a419c3172f9d87c9cc0d8e3e1cdfd8dd976
4
+ data.tar.gz: f48df2474a52c8bf85227f49d259e93be8d4c28f
5
5
  SHA512:
6
- metadata.gz: 22736686be117249372d7bdc484fff4b4d0cc89ea93357e4cfea1fce8de1de4725ef869b7a6b6d56b304a835aa0af2e13daaf5f918d0abcb265762f1f383ce30
7
- data.tar.gz: 52fc4d5438bbd7b057b4b05c8d1478a25f58d04b7358b05a269fd817dd40a3bca7ce5b693cea4e91ee23464a9ef57171a661ba6856831dba33005b9281f653f8
6
+ metadata.gz: 4249776a9c9e2c132cb8a0fbb934f5709c0f1554358707dd22e7ab0276523b295d4d067f436291e6e8966df1f936284a39ebf778ec3c78ca533c9d46b3bf7483
7
+ data.tar.gz: d272a0c303001814baa0b4be1a3ecb1f486475820788cdc5a8f8278680eead8b0c2f39c2d13d468a0533531014487d4951a768bc163026ec6fe17ddd76934528
@@ -12,14 +12,6 @@ module Crumpet
12
12
  @config ||= Crumpet::Configuration.new
13
13
  end
14
14
 
15
- module_function def crumbs
16
- @crumbs ||= Crumpet::Repository.new
17
- end
18
-
19
- def self.render(options = {})
20
- Crumpet::Renderer.new(options).render
21
- end
22
-
23
15
  def self.configure
24
16
  yield config
25
17
  end
@@ -5,16 +5,15 @@ module Crumpet
5
5
  end
6
6
 
7
7
  def add_crumb(*args)
8
- Crumpet.crumbs.add_crumb(*args)
8
+ crumbs.add_crumb(*args)
9
9
  end
10
10
 
11
11
  def clear_crumbs
12
- Crumpet.crumbs.clear
12
+ crumbs.clear
13
13
  end
14
14
 
15
15
  def crumbs(&block)
16
- yield if block_given?
17
- Crumpet.crumbs
16
+ @_crumbs ||= Crumpet::Repository.new
18
17
  end
19
18
 
20
19
  module ClassMethods
@@ -26,10 +25,9 @@ module Crumpet
26
25
  if block_given?
27
26
  options = args.present? ? { only: args } : {}
28
27
  before_action(options) do |instance|
29
- instance.instance_exec(:crumbs, &block)
28
+ instance.instance_exec(&block)
30
29
  end
31
30
  end
32
- Crumpet.crumbs
33
31
  end
34
32
  end
35
33
  end
@@ -4,8 +4,6 @@ module Crumpet
4
4
  ActiveSupport.on_load :action_controller do
5
5
  self.class_eval do
6
6
  include Crumpet::ControllerAdditions
7
-
8
- before_action :clear_crumbs
9
7
  end
10
8
  end
11
9
  end
@@ -3,9 +3,14 @@ module Crumpet
3
3
  include ActionView::Helpers::UrlHelper
4
4
  include ERB::Util
5
5
 
6
- attr_reader :options
6
+ attr_reader :crumbs, :options
7
7
 
8
- def initialize(options = {})
8
+ def self.render(crumbs, options = {})
9
+ new(crumbs, options).render
10
+ end
11
+
12
+ def initialize(crumbs, options = {})
13
+ @crumbs = crumbs
9
14
  @options = options
10
15
  end
11
16
 
@@ -30,10 +35,6 @@ module Crumpet
30
35
 
31
36
  private
32
37
 
33
- def crumbs
34
- Crumpet.crumbs
35
- end
36
-
37
38
  def render_html(crumb)
38
39
  name = render_name(crumb)
39
40
  item_options = build_html_options(crumb)
@@ -1,5 +1,9 @@
1
1
  module Crumpet
2
2
  class Repository < Array
3
+ def render(options = {})
4
+ Crumpet::Renderer.render(self, options)
5
+ end
6
+
3
7
  def add_crumb(*args)
4
8
  self << Crumpet::Crumb.new(*args)
5
9
  end
@@ -1,3 +1,3 @@
1
1
  module Crumpet
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,11 +1,11 @@
1
1
  module Crumpet
2
2
  module ViewHelpers
3
3
  def render_crumbs(options = {})
4
- Crumpet.render(options)
4
+ crumbs.render(options)
5
5
  end
6
6
 
7
7
  def crumbs
8
- Crumpet.crumbs
8
+ @_crumbs ||= Crumpet::Repository.new
9
9
  end
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crumpet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Colegate
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-20 00:00:00.000000000 Z
11
+ date: 2017-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails