usmu 1.2.2 → 1.3.0.dev

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fd3da296c75ec27090a515a0d2c1cba18a33a40
4
- data.tar.gz: ef74e9b5e859c7ccd183c59f1a241e406fd8e590
3
+ metadata.gz: b969706a43f9816cdf182e9b9d76c37693928065
4
+ data.tar.gz: 474dbcc925a8e305eff9bcd45085a59ff65d0459
5
5
  SHA512:
6
- metadata.gz: 4797dce796a431c89bf24361b0aad782d28e1d011340a0f7719745cbfabc66c28b37799f79907b080cb6efbfb6f55eab6d575902debeb43674316ff680c23685
7
- data.tar.gz: 433db4d6a99491e0c66a96f4833757da16c560fd6a0e1a41ad6e6f1c93af624e2c9dbe043c2b0b623e84bb3eb3f0acdb1bc6595c5db22c9260caba6a211b4141
6
+ metadata.gz: f3eb6652e45504c6bef59b5f6029262006bd3d7bd86ca2a24251212b7425d92ef0fb44f14248b1dd5c01399507a788112c2aa968618005008be2e0170898d2d3
7
+ data.tar.gz: 26ed816e133d3e17ebd230d465be2d84c70bccabf16e2d857b987f9d9c58643943305b9a28927dead3322799d304a01415ba8ed6433c92906dad69bd1a2f5159
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
data/lib/usmu/version.rb CHANGED
@@ -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()
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.2.2
4
+ version: 1.3.0.dev
5
5
  platform: ruby
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
@@ -353,12 +367,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
353
367
  version: '2.0'
354
368
  required_rubygems_version: !ruby/object:Gem::Requirement
355
369
  requirements:
356
- - - ">="
370
+ - - ">"
357
371
  - !ruby/object:Gem::Version
358
- version: '0'
372
+ version: 1.3.1
359
373
  requirements: []
360
374
  rubyforge_project:
361
- rubygems_version: 2.4.8
375
+ rubygems_version: 2.4.5.1
362
376
  signing_key:
363
377
  specification_version: 4
364
378
  summary: A static site generator with a web-based frontend for editing.