kisko-suits 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kisko-suits.rb +1 -1
- data/lib/kisko-suits/application.rb +14 -7
- data/lib/kisko-suits/compiler.rb +30 -18
- data/lib/kisko-suits/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bca5121f773054ddae30e80e7ac5fc600e51dd0b
|
4
|
+
data.tar.gz: 4d663b82ac1b9e51cd51654fa52ee653e9f46150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '069f74c8bc91e15021fcb55abda9aa6af79921e5800f285e5a2b876d9367918dc4c3aa01d82a54d447aae38466a238127451e0cca5d2285ac9111392d6124e17'
|
7
|
+
data.tar.gz: a6b263b27355379ed9a31202ba32104bfd9261e44b5e789badb620125b9b5562436d0105bddcce4a682beda3009c454b969e4cd9ee0371fd7b20e8731080eccc
|
data/lib/kisko-suits.rb
CHANGED
@@ -5,21 +5,17 @@ module KiskoSuits
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def run
|
8
|
-
if
|
8
|
+
if !suits_file_passed?
|
9
9
|
abort "Usage: 'kisko-suits my-presentation.md.suits'\n\nOr start watching file with: 'kisko-suits -w my-presentation.md.suits'"
|
10
10
|
else
|
11
11
|
if @params[:watch]
|
12
12
|
on_update = ->(filename) {
|
13
|
-
compiler =
|
14
|
-
compiler.render
|
15
|
-
puts "Processed files and compiled '#{compiler.output_filename}'"
|
13
|
+
compiler = compile_and_render
|
16
14
|
compiler.included_filenames
|
17
15
|
}
|
18
16
|
KiskoSuits::Watcher.new(@files.first, on_update).start
|
19
17
|
else
|
20
|
-
|
21
|
-
compiler.render
|
22
|
-
puts "Processed files and compiled '#{compiler.output_filename}'"
|
18
|
+
compile_and_render
|
23
19
|
end
|
24
20
|
end
|
25
21
|
end
|
@@ -33,5 +29,16 @@ module KiskoSuits
|
|
33
29
|
|
34
30
|
[params, files]
|
35
31
|
end
|
32
|
+
|
33
|
+
def suits_file_passed?
|
34
|
+
@files.size == 1 && @files.first.include?(".suits")
|
35
|
+
end
|
36
|
+
|
37
|
+
def compile_and_render
|
38
|
+
compiler = KiskoSuits::Compiler.new(@files.first)
|
39
|
+
compiler.render
|
40
|
+
puts "Processed files and compiled '#{compiler.output_filename}'"
|
41
|
+
compiler
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
data/lib/kisko-suits/compiler.rb
CHANGED
@@ -32,27 +32,12 @@ module KiskoSuits
|
|
32
32
|
# It's a comment
|
33
33
|
""
|
34
34
|
elsif line.match(/\s*\$\$\w+\s?=/)
|
35
|
-
|
36
|
-
@variables[variable_name] = variable_value
|
37
|
-
""
|
35
|
+
set_variable(line)
|
38
36
|
elsif match = line.match(/\s*include:\s*([\w\.\/]+)/)
|
39
37
|
included_path = "#{root_dir}/#{match[1]}"
|
40
|
-
|
41
|
-
@included_filenames << included_path
|
42
|
-
|
43
|
-
File.foreach(included_path).map { |included_line|
|
44
|
-
process_line(File.dirname(included_path), included_line)
|
45
|
-
}.join
|
46
|
-
else
|
47
|
-
puts "Include #{included_path} can't be found"
|
48
|
-
""
|
49
|
-
end
|
38
|
+
include_file(included_path)
|
50
39
|
else
|
51
|
-
|
52
|
-
line.gsub!(Regexp.new(Regexp.escape(variable_name)), variable_value)
|
53
|
-
end
|
54
|
-
|
55
|
-
line
|
40
|
+
substitute_variables(line)
|
56
41
|
end
|
57
42
|
end
|
58
43
|
|
@@ -63,5 +48,32 @@ module KiskoSuits
|
|
63
48
|
|
64
49
|
File.open(@output_filename, 'w', &block)
|
65
50
|
end
|
51
|
+
|
52
|
+
def set_variable(line)
|
53
|
+
variable_name, variable_value = line.split("=").map(&:strip)
|
54
|
+
@variables[variable_name] = variable_value
|
55
|
+
""
|
56
|
+
end
|
57
|
+
|
58
|
+
def include_file(included_path)
|
59
|
+
if File.exists?(included_path)
|
60
|
+
@included_filenames << included_path
|
61
|
+
|
62
|
+
File.foreach(included_path).map { |included_line|
|
63
|
+
process_line(File.dirname(included_path), included_line)
|
64
|
+
}.join
|
65
|
+
else
|
66
|
+
puts "Include #{included_path} can't be found"
|
67
|
+
""
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def substitute_variables(line)
|
72
|
+
@variables.each do |variable_name, variable_value|
|
73
|
+
line = line.gsub(Regexp.new(Regexp.escape(variable_name)), variable_value)
|
74
|
+
end
|
75
|
+
|
76
|
+
line
|
77
|
+
end
|
66
78
|
end
|
67
79
|
end
|
data/lib/kisko-suits/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kisko-suits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antti Akonniemi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filewatcher
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|