roger 1.5.0 → 1.6.0
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 +5 -13
- data/CHANGELOG.md +8 -0
- data/examples/default_template/Gemfile +1 -1
- data/lib/roger/release/finalizers/git_branch.rb +2 -2
- data/lib/roger/resolver.rb +8 -6
- data/lib/roger/template/helpers/capture.rb +9 -0
- data/lib/roger/testing/mock_project.rb +5 -1
- data/lib/roger/testing/mock_shell.rb +18 -0
- data/lib/roger/version.rb +1 -1
- data/test/project/html/formats/same/.gitkeep +0 -0
- data/test/project/html/formats/same.html +0 -0
- data/test/unit/renderer/renderer_content_for_test.rb +16 -0
- data/test/unit/resolver_test.rb +8 -0
- metadata +14 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MjRlNGI2OWY2NTJmY2YxMTMyYjdkYzUyZTljN2Q5MTk1NGMxNWJhNg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9aa7b1fae76209ccfb5300d71b9bfc1c0a2c4ec7
|
4
|
+
data.tar.gz: d8ba78beae86ccad4f13c897dcad096c3e909c8e
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YjdlMDZhY2VhZjFjNDBmMTVhNDQ1YzhkOTg2MjEyZGQ5ZjA4N2M3NGY5YjVl
|
11
|
-
N2YyNDM5NTUyNmZmZTk2ODQyZDE3ZDcyNmQ2MTcxZjVhMDUzMWU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZTcxYWI2MGJlMWU0YTZmYTVmNjAxMDdiOGE1MzAxYzI0ZTFjZmFhMWY1MmQ1
|
14
|
-
YmRhNzMzMjczZDA1NTJiOTY1MjEwN2NhZGVlY2QwYjE1MDVjZWVhYTBmMWJi
|
15
|
-
ODAxZTFmNjNhYzQwMjc0MmYyMjMzNGJlMmJiNjU0NTVmNmRiZTU=
|
6
|
+
metadata.gz: 4c153e06e6af491d328830095840778aad088ef65141369d9066c41cfc1e7ec5c9da1092994e0010f770e7db41f50e053476ddd019741c2e00eaba37d6447c4f
|
7
|
+
data.tar.gz: f6edd854bc25ef440f412eb23cdd4157b9fedf10859f1d68cdcfab8a4b5cf70efdd9e444460dddf9adb9a21d6a5b609d2d16c892363442cb599215a32c6d7d2c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Version 1.6.0
|
4
|
+
* Change the way template resolving works so if you have a file and directory with the same basename it will prefer to use the file instead of looking for name/index.xyz
|
5
|
+
* Add `content_for?(:xyz)` helper so you can check if a `content_for` block exists in templates.
|
6
|
+
* Fix bug with resolving of trailing slashes.
|
7
|
+
|
8
|
+
## Version 1.5.1
|
9
|
+
* Add MockShell object to stub out shell interactions. MockShell is also used by MockProject. This means all tests are silent on STDOUT/STDERR now.
|
10
|
+
|
3
11
|
## Version 1.5.0
|
4
12
|
* Roger won't be tested on Ruby 1.9.x anymore
|
5
13
|
* The way we render templates has been revamped. It is now possible to have multi-pass templates so you can do `.md.erb` which will first be processed by `erb` and then by the `md` tilt template handler.
|
@@ -39,7 +39,7 @@ module Roger::Release::Finalizers
|
|
39
39
|
|
40
40
|
release.log(self, "Working git magic in #{clone_dir}")
|
41
41
|
|
42
|
-
commit_and_push_release(clone_dir, release, @options)
|
42
|
+
commit_and_push_release(clone_dir, release, branch, @options)
|
43
43
|
|
44
44
|
if @options[:cleanup]
|
45
45
|
FileUtils.rm_rf(tmp_dir)
|
@@ -50,7 +50,7 @@ module Roger::Release::Finalizers
|
|
50
50
|
|
51
51
|
protected
|
52
52
|
|
53
|
-
def commit_and_push_release(clone_dir, release, options)
|
53
|
+
def commit_and_push_release(clone_dir, release, branch, options)
|
54
54
|
::Dir.chdir(clone_dir) do
|
55
55
|
# 3. Copy changes
|
56
56
|
FileUtils.rm_rf("*")
|
data/lib/roger/resolver.rb
CHANGED
@@ -135,8 +135,13 @@ module Roger
|
|
135
135
|
|
136
136
|
results = filter_files(files, path, path_without_extension, template_extensions)
|
137
137
|
|
138
|
-
|
139
|
-
|
138
|
+
if !results[0]
|
139
|
+
# No results found, but maybe there is a directory
|
140
|
+
# with the same name and it contains an index.XYZ
|
141
|
+
find_template_path(File.join(name, "index")) if File.directory?(name)
|
142
|
+
else
|
143
|
+
Pathname.new(results[0])
|
144
|
+
end
|
140
145
|
end
|
141
146
|
|
142
147
|
# Filter a list of files to see wether or not we can process them.
|
@@ -175,9 +180,6 @@ module Roger
|
|
175
180
|
def sanitize_name(name, prefer = nil)
|
176
181
|
path = name.to_s
|
177
182
|
|
178
|
-
# If it's a directory append "index"
|
179
|
-
path = File.join(path, "index") if File.directory?(name)
|
180
|
-
|
181
183
|
# Check if we haven't got an extension
|
182
184
|
# we'll assume you're looking for prefer or "html" otherwise
|
183
185
|
path += ".#{prefer || 'html'}" unless File.basename(path).include?(".")
|
@@ -188,7 +190,7 @@ module Roger
|
|
188
190
|
# Split path in to extension an path without extension
|
189
191
|
def split_path(path)
|
190
192
|
path = path.to_s
|
191
|
-
extension = File.extname(path)[1..-1]
|
193
|
+
extension = File.extname(path)[1..-1] || ""
|
192
194
|
path_without_extension = path.sub(/\.#{Regexp.escape(extension)}\Z/, "")
|
193
195
|
[extension, path_without_extension]
|
194
196
|
end
|
@@ -25,6 +25,15 @@ module Roger
|
|
25
25
|
@_content_for_blocks[block_name] = capture(&block)
|
26
26
|
end
|
27
27
|
|
28
|
+
# Check if a block will yield content
|
29
|
+
#
|
30
|
+
# ```
|
31
|
+
# <% if content_for? :name %> bla bla <% end %>
|
32
|
+
# ```
|
33
|
+
def content_for?(block_name)
|
34
|
+
(!_content_for_blocks[block_name].nil? && !_content_for_blocks[block_name].empty?)
|
35
|
+
end
|
36
|
+
|
28
37
|
# rubocop:disable Lint/Eval
|
29
38
|
def capture(&block)
|
30
39
|
unless template.current_tilt_template == Tilt::ERBTemplate
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../project"
|
2
|
+
require File.dirname(__FILE__) + "/mock_shell"
|
2
3
|
require "test_construct"
|
3
4
|
|
4
5
|
module Roger
|
@@ -30,7 +31,6 @@ module Roger
|
|
30
31
|
construct.directory dir
|
31
32
|
end
|
32
33
|
end
|
33
|
-
|
34
34
|
# Call super to initialize
|
35
35
|
super(path, config)
|
36
36
|
end
|
@@ -39,6 +39,10 @@ module Roger
|
|
39
39
|
def destroy
|
40
40
|
teardown_construct(construct) if construct
|
41
41
|
end
|
42
|
+
|
43
|
+
def shell
|
44
|
+
@shell ||= MockShell.new
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "stringio"
|
2
|
+
|
3
|
+
module Roger
|
4
|
+
# A shell that does not output to stdout but will
|
5
|
+
# just have two StringIO objects which can be accessed by using
|
6
|
+
# #stdout and #stderr methods.
|
7
|
+
class MockShell < Thor::Shell::Basic
|
8
|
+
public :stdout, :stderr
|
9
|
+
|
10
|
+
def stdout
|
11
|
+
@_stdout ||= StringIO.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def stderr
|
15
|
+
@_stderr ||= StringIO.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/roger/version.rb
CHANGED
File without changes
|
File without changes
|
@@ -46,5 +46,21 @@ module Roger
|
|
46
46
|
|
47
47
|
assert_equal "BAB-CONTENT-A", @renderer.render(@source_path, source: template_string)
|
48
48
|
end
|
49
|
+
|
50
|
+
def test_content_for_check
|
51
|
+
# Is false when undefined
|
52
|
+
template = 'B<% if content_for? :one %><%= "one" %><% end %>A'
|
53
|
+
assert_equal "BA", @renderer.render(@source_path, source: template)
|
54
|
+
|
55
|
+
# Is false when empty
|
56
|
+
template = "<% content_for :one do %><% end %>"
|
57
|
+
template << 'B<% if content_for? :one %><%= "one" %><% end %>A'
|
58
|
+
assert_equal "BA", @renderer.render(@source_path, source: template)
|
59
|
+
|
60
|
+
# Is true when set
|
61
|
+
template = "<% content_for :one do %>one<% end %>"
|
62
|
+
template << "B<% if content_for? :one %><%= yield(:one) %><% end %>A"
|
63
|
+
assert_equal "BoneA", @renderer.render(@source_path, source: template)
|
64
|
+
end
|
49
65
|
end
|
50
66
|
end
|
data/test/unit/resolver_test.rb
CHANGED
@@ -76,6 +76,10 @@ module Roger
|
|
76
76
|
)
|
77
77
|
end
|
78
78
|
|
79
|
+
def test_trailing_slashes_break
|
80
|
+
assert !@resolver.url_to_relative_url("/de/", "/")
|
81
|
+
end
|
82
|
+
|
79
83
|
def test_path_to_url_relative_to_absolute_path
|
80
84
|
assert_equal(
|
81
85
|
@resolver.path_to_url(
|
@@ -85,6 +89,10 @@ module Roger
|
|
85
89
|
"../formats/erb.html.erb"
|
86
90
|
)
|
87
91
|
end
|
92
|
+
|
93
|
+
def test_return_filepath_when_dirname_and_filename_are_same
|
94
|
+
assert_find "formats/same.html", "formats/same"
|
95
|
+
end
|
88
96
|
end
|
89
97
|
|
90
98
|
# Test resolver with multiple load paths
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flurin Egger
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
name: rack
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - '>='
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: 1.0.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - '>='
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 1.0.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
name: redcarpet
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - '>='
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: 3.1.1
|
92
92
|
type: :runtime
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: 3.1.1
|
99
99
|
- !ruby/object:Gem::Dependency
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- lib/roger/test.rb
|
257
257
|
- lib/roger/testing/mock_project.rb
|
258
258
|
- lib/roger/testing/mock_release.rb
|
259
|
+
- lib/roger/testing/mock_shell.rb
|
259
260
|
- lib/roger/version.rb
|
260
261
|
- roger.gemspec
|
261
262
|
- test/helpers/cli.rb
|
@@ -271,6 +272,8 @@ files:
|
|
271
272
|
- test/project/html/formats/markdown.md
|
272
273
|
- test/project/html/formats/preferred.html.erb
|
273
274
|
- test/project/html/formats/preferred.json.erb
|
275
|
+
- test/project/html/formats/same.html
|
276
|
+
- test/project/html/formats/same/.gitkeep
|
274
277
|
- test/project/html/front_matter/erb.html.erb
|
275
278
|
- test/project/html/front_matter/markdown.md
|
276
279
|
- test/project/html/layouts/content-for.html.erb
|
@@ -346,17 +349,17 @@ require_paths:
|
|
346
349
|
- lib
|
347
350
|
required_ruby_version: !ruby/object:Gem::Requirement
|
348
351
|
requirements:
|
349
|
-
- -
|
352
|
+
- - '>='
|
350
353
|
- !ruby/object:Gem::Version
|
351
354
|
version: '0'
|
352
355
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
353
356
|
requirements:
|
354
|
-
- -
|
357
|
+
- - '>='
|
355
358
|
- !ruby/object:Gem::Version
|
356
359
|
version: '0'
|
357
360
|
requirements: []
|
358
361
|
rubyforge_project:
|
359
|
-
rubygems_version: 2.
|
362
|
+
rubygems_version: 2.2.2
|
360
363
|
signing_key:
|
361
364
|
specification_version: 4
|
362
365
|
summary: Roger is a set of tools to create self-containing HTML mockups.
|
@@ -374,6 +377,8 @@ test_files:
|
|
374
377
|
- test/project/html/formats/markdown.md
|
375
378
|
- test/project/html/formats/preferred.html.erb
|
376
379
|
- test/project/html/formats/preferred.json.erb
|
380
|
+
- test/project/html/formats/same.html
|
381
|
+
- test/project/html/formats/same/.gitkeep
|
377
382
|
- test/project/html/front_matter/erb.html.erb
|
378
383
|
- test/project/html/front_matter/markdown.md
|
379
384
|
- test/project/html/layouts/content-for.html.erb
|