alephant-preview 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alephant/preview/template/base.rb +47 -0
- data/lib/alephant/preview/version.rb +1 -1
- data/lib/alephant/preview.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6145f10012de3dabfe234787f636e5a8b011ad5e
|
4
|
+
data.tar.gz: ecdf7211609f469e812feb7cc856b0228a8af42c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ebf87172b14488e9fe2081077234dc78d72d11c4170ad48a174ae220ee8af3f8a4d1dd40737d75c0af0a37b2d2f79f937d5d01d79c7e87d9b61d87db00a6f6b
|
7
|
+
data.tar.gz: 54719f3ceb52daa9db26cbfd9ea4358ad89434bb7a13a0f26923449db3692ede5435e56a41cd3b150e2bb7bdb036ac43bc201a5d638b1f8a6a4aa944f14b5029
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'mustache'
|
2
|
+
|
3
|
+
module Alephant
|
4
|
+
module Preview
|
5
|
+
module Template
|
6
|
+
|
7
|
+
class Base < Mustache
|
8
|
+
attr_accessor :regions
|
9
|
+
|
10
|
+
def initialize(regions, template_location)
|
11
|
+
@regions=regions
|
12
|
+
self.template_file = template_location
|
13
|
+
end
|
14
|
+
|
15
|
+
def static_host
|
16
|
+
ENV['STATIC_HOST'] || 'localhost:8000'
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing(name, *args, &block)
|
20
|
+
return super unless respond_to? name.to_s
|
21
|
+
region @regions[name.to_s]
|
22
|
+
end
|
23
|
+
|
24
|
+
def respond_to?(method)
|
25
|
+
valid_regions.include? method.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
def region(components)
|
29
|
+
if components.kind_of?(Array)
|
30
|
+
components.join
|
31
|
+
else
|
32
|
+
components
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid_regions
|
37
|
+
self.template.tokens.find_all { |token|
|
38
|
+
token.is_a?(Array) && token[0] == :mustache
|
39
|
+
}.map{ |token|
|
40
|
+
token[2][2][0].to_s
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/alephant/preview.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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
|