usmu 0.2.1-java → 0.2.2-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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -22
  3. data/CHANGELOG.md +82 -0
  4. data/README.md +0 -8
  5. data/Rakefile +32 -0
  6. data/bin/usmu +1 -5
  7. data/lib/usmu.rb +5 -3
  8. data/lib/usmu/configuration.rb +13 -1
  9. data/lib/usmu/plugin/core.rb +35 -1
  10. data/lib/usmu/site_generator.rb +13 -13
  11. data/lib/usmu/template/helpers.rb +19 -0
  12. data/lib/usmu/template/include.rb +87 -0
  13. data/lib/usmu/template/layout.rb +198 -0
  14. data/lib/usmu/template/page.rb +22 -0
  15. data/lib/usmu/template/static_file.rb +50 -0
  16. data/lib/usmu/version.rb +1 -1
  17. data/share/init-site/.gitignore +2 -0
  18. data/share/init-site/Gemfile +6 -0
  19. data/share/init-site/layouts/html.slim +8 -0
  20. data/share/init-site/source/index.md +3 -0
  21. data/share/init-site/usmu.yml +3 -0
  22. data/test/expected-site/.dotfiletest.txt +1 -0
  23. data/test/expected-site/default.html +4 -0
  24. data/test/expected-site/embedded.html +7 -0
  25. data/test/expected-site/index.html +4 -0
  26. data/test/site/content/.dotfiletest.txt +1 -0
  27. data/test/site/includes/footer.meta.yml +2 -0
  28. data/test/site/includes/footer.slim +1 -0
  29. data/test/site/layouts/embedded.slim +2 -0
  30. data/test/site/layouts/html.slim +2 -0
  31. data/test/spec/acceptance/full_site_build.feature +7 -2
  32. data/test/spec/acceptance/steps/full_site_build_steps.rb +9 -4
  33. data/test/spec/configuration_spec.rb +35 -14
  34. data/test/spec/site_generator_spec.rb +2 -2
  35. data/test/spec/{layout_spec.rb → template/layout_spec.rb} +4 -4
  36. data/test/spec/{page_spec.rb → template/page_spec.rb} +4 -4
  37. data/test/spec/{static_file_spec.rb → template/static_file_spec.rb} +5 -5
  38. data/usmu-jruby.gemspec +1 -1
  39. data/usmu.gemspec +1 -1
  40. metadata +29 -13
  41. data/lib/usmu/layout.rb +0 -189
  42. data/lib/usmu/page.rb +0 -20
  43. data/lib/usmu/static_file.rb +0 -48
@@ -11,7 +11,7 @@ RSpec.describe Usmu::SiteGenerator do
11
11
 
12
12
  it 'should have a list of renderable items' do
13
13
  expect(generator.respond_to? :renderables).to eq(true)
14
- expect(generator.renderables.map {|r| r.name}.sort).to eq(%w{default.md embedded.md index.md robots.txt})
14
+ expect(generator.renderables.map {|r| r.name}.sort).to eq(%w{.dotfiletest.txt default.md embedded.md index.md robots.txt})
15
15
  end
16
16
 
17
17
  it 'should have pages' do
@@ -21,7 +21,7 @@ RSpec.describe Usmu::SiteGenerator do
21
21
 
22
22
  it 'should have files' do
23
23
  expect(generator.respond_to? :files).to eq(true)
24
- expect(generator.files.map {|f| f.name}.sort).to eq(%w{robots.txt})
24
+ expect(generator.files.map {|f| f.name}.sort).to eq(%w{.dotfiletest.txt robots.txt})
25
25
  end
26
26
 
27
27
  it 'should be able to generate a site' do
@@ -1,18 +1,18 @@
1
1
  require 'support/shared_layout'
2
- require 'usmu/layout'
2
+ require 'usmu/template/layout'
3
3
 
4
- RSpec.describe Usmu::Layout do
4
+ RSpec.describe Usmu::Template::Layout do
5
5
  it_behaves_like 'an embeddable layout'
6
6
 
7
7
  let(:configuration) { Usmu::Configuration.from_hash({}) }
8
8
 
9
9
  it 'uses the \'layouts\' folder' do
10
- layout = Usmu::Layout.new(configuration, 'html.slim', 'slim', "head\nbody", {})
10
+ layout = Usmu::Template::Layout.new(configuration, 'html.slim', 'slim', "head\nbody", {})
11
11
  expect(layout.send :content_path).to eq('layouts')
12
12
  end
13
13
 
14
14
  it 'has an input path' do
15
- layout = Usmu::Layout.new(configuration, 'html.slim', 'slim', "head\nbody", {})
15
+ layout = Usmu::Template::Layout.new(configuration, 'html.slim', 'slim', "head\nbody", {})
16
16
  expect(layout.respond_to? :input_path).to eq(true)
17
17
  expect(layout.input_path).to eq('layouts/html.slim')
18
18
  end
@@ -1,18 +1,18 @@
1
1
  require 'support/shared_layout'
2
- require 'usmu/page'
2
+ require 'usmu/template/page'
3
3
 
4
- RSpec.describe Usmu::Page do
4
+ RSpec.describe Usmu::Template::Page do
5
5
  it_behaves_like 'an embeddable layout'
6
6
 
7
7
  let(:configuration) { Usmu::Configuration.from_hash({}) }
8
8
 
9
9
  it 'uses the \'source\' folder' do
10
- page = Usmu::Page.new(configuration, 'index.md', 'md', '# test', {})
10
+ page = Usmu::Template::Page.new(configuration, 'index.md', 'md', '# test', {})
11
11
  expect(page.send :content_path).to eq('src')
12
12
  end
13
13
 
14
14
  it 'has an input path' do
15
- page = Usmu::Page.new(configuration, 'index.md', 'md', '# test', {})
15
+ page = Usmu::Template::Page.new(configuration, 'index.md', 'md', '# test', {})
16
16
  expect(page.respond_to? :input_path).to eq(true)
17
17
  expect(page.input_path).to eq('src/index.md')
18
18
  end
@@ -1,26 +1,26 @@
1
1
  require 'support/shared_layout'
2
- require 'usmu/static_file'
2
+ require 'usmu/template/static_file'
3
3
 
4
- RSpec.describe Usmu::StaticFile do
4
+ RSpec.describe Usmu::Template::StaticFile do
5
5
  it_behaves_like 'a renderable file'
6
6
 
7
7
  let(:configuration) { Usmu::Configuration.from_file('test/site/usmu.yml') }
8
8
 
9
9
  it 'uses the \'source\' folder' do
10
- file = Usmu::StaticFile.new(configuration, 'robots.txt')
10
+ file = Usmu::Template::StaticFile.new(configuration, 'robots.txt')
11
11
  rendered = file.render
12
12
  expect(rendered).to eq(File.read('test/expected-site/robots.txt'))
13
13
  end
14
14
 
15
15
  it 'has an input path' do
16
16
  configuration = Usmu::Configuration.from_hash({})
17
- page = Usmu::StaticFile.new(configuration, 'robots.txt', 'txt', '', {})
17
+ page = Usmu::Template::StaticFile.new(configuration, 'robots.txt', 'txt', '', {})
18
18
  expect(page.respond_to? :input_path).to eq(true)
19
19
  expect(page.input_path).to eq('src/robots.txt')
20
20
  end
21
21
 
22
22
  it 'has an output filename that matches input' do
23
- file = Usmu::StaticFile.new(configuration, 'robots.txt')
23
+ file = Usmu::Template::StaticFile.new(configuration, 'robots.txt')
24
24
  expect(file.output_filename).to eq('robots.txt')
25
25
  end
26
26
  end
data/usmu-jruby.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_dependency 'slim', '~> 2.1'
25
+ spec.add_dependency 'slim', '~> 3.0'
26
26
  spec.add_dependency 'tilt', '~> 2.0'
27
27
  spec.add_dependency 'kramdown', '~> 1.5'
28
28
  spec.add_dependency 'deep_merge', '~> 1.0'
data/usmu.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'slim', '~> 2.1'
24
+ spec.add_dependency 'slim', '~> 3.0'
25
25
  spec.add_dependency 'tilt', '~> 2.0'
26
26
  spec.add_dependency 'redcarpet', '~> 3.2', '>= 3.2.1'
27
27
  spec.add_dependency 'deep_merge', '~> 1.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: 0.2.1
4
+ version: 0.2.2
5
5
  platform: java
6
6
  authors:
7
7
  - Matthew Scharley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2014-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slim
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.1'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tilt
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -236,6 +236,7 @@ files:
236
236
  - ".simplecov"
237
237
  - ".travis.yml"
238
238
  - ".yardopts"
239
+ - CHANGELOG.md
239
240
  - CONTRIBUTING.md
240
241
  - Gemfile
241
242
  - Gemfile-jruby
@@ -247,25 +248,36 @@ files:
247
248
  - cucumber.yml
248
249
  - lib/usmu.rb
249
250
  - lib/usmu/configuration.rb
250
- - lib/usmu/layout.rb
251
- - lib/usmu/page.rb
252
251
  - lib/usmu/plugin.rb
253
252
  - lib/usmu/plugin/core.rb
254
253
  - lib/usmu/site_generator.rb
255
- - lib/usmu/static_file.rb
254
+ - lib/usmu/template/helpers.rb
255
+ - lib/usmu/template/include.rb
256
+ - lib/usmu/template/layout.rb
257
+ - lib/usmu/template/page.rb
258
+ - lib/usmu/template/static_file.rb
256
259
  - lib/usmu/ui.rb
257
260
  - lib/usmu/ui/console.rb
258
261
  - lib/usmu/version.rb
262
+ - share/init-site/.gitignore
263
+ - share/init-site/Gemfile
264
+ - share/init-site/layouts/html.slim
265
+ - share/init-site/source/index.md
266
+ - share/init-site/usmu.yml
267
+ - test/expected-site/.dotfiletest.txt
259
268
  - test/expected-site/default.html
260
269
  - test/expected-site/embedded.html
261
270
  - test/expected-site/index.html
262
271
  - test/expected-site/robots.txt
272
+ - test/site/content/.dotfiletest.txt
263
273
  - test/site/content/default.md
264
274
  - test/site/content/embedded.md
265
275
  - test/site/content/embedded.meta.yml
266
276
  - test/site/content/index.md
267
277
  - test/site/content/index.meta.yml
268
278
  - test/site/content/robots.txt
279
+ - test/site/includes/footer.meta.yml
280
+ - test/site/includes/footer.slim
269
281
  - test/site/layouts/embedded.meta.yml
270
282
  - test/site/layouts/embedded.slim
271
283
  - test/site/layouts/html.meta.yml
@@ -274,15 +286,15 @@ files:
274
286
  - test/spec/acceptance/full_site_build.feature
275
287
  - test/spec/acceptance/steps/full_site_build_steps.rb
276
288
  - test/spec/configuration_spec.rb
277
- - test/spec/layout_spec.rb
278
289
  - test/spec/mock/usmu/mock_plugin.rb
279
- - test/spec/page_spec.rb
280
290
  - test/spec/plugin/core_spec.rb
281
291
  - test/spec/plugin_spec.rb
282
292
  - test/spec/site_generator_spec.rb
283
293
  - test/spec/spec_helper.rb
284
- - test/spec/static_file_spec.rb
285
294
  - test/spec/support/shared_layout.rb
295
+ - test/spec/template/layout_spec.rb
296
+ - test/spec/template/page_spec.rb
297
+ - test/spec/template/static_file_spec.rb
286
298
  - test/spec/ui/console_spec.rb
287
299
  - usmu-jruby.gemspec
288
300
  - usmu.gemspec
@@ -311,16 +323,20 @@ signing_key:
311
323
  specification_version: 4
312
324
  summary: A static site generator with a web-based frontend for editing.
313
325
  test_files:
326
+ - test/expected-site/.dotfiletest.txt
314
327
  - test/expected-site/default.html
315
328
  - test/expected-site/embedded.html
316
329
  - test/expected-site/index.html
317
330
  - test/expected-site/robots.txt
331
+ - test/site/content/.dotfiletest.txt
318
332
  - test/site/content/default.md
319
333
  - test/site/content/embedded.md
320
334
  - test/site/content/embedded.meta.yml
321
335
  - test/site/content/index.md
322
336
  - test/site/content/index.meta.yml
323
337
  - test/site/content/robots.txt
338
+ - test/site/includes/footer.meta.yml
339
+ - test/site/includes/footer.slim
324
340
  - test/site/layouts/embedded.meta.yml
325
341
  - test/site/layouts/embedded.slim
326
342
  - test/site/layouts/html.meta.yml
@@ -329,14 +345,14 @@ test_files:
329
345
  - test/spec/acceptance/full_site_build.feature
330
346
  - test/spec/acceptance/steps/full_site_build_steps.rb
331
347
  - test/spec/configuration_spec.rb
332
- - test/spec/layout_spec.rb
333
348
  - test/spec/mock/usmu/mock_plugin.rb
334
- - test/spec/page_spec.rb
335
349
  - test/spec/plugin/core_spec.rb
336
350
  - test/spec/plugin_spec.rb
337
351
  - test/spec/site_generator_spec.rb
338
352
  - test/spec/spec_helper.rb
339
- - test/spec/static_file_spec.rb
340
353
  - test/spec/support/shared_layout.rb
354
+ - test/spec/template/layout_spec.rb
355
+ - test/spec/template/page_spec.rb
356
+ - test/spec/template/static_file_spec.rb
341
357
  - test/spec/ui/console_spec.rb
342
358
  has_rdoc:
data/lib/usmu/layout.rb DELETED
@@ -1,189 +0,0 @@
1
- require 'tilt'
2
- require 'deep_merge'
3
- require 'usmu/static_file'
4
-
5
- module Usmu
6
- # Class to represent files templated with a Tilt library. Most of the custom rendering logic is contained here.
7
- class Layout < StaticFile
8
- # @!attribute [r] type
9
- # @return [String] the type of file this is. This is used to determine which template engine to use.
10
- attr_reader :type
11
-
12
- # @param configuration [Usmu::Configuration] The configuration for the website we're generating.
13
- # @param name [String] The name of the file in the source directory.
14
- # @param type [String] The type of template to use with the file. Used for testing purposes.
15
- # @param content [String] The content of the file. Used for testing purposes.
16
- # @param metadata [String] The metadata for the file. Used for testing purposes.
17
- def initialize(configuration, name, type = nil, content = nil, metadata = nil)
18
- super(configuration, name)
19
-
20
- if type.nil?
21
- type = name.split('.').last
22
- unless ::Tilt.default_mapping[type]
23
- raise "Templates of type '#{type}' aren't currently supported by Tilt. " +
24
- 'Do you have the required gem installed?'
25
- end
26
- end
27
- @type = type
28
- path = File.join("#{content_path}", "#{name[0, name.length - type.length - 1]}")
29
-
30
- if content.nil?
31
- content = File.read("#{path}.#{type}")
32
- end
33
- @content = content
34
-
35
- if metadata.nil?
36
- meta_file = "#{path}.meta.yml"
37
- metadata = if File.exist? meta_file
38
- YAML.load_file(meta_file)
39
- else
40
- {}
41
- end
42
- end
43
- @metadata = metadata
44
-
45
- @parent = nil
46
- @parent = Layout.find_layout(configuration, self.metadata['layout'])
47
- end
48
-
49
- # @!attribute [r] metadata
50
- # @return [Hash] the metadata associated with this layout.
51
- #
52
- # Returns the metadata associated with this layout.
53
- #
54
- # This will include any metadata from parent templates and default metadata
55
- def metadata
56
- if @parent.nil?
57
- (@configuration['default meta'] || {}).dup.deep_merge!(@metadata)
58
- else
59
- @parent.metadata.deep_merge!(@metadata)
60
- end
61
- end
62
-
63
- # Renders the file with any templating language required and returns the result
64
- #
65
- # @param variables [Hash] Variables to be used in the template.
66
- # @return [String] The rendered file.
67
- def render(variables = {})
68
- content = template_class.new("#{@name}.#{@type}", 1, @configuration[provider_name]) { @content }.
69
- render(nil, get_variables(variables))
70
- has_cr = content.index("\r")
71
- content += (has_cr ? "\r\n" : "\n") if content[-1] != "\n"
72
- if @parent.nil?
73
- content
74
- else
75
- @parent.render({'content' => content})
76
- end
77
- end
78
-
79
- # @!attribute [r] input_path
80
- # @return [String] the full path to the file in the source directory
81
- def input_path
82
- File.join(content_path, @name)
83
- end
84
-
85
- # @!attribute [r] output_extension
86
- # @return [String] the extension to use with the output file.
87
- def output_extension
88
- case @type
89
- when 'erb', 'rhtml', 'erubis', 'liquid'
90
- nil
91
- when 'coffee'
92
- 'js'
93
- when 'less', 'sass', 'scss'
94
- 'css'
95
- else
96
- 'html'
97
- end
98
- end
99
-
100
- # @!attribute [r] output_filename
101
- # @return [String] the filename to use in the output directory.
102
- #
103
- # Returns the filename to use for the output directory with any modifications to the input filename required.
104
- def output_filename
105
- if output_extension
106
- @name[0..@name.rindex('.')] + output_extension
107
- else
108
- @name[0..@name.rindex('.') - 1]
109
- end
110
- end
111
-
112
- # Static method to create a layout for a given configuration by it's name if it exists. This differs from
113
- # `#initialise` in that it allows different types of values to be supplied as the name and will not fail if name
114
- # is nil
115
- #
116
- # @param configuration [Usmu::Configuration] The configuration to use for the search
117
- # @param name [String]
118
- # If name is a string then search for a template with that name. Name here should not include
119
- # file extension, eg. body not body.slim. If name is not a string then it will be returned verbatim. This means
120
- # that name is nilable and can also be passed in as an Usmu::Layout already for testing purposes.
121
- # @return [Usmu::Layout]
122
- def self.find_layout(configuration, name)
123
- if name === 'none'
124
- nil
125
- elsif name.class.name == 'String'
126
- Dir["#{configuration.layouts_path}/#{name}.*"].each do |f|
127
- filename = File.basename(f)
128
- if filename != "#{name}.meta.yml"
129
- return new(configuration, f[(configuration.layouts_path.length + 1)..f.length])
130
- end
131
- end
132
- nil
133
- else
134
- name
135
- end
136
- end
137
-
138
- # Tests if a given file is a valid Tilt template based on the filename.
139
- #
140
- # @param folder_type [String]
141
- # One of `"source"` or `"layout"` depending on where the template is in the source tree.
142
- # Not used by Usmu::Layout directly but intended to be available for future API.
143
- # @param name [String] The filename to be tested.
144
- # @return [Boolean]
145
- def self.is_valid_file?(folder_type, name)
146
- type = name.split('.').last
147
- ::Tilt.default_mapping[type] ? true : false
148
- end
149
-
150
- protected
151
-
152
- # @!attribute [r] template_class
153
- # @return [Tilt::Template] the Tilt template engine for this layout
154
- def template_class
155
- @template_class ||= ::Tilt.default_mapping[@type]
156
- end
157
-
158
- # @!attribute [r] provider_name
159
- # @return [String] the Tilt template engine's name for this layout
160
- #
161
- # Returns the Tilt template engine's name for this layout.
162
- #
163
- # This is used to determine which settings to use from the configuration file.
164
- def provider_name
165
- Tilt.default_mapping.lazy_map[@type].select {|x| x[0] == template_class.name }.first[1].split('/').last
166
- end
167
-
168
- # @!attribute [r] content_path
169
- # @return [string] the base path to the files used by this class.
170
- #
171
- # Returns the base path to the files used by this class.
172
- #
173
- # This folder should be the parent folder for the file named by the name attribute.
174
- #
175
- # @see #name
176
- def content_path
177
- @configuration.layouts_path
178
- end
179
-
180
- private
181
-
182
- # Utility function which collates variables to pass to the template engine.
183
- #
184
- # @return [Hash]
185
- def get_variables(variables)
186
- {site: @configuration}.deep_merge!(metadata).deep_merge!(variables)
187
- end
188
- end
189
- end
data/lib/usmu/page.rb DELETED
@@ -1,20 +0,0 @@
1
- require 'usmu/layout'
2
-
3
- module Usmu
4
- # Represents a page in the source directory of the website.
5
- class Page < Layout
6
- protected
7
-
8
- # @!attribute [r] content_path
9
- # @return [string] the base path to the files used by this class.
10
- #
11
- # Returns the base path to the files used by this class.
12
- #
13
- # This folder should be the parent folder for the file named by the name attribute.
14
- #
15
- # @see #name
16
- def content_path
17
- @configuration.source_path
18
- end
19
- end
20
- end