metatext 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/metatext.rb +16 -6
- 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: 5db5693037bf42eb2e14c7a95992ee8d9f4c88fe
|
|
4
|
+
data.tar.gz: 19c806d439bd60cf42af803c36f7801c025cffa1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 704e05765d73a865821aa7e73b429cb6ddcf673d1f11602c4ae7583d86f7ebf0bec49419d8898d84202d9c16448f098e55dc66b28be867fac3b175b7f9f2e4c4
|
|
7
|
+
data.tar.gz: a3132a73143a2b4681ef46df2b4b176b4d153aa3c8e6d077df1c54366a5a8a94867b99593262dcda0917aeb6bc94c38ee73fb69c87b2abbc9fc02cffb5392c13
|
data/lib/metatext.rb
CHANGED
|
@@ -19,8 +19,9 @@ class Metatext
|
|
|
19
19
|
|
|
20
20
|
# @param dir - path to metatext files
|
|
21
21
|
# @param ext - the file extention (e.g. 'txt', 'md', 'txt.erb')
|
|
22
|
+
# @param processor - any object that responds to `#render`
|
|
22
23
|
|
|
23
|
-
def configure(dir
|
|
24
|
+
def configure(dir: nil, ext: nil, processor: nil)
|
|
24
25
|
@dir = dir
|
|
25
26
|
@ext = ext
|
|
26
27
|
@pro = processor
|
|
@@ -29,9 +30,9 @@ class Metatext
|
|
|
29
30
|
# main driver method for metatext parsing
|
|
30
31
|
# @return self
|
|
31
32
|
|
|
32
|
-
def parse(
|
|
33
|
-
raw = read
|
|
34
|
-
raw = erbify raw, with: locals if
|
|
33
|
+
def parse(to_parse, locals={})
|
|
34
|
+
raw = read(to_parse) || to_parse
|
|
35
|
+
raw = erbify raw, with: locals if parse_as_erb? raw
|
|
35
36
|
yield metadata(raw), render(raw)
|
|
36
37
|
end
|
|
37
38
|
|
|
@@ -40,8 +41,17 @@ class Metatext
|
|
|
40
41
|
# opens and reads the metatext file
|
|
41
42
|
# @param file
|
|
42
43
|
|
|
43
|
-
def read(
|
|
44
|
-
|
|
44
|
+
def read(to_parse)
|
|
45
|
+
if to_parse.is_a? Symbol
|
|
46
|
+
File.read "#{@dir}/#{to_parse.to_s}.#{@ext}"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# run raw content through erb?
|
|
51
|
+
# @param raw
|
|
52
|
+
|
|
53
|
+
def parse_as_erb?(raw)
|
|
54
|
+
(@ext && @ext.include?("erb")) || (@ext.nil? && raw.include?("<%"))
|
|
45
55
|
end
|
|
46
56
|
|
|
47
57
|
# run the file contents through erb
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metatext
|
|
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
|
- John Guest
|
|
@@ -29,7 +29,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
32
|
+
version: 2.0.0
|
|
33
33
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
34
|
requirements:
|
|
35
35
|
- - ">="
|