sept 1.4.2 → 1.5.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 +84 -23
- data/lib/sept.rb +23 -4
- 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: cb79f409d649578f3eaf43a0457b76be9fcc45e2
|
|
4
|
+
data.tar.gz: 6ef51f7d67148c2b04954bcded05fcb7ea437b5a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 483db3e80c2f9c9a90e819162fa7f12b525c9f70342dba981ce1c926f4da246efbe2e7df1c29ba63080a9096a9124d8b9cd0fcfdda273e2b0d87254eb090bf2a
|
|
7
|
+
data.tar.gz: 2c967602266c7dfdf0eb711a7a3de35bd38b2b680d33b218c1a2b15df02b5b92dd780ba1a7643a927392f0ad0087ab4137c5acb38ca23dd152f3b1073b944e5b
|
data/bin/sept
CHANGED
|
@@ -15,11 +15,9 @@ DESCRIPTION
|
|
|
15
15
|
(p Hello) -> <p>Hello</p>
|
|
16
16
|
(div (p Hello) (br)) -> <div><p>Hello</p><br></div>
|
|
17
17
|
|
|
18
|
-
If a string contains spaces, it must be surrounded by quotes.
|
|
19
|
-
|
|
20
|
-
are supported, I think. For example:
|
|
18
|
+
If a string contains spaces, it must be surrounded by double quotes. C-style
|
|
19
|
+
escape sequences are supported, I think. For example:
|
|
21
20
|
(title "Demo page") -> <title>Demo page</title>
|
|
22
|
-
(title 'Demo page') -> <title>Demo page</title>
|
|
23
21
|
(title "\"Demo page") -> <title>"Demo page</title>
|
|
24
22
|
(title Demo page) -> <title>Demopage</title>
|
|
25
23
|
|
|
@@ -36,17 +34,39 @@ DESCRIPTION
|
|
|
36
34
|
(p.the#best "This is best") -> <p class="the" id="best">This is best</p>
|
|
37
35
|
(p.one.two Hey) -> <p class="one two">Hey</p>
|
|
38
36
|
|
|
37
|
+
Be careful that program does not include `<!doctype html>` by default. To
|
|
38
|
+
turn this feature on, you need to pass `-dt` argument. If you want to use a
|
|
39
|
+
different doctype, use `--doctype <doctype>` argument. For example:
|
|
40
|
+
$ cat page.septh
|
|
41
|
+
(html
|
|
42
|
+
(body
|
|
43
|
+
(h1 hi)))
|
|
44
|
+
$ sept page.septh
|
|
45
|
+
page.html will be made:
|
|
46
|
+
<html><body><h1>hi</hi></body></html>
|
|
47
|
+
$ sept -dt page.septh
|
|
48
|
+
<!doctype html><html><body><h1>hi</h1></body></html>
|
|
49
|
+
$ sept --doctype 'You can pass anything here' page.septh
|
|
50
|
+
You can pass anything here<html><body><h1>hi</h1></body></html>
|
|
51
|
+
|
|
39
52
|
CLI UTILITY
|
|
53
|
+
In a nusthell:
|
|
54
|
+
sept -h
|
|
55
|
+
sept -v
|
|
56
|
+
sept [-nx] [-dt|-cdt <doctype>] [-d <data>|-f <file>] <files>
|
|
57
|
+
Others forms should not work. If they work, something is wrong or you have
|
|
58
|
+
found an easter egg
|
|
59
|
+
|
|
40
60
|
After installing `sept` gem, `sept` utility is installed too. This section
|
|
41
61
|
covers it. Several arguments are understood by the program:
|
|
42
62
|
|
|
43
|
-
sept -v
|
|
63
|
+
sept -v
|
|
44
64
|
Prints version and exits.
|
|
45
65
|
|
|
46
|
-
sept -h
|
|
66
|
+
sept -h
|
|
47
67
|
Prints this message and exits.
|
|
48
68
|
|
|
49
|
-
sept -d <data>
|
|
69
|
+
sept -d <data>
|
|
50
70
|
You pass JSON hash to <data> for parser to use as parameters. You can
|
|
51
71
|
read more about parameters in the section above. <files> are filenames of
|
|
52
72
|
files, they must have one of extensions supported by Sept. For example:
|
|
@@ -54,7 +74,7 @@ CLI UTILITY
|
|
|
54
74
|
`bio.smith` will be parsed and saved in `bio.html`, `not_bio` will be
|
|
55
75
|
ignored and error message will be printed.
|
|
56
76
|
|
|
57
|
-
sept -f <json file>
|
|
77
|
+
sept -f <json file>
|
|
58
78
|
Same as above, but instead of JSON hash, you pass name of the file with
|
|
59
79
|
JSON hash. For example:
|
|
60
80
|
$ cat data
|
|
@@ -66,18 +86,66 @@ CLI UTILITY
|
|
|
66
86
|
sept <files>
|
|
67
87
|
Same as above, but no parameters are passed. If any of the files you
|
|
68
88
|
passed needs it, error message will be printed and the program will stop.
|
|
89
|
+
|
|
90
|
+
sept -dt <files>
|
|
91
|
+
Use default doctype: `<!doctype html>` with every file you pass.
|
|
92
|
+
|
|
93
|
+
sept -cdt <doctype>
|
|
94
|
+
Same as above, but you specify the doctype by yourself.
|
|
95
|
+
|
|
96
|
+
sept -nx <files>
|
|
97
|
+
Output files will not have `.html` extension.
|
|
69
98
|
END
|
|
70
99
|
def validate_list_of_files(list_of_files)
|
|
71
100
|
correct_ones = []
|
|
72
101
|
list_of_files.each do |file|
|
|
73
|
-
if %w(.septh .septc).include? file
|
|
74
|
-
correct_ones
|
|
102
|
+
if %w(.septh .septc).include? File.extname file
|
|
103
|
+
correct_ones.push file
|
|
75
104
|
else
|
|
76
105
|
puts "ERROR #{file} is not a Sept file. Use `.septh` or `.septc`".red
|
|
77
106
|
end
|
|
78
107
|
end
|
|
108
|
+
|
|
109
|
+
correct_ones
|
|
79
110
|
end
|
|
80
111
|
|
|
112
|
+
def parse_arguments
|
|
113
|
+
args = [{}, [], '', true] # params files_to_parse doctype must_use_extension
|
|
114
|
+
|
|
115
|
+
if ARGV.include? '-nx'
|
|
116
|
+
puts "Output files will have no extension".light_blue
|
|
117
|
+
args[3] = false
|
|
118
|
+
ARGV.delete '-nx'
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if ARGV.include? '-dt'
|
|
122
|
+
args[2] = '<!doctype html>'
|
|
123
|
+
ARGV.delete '-dt'
|
|
124
|
+
puts "`<!doctype html>` will be used as doctype".light_blue
|
|
125
|
+
elsif ARGV[0] == '-cdt'
|
|
126
|
+
args[2] = ARGV[1]
|
|
127
|
+
puts "`#{args[2]}` will be used as doctype".light_blue
|
|
128
|
+
ARGV.shift 2
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
case ARGV[0]
|
|
132
|
+
when '-d', '--data'
|
|
133
|
+
puts "Passed data as argument".light_blue
|
|
134
|
+
args[0] = JSON.parse ARGV[1]
|
|
135
|
+
args[1] = validate_list_of_files ARGV[2..-1]
|
|
136
|
+
when '-f', '--file'
|
|
137
|
+
puts "Passed data as file".light_blue
|
|
138
|
+
args[0] = JSON.parse File.read ARGV[1]
|
|
139
|
+
args[1] = validate_list_of_files ARGV[2..-1]
|
|
140
|
+
else
|
|
141
|
+
puts "No passed data".light_blue
|
|
142
|
+
args[1] = validate_list_of_files ARGV
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
args
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
args = []
|
|
81
149
|
if ARGV.length == 0
|
|
82
150
|
puts "ERROR No arguments passed!".red
|
|
83
151
|
exit 1
|
|
@@ -85,22 +153,15 @@ else
|
|
|
85
153
|
case ARGV[0]
|
|
86
154
|
when '-h', '--help' # help
|
|
87
155
|
puts HELP_MESSAGE
|
|
156
|
+
exit
|
|
88
157
|
when '-v', '--version'
|
|
89
158
|
# TODO: fetch version from sept.gemspec automatically
|
|
90
|
-
puts "SEPT HTML version 1.
|
|
91
|
-
|
|
92
|
-
puts "Passed data as argument".light_blue
|
|
93
|
-
params = JSON.parse ARGV[1]
|
|
94
|
-
list_of_files = validate_list_of_files ARGV[2..-1]
|
|
95
|
-
when '-f', '--file'
|
|
96
|
-
puts "Passed data as file".light_blue
|
|
97
|
-
params = JSON.parse File.read ARGV[1]
|
|
98
|
-
list_of_files = validate_list_of_files ARGV[2..-1]
|
|
159
|
+
puts "SEPT HTML version 1.5.0"
|
|
160
|
+
exit
|
|
99
161
|
else
|
|
100
|
-
|
|
101
|
-
params = {}
|
|
102
|
-
list_of_files = validate_list_of_files ARGV
|
|
162
|
+
args = parse_arguments
|
|
103
163
|
end
|
|
104
164
|
end
|
|
165
|
+
puts args
|
|
105
166
|
|
|
106
|
-
sept = Sept.new(
|
|
167
|
+
sept = Sept.new(args[0], args[1], args[2], args[3])
|
data/lib/sept.rb
CHANGED
|
@@ -27,9 +27,12 @@ class Sept
|
|
|
27
27
|
#
|
|
28
28
|
# @param params [Hash] Hash with parameters.
|
|
29
29
|
# @params files_to_parse [Array] List of files program will try to parse
|
|
30
|
-
def initialize(params, files_to_parse)
|
|
30
|
+
def initialize(params, files_to_parse, doctype, must_use_extension)
|
|
31
31
|
@params = params
|
|
32
|
+
@doctype = doctype
|
|
33
|
+
@must_use_extension = must_use_extension
|
|
32
34
|
@html = ''
|
|
35
|
+
puts "@params: #{params}\n@doctype: #{@doctype}\n@must_use_extension: #{must_use_extension}\nfiles_to_parse: #{files_to_parse}"
|
|
33
36
|
|
|
34
37
|
files_to_parse.each { |f| self.cook f }
|
|
35
38
|
end
|
|
@@ -39,19 +42,19 @@ class Sept
|
|
|
39
42
|
# @param file [String] Sept file
|
|
40
43
|
# @return [String] HTML file
|
|
41
44
|
def generate(file)
|
|
42
|
-
self.to_html
|
|
45
|
+
self.to_html Sept.prepare SXP.read file % @params
|
|
43
46
|
end
|
|
44
47
|
|
|
45
48
|
# Function that 'cooks' passed file. It logs some info. The name is bad
|
|
46
49
|
#
|
|
47
50
|
# @param filename [String] Name of file to 'cook'
|
|
48
51
|
def cook(filename)
|
|
49
|
-
@html =
|
|
52
|
+
@html = @doctype
|
|
50
53
|
|
|
51
54
|
file = File.read filename
|
|
52
55
|
puts "Got #{filename}:\n#{file}"
|
|
53
56
|
|
|
54
|
-
filename = filename
|
|
57
|
+
filename = self.make_name filename
|
|
55
58
|
file = self.generate file
|
|
56
59
|
|
|
57
60
|
# Create file if it does not exist yet
|
|
@@ -73,6 +76,22 @@ class Sept
|
|
|
73
76
|
end
|
|
74
77
|
end
|
|
75
78
|
|
|
79
|
+
# Function to make correct filename
|
|
80
|
+
#
|
|
81
|
+
# @param [String] Filename
|
|
82
|
+
# @return [String] New filename
|
|
83
|
+
def make_name(filename)
|
|
84
|
+
if @must_use_extension
|
|
85
|
+
if File.extname(filename) == '.septh'
|
|
86
|
+
"#{filename[0..-6]}html"
|
|
87
|
+
else
|
|
88
|
+
"#{filename[0..-6]}css"
|
|
89
|
+
end
|
|
90
|
+
else
|
|
91
|
+
File.basename filename, File.extname(filename)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
76
95
|
# Recursive function that generates HTML string and handles `#include`
|
|
77
96
|
#
|
|
78
97
|
# @param node [Array, String] A Sept node
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sept
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Timur Ismagilov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-10-
|
|
11
|
+
date: 2017-10-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |2
|
|
14
14
|
Write your HTML pages like Lisp code. CLI utility. Run `sept -h` for info
|