sept 1.2.2 → 1.3.0
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/bin/sept +3 -3
- data/lib/sept.rb +21 -20
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 877a538c2d04ccdf7b6bb1835008707e7c51a6ea
|
|
4
|
+
data.tar.gz: 05616b59c02b6cc45282a97143b0c1f1e4c7071b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7e491d390763c0efb8b88950b2234697e110b887bdf80f2a666d9bb9b487e6f8d1dd13c601b5b04a4412578ffa090a2c4c6f7008490936502777ec2338e759d
|
|
7
|
+
data.tar.gz: a1cf48909ed536bc1d4ff23e6f6ef23a3b12679387f4fd3fd9b531113ec54eb3903ff56ee6f858db065c890090ce5476839d14a3547df9747118a910db4f410e
|
data/bin/sept
CHANGED
|
@@ -17,13 +17,13 @@ else
|
|
|
17
17
|
'validation coming soon'
|
|
18
18
|
when "-v" # version
|
|
19
19
|
# TODO: fetch version from sept.gemspec automatically
|
|
20
|
-
puts "SEPT HTML version 1.
|
|
20
|
+
puts "SEPT HTML version 1.3.0"
|
|
21
21
|
when "-d" # data
|
|
22
|
-
# TODO:
|
|
23
|
-
# maybe json?
|
|
22
|
+
# TODO: replace this with json
|
|
24
23
|
puts "Passed data as argument"
|
|
25
24
|
sept = Sept.new(eval(ARGV[1]), ARGV[2..-1])
|
|
26
25
|
when '-f' # file
|
|
26
|
+
# TODO: replace this with json
|
|
27
27
|
puts "Passed data as file"
|
|
28
28
|
sept = Sept.new(eval(File.read ARGV[1]), ARGV[2..-1])
|
|
29
29
|
else
|
data/lib/sept.rb
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
# - https://github.com/bouncepaw/sept
|
|
24
24
|
class Sept
|
|
25
25
|
|
|
26
|
-
# Constructor
|
|
26
|
+
# Constructor. The only method you would need
|
|
27
27
|
#
|
|
28
28
|
# @param params [Hash] Hash with parameters. Keys are symbols, values are strings.
|
|
29
29
|
# @params files_to_parse [Array] List of files program will try to parse
|
|
@@ -34,12 +34,12 @@ class Sept
|
|
|
34
34
|
files_to_parse.each { |f| self.cook f }
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
# Method that
|
|
37
|
+
# Method that chains lots of methods
|
|
38
38
|
#
|
|
39
39
|
# @param file [String] Sept file
|
|
40
40
|
# @return [String] HTML file
|
|
41
41
|
def generate(file)
|
|
42
|
-
self.to_html(self.prepare
|
|
42
|
+
self.to_html(self.prepare SXP.read file) % @params
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# Function that 'cooks' passed file. It logs some info. The name is bad
|
|
@@ -47,13 +47,13 @@ class Sept
|
|
|
47
47
|
# @param filename [String] Name of file to 'cook'
|
|
48
48
|
def cook(filename)
|
|
49
49
|
unless File.extname(filename) == ".sept"
|
|
50
|
-
puts "#{filename} is not `.sept` file, so can't parse it!".red
|
|
50
|
+
puts "ERROR #{filename} is not `.sept` file, so can't parse it!".red
|
|
51
51
|
return
|
|
52
52
|
end
|
|
53
53
|
@html = ''
|
|
54
54
|
|
|
55
55
|
file = File.read filename
|
|
56
|
-
puts "
|
|
56
|
+
puts "Got #{filename}, its content is:\n#{file}"
|
|
57
57
|
|
|
58
58
|
new_filename = filename[0..-6] + ".html"
|
|
59
59
|
new_file = self.generate file
|
|
@@ -61,11 +61,10 @@ class Sept
|
|
|
61
61
|
# Create file if it does not exist yet
|
|
62
62
|
File.new new_filename, 'w+' unless File.file? new_filename
|
|
63
63
|
File.write new_filename, new_file
|
|
64
|
-
puts "
|
|
64
|
+
puts "Parsed #{filename} and saved in #{new_filename}:\n #{new_file}"
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
# Recursive function that turns everything in `node` to a string
|
|
68
|
-
# including of other files (well, will handle)
|
|
67
|
+
# Recursive function that turns everything in `node` to a string
|
|
69
68
|
#
|
|
70
69
|
# @param node [Array, String] A Sept node
|
|
71
70
|
def prepare(node)
|
|
@@ -74,29 +73,31 @@ class Sept
|
|
|
74
73
|
self.prepare sub
|
|
75
74
|
else
|
|
76
75
|
node[i] = sub.to_s
|
|
77
|
-
# TODO: finish this thing
|
|
78
|
-
if node[0] == "#include"
|
|
79
|
-
file = self.generate File.read node[1].to_s
|
|
80
|
-
node.pop until node.length == 0
|
|
81
|
-
node[0] = file
|
|
82
|
-
end
|
|
83
76
|
end
|
|
84
77
|
end
|
|
85
78
|
end
|
|
86
79
|
|
|
87
|
-
# Recursive function that generates HTML string
|
|
80
|
+
# Recursive function that generates HTML string and handles `#include`
|
|
88
81
|
#
|
|
89
82
|
# @param node [Array, String] A Sept node
|
|
90
83
|
# @return [String]
|
|
91
84
|
def to_html(node)
|
|
92
85
|
if node.is_a? Array
|
|
93
|
-
if node.length == 1
|
|
86
|
+
if node.length == 1
|
|
87
|
+
@html << "<#{node[0]}/>"
|
|
94
88
|
else
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
if node[0] == "#include"
|
|
90
|
+
file = self.generate File.read node[1].to_s
|
|
91
|
+
node = []
|
|
92
|
+
node[0] = file
|
|
93
|
+
else
|
|
94
|
+
@html << "<#{node[0]}>"
|
|
95
|
+
node[1..-1].each { |e| self.to_html e }
|
|
96
|
+
@html << "</#{node[0].split(' ')[0]}>"
|
|
97
|
+
end
|
|
98
98
|
end
|
|
99
|
-
else
|
|
99
|
+
else
|
|
100
|
+
@html << node
|
|
100
101
|
end
|
|
101
102
|
|
|
102
103
|
@html
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sept
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Timur Ismagilov
|
|
@@ -10,8 +10,12 @@ bindir: bin
|
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2017-10-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description: Write your HTML pages like Lisp code. Support of included files
|
|
14
|
-
CLI utility provided
|
|
13
|
+
description: " Write your HTML pages like Lisp code. Support of included files,\n
|
|
14
|
+
\ parameters. CLI utility provided.\n\n Example:\n ```\n (html\n (head\n
|
|
15
|
+
\ (title \"Hello world\")\n (style \".class { color: blue }\"))\n (body\n
|
|
16
|
+
\ (\"p class='class'\" \"Note that if a tag has attributes, they are expressed
|
|
17
|
+
this way\")\n (p Cool?)\n (p \"This is %{param}\")))\n ```\n\n\t\tThen
|
|
18
|
+
run:\n\t\t```\n\t\tsept -d '{:param=>\"Parameter\"}' file.sept\n\t\t```\n"
|
|
15
19
|
email: bouncepaw2@ya.ru
|
|
16
20
|
executables:
|
|
17
21
|
- sept
|