alephant-renderer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alephant/renderer/version.rb +1 -1
- data/lib/alephant/renderer.rb +1 -2
- data/lib/alephant/views/base.rb +17 -0
- data/lib/alephant/views.rb +32 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e10f2ccda58347efd0066e188a2476184a678d7b
|
4
|
+
data.tar.gz: 381928cd451908ffa930066a001356c19f492c57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0415a201d03b777715029ed77a0aafdf1a34c8689b0bf6e66615e07568dc42ad0c247f9da11bc1a0433e387de14a02f8a195c485e58168db838919dfcd4a23d
|
7
|
+
data.tar.gz: ab1c19eafdaeccd8a94a53c196855827751c55f1c8ceca01139b0713c56c09e070c9ad799c83a4c713c1cdd7b218077a073fa8240136ee2cba5c3a73809d73dd
|
data/lib/alephant/renderer.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mustache'
|
2
|
+
require 'alephant/views'
|
3
|
+
|
4
|
+
module Alephant::Views
|
5
|
+
class Base < Mustache
|
6
|
+
attr_accessor :data
|
7
|
+
|
8
|
+
def initialize(data = {})
|
9
|
+
@data = data
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.inherited(subclass)
|
13
|
+
::Alephant::Views.register(subclass)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'alephant/views/base'
|
2
|
+
|
3
|
+
module Alephant
|
4
|
+
module Views
|
5
|
+
@@views = {}
|
6
|
+
|
7
|
+
def self.register(klass)
|
8
|
+
id = klass.name.split('::').last
|
9
|
+
self.underscorify(id)
|
10
|
+
|
11
|
+
@@views[id.underscore] = klass
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.get_registered_class(id)
|
15
|
+
@@views[id]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.underscorify(str)
|
19
|
+
unless str.respond_to? :underscore
|
20
|
+
str.instance_eval do
|
21
|
+
def underscore
|
22
|
+
self.gsub(/::/, '/').
|
23
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
24
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
25
|
+
tr("-", "_").
|
26
|
+
downcase
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-renderer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Kenny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -183,6 +183,8 @@ files:
|
|
183
183
|
- lib/alephant/renderer.rb
|
184
184
|
- lib/alephant/renderer/engines/mustache.rb
|
185
185
|
- lib/alephant/renderer/version.rb
|
186
|
+
- lib/alephant/views.rb
|
187
|
+
- lib/alephant/views/base.rb
|
186
188
|
- spec/fixtures/components/foo/models/foo.rb
|
187
189
|
- spec/fixtures/components/foo/templates/bar.mustache
|
188
190
|
- spec/fixtures/components/foo/templates/foo.mustache
|