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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4fd97409139665070cff877915e10c5d97e1ed7
4
- data.tar.gz: acc3084e5e29a671813f3106b10d21098ab50586
3
+ metadata.gz: 6145f10012de3dabfe234787f636e5a8b011ad5e
4
+ data.tar.gz: ecdf7211609f469e812feb7cc856b0228a8af42c
5
5
  SHA512:
6
- metadata.gz: 5a84dcc2fd08f92934168e4bac6bfdb363c45f3e12dee8038cad5563460bb7cf19664662c4faf12463fa78ae74363a369df3c1f406a3ef979d44ef77b5845719
7
- data.tar.gz: 9d455aab4499a6f16b127f5b947d49f59d89bb932a8ae3cde4491fef330dbf0056381d441b4fed0db1a78a9680f80aee54150845c0ea9c02e4f98295c013655a
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
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Preview
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,3 +1,6 @@
1
+ lib = File.expand_path('../..', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
1
4
  require "alephant/preview/version"
2
5
  require "alephant/preview/server"
3
6
  require "alephant/preview/template"
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.1
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-18 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