little_wheels 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/little_wheels.rb +29 -65
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c0ec5d5d5eb32b8ba9bdd696430909237d694878ea33a17ed287589b2f109fb
4
- data.tar.gz: 6ac0b57e365ee4072c5457899e6391ceb94afe3222da69db8172ba43b19ea071
3
+ metadata.gz: 4032c8ab3d1e59679bd977a166d021f3da97bc3c6e88931fb56abd7a233eceea
4
+ data.tar.gz: 670ee7c08d9ec651e76892bd6c36fdb9046638c7a0aa572948b8e920dd7224f6
5
5
  SHA512:
6
- metadata.gz: 28f9a1fe64568d1f718a011451d9c926590ca97c6a2f7dce63d47267c6ed52583bb84c7e3c770565c4f8bb384d2a6b04aee65b1e48ea5bfaa62f37c8f0938a91
7
- data.tar.gz: fbcc810c8fe34c7c56bf58b074515d486e6a6d410fd3eb53182aa6f2605c0e5971e92780cde9cbfc6452c1c67e23318d2e2c2edecacd9c74837499a763a455a1
6
+ metadata.gz: 87033bb602b579ca4c7682820d6cd4d09d4b98638c90f840fad14db9c7ef8d81ca618a114e34539e49f0b0d38c53c77012071ebd3f9893d03b59727a9490d91c
7
+ data.tar.gz: a7576f978be846cfd4d20fd5cff23a159e7c1d9226b28ed532d1c8073fc91aba76ad783751ad1abb8243e9a4e3903bc64b04688df93c39c7f99b784f050e4ca8
data/lib/little_wheels.rb CHANGED
@@ -1,26 +1,16 @@
1
1
  module LittleWheels
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
 
4
- def self.renderer
5
- ApplicationController
6
- end
7
-
8
- def self.helpers
9
- renderer.helpers
10
- end
4
+ def self.renderer = ApplicationController
5
+ def self.helpers = self.renderer.helpers
11
6
 
12
7
  class Buffer
13
8
  def initialize(string)
14
9
  @string = string.html_safe
15
10
  end
16
11
 
17
- def +(other)
18
- self.class.new(@string + other.to_s)
19
- end
20
-
21
- def to_s
22
- @string
23
- end
12
+ def +(other) = self.class.new(@string + other.to_s)
13
+ def to_s = @string
24
14
  end
25
15
 
26
16
  module Component
@@ -28,72 +18,46 @@ module LittleWheels
28
18
  def [](*a, **o, &b) = new(*a, **o, &b)
29
19
  end
30
20
 
31
- def self.included(base)
32
- base.extend(ClassMethods)
33
- end
21
+ def self.included(base) = base.extend(ClassMethods)
34
22
 
35
- def t(template, **locals)
36
- renderer.render(inline: template, locals:)
37
- end
23
+ def t(template, **locals) = renderer.render(inline: template, locals:)
38
24
 
39
- def t!(template, **locals)
40
- renderer.render(template, locals:, layout: nil)
41
- end
25
+ def t!(template, **locals) = renderer.render(template, locals:, layout: nil)
42
26
 
43
- def x
44
- helpers.tag
45
- end
27
+ def x = helpers.tag
46
28
 
47
- def o(&block)
48
- block.binding.receiver.capture(&block)
49
- end
29
+ def o(&block) = block.binding.receiver.capture(&block)
50
30
 
51
- def +(other)
52
- Buffer.new(to_s + other.to_s)
53
- end
31
+ def +(other) = Buffer.new(to_s + other.to_s)
54
32
 
55
- def to_s
56
- to_html
57
- end
33
+ def accepts_slot(block) = @_slot = block
58
34
 
59
- def to_html
60
- helpers.capture do
61
- if self.class.const_defined?(:TEMPLATE)
62
- t(self.class.const_get(:TEMPLATE), c: self, x: self.x )
63
- else
64
- t!(default_template_name, c: self, x: self.x )
65
- end
66
- end
67
- end
35
+ def capture(&block) = block.call.to_s.html_safe
68
36
 
69
- def accepts_slot(block)
70
- @_slot = block
71
- end
37
+ def default_template_name = "shared/#{self.class.name.underscore}"
72
38
 
73
- def slot
74
- context = @_slot.binding.receiver
39
+ def helpers = LittleWheels.helpers
75
40
 
76
- context.capture { @_slot.call.to_s }
77
- end
41
+ def renderer = LittleWheels.renderer
78
42
 
79
- def renderer
80
- LittleWheels.renderer
81
- end
43
+ def render_in(context) = context.render(:inline => to_html)
82
44
 
83
- def helpers
84
- LittleWheels.helpers
85
- end
45
+ def to_s = to_html
86
46
 
87
- def default_template_name
88
- "shared/#{self.class.name.underscore}"
89
- end
47
+ def slot
48
+ context = @_slot.binding.receiver
90
49
 
91
- def capture(&block)
92
- block.call.to_s.html_safe
50
+ context.capture { @_slot.call.to_s }
93
51
  end
94
52
 
95
- def render_in(context)
96
- context.render(:inline => to_html)
53
+ def to_html
54
+ helpers.capture do
55
+ if self.class.const_defined?(:TEMPLATE)
56
+ t(self.class.const_get(:TEMPLATE), c: self, x: self.x )
57
+ else
58
+ t!(default_template_name, c: self, x: self.x )
59
+ end
60
+ end
97
61
  end
98
62
  end
99
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: little_wheels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Brown