frontman-ssg 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +42 -0
- data/.github/CODE_OF_CONDUCT.md +9 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +25 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +22 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +88 -0
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +42 -0
- data/Gemfile +5 -0
- data/LICENSE.md +21 -0
- data/Rakefile +94 -0
- data/SECURITY.md +6 -0
- data/bin/frontman +6 -0
- data/frontman-ssg.gemspec +48 -0
- data/frontman.svg +2 -0
- data/lib/frontman.rb +15 -0
- data/lib/frontman/app.rb +175 -0
- data/lib/frontman/bootstrapper.rb +70 -0
- data/lib/frontman/builder/asset_pipeline.rb +55 -0
- data/lib/frontman/builder/builder.rb +193 -0
- data/lib/frontman/builder/file.rb +55 -0
- data/lib/frontman/builder/mapping.rb +54 -0
- data/lib/frontman/builder/statistics_collector.rb +37 -0
- data/lib/frontman/cli.rb +6 -0
- data/lib/frontman/commands/build.rb +76 -0
- data/lib/frontman/commands/init.rb +58 -0
- data/lib/frontman/commands/serve.rb +110 -0
- data/lib/frontman/concerns/dispatch_events.rb +56 -0
- data/lib/frontman/concerns/forward_calls_to_app.rb +28 -0
- data/lib/frontman/config.rb +52 -0
- data/lib/frontman/context.rb +125 -0
- data/lib/frontman/custom_struct.rb +44 -0
- data/lib/frontman/data_store.rb +106 -0
- data/lib/frontman/data_store_file.rb +60 -0
- data/lib/frontman/helpers/app_helper.rb +18 -0
- data/lib/frontman/helpers/link_helper.rb +35 -0
- data/lib/frontman/helpers/render_helper.rb +76 -0
- data/lib/frontman/helpers/url_helper.rb +11 -0
- data/lib/frontman/iterator.rb +48 -0
- data/lib/frontman/process/chain.rb +43 -0
- data/lib/frontman/process/processor.rb +11 -0
- data/lib/frontman/renderers/erb_renderer.rb +21 -0
- data/lib/frontman/renderers/haml_renderer.rb +22 -0
- data/lib/frontman/renderers/markdown_renderer.rb +26 -0
- data/lib/frontman/renderers/renderer.rb +26 -0
- data/lib/frontman/renderers/renderer_resolver.rb +26 -0
- data/lib/frontman/resource.rb +279 -0
- data/lib/frontman/sitemap_tree.rb +211 -0
- data/lib/frontman/toolbox/timer.rb +49 -0
- data/lib/frontman/version.rb +6 -0
- data/project-templates/default/.gitignore +2 -0
- data/project-templates/default/Gemfile +3 -0
- data/project-templates/default/config.rb +17 -0
- data/project-templates/default/data/site.yml +4 -0
- data/project-templates/default/helpers/site_helper.rb +7 -0
- data/project-templates/default/public/code.css +77 -0
- data/project-templates/default/public/frontman-logo.svg +2 -0
- data/project-templates/default/public/main.css +27 -0
- data/project-templates/default/public/main.js +1 -0
- data/project-templates/default/source/index.html.md.erb +7 -0
- data/project-templates/default/source/sitemap.xml.erb +11 -0
- data/project-templates/default/views/layouts/main.erb +19 -0
- data/project-templates/default/views/layouts/main.haml +15 -0
- data/project-templates/default/views/partials/menu.erb +7 -0
- data/project-templates/webpack/.gitignore +4 -0
- data/project-templates/webpack/Gemfile +3 -0
- data/project-templates/webpack/README.md +54 -0
- data/project-templates/webpack/assets/css/code.css +77 -0
- data/project-templates/webpack/assets/css/style.css +27 -0
- data/project-templates/webpack/assets/images/.gitkeep +0 -0
- data/project-templates/webpack/assets/images/frontman_logo.svg +2 -0
- data/project-templates/webpack/assets/js/index.js +1 -0
- data/project-templates/webpack/config.rb +24 -0
- data/project-templates/webpack/data/site.yml +4 -0
- data/project-templates/webpack/helpers/assets_helper.rb +24 -0
- data/project-templates/webpack/helpers/site_helper.rb +7 -0
- data/project-templates/webpack/package-lock.json +7603 -0
- data/project-templates/webpack/package.json +34 -0
- data/project-templates/webpack/source/index.html.md.erb +7 -0
- data/project-templates/webpack/source/sitemap.xml.erb +11 -0
- data/project-templates/webpack/views/layouts/main.erb +20 -0
- data/project-templates/webpack/views/layouts/main.haml +14 -0
- data/project-templates/webpack/views/partials/menu.erb +7 -0
- data/project-templates/webpack/views/partials/script_with_vendors.haml +5 -0
- data/project-templates/webpack/webpack/base.config.js +51 -0
- data/project-templates/webpack/webpack/dev.config.js +6 -0
- data/project-templates/webpack/webpack/prod.config.js +30 -0
- data/readme.md +80 -0
- data/sorbet/config +2 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +27259 -0
- data/sorbet/rbi/hidden-definitions/hidden.rbi +45122 -0
- data/sorbet/rbi/sorbet-typed/lib/rainbow/all/rainbow.rbi +276 -0
- data/sorbet/rbi/todo.rbi +6 -0
- data/spec/frontman/app_spec.rb +48 -0
- data/spec/frontman/bootstrapper_spec.rb +26 -0
- data/spec/frontman/builder/builder_spec.rb +79 -0
- data/spec/frontman/builder/file_spec.rb +45 -0
- data/spec/frontman/builder/mapping_spec.rb +8 -0
- data/spec/frontman/concerns/dispatch_events_spec.rb +70 -0
- data/spec/frontman/concerns/forward_calls_to_app_spec.rb +21 -0
- data/spec/frontman/config_spec.rb +54 -0
- data/spec/frontman/context_spec.rb +48 -0
- data/spec/frontman/custom_struct_spec.rb +51 -0
- data/spec/frontman/data_store_file_spec.rb +9 -0
- data/spec/frontman/data_store_spec.rb +36 -0
- data/spec/frontman/frontman_ssg_spec.rb +7 -0
- data/spec/frontman/helpers/app_helper_spec.rb +24 -0
- data/spec/frontman/helpers/link_helper_spec.rb +37 -0
- data/spec/frontman/helpers/render_helper_spec.rb +55 -0
- data/spec/frontman/helpers/url_helper_spec.rb +21 -0
- data/spec/frontman/iterator_spec.rb +47 -0
- data/spec/frontman/mocks/asset.css +3 -0
- data/spec/frontman/mocks/config.rb +0 -0
- data/spec/frontman/mocks/helpers/formatting_helper.rb +5 -0
- data/spec/frontman/mocks/helpers/language_helper.rb +5 -0
- data/spec/frontman/mocks/helpers/link_helper.rb +5 -0
- data/spec/frontman/mocks/helpers/test_command.rb +5 -0
- data/spec/frontman/mocks/html_file.html +8 -0
- data/spec/frontman/mocks/html_file.html.md.erb +9 -0
- data/spec/frontman/mocks/html_file.md.html +8 -0
- data/spec/frontman/mocks/info.yml +4 -0
- data/spec/frontman/mocks/layouts/raw_without_body.haml +1 -0
- data/spec/frontman/mocks/nested/data.yml +4 -0
- data/spec/frontman/mocks/nested/more_data.yml +4 -0
- data/spec/frontman/mocks/partials/paragraph.haml +2 -0
- data/spec/frontman/mocks/snippet/html_file.html +8 -0
- data/spec/frontman/mocks/snippet/html_file.yml +670 -0
- data/spec/frontman/mocks/test.html +8 -0
- data/spec/frontman/mocks/wrap.haml +3 -0
- data/spec/frontman/process/chain_spec.rb +56 -0
- data/spec/frontman/renderers/erb_renderer_spec.rb +22 -0
- data/spec/frontman/renderers/haml_renderer_spec.rb +12 -0
- data/spec/frontman/renderers/markdown_renderer_spec.rb +12 -0
- data/spec/frontman/renderers/renderer_spec.rb +16 -0
- data/spec/frontman/resource_spec.rb +151 -0
- data/spec/frontman/sitemap_tree_spec.rb +128 -0
- data/spec/frontman/toolbox/timer_spec.rb +34 -0
- data/spec/spec_setup.rb +19 -0
- metadata +507 -0
@@ -0,0 +1,276 @@
|
|
1
|
+
# This file is autogenerated. Do not edit it by hand. Regenerate it with:
|
2
|
+
# srb rbi sorbet-typed
|
3
|
+
#
|
4
|
+
# If you would like to make changes to this file, great! Please upstream any changes you make here:
|
5
|
+
#
|
6
|
+
# https://github.com/sorbet/sorbet-typed/edit/master/lib/rainbow/all/rainbow.rbi
|
7
|
+
#
|
8
|
+
# typed: strong
|
9
|
+
|
10
|
+
module Rainbow
|
11
|
+
sig { returns(T::Boolean) }
|
12
|
+
attr_accessor :enabled
|
13
|
+
|
14
|
+
class Color
|
15
|
+
sig { returns(Symbol) }
|
16
|
+
attr_reader :ground
|
17
|
+
|
18
|
+
sig do
|
19
|
+
params(
|
20
|
+
ground: Symbol,
|
21
|
+
values: T.any([Integer], [Integer, Integer, Integer])
|
22
|
+
).returns(Color)
|
23
|
+
end
|
24
|
+
def self.build(ground, values); end
|
25
|
+
|
26
|
+
sig { params(hex: String).returns([Integer, Integer, Integer]) }
|
27
|
+
def self.parse_hex_color(hex); end
|
28
|
+
|
29
|
+
class Indexed < Color
|
30
|
+
sig { returns(Integer) }
|
31
|
+
attr_reader :num
|
32
|
+
|
33
|
+
sig { params(ground: Symbol, num: Integer).returns(Indexed) }
|
34
|
+
def initialize(ground, num); end
|
35
|
+
|
36
|
+
sig { returns(T::Array[Integer]) }
|
37
|
+
def codes; end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Named < Indexed
|
41
|
+
NAMES = T.let(nil, T::Hash[Symbol, Integer])
|
42
|
+
|
43
|
+
sig { returns(T::Array[Symbol]) }
|
44
|
+
def self.color_names; end
|
45
|
+
|
46
|
+
sig { returns(String) }
|
47
|
+
def self.valid_names; end
|
48
|
+
|
49
|
+
sig { params(ground: Symbol, name: Symbol).returns(Named) }
|
50
|
+
def initialize(ground, name); end
|
51
|
+
end
|
52
|
+
|
53
|
+
class RGB < Indexed
|
54
|
+
sig { returns(Integer) }
|
55
|
+
attr_accessor :r, :g, :b
|
56
|
+
|
57
|
+
sig { params(value: Numeric).returns(Integer) }
|
58
|
+
def to_ansi_domain(value); end
|
59
|
+
|
60
|
+
sig { params(ground: Symbol, values: Integer).returns(RGB) }
|
61
|
+
def initialize(ground, *values); end
|
62
|
+
|
63
|
+
sig { returns(T::Array[Integer]) }
|
64
|
+
def codes; end
|
65
|
+
end
|
66
|
+
|
67
|
+
class X11Named < RGB
|
68
|
+
include X11ColorNames
|
69
|
+
|
70
|
+
sig { returns(T::Array[Symbol]) }
|
71
|
+
def self.color_names; end
|
72
|
+
|
73
|
+
sig { returns(String) }
|
74
|
+
def self.valid_names; end
|
75
|
+
|
76
|
+
sig { params(ground: Symbol, name: Symbol).returns(X11Named) }
|
77
|
+
def initialize(ground, name); end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
sig { returns(Wrapper) }
|
82
|
+
def self.global; end
|
83
|
+
|
84
|
+
sig { returns(T::Boolean) }
|
85
|
+
def self.enabled; end
|
86
|
+
|
87
|
+
sig { params(value: T::Boolean).returns(T::Boolean) }
|
88
|
+
def self.enabled=(value); end
|
89
|
+
|
90
|
+
sig { params(string: String).returns(String) }
|
91
|
+
def self.uncolor(string); end
|
92
|
+
|
93
|
+
class NullPresenter < String
|
94
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
95
|
+
def color(*values); end
|
96
|
+
|
97
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
98
|
+
def foreground(*values); end
|
99
|
+
|
100
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
101
|
+
def fg(*values); end
|
102
|
+
|
103
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
104
|
+
def background(*values); end
|
105
|
+
|
106
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
|
107
|
+
def bg(*values); end
|
108
|
+
|
109
|
+
sig { returns(NullPresenter) }
|
110
|
+
def reset; end
|
111
|
+
|
112
|
+
sig { returns(NullPresenter) }
|
113
|
+
def bright; end
|
114
|
+
|
115
|
+
sig { returns(NullPresenter) }
|
116
|
+
def faint; end
|
117
|
+
|
118
|
+
sig { returns(NullPresenter) }
|
119
|
+
def italic; end
|
120
|
+
|
121
|
+
sig { returns(NullPresenter) }
|
122
|
+
def underline; end
|
123
|
+
|
124
|
+
sig { returns(NullPresenter) }
|
125
|
+
def blink; end
|
126
|
+
|
127
|
+
sig { returns(NullPresenter) }
|
128
|
+
def inverse; end
|
129
|
+
|
130
|
+
sig { returns(NullPresenter) }
|
131
|
+
def hide; end
|
132
|
+
|
133
|
+
sig { returns(NullPresenter) }
|
134
|
+
def cross_out; end
|
135
|
+
|
136
|
+
sig { returns(NullPresenter) }
|
137
|
+
def black; end
|
138
|
+
|
139
|
+
sig { returns(NullPresenter) }
|
140
|
+
def red; end
|
141
|
+
|
142
|
+
sig { returns(NullPresenter) }
|
143
|
+
def green; end
|
144
|
+
|
145
|
+
sig { returns(NullPresenter) }
|
146
|
+
def yellow; end
|
147
|
+
|
148
|
+
sig { returns(NullPresenter) }
|
149
|
+
def blue; end
|
150
|
+
|
151
|
+
sig { returns(NullPresenter) }
|
152
|
+
def magenta; end
|
153
|
+
|
154
|
+
sig { returns(NullPresenter) }
|
155
|
+
def cyan; end
|
156
|
+
|
157
|
+
sig { returns(NullPresenter) }
|
158
|
+
def white; end
|
159
|
+
|
160
|
+
sig { returns(NullPresenter) }
|
161
|
+
def bold; end
|
162
|
+
|
163
|
+
sig { returns(NullPresenter) }
|
164
|
+
def dark; end
|
165
|
+
|
166
|
+
sig { returns(NullPresenter) }
|
167
|
+
def strike; end
|
168
|
+
end
|
169
|
+
|
170
|
+
class Presenter < String
|
171
|
+
TERM_EFFECTS = T.let(nil, T::Hash[Symbol, Integer])
|
172
|
+
|
173
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
174
|
+
def color(*values); end
|
175
|
+
|
176
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
177
|
+
def foreground(*values); end
|
178
|
+
|
179
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
180
|
+
def fg(*values); end
|
181
|
+
|
182
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
183
|
+
def background(*values); end
|
184
|
+
|
185
|
+
sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
|
186
|
+
def bg(*values); end
|
187
|
+
|
188
|
+
sig { returns(Presenter) }
|
189
|
+
def reset; end
|
190
|
+
|
191
|
+
sig { returns(Presenter) }
|
192
|
+
def bright; end
|
193
|
+
|
194
|
+
sig { returns(Presenter) }
|
195
|
+
def faint; end
|
196
|
+
|
197
|
+
sig { returns(Presenter) }
|
198
|
+
def italic; end
|
199
|
+
|
200
|
+
sig { returns(Presenter) }
|
201
|
+
def underline; end
|
202
|
+
|
203
|
+
sig { returns(Presenter) }
|
204
|
+
def blink; end
|
205
|
+
|
206
|
+
sig { returns(Presenter) }
|
207
|
+
def inverse; end
|
208
|
+
|
209
|
+
sig { returns(Presenter) }
|
210
|
+
def hide; end
|
211
|
+
|
212
|
+
sig { returns(Presenter) }
|
213
|
+
def cross_out; end
|
214
|
+
|
215
|
+
sig { returns(Presenter) }
|
216
|
+
def black; end
|
217
|
+
|
218
|
+
sig { returns(Presenter) }
|
219
|
+
def red; end
|
220
|
+
|
221
|
+
sig { returns(Presenter) }
|
222
|
+
def green; end
|
223
|
+
|
224
|
+
sig { returns(Presenter) }
|
225
|
+
def yellow; end
|
226
|
+
|
227
|
+
sig { returns(Presenter) }
|
228
|
+
def blue; end
|
229
|
+
|
230
|
+
sig { returns(Presenter) }
|
231
|
+
def magenta; end
|
232
|
+
|
233
|
+
sig { returns(Presenter) }
|
234
|
+
def cyan; end
|
235
|
+
|
236
|
+
sig { returns(Presenter) }
|
237
|
+
def white; end
|
238
|
+
|
239
|
+
sig { returns(Presenter) }
|
240
|
+
def bold; end
|
241
|
+
|
242
|
+
sig { returns(Presenter) }
|
243
|
+
def dark; end
|
244
|
+
|
245
|
+
sig { returns(Presenter) }
|
246
|
+
def strike; end
|
247
|
+
end
|
248
|
+
|
249
|
+
class StringUtils
|
250
|
+
sig { params(string: String, codes: T::Array[Integer]).returns(String) }
|
251
|
+
def self.wrap_with_sgr(string, codes); end
|
252
|
+
|
253
|
+
sig { params(string: String).returns(String) }
|
254
|
+
def uncolor(string); end
|
255
|
+
end
|
256
|
+
|
257
|
+
VERSION = T.let(nil, String)
|
258
|
+
|
259
|
+
class Wrapper
|
260
|
+
sig { returns(T::Boolean) }
|
261
|
+
attr_accessor :enabled
|
262
|
+
|
263
|
+
sig { params(enabled: T::Boolean).returns(Wrapper) }
|
264
|
+
def initialize(enabled = true); end
|
265
|
+
|
266
|
+
sig { params(string: String).returns(T.any(Rainbow::Presenter, Rainbow::NullPresenter)) }
|
267
|
+
def wrap(string); end
|
268
|
+
end
|
269
|
+
|
270
|
+
module X11ColorNames
|
271
|
+
NAMES = T.let(nil, T::Hash[Symbol, [Integer, Integer, Integer]])
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
sig { params(string: String).returns(Rainbow::Presenter) }
|
276
|
+
def Rainbow(string); end
|
data/sorbet/rbi/todo.rbi
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require './spec/spec_setup'
|
5
|
+
require 'lib/frontman/app'
|
6
|
+
require 'lib/frontman/sitemap_tree'
|
7
|
+
|
8
|
+
describe Frontman::App do
|
9
|
+
subject { Frontman::App.instance }
|
10
|
+
|
11
|
+
context 'Helpers' do
|
12
|
+
it 'should register helpers correctly' do
|
13
|
+
# TODO: make test
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should throw an error when registering a missing helpers' do
|
17
|
+
expect do
|
18
|
+
subject.register_helpers(
|
19
|
+
[
|
20
|
+
{ path: File.join(Dir.pwd, 'helpers/MissingHelper.rb'), name: 'MissingHelper' }
|
21
|
+
]
|
22
|
+
)
|
23
|
+
end.to raise_error LoadError
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'Redirects' do
|
28
|
+
it 'should store redirects' do
|
29
|
+
subject.add_redirect('/foo', '/bar')
|
30
|
+
expect(subject.get_redirect('/foo')).to eq '/bar'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'manifest' do
|
35
|
+
it 'should prepend with a slash if needed' do
|
36
|
+
expect(subject.add_to_manifest('key', 'foo/bar')).to eq '/foo/bar'
|
37
|
+
expect(subject.add_to_manifest('key', '/bar/foo')).to eq '/bar/foo'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return a sitemap_tree' do
|
42
|
+
expect(subject.sitemap_tree.is_a?(Frontman::SitemapTree)).to eq true
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should return itself when calling app' do
|
46
|
+
expect(subject.app).to eq subject
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require './spec/spec_setup'
|
5
|
+
require 'frontman/app'
|
6
|
+
require 'frontman/bootstrapper'
|
7
|
+
require 'frontman/config'
|
8
|
+
|
9
|
+
describe Frontman::Bootstrapper do
|
10
|
+
context 'helpers' do
|
11
|
+
it 'should find all helpers in a given folder' do
|
12
|
+
result = Frontman::Bootstrapper.find_helpers_in(
|
13
|
+
'spec/frontman/mocks/helpers/'
|
14
|
+
)
|
15
|
+
expect(result.size).to eq 3
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'resources' do
|
20
|
+
it 'should find all resources in a given folder' do
|
21
|
+
resources = Frontman::Bootstrapper.resources_from_dir('spec/frontman/mocks')
|
22
|
+
|
23
|
+
expect(resources.size).to eq 14 # Number of non-YAML files in this folder
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require './spec/spec_setup'
|
5
|
+
require 'frontman/builder/builder'
|
6
|
+
require 'frontman/resource'
|
7
|
+
|
8
|
+
describe Frontman::Builder::Builder do
|
9
|
+
subject { Frontman::Builder::Builder.new }
|
10
|
+
|
11
|
+
context 'build directory' do
|
12
|
+
it 'should default to build folder in root' do
|
13
|
+
expect(subject.build_directory).to eq Dir.pwd + '/build/'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should override the build directory' do
|
17
|
+
directory = Dir.pwd + '/fake-build/'
|
18
|
+
expect(subject.build_directory).to eq Dir.pwd + '/build/'
|
19
|
+
subject.build_directory = directory
|
20
|
+
expect(subject.build_directory).to eq directory
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'building' do
|
25
|
+
subject do
|
26
|
+
builder = Frontman::Builder::Builder.new
|
27
|
+
builder.build_directory = Dir.pwd + '/spec/frontman/build/'
|
28
|
+
builder
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should properly build a redirect' do
|
32
|
+
# TODO
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should build from an ERB file' do
|
36
|
+
subject.build_from_erb('spec/frontman/mocks/html_file.html.md.erb', 'spec/frontman/mocks/html_file.html.md.erb')
|
37
|
+
path = subject.build_directory + '/spec/frontman/mocks/html_file/index.html'
|
38
|
+
|
39
|
+
expect(File.exist?(path)).to eq true
|
40
|
+
expect(File.read(path).include?('testing erb')).to eq true # This text will be rendered by ERB
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should build from an asset' do
|
44
|
+
subject.build_from_asset('spec/frontman/mocks/asset.css', 'spec/frontman/mocks/asset.css')
|
45
|
+
path = subject.build_directory + '/spec/frontman/mocks/asset.css'
|
46
|
+
|
47
|
+
expect(File.exist?(path)).to eq true
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should not rebuild an existing file' do
|
51
|
+
file_path = subject.build_directory + 'spec/frontman/mocks/asset.css'
|
52
|
+
current_mtime = File.mtime(file_path)
|
53
|
+
subject.current_build_files = Dir.glob(Dir.pwd + '/spec/frontman/build/**/*').reject { |f| File.directory? f }
|
54
|
+
subject.build_from_asset('spec/frontman/mocks/asset.css', 'spec/frontman/mocks/asset.css')
|
55
|
+
|
56
|
+
expect(File.mtime(file_path)).to eq current_mtime
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should build from resource' do
|
60
|
+
subject.build_resource(Frontman::Resource.from_path('spec/frontman/mocks/test.html'))
|
61
|
+
path = subject.build_directory + '/spec/frontman/mocks/test/index.html'
|
62
|
+
expect(File.exist?(path)).to eq true
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should skip rebuilding from resource' do
|
66
|
+
resource = Frontman::Resource.from_path('spec/frontman/mocks/test.html')
|
67
|
+
path = subject.build_directory + 'spec/frontman/mocks/test/index.html'
|
68
|
+
subject.current_build_files = [path]
|
69
|
+
|
70
|
+
current_mtime = File.mtime(path)
|
71
|
+
subject.build_resource(resource)
|
72
|
+
expect(File.mtime(path)).to eq current_mtime
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should delete files properly' do
|
76
|
+
# TODO
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require './spec/spec_setup'
|
5
|
+
require 'frontman/builder/file'
|
6
|
+
|
7
|
+
describe Frontman::Builder::File do
|
8
|
+
subject { Frontman::Builder::File.new('fake/path', :created) }
|
9
|
+
|
10
|
+
it 'should return the correct path' do
|
11
|
+
expect(subject.path).to eq 'fake/path'
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'updated' do
|
15
|
+
subject { Frontman::Builder::File.updated('fake/path') }
|
16
|
+
|
17
|
+
it 'should initialize with the right status' do
|
18
|
+
expect(subject.status).to eq :updated
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'created' do
|
23
|
+
subject { Frontman::Builder::File.created('fake/path') }
|
24
|
+
|
25
|
+
it 'should initialize with the right status' do
|
26
|
+
expect(subject.status).to eq :created
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'deleted' do
|
31
|
+
subject { Frontman::Builder::File.deleted('fake/path') }
|
32
|
+
|
33
|
+
it 'should initialize with the right status' do
|
34
|
+
expect(subject.status).to eq :deleted
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'unchanged' do
|
39
|
+
subject { Frontman::Builder::File.unchanged('fake/path') }
|
40
|
+
|
41
|
+
it 'should initialize with the right status' do
|
42
|
+
expect(subject.status).to eq :unchanged
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|