opulent 0.0.8
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 +7 -0
- data/lib/opulent.rb +77 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a157e5d1656574b3e10e7be95442def3d8492944
|
4
|
+
data.tar.gz: c82f2a8c9cf6bb67776f8f424ceb56346334553c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 805f557356a0d1a07496247844a45eb6aa1df4429d763e83b545b5f79c8ff1a9c838fbe9ce64e4ed1c10ae84a95cd8675b8b4d047bb3db88e684c39c89a8cb39
|
7
|
+
data.tar.gz: 2fd74584d3f2d8839d5b07e18f0c239ac7fcbddfe9df59e01acd7952fc3f94ec30813a2c9cdeee6d73c66d18c76d1427d94e146546d1ec680bdc80c3f4a1e00d
|
data/lib/opulent.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'json'
|
3
|
+
require_relative 'opulent/engine'
|
4
|
+
require_relative 'opulent/logger'
|
5
|
+
require_relative 'opulent/preprocessor'
|
6
|
+
require_relative 'opulent/tokens'
|
7
|
+
require_relative 'opulent/nodes'
|
8
|
+
require_relative 'opulent/parser'
|
9
|
+
|
10
|
+
module Opulent
|
11
|
+
class << self
|
12
|
+
def compile(code = "")
|
13
|
+
# Instantiate required language components
|
14
|
+
@syntax = Parser.parse code
|
15
|
+
|
16
|
+
pp @syntax
|
17
|
+
|
18
|
+
pretty = Proc.new do |elements, indent|
|
19
|
+
if elements.is_a? Nodes::Text
|
20
|
+
puts " " * indent + "text: " + elements.value
|
21
|
+
else
|
22
|
+
elements.each do |element|
|
23
|
+
text = " " * indent + element.name.to_s
|
24
|
+
if element.respond_to? :attributes
|
25
|
+
text += " " + element.attributes.to_s
|
26
|
+
elsif element.respond_to? :value
|
27
|
+
text += " -> " + element.value.to_s
|
28
|
+
end
|
29
|
+
puts text
|
30
|
+
|
31
|
+
if element.is_a?(Nodes::Text) || element.children.empty?
|
32
|
+
elsif [Nodes::CnditionalControl, Nodes::CaseControl].any? do |node| element.is_a? node end
|
33
|
+
element.children.each do |c| pretty[c, indent+2] end
|
34
|
+
else
|
35
|
+
pretty[element.children, indent + 2]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
puts "Definitions\n---"
|
42
|
+
@syntax.themes.each do |theme, theme_value|
|
43
|
+
puts theme.to_s
|
44
|
+
theme_value.each do |key, value|
|
45
|
+
puts " " + key.to_s + " " + value.attributes.to_s
|
46
|
+
pretty[value.children, 4]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
puts "\n\nNodes\n---"
|
50
|
+
pretty[@syntax.children, 0]
|
51
|
+
|
52
|
+
|
53
|
+
#pp @syntax
|
54
|
+
end
|
55
|
+
|
56
|
+
# Analyze the input code and check for matching tokens. In case no match was
|
57
|
+
# found, throw an exception. In special cases, modify the token hash.
|
58
|
+
#
|
59
|
+
# @param file [String] The file that needs to be analyzed
|
60
|
+
# @param context [Hash | String] Processing environment data
|
61
|
+
#
|
62
|
+
def render(file, context = {})
|
63
|
+
@file = file
|
64
|
+
|
65
|
+
# Accept both ruby hashes and JSON files as database environments
|
66
|
+
case context
|
67
|
+
when Hash
|
68
|
+
@context = context
|
69
|
+
when String
|
70
|
+
@context = JSON.parse(File.read context)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Run all the processors
|
74
|
+
compile PreProcessor.process @file
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opulent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Grozav
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: "!!UNDER DEVELOPMENT!! - Intelligent HTML Templating System"
|
14
|
+
email: alex@grozav.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/opulent.rb
|
20
|
+
homepage: http://opulent.io
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Opulent
|
44
|
+
test_files: []
|