schizm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/schizm/chunk.rb +129 -101
- data/lib/schizm/env.rb +49 -14
- data/lib/schizm/env_colors.rb +28 -0
- data/lib/schizm/markup.rb +152 -120
- data/lib/schizm/match.rb +45 -0
- data/lib/schizm/parse.rb +350 -344
- data/lib/schizm/string.rb +179 -150
- data/res/fonts/{fira-code-bold.otf → Fira-Code-Bold.otf} +0 -0
- data/res/fonts/{fira-code-license → Fira-Code-LICENSE} +0 -0
- data/res/fonts/{fira-code-light.otf → Fira-Code-Light.otf} +0 -0
- data/res/fonts/{fira-code-medium.otf → Fira-Code-Medium.otf} +0 -0
- data/res/fonts/{fira-code-regular.otf → Fira-Code-Regular.otf} +0 -0
- data/res/fonts/{fira-code.css → Fira-Code.css} +4 -4
- data/res/fonts/{genericons-neue-license → Genericons-Neue-LICENSE} +0 -0
- data/res/fonts/{genericons-neue.css → Genericons-Neue.css} +0 -0
- data/res/fonts/{genericons-neue.eot → Genericons-Neue.eot} +0 -0
- data/res/fonts/{genericons-neue.ttf → Genericons-Neue.ttf} +0 -0
- data/res/fonts/{genericons-neue.woff2 → Genericons-Neue.woff2} +0 -0
- data/res/fonts/{social-logos-license → Social-Logos-LICENSE} +0 -0
- data/res/fonts/{social-logos.css → Social-Logos.css} +0 -0
- data/res/fonts/{social-logos.eot → Social-Logos.eot} +0 -0
- data/res/fonts/{social-logos.ttf → Social-Logos.ttf} +0 -0
- data/res/fonts/{social-logos.woff2 → Social-Logos.woff2} +0 -0
- data/res/schizm.liquid +4 -4
- data/res/scss/style.scss +1 -1
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec626d76f2d425ade64be899c1784234153fd8ee
|
4
|
+
data.tar.gz: 21b0ae3b7389198d70b078cd6ac9fd757546b1bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fd538deab37751a92026371b5244af68c57489937ff676d1e62f1d97c3c75650850c8f67b4d53262877af923c7996c32f9cab291b4d80e2681dae51627ce9f7
|
7
|
+
data.tar.gz: 6e4e26bbbd82d52a09391856b17e2efc745e10ae6c3afa80a3d92d3dea0db14c59cd4d4345832c1688c5bbb056950073c6a8369ac71ce288d107a2fc3ef1a807
|
data/lib/schizm/chunk.rb
CHANGED
@@ -1,130 +1,158 @@
|
|
1
|
+
# Copyright (c) 2017 M. Grady Saunders
|
2
|
+
#
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
4
|
+
# modification, are permitted provided that the following conditions
|
5
|
+
# are met:
|
6
|
+
#
|
7
|
+
# 1. Redistributions of source code must retain the above
|
8
|
+
# copyright notice, this list of conditions and the following
|
9
|
+
# disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above
|
12
|
+
# copyright notice, this list of conditions and the following
|
13
|
+
# disclaimer in the documentation and/or other materials
|
14
|
+
# provided with the distribution.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
20
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
24
|
+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
1
28
|
require_relative 'env'
|
2
29
|
require_relative 'string'
|
3
30
|
require_relative 'match'
|
4
31
|
|
5
32
|
module Schizm
|
6
33
|
|
7
|
-
|
34
|
+
# Structure to resolve chunks of source code.
|
35
|
+
class Chunk
|
8
36
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
37
|
+
def initialize where, label
|
38
|
+
@where = String.new where
|
39
|
+
@label = String.new label
|
40
|
+
@share = Env.var[:share] if Env.var? :share
|
41
|
+
@target = nil
|
42
|
+
@blocks = Array.new
|
43
|
+
@labels = Array.new
|
44
|
+
@params = Hash.new
|
45
|
+
end
|
18
46
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# Boolean reader for +@share+.
|
26
|
-
def share?
|
27
|
-
case
|
28
|
-
when (@share == true) then return true
|
29
|
-
when (@share != true) then return false
|
30
|
-
end
|
31
|
-
end
|
47
|
+
attr_reader :where
|
48
|
+
attr_reader :label
|
49
|
+
attr_accessor :share
|
50
|
+
attr_accessor :target
|
51
|
+
attr_accessor :blocks
|
32
52
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
53
|
+
# Boolean reader for +@share+.
|
54
|
+
def share?
|
55
|
+
case
|
56
|
+
when (@share == true) then return true
|
57
|
+
when (@share != true) then return false
|
38
58
|
end
|
59
|
+
end
|
39
60
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
61
|
+
# Boolean reader for +@target+.
|
62
|
+
def target?
|
63
|
+
return false unless @target.is_a? ::String
|
64
|
+
return false unless @target != ""
|
65
|
+
return true
|
66
|
+
end
|
48
67
|
|
49
|
-
|
50
|
-
|
51
|
-
|
68
|
+
# Hash organizing active chunks by +@where+ and +@label+.
|
69
|
+
@@hash =
|
70
|
+
Hash.new do |hash, where|
|
71
|
+
hash[where] =
|
72
|
+
Hash.new do |hash, label|
|
73
|
+
hash[label] = Chunk.new where, label
|
74
|
+
end
|
52
75
|
end
|
53
76
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
77
|
+
# Hash reader.
|
78
|
+
def self.hash
|
79
|
+
@@hash
|
80
|
+
end
|
81
|
+
|
82
|
+
# Hash iteration interface.
|
83
|
+
def self.each
|
84
|
+
@@hash.each do |where, hash|
|
85
|
+
hash.each do |label, chunk|
|
86
|
+
yield chunk
|
60
87
|
end
|
61
88
|
end
|
89
|
+
end
|
62
90
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
91
|
+
# Push a code block.
|
92
|
+
def push block, label = nil
|
93
|
+
block = String.new block
|
94
|
+
label = String.new label if label
|
95
|
+
@blocks.push block
|
96
|
+
@labels.push label
|
97
|
+
end
|
70
98
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
99
|
+
# Find a chunk relative to +self+. That is, consider only
|
100
|
+
# chunks defined in the same file, plus chunks shared with the
|
101
|
+
# entire project.
|
102
|
+
def find label
|
103
|
+
Chunk.each do |chunk|
|
104
|
+
if chunk.label == label and
|
105
|
+
(chunk.where == @where or chunk.share?)
|
106
|
+
return chunk
|
80
107
|
end
|
81
|
-
nil
|
82
108
|
end
|
109
|
+
nil
|
110
|
+
end
|
83
111
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
112
|
+
# Resolve chunk references to generate the final source string.
|
113
|
+
def to_s *trace
|
114
|
+
if trace.include? @label
|
115
|
+
raise "Infinite recursion!"
|
116
|
+
end
|
117
|
+
total = String.new(@blocks.join "\n")
|
118
|
+
total.trim!
|
119
|
+
while true
|
120
|
+
unless (total.sub! CHUNK_LABEL do
|
121
|
+
if (chunk = find $1)
|
122
|
+
replace = chunk.to_s *trace, @label
|
123
|
+
replace.gsub /(?<=\n)/, " " * String.new($`).find_indent
|
124
|
+
else
|
125
|
+
"/* " + $1 + " ... */"
|
126
|
+
end
|
127
|
+
end)
|
128
|
+
break
|
88
129
|
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
else
|
97
|
-
"/* " + $1 + " ... */"
|
98
|
-
end
|
99
|
-
end)
|
100
|
-
break
|
130
|
+
end
|
131
|
+
if target?
|
132
|
+
if Env.var? :guard and @target =~ HEADER_PATH
|
133
|
+
guardify = String.new(@target).guardify
|
134
|
+
if Env.var? :title
|
135
|
+
guardify.prepend "_"
|
136
|
+
guardify.prepend String.new(Env.var[:title]).guardify
|
101
137
|
end
|
138
|
+
total.prepend "\#define #{guardify}\n\n"
|
139
|
+
total.prepend "\#ifndef #{guardify}\n"
|
140
|
+
total.concat "\n\n"
|
141
|
+
total.concat "\#endif /* \#ifndef #{guardify} */"
|
102
142
|
end
|
103
|
-
if
|
104
|
-
|
105
|
-
|
106
|
-
if Env.var? :title
|
107
|
-
guardify.prepend "_"
|
108
|
-
guardify.prepend String.new(Env.var[:title]).guardify
|
109
|
-
end
|
110
|
-
total.prepend "\#define #{guardify}\n\n"
|
111
|
-
total.prepend "\#ifndef #{guardify}\n"
|
112
|
-
total.concat "\n\n"
|
113
|
-
total.concat "\#endif /* \#ifndef #{guardify} */"
|
114
|
-
end
|
115
|
-
if File.file? "LICENSE"
|
116
|
-
total.prepend "\n"
|
117
|
-
total.prepend String.new(File.read("LICENSE")).comment
|
118
|
-
end
|
143
|
+
if File.file? "LICENSE"
|
144
|
+
total.prepend "\n"
|
145
|
+
total.prepend String.new(File.read("LICENSE")).comment
|
119
146
|
end
|
120
|
-
total
|
121
|
-
end
|
122
|
-
|
123
|
-
# Identifier for a particular block.
|
124
|
-
def id block = @blocks.size
|
125
|
-
"#{@label.slugify}-#{block}"
|
126
147
|
end
|
148
|
+
total
|
149
|
+
end
|
127
150
|
|
151
|
+
# Identifier for +block+.
|
152
|
+
def id block = @blocks.size
|
153
|
+
String.new "#{@label.slugify}-#{block}"
|
128
154
|
end
|
129
155
|
|
130
|
-
end
|
156
|
+
end # class Chunk
|
157
|
+
|
158
|
+
end # module Schizm
|
data/lib/schizm/env.rb
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
# Copyright (c) 2017 M. Grady Saunders
|
2
|
+
#
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
4
|
+
# modification, are permitted provided that the following conditions
|
5
|
+
# are met:
|
6
|
+
#
|
7
|
+
# 1. Redistributions of source code must retain the above
|
8
|
+
# copyright notice, this list of conditions and the following
|
9
|
+
# disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above
|
12
|
+
# copyright notice, this list of conditions and the following
|
13
|
+
# disclaimer in the documentation and/or other materials
|
14
|
+
# provided with the distribution.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
20
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
24
|
+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
1
28
|
require 'etc'
|
2
29
|
require 'optparse'
|
3
30
|
require 'pathname'
|
@@ -9,19 +36,22 @@ module Schizm
|
|
9
36
|
|
10
37
|
module Env
|
11
38
|
|
39
|
+
# Global variable hash.
|
12
40
|
@@var = {}
|
13
41
|
|
42
|
+
# Global variable hash getter.
|
14
43
|
def self.var
|
15
44
|
return @@var
|
16
45
|
end
|
17
46
|
|
47
|
+
# +true+ if +@@var[key]+ is neither +nil+ nor +false+.
|
18
48
|
def self.var? key
|
19
49
|
return true if @@var.has_key?(key) and
|
20
50
|
@@var[key] != nil and @@var[key] != false
|
21
51
|
return false
|
22
52
|
end
|
23
53
|
|
24
|
-
# Prompt yes/no question.
|
54
|
+
# Prompt the user with a yes/no question.
|
25
55
|
def self.yes? string, backup
|
26
56
|
backup = backup.downcase[0]
|
27
57
|
print "#{string} [Y/n] " if backup == "y"
|
@@ -31,6 +61,8 @@ module Env
|
|
31
61
|
return backup == "y"
|
32
62
|
end
|
33
63
|
|
64
|
+
# Write +string+ to +target+. If +target+ is an existing file and
|
65
|
+
# +var[:rewrite]+ is not set, prompts the user for permission to rewrite.
|
34
66
|
def self.write target, string
|
35
67
|
if (not File.file? target or
|
36
68
|
var? :rewrite or
|
@@ -179,19 +211,22 @@ YAMLCONFIG
|
|
179
211
|
assets = {
|
180
212
|
"schizm.liquid" => "docs/_layouts",
|
181
213
|
"schizm.js" => "docs/assets/js",
|
182
|
-
"fonts/
|
183
|
-
"fonts/
|
184
|
-
"fonts/
|
185
|
-
"fonts/
|
186
|
-
"fonts/
|
187
|
-
"fonts/
|
188
|
-
"fonts/
|
189
|
-
"fonts/
|
190
|
-
"fonts/
|
191
|
-
"fonts/
|
192
|
-
"fonts/
|
193
|
-
"fonts/
|
194
|
-
"fonts/
|
214
|
+
"fonts/Fira-Code.css" => "docs/assets/fonts",
|
215
|
+
"fonts/Fira-Code-Light.otf" => "docs/assets/fonts",
|
216
|
+
"fonts/Fira-Code-Regular.otf" => "docs/assets/fonts",
|
217
|
+
"fonts/Fira-Code-Medium.otf" => "docs/assets/fonts",
|
218
|
+
"fonts/Fira-Code-Bold.otf" => "docs/assets/fonts",
|
219
|
+
"fonts/Fira-Code-LICENSE" => "docs/assets/fonts",
|
220
|
+
"fonts/Genericons-Neue.css" => "docs/assets/fonts",
|
221
|
+
"fonts/Genericons-Neue.eot" => "docs/assets/fonts",
|
222
|
+
"fonts/Genericons-Neue.ttf" => "docs/assets/fonts",
|
223
|
+
"fonts/Genericons-Neue.woff2" => "docs/assets/fonts",
|
224
|
+
"fonts/Genericons-Neue-LICENSE" => "docs/assets/fonts",
|
225
|
+
"fonts/Social-Logos.css" => "docs/assets/fonts",
|
226
|
+
"fonts/Social-Logos.eot" => "docs/assets/fonts",
|
227
|
+
"fonts/Social-Logos.ttf" => "docs/assets/fonts",
|
228
|
+
"fonts/Social-Logos.woff2" => "docs/assets/fonts",
|
229
|
+
"fonts/Social-Logos-LICENSE" => "docs/assets/fonts"
|
195
230
|
}
|
196
231
|
assets.each do |from, to|
|
197
232
|
write File.join(to, File.basename(from)), resource(from)
|
data/lib/schizm/env_colors.rb
CHANGED
@@ -1,7 +1,35 @@
|
|
1
|
+
# Copyright (c) 2017 M. Grady Saunders
|
2
|
+
#
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
4
|
+
# modification, are permitted provided that the following conditions
|
5
|
+
# are met:
|
6
|
+
#
|
7
|
+
# 1. Redistributions of source code must retain the above
|
8
|
+
# copyright notice, this list of conditions and the following
|
9
|
+
# disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above
|
12
|
+
# copyright notice, this list of conditions and the following
|
13
|
+
# disclaimer in the documentation and/or other materials
|
14
|
+
# provided with the distribution.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
20
|
+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
24
|
+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
1
28
|
module Schizm
|
2
29
|
|
3
30
|
module Env
|
4
31
|
|
32
|
+
# https://material.io/guidelines/style/color.html
|
5
33
|
COLORS = {
|
6
34
|
'red' => {
|
7
35
|
'50' => ['#FFEBEE', '#222222'],
|