clash 2.0.2 → 2.2.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 +4 -4
- data/bin/clash +39 -17
- data/lib/clash/help.rb +43 -10
- data/lib/clash/scaffold.rb +80 -14
- data/lib/clash/version.rb +1 -1
- data/scaffold/site/_config.yml +1 -2
- data/scaffold/site/_layouts/default.html +9 -0
- data/scaffold/site/index.html +1 -0
- data/{scaffold → test/test-scaffold}/_clash.yml +2 -2
- data/test/test-scaffold/test-site/_config.yml +3 -0
- data/test/test-scaffold/test-site/_expected/index.html +1 -0
- data/test/test-scaffold/test-site/_layouts/default.html +9 -0
- data/test/test-scaffold/test-site/index.html +5 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f038c9d8b4b1cc0df3cb05eb1e66a09bcc33e5d6
|
4
|
+
data.tar.gz: 5ffd37edc3f92f74b9268d2fc9eb827cffc77c76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a79902e390843533618c831035f9c6fd20c9df2a148827b826781b6173c75291cf9a834ca7b531e5b4e058b4c324e0b4dc34d60d998bb60f6c1b30b48e23ae49
|
7
|
+
data.tar.gz: 6a45656ef314abe34543bf54312b7b6404e1dc59f335f9686dbfd5829eb85ed88f17d29f21a8c88cb8f090dccfea77325637c46a47250629e6c78e9b3a1655ac
|
data/bin/clash
CHANGED
@@ -12,19 +12,28 @@ OptionParser.new do |opts|
|
|
12
12
|
|
13
13
|
if ARGV.first == 'accept'
|
14
14
|
options[:accept] = ARGV.shift
|
15
|
+
elsif ARGV.first == 'new' || ARGV.first == 'init'
|
16
|
+
options[:new] = ARGV.shift
|
17
|
+
elsif ARGV.first == 'list'
|
18
|
+
options[:list] = ARGV.shift
|
15
19
|
end
|
16
20
|
|
17
|
-
if
|
18
|
-
options[:
|
19
|
-
|
20
|
-
opts.on("-f", "--force", "Overwrite existing content") do |f|
|
21
|
-
options[:force] = f
|
22
|
-
end
|
21
|
+
if !(options[:list] || options[:new] || options[:accept])
|
22
|
+
options[:normal] = true
|
23
23
|
end
|
24
24
|
|
25
25
|
opts.banner = banner(options)
|
26
26
|
|
27
|
-
if
|
27
|
+
if options[:new]
|
28
|
+
opts.on("-t", "--title TITLE", String, "Enter a title for your test (default: \"Test Build\")") do |title|
|
29
|
+
options[:title] = title
|
30
|
+
end
|
31
|
+
opts.on("-d", "--dir SITE_DIR", String, "Enter a directory name for your new test site (default: test-site)") do |dir|
|
32
|
+
options[:dir] = dir
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if options[:normal]
|
28
37
|
opts.on("-b", "--build", "Build mode: Runs only 'before' and 'build' actions") do |b|
|
29
38
|
options[:build_only] = b
|
30
39
|
end
|
@@ -37,21 +46,18 @@ OptionParser.new do |opts|
|
|
37
46
|
options[:trace] = t
|
38
47
|
end
|
39
48
|
|
40
|
-
opts.on("-
|
41
|
-
options[:
|
49
|
+
opts.on("-v", "--version", "Show version number") do |v|
|
50
|
+
options[:version] = v
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
45
|
-
opts.on("-v", "--version", "Show version number") do |v|
|
46
|
-
options[:version] = v
|
47
|
-
end
|
48
|
-
|
49
54
|
opts.on("-h", "--help", "Show this message") do |h|
|
50
55
|
options[:help] = opts
|
51
56
|
end
|
52
57
|
|
53
58
|
end.parse!
|
54
59
|
|
60
|
+
|
55
61
|
if options[:version]
|
56
62
|
puts "Clash #{Clash::VERSION}"
|
57
63
|
abort
|
@@ -60,17 +66,33 @@ end
|
|
60
66
|
if options[:help]
|
61
67
|
IO.popen("less", "w") do |f|
|
62
68
|
f.puts options[:help]
|
63
|
-
|
69
|
+
|
64
70
|
if options[:accept]
|
65
71
|
f.puts accept_examples
|
66
|
-
elsif
|
72
|
+
elsif options[:list]
|
73
|
+
f.puts list_examples
|
74
|
+
end
|
75
|
+
|
76
|
+
if options[:normal]
|
67
77
|
f.puts default_examples
|
78
|
+
f.puts config_info
|
68
79
|
end
|
69
80
|
end
|
70
|
-
elsif options[:init]
|
71
|
-
Clash::Scaffold.new(ARGV, options)
|
72
81
|
else
|
73
82
|
|
83
|
+
if options[:new]
|
84
|
+
# Grab path from args if it exists
|
85
|
+
#
|
86
|
+
if !(path = ARGV.join(" ")).empty?
|
87
|
+
options[:path] = path
|
88
|
+
end
|
89
|
+
|
90
|
+
Clash::Scaffold.new(options).add_test
|
91
|
+
|
92
|
+
# List tests bceause that's nice.
|
93
|
+
options[:list] = true
|
94
|
+
end
|
95
|
+
|
74
96
|
unless ARGV.empty?
|
75
97
|
# Parse input `clash 1 2 3` and `clash 1,2,3` and `clash 1-3` the same
|
76
98
|
#
|
data/lib/clash/help.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
def version_banner
|
2
|
-
"Clash #{Clash::VERSION} -- a diff based testing suite for Jekyll."
|
2
|
+
"Clash #{Clash::VERSION} -- a diff based testing suite for Jekyll sites and plugins."
|
3
3
|
end
|
4
4
|
|
5
5
|
def banner(options)
|
6
|
-
banner = if options[:
|
7
|
-
|
6
|
+
banner = if options[:new]
|
7
|
+
new_banner
|
8
8
|
elsif options[:accept]
|
9
9
|
accept_banner
|
10
|
+
elsif options[:list]
|
11
|
+
list_banner
|
10
12
|
else
|
11
13
|
default_banner
|
12
14
|
end
|
@@ -17,20 +19,34 @@ end
|
|
17
19
|
def default_banner
|
18
20
|
<<-BANNER
|
19
21
|
Usage:
|
20
|
-
$ clash [
|
21
|
-
$ clash
|
22
|
-
$ clash
|
22
|
+
$ clash [path] [tests] [options] # Run tests
|
23
|
+
$ clash list [path] [tests] [options] # Print a list of tests
|
24
|
+
$ clash accept [path] [tests] [options] # Accept build: overwrite expected files with build files
|
25
|
+
$ clash new [path] [options] # Add a new testing scaffold
|
23
26
|
|
24
27
|
Options:
|
25
28
|
BANNER
|
26
29
|
end
|
27
30
|
|
28
|
-
def
|
31
|
+
def new_banner
|
29
32
|
<<-BANNER
|
30
|
-
Add testing scaffold.
|
33
|
+
Add a new testing scaffold or a new test site to your existing test suite.
|
31
34
|
|
32
35
|
Usage:
|
33
|
-
$ clash
|
36
|
+
$ clash new [path] [options]
|
37
|
+
|
38
|
+
Note: path defaults to `./test`.
|
39
|
+
|
40
|
+
Options:
|
41
|
+
BANNER
|
42
|
+
end
|
43
|
+
|
44
|
+
def list_banner
|
45
|
+
<<-BANNER
|
46
|
+
Print a list of test numbers and titles
|
47
|
+
|
48
|
+
Usage:
|
49
|
+
$ clash list [path] [tests] [options]
|
34
50
|
|
35
51
|
Options:
|
36
52
|
BANNER
|
@@ -41,7 +57,7 @@ def accept_banner
|
|
41
57
|
This accepts a build, overwriting expected files with build files.
|
42
58
|
|
43
59
|
Usage:
|
44
|
-
$ clash accept [
|
60
|
+
$ clash accept [path] [tests] [options]
|
45
61
|
|
46
62
|
Options:
|
47
63
|
BANNER
|
@@ -64,6 +80,23 @@ Examples:
|
|
64
80
|
EXAMPLES
|
65
81
|
end
|
66
82
|
|
83
|
+
def list_examples
|
84
|
+
<<-EXAMPLES
|
85
|
+
|
86
|
+
Examples:
|
87
|
+
To run only specific tests, pass test numbers separated by commas.
|
88
|
+
|
89
|
+
$ clash list # List all tests
|
90
|
+
$ clash list 1 # List only the first test
|
91
|
+
$ clash list 2,3 # List the second and third tests
|
92
|
+
$ clash list 2-4 # List the second, third, and fourth tests
|
93
|
+
$ clash list :10 # List the test on line 10
|
94
|
+
$ clash list :10-:35 # List all tests from line 10 to 35
|
95
|
+
$ clash list awesome # List all tests in the 'awesome' directory, reading awesome/_clash.yml.
|
96
|
+
$ clash list awesome 1 # List the first test in the 'awesome' directory.
|
97
|
+
EXAMPLES
|
98
|
+
end
|
99
|
+
|
67
100
|
def accept_examples
|
68
101
|
<<-EXAMPLES
|
69
102
|
|
data/lib/clash/scaffold.rb
CHANGED
@@ -2,32 +2,98 @@ module Clash
|
|
2
2
|
class Scaffold
|
3
3
|
attr_accessor :options
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
|
5
|
+
def initialize(options = {})
|
6
|
+
@options = {
|
7
|
+
path: 'test',
|
8
|
+
title: 'Test Build',
|
9
|
+
dir: 'test-site',
|
10
|
+
force: false
|
11
|
+
}.merge(options)
|
7
12
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
13
|
+
@options[:path] = File.expand_path(@options[:path], Dir.pwd)
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_test
|
17
|
+
config = File.join(@options[:path], '_clash.yml')
|
18
|
+
|
19
|
+
prevent_dir_name_collisions
|
20
|
+
content = test_content
|
21
|
+
|
22
|
+
if !File.exist?(config)
|
23
|
+
content.lstrip!
|
12
24
|
end
|
13
25
|
|
14
|
-
|
26
|
+
path = File.join(@options[:path], @options[:dir])
|
27
|
+
|
28
|
+
FileUtils.mkdir_p path
|
29
|
+
FileUtils.cp_r test_template + '/.', path
|
30
|
+
|
15
31
|
|
16
|
-
|
32
|
+
File.open(config, 'a') do |f|
|
33
|
+
f.write content
|
34
|
+
end
|
35
|
+
|
36
|
+
puts "New Clash test added to " + @options[:path].yellow
|
37
|
+
print_test_files(path)
|
38
|
+
puts "Tests:"
|
17
39
|
end
|
18
40
|
|
19
|
-
|
20
|
-
|
41
|
+
private
|
42
|
+
|
43
|
+
def print_test_files(path)
|
44
|
+
FileUtils.cd path do
|
45
|
+
files = Dir['**/*']
|
46
|
+
files.map! { |f|
|
47
|
+
if f.match /\//
|
48
|
+
f.gsub!(/[^\/]+\//, ' ')
|
49
|
+
end
|
50
|
+
if File.directory?(f)
|
51
|
+
f += '/'
|
52
|
+
end
|
53
|
+
"+ #{f}"
|
54
|
+
}
|
55
|
+
puts "\n+ #{@options[:dir]}/\n#{files.join("\n")}\n".green
|
56
|
+
end
|
21
57
|
end
|
22
58
|
|
23
59
|
def test_template
|
24
|
-
File.expand_path("../../scaffold", File.dirname(__FILE__))
|
60
|
+
File.expand_path("../../scaffold/site", File.dirname(__FILE__))
|
25
61
|
end
|
26
62
|
|
27
|
-
|
63
|
+
# If necessary append a number to directory to avoid directory collision
|
64
|
+
#
|
65
|
+
def prevent_dir_name_collisions
|
66
|
+
|
67
|
+
# Find directories beginning with test directory name
|
68
|
+
#
|
69
|
+
dirs = Dir.glob("#{@options[:path]}/*").select { |d|
|
70
|
+
File.directory?(d) && d.match(/#{@options[:dir]}($|-\d+$)/)
|
71
|
+
}.size
|
72
|
+
|
73
|
+
# If matching directories are found, increment the dir name
|
74
|
+
# e.g. "test-site-2"
|
75
|
+
#
|
76
|
+
if dirs > 0
|
77
|
+
@options[:dir] << "-#{dirs += 1}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def preserve_source_location?
|
82
|
+
!@options[:force] && !Dir["#{@options[:path]}/**/*"].empty?
|
83
|
+
end
|
84
|
+
|
85
|
+
def dasherize(string)
|
86
|
+
string.gsub(/ /,'-').gsub(/[^\w-]/,'').gsub(/-{2,}/,'-').downcase
|
87
|
+
end
|
28
88
|
|
29
|
-
def
|
30
|
-
|
89
|
+
def test_content
|
90
|
+
%Q{
|
91
|
+
-
|
92
|
+
title: "#{@options[:title]}"
|
93
|
+
dir: #{@options[:dir]}
|
94
|
+
build: true
|
95
|
+
compare: _expected _site
|
96
|
+
}
|
31
97
|
end
|
32
98
|
end
|
33
99
|
end
|
data/lib/clash/version.rb
CHANGED
data/scaffold/site/_config.yml
CHANGED
data/scaffold/site/index.html
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Test content
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|
@@ -125,10 +125,15 @@ files:
|
|
125
125
|
- lib/clash/test.rb
|
126
126
|
- lib/clash/tests.rb
|
127
127
|
- lib/clash/version.rb
|
128
|
-
- scaffold/_clash.yml
|
129
128
|
- scaffold/site/_config.yml
|
130
129
|
- scaffold/site/_expected/index.html
|
130
|
+
- scaffold/site/_layouts/default.html
|
131
131
|
- scaffold/site/index.html
|
132
|
+
- test/test-scaffold/_clash.yml
|
133
|
+
- test/test-scaffold/test-site/_config.yml
|
134
|
+
- test/test-scaffold/test-site/_expected/index.html
|
135
|
+
- test/test-scaffold/test-site/_layouts/default.html
|
136
|
+
- test/test-scaffold/test-site/index.html
|
132
137
|
homepage: https://github.com/imathis/clash
|
133
138
|
licenses:
|
134
139
|
- MIT
|