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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c5b29eb5647e658be6491f5492f46a9cc60ff46
4
- data.tar.gz: 6be918b1ccb06ab5f1a6f5c4fdc5108630ba431b
3
+ metadata.gz: e10f2ccda58347efd0066e188a2476184a678d7b
4
+ data.tar.gz: 381928cd451908ffa930066a001356c19f492c57
5
5
  SHA512:
6
- metadata.gz: bdd7bdfdf6e890332e0ab835f560ce46b5c117d039f4bedb1844623aaeecf0d4d8f5b6163ad64f61d19e1549d22c0f0b25c05bb19a23965b110ec47b809c4dd8
7
- data.tar.gz: 259c686de1aa335e88d8442b91c27ec3d6a99db24f34ed39efe6380ed46d97d75f139853215bcd1e2205309c6bd16c2b6832abdc06cd80a35200b3de1e9bf4d3
6
+ metadata.gz: c0415a201d03b777715029ed77a0aafdf1a34c8689b0bf6e66615e07568dc42ad0c247f9da11bc1a0433e387de14a02f8a195c485e58168db838919dfcd4a23d
7
+ data.tar.gz: ab1c19eafdaeccd8a94a53c196855827751c55f1c8ceca01139b0713c56c09e070c9ad799c83a4c713c1cdd7b218077a073fa8240136ee2cba5c3a73809d73dd
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Renderer
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -3,10 +3,9 @@ require 'alephant/renderer/engines/mustache'
3
3
 
4
4
  module Alephant
5
5
  module Renderer
6
-
7
6
  def self.create(*args)
8
7
  Mustache.new(*args)
9
8
  end
10
-
11
9
  end
12
10
  end
11
+
@@ -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.2
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-13 00:00:00.000000000 Z
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