usmu 1.2.2-java → 1.3.0.dev-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81a43dff429f977a6a999c44ae5e535da06493aa
4
- data.tar.gz: ef74e9b5e859c7ccd183c59f1a241e406fd8e590
3
+ metadata.gz: 955d9867a7340719b187794da38d048e172fc181
4
+ data.tar.gz: 8041aa24f2ea359222142730769c344a27514fcd
5
5
  SHA512:
6
- metadata.gz: 5c66ccfce6d102e5d12193ccb48ffada5d40863daa0a8b8ddcc11d9705d09609758f05703abb451e456a710331bcad31e28c79738ce820e11f472a1cf2cd4ea3
7
- data.tar.gz: 433db4d6a99491e0c66a96f4833757da16c560fd6a0e1a41ad6e6f1c93af624e2c9dbe043c2b0b623e84bb3eb3f0acdb1bc6595c5db22c9260caba6a211b4141
6
+ metadata.gz: fed9c91817e2c52bebea2812cd162847028a89ca171dc5b085885b367b8e084d4ab9a6c4a101f8d6b33ba95c405c17e70cd8366051189cb40effd3956109b4f8
7
+ data.tar.gz: 3c3cedd5daaf3aa81c49301762fc902aa49158bafdfde4b20d422015693360fd9fb3b2b7a1c72a064b67f3d24aa7ea03ec7e226847d317f48c8cf64a5b42b417
data/bin/usmu CHANGED
File without changes
@@ -102,7 +102,7 @@ module Usmu
102
102
 
103
103
  # @return [Usmu::SiteGenerator]
104
104
  def generator
105
- @generator ||= SiteGenerator.new(self)
105
+ SiteGenerator.new(self)
106
106
  end
107
107
 
108
108
  private
@@ -77,9 +77,15 @@ module Usmu
77
77
  configuration = @ui.configuration
78
78
  @log.info('Starting webserver...')
79
79
 
80
- Rack::Handler::WEBrick.run Ui::RackServer.new(configuration),
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
@@ -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 = @generator.renderables.select {|r| r.output_filename == path }
20
+ valid = generator.renderables.select {|r| r.output_filename == path }
20
21
 
21
22
  if valid.length > 0
22
- @generator.refresh
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
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Usmu
3
3
  # The current version string for the gem
4
- VERSION = '1.2.2'
4
+ VERSION = '1.3.0.dev'
5
5
  end
@@ -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()
@@ -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.2.2
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: 2015-12-20 00:00:00.000000000 Z
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: '0'
358
+ version: 1.3.1
345
359
  requirements: []
346
360
  rubyforge_project:
347
- rubygems_version: 2.4.8
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.