usmu 1.2.2-java → 1.3.0.dev-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/usmu +0 -0
- data/lib/usmu/configuration.rb +1 -1
- data/lib/usmu/plugin/core.rb +7 -1
- data/lib/usmu/template/static_file.rb +1 -1
- data/lib/usmu/ui/rack_server.rb +7 -3
- data/lib/usmu/version.rb +1 -1
- data/spec/support/shared_layout.rb +10 -0
- data/usmu.gemspec +1 -0
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 955d9867a7340719b187794da38d048e172fc181
|
4
|
+
data.tar.gz: 8041aa24f2ea359222142730769c344a27514fcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fed9c91817e2c52bebea2812cd162847028a89ca171dc5b085885b367b8e084d4ab9a6c4a101f8d6b33ba95c405c17e70cd8366051189cb40effd3956109b4f8
|
7
|
+
data.tar.gz: 3c3cedd5daaf3aa81c49301762fc902aa49158bafdfde4b20d422015693360fd9fb3b2b7a1c72a064b67f3d24aa7ea03ec7e226847d317f48c8cf64a5b42b417
|
data/bin/usmu
CHANGED
File without changes
|
data/lib/usmu/configuration.rb
CHANGED
data/lib/usmu/plugin/core.rb
CHANGED
@@ -77,9 +77,15 @@ module Usmu
|
|
77
77
|
configuration = @ui.configuration
|
78
78
|
@log.info('Starting webserver...')
|
79
79
|
|
80
|
-
|
80
|
+
server = Ui::RackServer.new(configuration)
|
81
|
+
trap :INT do
|
82
|
+
Rack::Handler::WEBrick.shutdown
|
83
|
+
server.shutdown
|
84
|
+
end
|
85
|
+
Rack::Handler::WEBrick.run server,
|
81
86
|
Host: configuration['serve', 'host', default: 'localhost'],
|
82
87
|
Port: configuration['serve', 'port', default: 8080]
|
88
|
+
@log.info('Stopped webserver.')
|
83
89
|
end
|
84
90
|
|
85
91
|
private
|
@@ -35,7 +35,7 @@ module Usmu
|
|
35
35
|
# @param variables [Hash] Variables to be used in the template.
|
36
36
|
# @return [String] The rendered file
|
37
37
|
def render(variables = {})
|
38
|
-
@content || File.read(input_path)
|
38
|
+
@content || File.read(input_path, mode: 'rb')
|
39
39
|
end
|
40
40
|
|
41
41
|
# @!attribute [r] input_path
|
data/lib/usmu/ui/rack_server.rb
CHANGED
@@ -5,21 +5,22 @@ module Usmu
|
|
5
5
|
def initialize(configuration)
|
6
6
|
@log = Logging.logger[self]
|
7
7
|
@configuration = configuration
|
8
|
-
@generator = @configuration.generator
|
9
8
|
@index = configuration['serve', 'index', default: 'index.html']
|
10
9
|
end
|
11
10
|
|
12
11
|
def call(env)
|
12
|
+
generator = @configuration.generator
|
13
|
+
|
13
14
|
path = env['PATH_INFO'][1...env['PATH_INFO'].length]
|
14
15
|
@log.info "Received a request for: #{path}"
|
15
16
|
path = File.join(path, @index) if File.directory? File.join(@configuration.source_path, path)
|
16
17
|
path = path[1...path.length] if path[0] == '/'
|
17
18
|
@log.info "Serving: #{path}"
|
18
19
|
|
19
|
-
valid =
|
20
|
+
valid = generator.renderables.select {|r| r.output_filename == path }
|
20
21
|
|
21
22
|
if valid.length > 0
|
22
|
-
|
23
|
+
generator.refresh
|
23
24
|
page = valid[0]
|
24
25
|
type = case page.output_filename[page.output_filename.rindex('.')...page.output_filename.length]
|
25
26
|
when '.html', '.php'
|
@@ -37,6 +38,9 @@ module Usmu
|
|
37
38
|
['404', {'Content-Type' => 'text/html'}, ['<!DOCTYPE html><h1>File not found.</h1>']]
|
38
39
|
end
|
39
40
|
end
|
41
|
+
|
42
|
+
def shutdown
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
data/lib/usmu/version.rb
CHANGED
@@ -36,6 +36,16 @@ RSpec.shared_examples 'a layout' do
|
|
36
36
|
EOF
|
37
37
|
end
|
38
38
|
|
39
|
+
it 'and rendering two different files with the same name gives different output' do
|
40
|
+
layout = described_class.new(empty_configuration, 'body.slim', {}, 'slim', "html\n body")
|
41
|
+
layout2 = described_class.new(empty_configuration, 'body.slim', {}, 'slim', 'body')
|
42
|
+
|
43
|
+
output = layout.render 'content' => ''
|
44
|
+
output2 = layout2.render 'content' => ''
|
45
|
+
|
46
|
+
expect(output).to_not eq(output2)
|
47
|
+
end
|
48
|
+
|
39
49
|
context 'and when it\'s type' do
|
40
50
|
it 'is invalid' do
|
41
51
|
expect {described_class.new(empty_configuration, 'body.foo', {}, nil, '')}.to raise_error()
|
data/usmu.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_dependency 'deep_merge', '~> 1.0'
|
30
30
|
spec.add_dependency 'commander', '~> 4.2'
|
31
31
|
spec.add_dependency 'logging', '~> 2.0'
|
32
|
+
spec.add_dependency 'json', '~> 1.8'
|
32
33
|
|
33
34
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
34
35
|
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.
|
4
|
+
version: 1.3.0.dev
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Matthew Scharley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slim
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.8'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.8'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: bundler
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -339,12 +353,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
339
353
|
version: '2.0'
|
340
354
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
341
355
|
requirements:
|
342
|
-
- - "
|
356
|
+
- - ">"
|
343
357
|
- !ruby/object:Gem::Version
|
344
|
-
version:
|
358
|
+
version: 1.3.1
|
345
359
|
requirements: []
|
346
360
|
rubyforge_project:
|
347
|
-
rubygems_version: 2.4.
|
361
|
+
rubygems_version: 2.4.5.1
|
348
362
|
signing_key:
|
349
363
|
specification_version: 4
|
350
364
|
summary: A static site generator with a web-based frontend for editing.
|