octopress-ink 1.0.0.rc.11 → 1.0.0.rc.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +12 -3
- data/assets/docs/creating-a-plugin.markdown +85 -23
- data/assets/docs/plugin-reference.markdown +1 -1
- data/assets/docs/working-with-plugins.markdown +188 -0
- data/lib/octopress-ink.rb +40 -93
- data/lib/octopress-ink/assets/asset.rb +8 -10
- data/lib/octopress-ink/assets/doc_page.rb +3 -6
- data/lib/octopress-ink/assets/file.rb +2 -2
- data/lib/octopress-ink/assets/layout.rb +1 -1
- data/lib/octopress-ink/assets/page.rb +17 -4
- data/lib/octopress-ink/assets/sass.rb +1 -1
- data/lib/octopress-ink/commands/helpers.rb +1 -1
- data/lib/octopress-ink/commands/list.rb +1 -1
- data/lib/octopress-ink/commands/new.rb +1 -4
- data/lib/octopress-ink/configuration.rb +10 -27
- data/lib/octopress-ink/jekyll/hooks.rb +23 -149
- data/lib/octopress-ink/jekyll/page.rb +12 -0
- data/lib/octopress-ink/plugin.rb +1 -1
- data/lib/octopress-ink/plugin_asset_pipeline.rb +4 -5
- data/lib/octopress-ink/plugins.rb +5 -5
- data/lib/octopress-ink/tags.rb +0 -11
- data/lib/octopress-ink/version.rb +1 -1
- data/octopress-ink.gemspec +7 -5
- data/test/.clash.yml +46 -0
- data/test/Gemfile +1 -3
- data/test/_config.yml +7 -6
- data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/awesome-sauce/plugin-media-test.css +0 -0
- data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/awesome-sauce/plugin-test.css +0 -0
- data/test/_expected/combine_css_false/theme/main.css +2 -0
- data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/theme/theme-media-test.css +0 -0
- data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/theme/theme-test.css +0 -0
- data/test/{combine_css_false/stylesheets → _expected/combine_css_false}/theme/theme-test2.css +0 -0
- data/test/{combine_js_false/javascripts → _expected/combine_js_false}/theme/bar.js +0 -0
- data/test/{combine_js_false/javascripts → _expected/combine_js_false}/theme/blah.js +0 -0
- data/test/{combine_js_false/javascripts → _expected/combine_js_false}/theme/foo.js +0 -0
- data/test/{compress_false → _expected/compress_false}/javascripts/all-.js +0 -0
- data/test/{compress_false → _expected/compress_false}/stylesheets/all-.css +1 -1
- data/test/{compress_false → _expected/compress_false}/stylesheets/print-.css +0 -0
- data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/layouts/default.html +0 -0
- data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/layouts/test.html +0 -0
- data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/disable-test.html +0 -0
- data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/four.xml +0 -0
- data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/one.xml +0 -0
- data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/three.md +1 -1
- data/test/{copy_layouts_pages/_copy → _expected/copy_layouts_pages}/pages/two.md +0 -0
- data/test/{plugins/test-theme → _expected/copy_test}/config.yml +3 -0
- data/test/{copy_test/_copy → _expected/copy_test}/files/disabled-file.txt +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/files/favicon.ico +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/files/favicon.png +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/files/test.html +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/fonts/font-one.otf +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/fonts/font-two.ttf +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/includes/bar.html +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/includes/greet.html +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/javascripts/bar.js +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/javascripts/blah.coffee +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/javascripts/disable-this.js +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/javascripts/foo.js +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/layouts/default.html +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/layouts/test.html +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/pages/disable-test.html +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/pages/four.xml +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/pages/one.xml +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/pages/three.md +1 -1
- data/test/{copy_test/_copy → _expected/copy_test}/pages/two.md +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/_colors.scss +0 -0
- data/test/_expected/copy_test/stylesheets/disable-this.css +1 -0
- data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/disable.sass +0 -0
- data/test/_expected/copy_test/stylesheets/main.scss +5 -0
- data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/theme-media-test@print.css +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/theme-test.css +0 -0
- data/test/{copy_test/_copy → _expected/copy_test}/stylesheets/theme-test2.css +0 -0
- data/test/{expected → _expected/site}/2014/02/01/test-post.html +0 -0
- data/test/{expected → _expected/site}/2014/02/02/test-post-2.html +0 -0
- data/test/{expected → _expected/site}/favicon.ico +0 -0
- data/test/{expected → _expected/site}/favicon.png +0 -0
- data/test/{expected → _expected/site}/four/index.xml +0 -0
- data/test/_expected/site/index.html +15 -0
- data/test/{expected → _expected/site}/javascripts/all-.js +0 -0
- data/test/{expected → _expected/site}/robots.txt +0 -0
- data/test/_expected/site/stylesheets/all-.css +1 -0
- data/test/{expected → _expected/site}/stylesheets/print-.css +0 -0
- data/test/{expected → _expected/site}/test.html +0 -0
- data/test/{expected → _expected/site}/test_config/plugin_config.html +0 -0
- data/test/{expected → _expected/site}/test_config/theme_config.html +0 -0
- data/test/{expected → _expected/site}/test_layouts/local.html +0 -0
- data/test/{expected → _expected/site}/test_layouts/plugin_layout.html +0 -0
- data/test/{expected → _expected/site}/test_layouts/test_markdown.html +0 -0
- data/test/{expected → _expected/site}/test_layouts/theme.html +0 -0
- data/test/{expected → _expected/site}/test_layouts/theme_override.html +0 -0
- data/test/{expected → _expected/site}/test_pages/feed/index.xml +0 -0
- data/test/{expected → _expected/site}/test_pages/plugin_page.html +0 -0
- data/test/{expected → _expected/site}/test_pages/plugin_page_override.html +0 -0
- data/test/{expected → _expected/site}/test_pages/theme_page.html +0 -0
- data/test/_expected/site/test_pages/three.html +13 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/.gitignore +0 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/Gemfile +0 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/LICENSE.txt +0 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/README.md +0 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/Rakefile +0 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/assets/config.yml +0 -0
- data/test/_expected/test-plugin-expected/demo/Gemfile +3 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/demo/_config.yml +0 -0
- data/test/{plugins/awesome-sauce/docs → _expected/test-plugin-expected/demo}/index.html +0 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/lib/test-plugin.rb +0 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/lib/test-plugin/version.rb +0 -0
- data/test/{test-plugin-expected → _expected/test-plugin-expected}/test-plugin.gemspec +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/.gitignore +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/Gemfile +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/LICENSE.txt +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/README.md +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/Rakefile +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/assets/config.yml +0 -0
- data/test/_expected/test-theme-expected/demo/Gemfile +3 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/demo/_config.yml +0 -0
- data/test/{test-plugin-expected → _expected/test-theme-expected}/demo/index.html +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/lib/test-theme.rb +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/lib/test-theme/version.rb +0 -0
- data/test/{test-theme-expected → _expected/test-theme-expected}/test-theme.gemspec +0 -0
- data/test/{uglify_js_false/javascripts → _expected/uglify_js_false}/all-.js +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/config.yml +0 -0
- data/test/{test-theme-expected/demo → _ink_plugins/awesome-sauce/docs}/index.html +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/files/robots.txt +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/includes/some-include.html +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/layouts/test-layout.html +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/pages/a.html +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/pages/b.html +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/plugin.rb +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/stylesheets/plugin-media-test@print.css +0 -0
- data/test/{plugins → _ink_plugins}/awesome-sauce/stylesheets/plugin-test.css +0 -0
- data/test/{copy_test/_copy → _ink_plugins/test-theme}/config.yml +3 -0
- data/test/{plugins → _ink_plugins}/test-theme/files/disabled-file.txt +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/files/favicon.ico +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/files/favicon.png +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/files/test.html +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/fonts/font-one.otf +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/fonts/font-two.ttf +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/includes/bar.html +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/includes/greet.html +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/javascripts/bar.js +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/javascripts/blah.coffee +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/javascripts/disable-this.js +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/javascripts/foo.js +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/layouts/default.html +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/layouts/test.html +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/pages/disable-test.html +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/pages/four.xml +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/pages/one.xml +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/pages/three.md +1 -1
- data/test/{plugins → _ink_plugins}/test-theme/pages/two.md +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/plugin.rb +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/stylesheets/_colors.scss +0 -0
- data/test/_ink_plugins/test-theme/stylesheets/disable-this.css +1 -0
- data/test/{plugins → _ink_plugins}/test-theme/stylesheets/disable.sass +0 -0
- data/test/_ink_plugins/test-theme/stylesheets/main.scss +5 -0
- data/test/{plugins → _ink_plugins}/test-theme/stylesheets/theme-media-test@print.css +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/stylesheets/theme-test.css +0 -0
- data/test/{plugins → _ink_plugins}/test-theme/stylesheets/theme-test2.css +0 -0
- data/test/_templates/page +4 -0
- data/test/_templates/post +5 -0
- data/test/source/_layouts/local.html +2 -0
- data/test/source/_plugins/loader.rb +2 -2
- data/test/source/_plugins/theme/stylesheets/_colors.sass +1 -1
- data/test/source/index.html +3 -15
- metadata +309 -351
- data/lib/octopress-ink/filters.rb +0 -111
- data/lib/octopress-ink/generators/plugin_assets.rb +0 -13
- data/lib/octopress-ink/helpers.rb +0 -10
- data/lib/octopress-ink/helpers/conditional.rb +0 -24
- data/lib/octopress-ink/helpers/content_for.rb +0 -32
- data/lib/octopress-ink/helpers/path.rb +0 -74
- data/lib/octopress-ink/helpers/var.rb +0 -105
- data/lib/octopress-ink/tags/abort.rb +0 -22
- data/lib/octopress-ink/tags/assign.rb +0 -33
- data/lib/octopress-ink/tags/capture.rb +0 -38
- data/lib/octopress-ink/tags/content_for.rb +0 -24
- data/lib/octopress-ink/tags/filter.rb +0 -24
- data/lib/octopress-ink/tags/include.rb +0 -53
- data/lib/octopress-ink/tags/line_comment.rb +0 -10
- data/lib/octopress-ink/tags/render.rb +0 -85
- data/lib/octopress-ink/tags/return.rb +0 -19
- data/lib/octopress-ink/tags/wrap.rb +0 -81
- data/lib/octopress-ink/tags/yield.rb +0 -36
- data/lib/octopress-ink/utils.rb +0 -42
- data/test/combine_css_false/stylesheets/theme/main.css +0 -2
- data/test/copy_test/_copy/stylesheets/disable-this.css +0 -1
- data/test/copy_test/_copy/stylesheets/main.scss +0 -5
- data/test/expected/index.html +0 -71
- data/test/expected/stylesheets/all-.css +0 -1
- data/test/expected/test_pages/three.html +0 -1
- data/test/expected/test_tags/abort_false.html +0 -1
- data/test/expected/test_tags/assign.html +0 -23
- data/test/expected/test_tags/capture.html +0 -21
- data/test/expected/test_tags/content_for.html +0 -1
- data/test/expected/test_tags/filter.html +0 -4
- data/test/expected/test_tags/include.html +0 -33
- data/test/expected/test_tags/render.html +0 -34
- data/test/expected/test_tags/return.html +0 -23
- data/test/expected/test_tags/wrap.html +0 -29
- data/test/plugins/test-theme/stylesheets/disable-this.css +0 -1
- data/test/plugins/test-theme/stylesheets/main.scss +0 -5
- data/test/source/.gitignore +0 -1
- data/test/source/test_render/_f.html +0 -1
- data/test/source/test_render/_var.html +0 -1
- data/test/source/test_tags/_test_render.md +0 -4
- data/test/source/test_tags/abort_false.html +0 -5
- data/test/source/test_tags/abort_posts.html +0 -5
- data/test/source/test_tags/abort_true.html +0 -5
- data/test/source/test_tags/assign.html +0 -26
- data/test/source/test_tags/capture.html +0 -31
- data/test/source/test_tags/content_for.html +0 -7
- data/test/source/test_tags/filter.html +0 -6
- data/test/source/test_tags/include.html +0 -36
- data/test/source/test_tags/render.html +0 -36
- data/test/source/test_tags/return.html +0 -30
- data/test/source/test_tags/wrap.html +0 -32
- data/test/test-plugin-expected/demo/Gemfile +0 -6
- data/test/test-theme-expected/demo/Gemfile +0 -6
- data/test/test.rb +0 -110
- data/test/test_suite.rb +0 -161
data/test/test.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
require './test_suite'
|
2
|
-
ENV['JEKYLL_ENV'] = 'test'
|
3
|
-
|
4
|
-
@failures = []
|
5
|
-
@git_user_name = `git config user.name`.chomp
|
6
|
-
@git_user_email = `git config user.email`.chomp
|
7
|
-
|
8
|
-
build
|
9
|
-
|
10
|
-
test_dirs('Site build', 'site', 'expected')
|
11
|
-
|
12
|
-
build({octopress_config: '_combine_false.yml'})
|
13
|
-
|
14
|
-
test_dirs("Don't combine CSS", 'site/stylesheets', 'combine_css_false/stylesheets')
|
15
|
-
test_dirs("Don't combine JS", 'site/javascripts', 'combine_js_false/javascripts')
|
16
|
-
|
17
|
-
build({octopress_config: '_compress_false.yml'})
|
18
|
-
|
19
|
-
test_dirs("Don't compress JS", 'site/javascripts', 'compress_false/javascripts')
|
20
|
-
test_dirs("Don't compress CSS", 'site/stylesheets', 'compress_false/stylesheets')
|
21
|
-
|
22
|
-
test_cmd({
|
23
|
-
desc: 'Copy all theme assets',
|
24
|
-
cmd: 'octopress ink copy theme --path _copy --force',
|
25
|
-
expect: 'Copied files:
|
26
|
-
+ source/_copy/layouts/default.html
|
27
|
-
+ source/_copy/layouts/test.html
|
28
|
-
+ source/_copy/includes/bar.html
|
29
|
-
+ source/_copy/includes/greet.html
|
30
|
-
+ source/_copy/pages/disable-test.html
|
31
|
-
+ source/_copy/pages/four.xml
|
32
|
-
+ source/_copy/pages/one.xml
|
33
|
-
+ source/_copy/pages/three.md
|
34
|
-
+ source/_copy/pages/two.md
|
35
|
-
+ source/_copy/stylesheets/_colors.scss
|
36
|
-
+ source/_copy/stylesheets/disable.sass
|
37
|
-
+ source/_copy/stylesheets/main.scss
|
38
|
-
+ source/_copy/stylesheets/disable-this.css
|
39
|
-
+ source/_copy/stylesheets/theme-media-test@print.css
|
40
|
-
+ source/_copy/stylesheets/theme-test.css
|
41
|
-
+ source/_copy/stylesheets/theme-test2.css
|
42
|
-
+ source/_copy/javascripts/bar.js
|
43
|
-
+ source/_copy/javascripts/disable-this.js
|
44
|
-
+ source/_copy/javascripts/foo.js
|
45
|
-
+ source/_copy/javascripts/blah.coffee
|
46
|
-
+ source/_copy/fonts/font-one.otf
|
47
|
-
+ source/_copy/fonts/font-two.ttf
|
48
|
-
+ source/_copy/files/disabled-file.txt
|
49
|
-
+ source/_copy/files/favicon.ico
|
50
|
-
+ source/_copy/files/favicon.png
|
51
|
-
+ source/_copy/files/test.html
|
52
|
-
+ source/_copy/config.yml'
|
53
|
-
})
|
54
|
-
|
55
|
-
test_dirs('Copy theme', 'source/_copy', 'copy_test/_copy')
|
56
|
-
`rm -rf source/_copy`
|
57
|
-
|
58
|
-
test_cmd({
|
59
|
-
desc: 'Copy theme layouts and pages',
|
60
|
-
cmd: 'octopress ink copy theme --layouts --pages --path _copy --force',
|
61
|
-
expect: 'Copied files:
|
62
|
-
+ source/_copy/layouts/default.html
|
63
|
-
+ source/_copy/layouts/test.html
|
64
|
-
+ source/_copy/pages/disable-test.html
|
65
|
-
+ source/_copy/pages/four.xml
|
66
|
-
+ source/_copy/pages/one.xml
|
67
|
-
+ source/_copy/pages/three.md
|
68
|
-
+ source/_copy/pages/two.md'
|
69
|
-
})
|
70
|
-
|
71
|
-
test_dirs('Copy theme', 'source/_copy', 'copy_layouts_pages/_copy')
|
72
|
-
`rm -rf source/_copy`
|
73
|
-
|
74
|
-
`git config user.name ''`
|
75
|
-
`git config user.email ''`
|
76
|
-
|
77
|
-
test_cmd({
|
78
|
-
desc: 'New plugin',
|
79
|
-
cmd: [
|
80
|
-
'octopress ink new test-plugin',
|
81
|
-
'rm -rf test-plugin/.git'
|
82
|
-
]
|
83
|
-
})
|
84
|
-
|
85
|
-
`git config user.name "#{@git_user_name}"`
|
86
|
-
`git config user.email #{@git_user_email}`
|
87
|
-
|
88
|
-
test_dirs('New plugin', 'test-plugin', 'test-plugin-expected')
|
89
|
-
|
90
|
-
`rm -rf test-plugin`
|
91
|
-
|
92
|
-
`git config user.name ''`
|
93
|
-
`git config user.email ''`
|
94
|
-
|
95
|
-
test_cmd({
|
96
|
-
desc: 'New Theme',
|
97
|
-
cmd: [
|
98
|
-
'octopress ink new test-theme --theme',
|
99
|
-
'rm -rf test-theme/.git'
|
100
|
-
]
|
101
|
-
})
|
102
|
-
|
103
|
-
`git config user.name "#{@git_user_name}"`
|
104
|
-
`git config user.email #{@git_user_email}`
|
105
|
-
|
106
|
-
test_dirs('New plugin', 'test-theme', 'test-theme-expected')
|
107
|
-
|
108
|
-
`rm -rf test-theme`
|
109
|
-
|
110
|
-
print_results
|
data/test/test_suite.rb
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
require 'colorator'
|
2
|
-
require 'find'
|
3
|
-
|
4
|
-
# This is a makeshift integration test-suite.
|
5
|
-
# It is unapologetically pragmatic.
|
6
|
-
|
7
|
-
|
8
|
-
# Build Jekyll
|
9
|
-
#
|
10
|
-
def build(options={})
|
11
|
-
if options[:octopress_config]
|
12
|
-
FileUtils.cp options[:octopress_config], '_octopress.yml'
|
13
|
-
end
|
14
|
-
|
15
|
-
config = ['_config.yml'] << options[:config]
|
16
|
-
cmd = "rm -rf site && bundle exec jekyll build --config #{config.join(',')}"
|
17
|
-
|
18
|
-
`#{cmd}`
|
19
|
-
`rm _octopress.yml` if options[:octopress_config]
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
# Find all files in a given directory
|
24
|
-
#
|
25
|
-
def dir_files(dir)
|
26
|
-
Find.find(dir).to_a.reject!{|f| File.directory?(f) }
|
27
|
-
end
|
28
|
-
|
29
|
-
# Recursively diff two directories
|
30
|
-
#
|
31
|
-
# This will walk through dir1 and diff matching paths in dir2
|
32
|
-
#
|
33
|
-
def test_dirs(desc, dir1, dir2)
|
34
|
-
|
35
|
-
test_missing_files(desc, dir1, dir2)
|
36
|
-
|
37
|
-
dir_files(dir1).each do |file|
|
38
|
-
file2 = file.sub(dir1, dir2)
|
39
|
-
if File.exist?(file2)
|
40
|
-
if diff = diff_file(file, file2)
|
41
|
-
@failures << {
|
42
|
-
desc: "#{desc}\nDiff of file: #{file.sub(dir1+'/', '')}\n",
|
43
|
-
result: format_diff(diff)
|
44
|
-
}
|
45
|
-
pout 'F'.red
|
46
|
-
else
|
47
|
-
pout '.'.green
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def format_diff(diff)
|
54
|
-
"#{diff.gsub(/\A.+?\n/,'').gsub(/^[^><].+/,'---').gsub(/^>.+/){|m|
|
55
|
-
m.green
|
56
|
-
}.gsub(/^(<.+?)$/){ |m|
|
57
|
-
m.red
|
58
|
-
}}"
|
59
|
-
end
|
60
|
-
|
61
|
-
# List differences between files in two directories
|
62
|
-
#
|
63
|
-
def test_missing_files(desc, dir1, dir2)
|
64
|
-
files1 = dir_files(dir1).map {|f| f.sub(dir1,'') }
|
65
|
-
files2 = dir_files(dir2).map {|f| f.sub(dir2,'') }
|
66
|
-
|
67
|
-
missing = []
|
68
|
-
|
69
|
-
(files2 - files1).each do |file|
|
70
|
-
missing << File.join(dir1, file)
|
71
|
-
end
|
72
|
-
|
73
|
-
(files1 - files2).each do |file|
|
74
|
-
missing << File.join(dir2, file)
|
75
|
-
end
|
76
|
-
|
77
|
-
if !missing.empty?
|
78
|
-
@failures << {
|
79
|
-
desc: "#{desc}\nMissing files:\n",
|
80
|
-
result: " - " + missing.join("\n - ")
|
81
|
-
}
|
82
|
-
|
83
|
-
pout 'F'.red
|
84
|
-
else
|
85
|
-
pout '.'.green
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# Diff two files
|
90
|
-
#
|
91
|
-
def diff_file(file1, file2)
|
92
|
-
diff = `diff #{file1} #{file2}`
|
93
|
-
if diff.size > 0
|
94
|
-
diff
|
95
|
-
else
|
96
|
-
false
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# Test command output
|
101
|
-
#
|
102
|
-
# Input: options hash, format:
|
103
|
-
# {
|
104
|
-
# desc: description of task
|
105
|
-
# cmd: system command to be run, (String or Array)
|
106
|
-
# expect: expected output from command
|
107
|
-
# }
|
108
|
-
#
|
109
|
-
def test_cmd(options)
|
110
|
-
if cmd = options[:cmd]
|
111
|
-
cmd = [cmd] unless cmd.is_a? Array
|
112
|
-
|
113
|
-
# In debug mode command output is printed
|
114
|
-
#
|
115
|
-
if options[:debug]
|
116
|
-
system cmd.join('; ')
|
117
|
-
else
|
118
|
-
output = `#{cmd.join('; ')}`.gsub(/#{Dir.pwd}\/*/,'').strip
|
119
|
-
|
120
|
-
# Remove character color codes
|
121
|
-
output = output.gsub("\e",'').gsub(/\[\d+m/,'').gsub("\[0m",'')
|
122
|
-
end
|
123
|
-
if options[:expect] && options[:expect].strip == output
|
124
|
-
pout '.'.green
|
125
|
-
elsif options[:expect]
|
126
|
-
pout 'F'.red
|
127
|
-
@failures << {
|
128
|
-
desc: options[:desc]+"\n",
|
129
|
-
result: <<-HERE
|
130
|
-
expected: #{(options[:expect] || '').strip.green}
|
131
|
-
result: #{(output || '').strip.red}
|
132
|
-
HERE
|
133
|
-
}
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
|
139
|
-
# Print a single character without a newline
|
140
|
-
#
|
141
|
-
def pout(str)
|
142
|
-
print str
|
143
|
-
$stdout.flush
|
144
|
-
end
|
145
|
-
|
146
|
-
# Ouptut nicely formatted failure messages
|
147
|
-
#
|
148
|
-
def print_results
|
149
|
-
if !@failures.empty?
|
150
|
-
@failures.each do |test|
|
151
|
-
pout "\nFailed: #{test[:desc]}"
|
152
|
-
puts test[:result]
|
153
|
-
# print a newline for easier reading
|
154
|
-
puts ""
|
155
|
-
end
|
156
|
-
abort
|
157
|
-
else
|
158
|
-
puts "All passed!".green
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|