slight-lang 1.2.1.1 → 1.2.1.2
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/example/default_engine.rb +22 -4
- data/lib/slight.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce6c30afb54f39ed3a25b57b0f1f6a4324519c7f
|
4
|
+
data.tar.gz: 22949fd745f1a648590bdc9a908e58686917c464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e12f88ea9848dbe64e9fb3373b802155405cbc542367b76b4d8902193b8d861a87a70cb968f138eca8ebb12bd3cef9078aad607ef30f9fc57a8c266c73c5c5d
|
7
|
+
data.tar.gz: ce78e3875eb91781358350cc2dbe38e36f2f707970175cbd86a599337f1c426ca0d7bbbbe5da3b58c046bcb215c70bf4a3858f97542177af25212393265486d0
|
data/example/default_engine.rb
CHANGED
@@ -4,25 +4,43 @@ require 'slight'
|
|
4
4
|
module Slight
|
5
5
|
default_engine = Slight::Engine.new
|
6
6
|
io_out = STDOUT
|
7
|
+
buffer = ""
|
7
8
|
|
8
9
|
at_exit{
|
9
10
|
io_out.close
|
10
11
|
}
|
11
12
|
|
12
13
|
begin
|
13
|
-
if ARGV[0] == "-
|
14
|
+
if ARGV[0] == "-h" then
|
15
|
+
io_out.puts "Commands: build | <source_fn> (<dest_fn>) | -v | -h"
|
16
|
+
elsif ARGV[0] == "-v" then
|
14
17
|
io_out.puts VERSION
|
18
|
+
elsif ARGV[0] == "build" then
|
19
|
+
path = File.expand_path(".", __FILE__)
|
20
|
+
Dir.entries(File.dirname(path)).map { |e|
|
21
|
+
["slight", "slight.rb"].include? e.split["."][1]
|
22
|
+
}.each{ |src_file|
|
23
|
+
buffer << default_engine.render(src_file)
|
24
|
+
if buffer != nil and buffer != "" then
|
25
|
+
fn = ARGV[1] || src_file.split(".")[0] << ".htm"
|
26
|
+
io_out.puts "Source File [#{src_file}] => Dest File [#{fn}]"
|
27
|
+
io_out = File.open("#{fn}", 'w') if ARGV.size == 2
|
28
|
+
io_out.puts buffer
|
29
|
+
buffer.clear
|
30
|
+
end
|
31
|
+
}
|
15
32
|
else
|
16
33
|
raise IOError, "source file was not given." if ARGV.length == 0
|
17
34
|
src_file = ARGV[0]
|
18
|
-
buffer
|
35
|
+
buffer << default_engine.render(src_file)
|
19
36
|
if buffer != nil and buffer != "" then
|
20
|
-
|
37
|
+
fn = ARGV[1] || src_file.split(".")[0] << ".htm"
|
38
|
+
io_out = File.open("#{fn}", 'w') if ARGV.size == 2
|
21
39
|
io_out.puts buffer
|
22
40
|
end
|
23
41
|
end
|
24
42
|
rescue Exception => err
|
25
|
-
STDERR.puts "[Slight]" + err.message
|
43
|
+
STDERR.puts "[Slight] " + err.message
|
26
44
|
#STDERR.puts [err.inspect, err.backtrace.join("\n")].join("\n")
|
27
45
|
exit 1
|
28
46
|
end
|
data/lib/slight.rb
CHANGED