usmu 1.0.0-java → 1.0.1-java
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/CHANGELOG.md +26 -18
- data/Gemfile +2 -2
- data/bin/usmu +0 -0
- data/lib/usmu/configuration.rb +4 -0
- data/lib/usmu/site_generator.rb +18 -10
- data/lib/usmu/version.rb +1 -1
- data/spec/mock/usmu/mock_metadata_configuration.rb +12 -0
- data/spec/usmu/configuration_spec.rb +8 -0
- data/spec/usmu/site_generator_spec.rb +129 -18
- data/usmu.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: edd7433ee4c0dbc62aa99b6fea962c901e6bbf5f
|
|
4
|
+
data.tar.gz: fc146facac5a999db5b93052c2a673473b71fc8c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b32249f6dc8882c6b80222e27133bff664a2bb9abef545c958f5bf2634cb657289fc629ed167a645ec7b31a0233a3d441441f61c31f687231811d784fd48531f
|
|
7
|
+
data.tar.gz: c94c2d0e01c1abb342c798ebc7a02f835153e9fc2843a2a28bde29b9ae8c6227b367d37df96b569eff7d5331f3fb84ef568a9e5ed33692cee08ee5a5154ebaa0
|
data/CHANGELOG.md
CHANGED
|
@@ -6,10 +6,14 @@ Matthew Scharley <matt.scharley@gmail.com>
|
|
|
6
6
|
|
|
7
7
|
* Minor refactor of /spec (d353c8a1f8914dc9fb554770479092cfc1e526bc)
|
|
8
8
|
* Small update to the init site (d86e9a205a3a2f1cc76dec7e66f0540edc9e13c1)
|
|
9
|
-
* [
|
|
10
|
-
* [
|
|
11
|
-
* [
|
|
12
|
-
* [
|
|
9
|
+
* [\[\#29\]][GH-29] Generalise Configuration\#\[\] into Helpers::Indexer and add to Layout (474b5d778f841595602a4ec7913a646ff5e90106)
|
|
10
|
+
* [\[\#27\]][GH-27] Add permalinks (ce190c0d33e84bf38b26cc134fe96bb9a3bb3f22)
|
|
11
|
+
* [\[\#19\]][GH-19] Basic functional collection support for paging (de2fa4194fe9db955e09a302a1b87816557e8f3e)
|
|
12
|
+
* [\[\#19\]][GH-19] Add enumeration of collections (e6923cf10426e62bc5f35c3649303a1ae65466fd)
|
|
13
|
+
|
|
14
|
+
[GH-19]: https://github.com/usmu/usmu/issues/19
|
|
15
|
+
[GH-27]: https://github.com/usmu/usmu/issues/27
|
|
16
|
+
[GH-29]: https://github.com/usmu/usmu/issues/29
|
|
13
17
|
|
|
14
18
|
## 0.4.0
|
|
15
19
|
|
|
@@ -17,7 +21,9 @@ Matthew Scharley <matt.scharley@gmail.com>
|
|
|
17
21
|
|
|
18
22
|
* Bump to 0.4.0.dev for further dev (32596fe063dfb0452098b0bcac7d97f57ee772a5)
|
|
19
23
|
* Ensure that loggers have the right functions available (df1c685c9ee7f3e4070351700d0ec28d999bc345)
|
|
20
|
-
* [
|
|
24
|
+
* [\[\#25\]][GH-25] Include a Rack app for viewing site dynamically (964486386bfa6325f191a44be0eb301ce5d200be)
|
|
25
|
+
|
|
26
|
+
[GH-25]: https://github.com/usmu/usmu/issues/25
|
|
21
27
|
|
|
22
28
|
## 0.3.4
|
|
23
29
|
|
|
@@ -43,6 +49,10 @@ Matthew Scharley <matt.scharley@gmail.com>
|
|
|
43
49
|
* [\[#21\]][GH-21] Cover Usmu::Deployment::DirectoryDiff (d4836b1ddb950223786e35b024e2692e106a2c41)
|
|
44
50
|
* [\[#18\]][GH-16] Initialise logging before commander (6117299b6303b54249c06d894e074cbb437623c2)
|
|
45
51
|
|
|
52
|
+
[GH-15]: https://github.com/usmu/usmu/issues/15
|
|
53
|
+
[GH-16]: https://github.com/usmu/usmu/issues/16
|
|
54
|
+
[GH-21]: https://github.com/usmu/usmu/issues/21
|
|
55
|
+
|
|
46
56
|
## 0.3.2
|
|
47
57
|
|
|
48
58
|
Matthew Scharley <matt.scharley@gmail.com>
|
|
@@ -89,6 +99,11 @@ Matthew Scharley <matt.scharley@gmail.com>
|
|
|
89
99
|
* [\[\#13\]][GH-13] Add page metadata to parent layouts (c2da294e1f19e6404df178ee650c3818cc0f3846)
|
|
90
100
|
* Add a Sass partials exclude to default init site (4f70d5b1b5958b6c56338b8d077711c780c85763)
|
|
91
101
|
|
|
102
|
+
[GH-12]: https://github.com/usmu/usmu/issues/12
|
|
103
|
+
[GH-13]: https://github.com/usmu/usmu/issues/13
|
|
104
|
+
[GH-14]: https://github.com/usmu/usmu/issues/14
|
|
105
|
+
[GH-17]: https://github.com/usmu/usmu/issues/17
|
|
106
|
+
|
|
92
107
|
## 0.2.2
|
|
93
108
|
|
|
94
109
|
Matthew Scharley <matt.scharley@gmail.com>
|
|
@@ -125,6 +140,9 @@ Matthew Scharley <matt.scharley@gmail.com>
|
|
|
125
140
|
* Remove RBX 2.3 again. (b8675c07d0fe066c466144c27e690f1863a88888)
|
|
126
141
|
* Release 0.2.2 (986f611b167a0503108d41ac0a115e38d6aac2f9)
|
|
127
142
|
|
|
143
|
+
[GH-8]: https://github.com/usmu/usmu/issues/8
|
|
144
|
+
[GH-9]: https://github.com/usmu/usmu/issues/9
|
|
145
|
+
|
|
128
146
|
## 0.2.1
|
|
129
147
|
|
|
130
148
|
Matthew Scharley <matt.scharley@gmail.com>
|
|
@@ -160,6 +178,9 @@ Matthew Scharley <matt.scharley@gmail.com>
|
|
|
160
178
|
* Re-enable 1.9.3 CI and add some compat notes to the readme (cf34053aaaf6a85752ec8be70f7c9969a89990d9)
|
|
161
179
|
* Bump to 0.2.0 release (7e7dde04c180b5ae63268db647ba45ef63a6b3f3)
|
|
162
180
|
|
|
181
|
+
[GH-5]: https://github.com/usmu/usmu/issues/5
|
|
182
|
+
[GH-7]: https://github.com/usmu/usmu/issues/7
|
|
183
|
+
|
|
163
184
|
## 0.1.0
|
|
164
185
|
|
|
165
186
|
Matthew Scharley <matt.scharley@gmail.com>
|
|
@@ -205,16 +226,3 @@ Matthew Scharley <matt.scharley@gmail.com>
|
|
|
205
226
|
* Small stylistic change (ae008aa5492b2463774e4e4659d90666059b45e0)
|
|
206
227
|
* Add new custom rake tasks for building gems and fix a few small issues with the specs (5b1a4241cd9f31f39179ffaad49f7155617c0e6f)
|
|
207
228
|
* Bump to full 0.1.0 release (fb91c2b54f79eeaeb615f98f874c990e4cdddfd3)
|
|
208
|
-
|
|
209
|
-
[GH-5]: https://github.com/usmu/usmu/issues/5
|
|
210
|
-
[GH-7]: https://github.com/usmu/usmu/issues/7
|
|
211
|
-
[GH-8]: https://github.com/usmu/usmu/issues/8
|
|
212
|
-
[GH-9]: https://github.com/usmu/usmu/issues/9
|
|
213
|
-
[GH-12]: https://github.com/usmu/usmu/issues/12
|
|
214
|
-
[GH-13]: https://github.com/usmu/usmu/issues/13
|
|
215
|
-
[GH-14]: https://github.com/usmu/usmu/issues/14
|
|
216
|
-
[GH-15]: https://github.com/usmu/usmu/issues/15
|
|
217
|
-
[GH-16]: https://github.com/usmu/usmu/issues/16
|
|
218
|
-
[GH-17]: https://github.com/usmu/usmu/issues/17
|
|
219
|
-
[GH-18]: https://github.com/usmu/usmu/issues/18
|
|
220
|
-
[GH-21]: https://github.com/usmu/usmu/issues/21
|
data/Gemfile
CHANGED
|
@@ -15,6 +15,6 @@ gemspec name: 'usmu'
|
|
|
15
15
|
gem 'codeclimate-test-reporter', group: :test, require: nil
|
|
16
16
|
|
|
17
17
|
if RUBY_VERSION.to_f >= 2 && RUBY_VERSION.to_f < 2.2 && RUBY_ENGINE == 'ruby'
|
|
18
|
-
gem 'mutant', '~> 0.7'
|
|
19
|
-
gem 'mutant-rspec', '~> 0.7'
|
|
18
|
+
gem 'mutant', '~> 0.7', :group => :development
|
|
19
|
+
gem 'mutant-rspec', '~> 0.7', :group => :development
|
|
20
20
|
end
|
data/bin/usmu
CHANGED
|
File without changes
|
data/lib/usmu/configuration.rb
CHANGED
|
@@ -47,6 +47,8 @@ module Usmu
|
|
|
47
47
|
get_files source_path
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
# @!attribute [r] source_metadata
|
|
51
|
+
# @return [MetadataService] a metadata service for retrieving metadata about pages in #source_path
|
|
50
52
|
def source_metadata
|
|
51
53
|
@source_metadata ||= MetadataService.new(source_path)
|
|
52
54
|
end
|
|
@@ -85,6 +87,8 @@ module Usmu
|
|
|
85
87
|
get_files includes_path
|
|
86
88
|
end
|
|
87
89
|
|
|
90
|
+
# @!attribute [r] includes_metadata
|
|
91
|
+
# @return [MetadataService] a metadata service for retrieving metadata about includes
|
|
88
92
|
def includes_metadata
|
|
89
93
|
@includes_metadata ||= MetadataService.new(includes_path)
|
|
90
94
|
end
|
data/lib/usmu/site_generator.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
|
+
require 'usmu/collections'
|
|
2
3
|
require 'usmu/configuration'
|
|
3
4
|
require 'usmu/template/page'
|
|
4
5
|
require 'usmu/template/static_file'
|
|
@@ -15,7 +16,7 @@ module Usmu
|
|
|
15
16
|
# @!attribute [r] layouts
|
|
16
17
|
# @return [Array<Usmu::Layout>] a list of layouts available in this website.
|
|
17
18
|
def layouts
|
|
18
|
-
@configuration.layouts_files.map {|l|
|
|
19
|
+
@configuration.layouts_files.map {|l| Template::Layout.new(@configuration, l, @configuration.layouts_metadata.metadata(l)) }
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
# @!attribute [r] renderables
|
|
@@ -30,25 +31,26 @@ module Usmu
|
|
|
30
31
|
def renderables
|
|
31
32
|
@configuration.source_files.map do |filename|
|
|
32
33
|
metadata = @configuration.source_metadata.metadata(filename)
|
|
33
|
-
if
|
|
34
|
-
|
|
34
|
+
if Template::Layout.is_valid_file?('source', filename) && (!metadata['static'])
|
|
35
|
+
Template::Page.new(@configuration, filename, metadata)
|
|
35
36
|
else
|
|
36
|
-
|
|
37
|
+
Template::StaticFile.new(@configuration, filename, metadata)
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
# @!attribute [r] pages
|
|
42
|
-
# @return [Array<Usmu::Template::Page>]
|
|
43
|
-
# folder which is not static.
|
|
43
|
+
# @return [Array<Usmu::Template::Page>]
|
|
44
|
+
# a list of pages from the source folder. This is any file in the source folder which is not static.
|
|
44
45
|
def pages
|
|
45
|
-
renderables.select {|r| r.class
|
|
46
|
+
renderables.select {|r| r.class <= Template::Layout }
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
# @!attribute [r] files
|
|
49
|
-
# @return [Array<Usmu::Template::StaticFile>]
|
|
50
|
+
# @return [Array<Usmu::Template::StaticFile>]
|
|
51
|
+
# a list of static files from the source folder.
|
|
50
52
|
def files
|
|
51
|
-
renderables
|
|
53
|
+
renderables - pages
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
# Generate the website according to the configuration given.
|
|
@@ -63,12 +65,17 @@ module Usmu
|
|
|
63
65
|
nil
|
|
64
66
|
end
|
|
65
67
|
|
|
68
|
+
# Returns an interface for interacting with collections defined in this site.
|
|
69
|
+
#
|
|
70
|
+
# @return [Usmu::Collections]
|
|
66
71
|
def collections
|
|
67
72
|
@collections ||= Collections.new(self)
|
|
68
73
|
end
|
|
69
74
|
|
|
75
|
+
# Refresh information about this site.
|
|
70
76
|
def refresh
|
|
71
77
|
collections.refresh
|
|
78
|
+
nil
|
|
72
79
|
end
|
|
73
80
|
|
|
74
81
|
private
|
|
@@ -88,7 +95,8 @@ module Usmu
|
|
|
88
95
|
end
|
|
89
96
|
|
|
90
97
|
File.write file, page.render
|
|
91
|
-
FileUtils.touch file, :
|
|
98
|
+
FileUtils.touch file, mtime: File.stat(page.input_path).mtime
|
|
99
|
+
nil
|
|
92
100
|
end
|
|
93
101
|
end
|
|
94
102
|
end
|
data/lib/usmu/version.rb
CHANGED
|
@@ -167,6 +167,14 @@ RSpec.describe Usmu::Configuration do
|
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
+
context '#generator' do
|
|
171
|
+
it 'should return a new SiteGenerator' do
|
|
172
|
+
sg = {fake: 'success'}
|
|
173
|
+
expect(Usmu::SiteGenerator).to receive(:new).with(empty_configuration).and_return(sg)
|
|
174
|
+
expect(empty_configuration.generator).to eq(sg)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
170
178
|
context '#[]' do
|
|
171
179
|
it 'should remember arbitrary configuration' do
|
|
172
180
|
configuration = Usmu::Configuration.from_hash({:test => 'foo'})
|
|
@@ -1,35 +1,146 @@
|
|
|
1
1
|
require 'usmu/site_generator'
|
|
2
|
+
require 'usmu/mock_metadata_configuration'
|
|
3
|
+
require 'ostruct'
|
|
2
4
|
|
|
3
5
|
RSpec.describe Usmu::SiteGenerator do
|
|
4
|
-
let(:
|
|
6
|
+
let(:meta_mock) {
|
|
7
|
+
Usmu::MockMetadataConfiguration.new(
|
|
8
|
+
{
|
|
9
|
+
'assets/external.scss' => { 'static' => true }
|
|
10
|
+
}
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
let(:configuration) { Usmu::Configuration.from_hash({}) }
|
|
5
14
|
let(:generator) { Usmu::SiteGenerator.new(configuration) }
|
|
6
15
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
before do
|
|
17
|
+
allow(configuration).to receive(:layouts_metadata).and_return(meta_mock)
|
|
18
|
+
allow(configuration).to receive(:source_metadata).and_return(meta_mock)
|
|
19
|
+
|
|
20
|
+
allow(Dir).to receive(:[]).with('src/**/{*,.??*}').and_return(%w{src/.dotfiletest.txt src/assets src/assets/external.scss src/css src/css/app.scss src/index.md src/posts src/posts/second-post.md src/posts/test-post.md src/robots.txt})
|
|
21
|
+
allow(Dir).to receive(:[]).with('layouts/**/{*,.??*}').and_return(%w{layouts/embedded.slim layouts/html.slim layouts/post.slim})
|
|
22
|
+
|
|
23
|
+
allow(File).to receive(:directory?).and_return(false)
|
|
24
|
+
%w{src/assets src/css src/posts}.each do |f|
|
|
25
|
+
allow(File).to receive(:directory?).with(f).and_return(true)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
allow(Usmu::Template::StaticFile).to receive(:new) {|config, filename, metadata| instance_double('Usmu::Template::StaticFile', class: Usmu::Template::StaticFile, name: filename) if config == configuration && metadata == meta_mock.metadata(filename) }
|
|
29
|
+
allow(Usmu::Template::Page).to receive(:new) {|config, filename, metadata| instance_double('Usmu::Template::Page', class: Usmu::Template::Page, name: filename) if config == configuration && metadata == meta_mock.metadata(filename) }
|
|
30
|
+
allow(Usmu::Template::Layout).to receive(:new) {|config, filename, metadata| instance_double('Usmu::Template::Layout', class: Usmu::Template::Layout, name: filename) if config == configuration && metadata == meta_mock.metadata(filename) }
|
|
10
31
|
end
|
|
11
32
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
context '#layouts' do
|
|
34
|
+
it 'should list layouts' do
|
|
35
|
+
expect(meta_mock).to receive(:metadata).at_least(1).times.with('embedded.slim').and_return({})
|
|
36
|
+
expect(meta_mock).to receive(:metadata).at_least(1).times.with('html.slim').and_return({})
|
|
37
|
+
expect(meta_mock).to receive(:metadata).at_least(1).times.with('post.slim').and_return({})
|
|
38
|
+
expect(generator.layouts.map {|l| l.name}.sort).to eq(%w{embedded.slim html.slim post.slim})
|
|
39
|
+
end
|
|
15
40
|
end
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
42
|
+
context '#renderables' do
|
|
43
|
+
before do
|
|
44
|
+
allow(Usmu::Template::Layout).to receive(:is_valid_file?).with('source', '.dotfiletest.txt').and_return(false)
|
|
45
|
+
allow(Usmu::Template::Layout).to receive(:is_valid_file?).with('source', 'assets/external.scss').and_return(true)
|
|
46
|
+
allow(Usmu::Template::Layout).to receive(:is_valid_file?).with('source', 'css/app.scss').and_return(true)
|
|
47
|
+
allow(Usmu::Template::Layout).to receive(:is_valid_file?).with('source', 'index.md').and_return(true)
|
|
48
|
+
allow(Usmu::Template::Layout).to receive(:is_valid_file?).with('source', 'posts/second-post.md').and_return(true)
|
|
49
|
+
allow(Usmu::Template::Layout).to receive(:is_valid_file?).with('source', 'posts/test-post.md').and_return(true)
|
|
50
|
+
allow(Usmu::Template::Layout).to receive(:is_valid_file?).with('source', 'robots.txt').and_return(false)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'should create static files as StaticFile and honour the "static" metadata attribute' do
|
|
54
|
+
expect(generator.renderables.select {|r| r.class == Usmu::Template::StaticFile }.map {|r| r.name}.sort).to eq(%w{.dotfiletest.txt assets/external.scss robots.txt})
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'should create static files as StaticFile and honour the "static" metadata attribute' do
|
|
58
|
+
expect(generator.renderables.select {|r| r.class == Usmu::Template::Page }.map {|r| r.name}.sort).to eq(%w{css/app.scss index.md posts/second-post.md posts/test-post.md})
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'should not list directories' do
|
|
62
|
+
expect(generator.files.select {|f| f.name == 'posts'}.length).to eq(0)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context '#pages' do
|
|
67
|
+
it 'should list pages' do
|
|
68
|
+
expect(generator).to receive(:renderables).and_return(
|
|
69
|
+
[
|
|
70
|
+
instance_double('Usmu::Template::StaticFile', class: Usmu::Template::StaticFile, name: 'robots.txt'),
|
|
71
|
+
instance_double('Usmu::Template::Layout', class: Usmu::Template::Layout, name: 'layout.slim'),
|
|
72
|
+
instance_double('Usmu::Template::Page', class: Usmu::Template::Page, name: 'page.md'),
|
|
73
|
+
]
|
|
74
|
+
)
|
|
75
|
+
expect(generator.pages.map {|p| p.name}.sort).to eq(%w{layout.slim page.md})
|
|
76
|
+
end
|
|
20
77
|
end
|
|
21
78
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
79
|
+
context '#files' do
|
|
80
|
+
it 'should list static files' do
|
|
81
|
+
expect(generator).to receive(:renderables).at_least(1).times.and_return(
|
|
82
|
+
[
|
|
83
|
+
instance_double('Usmu::Template::StaticFile', class: Usmu::Template::StaticFile, name: 'robots.txt'),
|
|
84
|
+
instance_double('Usmu::Template::Layout', class: Usmu::Template::Layout, name: 'layout.slim'),
|
|
85
|
+
instance_double('Usmu::Template::Page', class: Usmu::Template::Page, name: 'page.md'),
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
expect(generator.files.map {|f| f.name}.sort).to eq(%w{robots.txt})
|
|
89
|
+
end
|
|
25
90
|
end
|
|
26
91
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
92
|
+
context '#generate' do
|
|
93
|
+
it 'should call #generate_page for each renderable' do
|
|
94
|
+
expect(generator).to receive(:renderables).and_return([{test: 'success'}])
|
|
95
|
+
expect(generator).to receive(:generate_page).with({test: 'success'})
|
|
96
|
+
expect(generator.generate).to eq(nil)
|
|
97
|
+
expect(@log_output.readline).to eq(" INFO Usmu::SiteGenerator : Source: src\n")
|
|
98
|
+
expect(@log_output.readline).to eq(" INFO Usmu::SiteGenerator : Destination: site\n")
|
|
99
|
+
expect(@log_output.readline).to eq(" INFO Usmu::SiteGenerator : \n")
|
|
100
|
+
end
|
|
30
101
|
end
|
|
31
102
|
|
|
32
|
-
|
|
33
|
-
|
|
103
|
+
context '#collections' do
|
|
104
|
+
it 'should return a Collections interface' do
|
|
105
|
+
expect(Usmu::Collections).to receive(:new).with(generator).and_return({test: 'success'})
|
|
106
|
+
expect(generator.collections).to eq({test: 'success'})
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context '#refresh' do
|
|
111
|
+
it 'refresh collections' do
|
|
112
|
+
expect(generator.collections).to receive(:refresh).and_return(true)
|
|
113
|
+
expect(generator.refresh).to eq(nil)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
context '#generate_page' do
|
|
118
|
+
before do
|
|
119
|
+
allow(File).to receive(:directory?).with('site').and_return(true)
|
|
120
|
+
allow(File).to receive(:directory?).with('site/subdir').and_return(false)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it 'should write a file and update mtime to match source files' do
|
|
124
|
+
page = OpenStruct.new name: 'test.slim', input_path: 'src/test.slim', output_filename: 'test.html', render: '<!DOCTYPE html><h1>It works!</h1>'
|
|
125
|
+
expect(File).to receive(:write).with('site/test.html', '<!DOCTYPE html><h1>It works!</h1>')
|
|
126
|
+
expect(File).to receive(:stat).with('src/test.slim').and_return(OpenStruct.new mtime: 100)
|
|
127
|
+
expect(FileUtils).to receive(:touch).with('site/test.html', mtime: 100).and_return(true)
|
|
128
|
+
expect(FileUtils).to_not receive(:mkdir_p)
|
|
129
|
+
|
|
130
|
+
expect(generator.send :generate_page, page).to eq(nil)
|
|
131
|
+
|
|
132
|
+
expect(@log_output.readline).to eq("SUCCESS Usmu::SiteGenerator : creating test.html...\n")
|
|
133
|
+
expect(@log_output.readline).to eq(" DEBUG Usmu::SiteGenerator : Rendering test.html from test.slim\n")
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'should create directories as necessary' do
|
|
137
|
+
page = OpenStruct.new name: 'test.slim', input_path: 'src/subdir/test.slim', output_filename: 'subdir/test.html', render: '<!DOCTYPE html><h1>It works!</h1>'
|
|
138
|
+
expect(File).to receive(:write).with('site/subdir/test.html', '<!DOCTYPE html><h1>It works!</h1>')
|
|
139
|
+
expect(File).to receive(:stat).with('src/subdir/test.slim').and_return(OpenStruct.new mtime: 100)
|
|
140
|
+
expect(FileUtils).to receive(:touch).with('site/subdir/test.html', mtime: 100).and_return(true)
|
|
141
|
+
expect(FileUtils).to receive(:mkdir_p).with('site/subdir')
|
|
142
|
+
|
|
143
|
+
expect(generator.send :generate_page, page).to eq(nil)
|
|
144
|
+
end
|
|
34
145
|
end
|
|
35
146
|
end
|
data/usmu.gemspec
CHANGED
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.add_dependency 'rack', '~> 1.6'
|
|
29
29
|
spec.add_dependency 'deep_merge', '~> 1.0'
|
|
30
30
|
spec.add_dependency 'commander', '~> 4.2'
|
|
31
|
-
spec.add_dependency 'logging', '~>
|
|
31
|
+
spec.add_dependency 'logging', '~> 2.0'
|
|
32
32
|
|
|
33
33
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
|
34
34
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usmu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew Scharley
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-05-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: slim
|
|
@@ -86,14 +86,14 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
89
|
+
version: '2.0'
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
96
|
+
version: '2.0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: bundler
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -285,6 +285,7 @@ files:
|
|
|
285
285
|
- share/init-site/usmu.yml
|
|
286
286
|
- spec/acceptance/full_site_build.feature
|
|
287
287
|
- spec/acceptance/steps/full_site_build_steps.rb
|
|
288
|
+
- spec/mock/usmu/mock_metadata_configuration.rb
|
|
288
289
|
- spec/mock/usmu/mock_plugin.rb
|
|
289
290
|
- spec/mock/usmu/mock_remote_files.rb
|
|
290
291
|
- spec/spec_helper.rb
|
|
@@ -362,6 +363,7 @@ summary: A static site generator with a web-based frontend for editing.
|
|
|
362
363
|
test_files:
|
|
363
364
|
- spec/acceptance/full_site_build.feature
|
|
364
365
|
- spec/acceptance/steps/full_site_build_steps.rb
|
|
366
|
+
- spec/mock/usmu/mock_metadata_configuration.rb
|
|
365
367
|
- spec/mock/usmu/mock_plugin.rb
|
|
366
368
|
- spec/mock/usmu/mock_remote_files.rb
|
|
367
369
|
- spec/spec_helper.rb
|