jekyll-testtasks 0.0.1 → 0.0.2
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.
- data/README +10 -2
- data/lib/jekyll/testtasks.rb +70 -24
- data/lib/jekyll/testtasks/helper.rb +2 -0
- data/lib/jekyll/testtasks/rake.rb +19 -0
- data/lib/jekyll/testtasks/version.rb +1 -1
- metadata +6 -4
data/README
CHANGED
@@ -2,18 +2,26 @@
|
|
2
2
|
|
3
3
|
== VERSION
|
4
4
|
|
5
|
-
This documentation refers to jekyll-testtasks version 0.0.
|
5
|
+
This documentation refers to jekyll-testtasks version 0.0.2
|
6
6
|
|
7
7
|
|
8
8
|
== DESCRIPTION
|
9
9
|
|
10
10
|
Simplifies testing your Jekyll plugins. Just add this to your Rakefile:
|
11
11
|
|
12
|
-
require 'jekyll/testtasks'
|
12
|
+
require 'jekyll/testtasks/rake'
|
13
13
|
|
14
14
|
Currently only allows to run Jekyll's original test tasks with your plugin
|
15
15
|
loaded to make sure you didn't break anything. More to come?
|
16
16
|
|
17
|
+
Note that your Jekyll installation needs to be patched in order to run with
|
18
|
+
your plugin loaded. The necessary patch will be displayed when you try to
|
19
|
+
run a task against an unpatched installation.
|
20
|
+
|
21
|
+
You can point at the Jekyll installation to use by either setting the
|
22
|
+
environment variable +JEKYLL+ or by creating a file <tt>.jekyll</tt> in
|
23
|
+
your plugin's project directory with the path in it.
|
24
|
+
|
17
25
|
|
18
26
|
== LINKS
|
19
27
|
|
data/lib/jekyll/testtasks.rb
CHANGED
@@ -4,12 +4,15 @@ module Jekyll
|
|
4
4
|
|
5
5
|
extend self
|
6
6
|
|
7
|
+
# Jekyll's test tasks to install for the plugin
|
8
|
+
TASKS = %w[test features].freeze
|
9
|
+
|
7
10
|
caller.find { |f| f =~ %r{(.*)/Rakefile:\d+(?::|\z)} }
|
8
11
|
|
9
12
|
# Where we're called from (the plugin location)
|
10
13
|
CALLER = $1 || File.expand_path('../../..', __FILE__)
|
11
14
|
|
12
|
-
# Patch to apply to Jekyll installation
|
15
|
+
# Patch to apply to the Jekyll installation
|
13
16
|
JEKYLL_PATCH = <<-JEKYLL_PATCH
|
14
17
|
diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb
|
15
18
|
index 7570cb0..9fbe738 100644
|
@@ -30,45 +33,88 @@ index 7570cb0..9fbe738 100644
|
|
30
33
|
# call-seq:
|
31
34
|
# setup_env
|
32
35
|
#
|
33
|
-
#
|
36
|
+
# Sets environment variables for the patched Jekyll to pick up.
|
34
37
|
def setup_env
|
35
38
|
ENV['PLUGIN_PATH'] = Dir[File.expand_path('../jekyll-*/lib', CALLER)].join(':')
|
36
39
|
ENV['PLUGIN'] = File.basename(CALLER).sub('-', '/')
|
37
40
|
end
|
38
41
|
|
42
|
+
# call-seq:
|
43
|
+
# ensure_jekyll_patch
|
44
|
+
#
|
45
|
+
# Ensures that the specified Jekyll installation seems
|
46
|
+
# to be patched appropriately.
|
47
|
+
def ensure_jekyll_patch
|
48
|
+
file = File.read('lib/jekyll/site.rb')
|
49
|
+
raise UnpatchedError.new(Dir.pwd) unless %w[PLUGIN_PATH PLUGIN].all? { |k| file =~ /'#{k}'/ }
|
50
|
+
end
|
51
|
+
|
52
|
+
# call-seq:
|
53
|
+
# jekyll_dir => aString
|
54
|
+
#
|
55
|
+
# Returns the Jekyll installation directory as specified through
|
56
|
+
# the +JEKYLL+ environment variable or the <tt>.jekyll</tt> file
|
57
|
+
# in your plugin's project directory.
|
58
|
+
def jekyll_dir
|
59
|
+
jekyll = ENV['JEKYLL'] || begin
|
60
|
+
dot_jekyll = File.join(CALLER, '.jekyll')
|
61
|
+
File.read(dot_jekyll).strip if File.readable?(dot_jekyll)
|
62
|
+
end
|
63
|
+
|
64
|
+
raise NotSetError unless jekyll
|
65
|
+
raise NotFoundError.new(jekyll) unless File.directory?(jekyll)
|
66
|
+
|
67
|
+
jekyll
|
68
|
+
end
|
69
|
+
|
70
|
+
# call-seq:
|
71
|
+
# in_jekyll_dir { ... }
|
72
|
+
#
|
73
|
+
# Runs the block inside the Jekyll installation directory.
|
74
|
+
def in_jekyll_dir
|
75
|
+
Dir.chdir(jekyll_dir) { ensure_jekyll_patch; yield }
|
76
|
+
end
|
77
|
+
|
39
78
|
# call-seq:
|
40
79
|
# run_jekyll_task(task)
|
41
80
|
#
|
42
|
-
#
|
81
|
+
# Runs Jekyll's original Rake task +task+.
|
43
82
|
def run_jekyll_task(task)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
warn 'Jekyll must be patched in order to run with this plugin loaded'
|
49
|
-
puts
|
50
|
-
puts JEKYLL_PATCH
|
83
|
+
in_jekyll_dir { system('rake', task) }
|
84
|
+
rescue TestTasksError => err
|
85
|
+
warn err.to_s
|
86
|
+
puts err.payload if err.payload
|
51
87
|
|
52
|
-
|
53
|
-
|
88
|
+
exit 1
|
89
|
+
end
|
54
90
|
|
55
|
-
|
56
|
-
|
91
|
+
# call-seq:
|
92
|
+
# install_tasks
|
93
|
+
#
|
94
|
+
# Installs the relevant tasks.
|
95
|
+
def install_tasks
|
96
|
+
require 'jekyll/testtasks/rake'
|
57
97
|
end
|
58
98
|
|
59
|
-
|
99
|
+
class TestTasksError < RuntimeError
|
100
|
+
attr_reader :dir, :payload
|
60
101
|
|
61
|
-
end
|
102
|
+
def initialize(dir = nil); @dir = dir; end
|
103
|
+
end
|
104
|
+
|
105
|
+
class NotSetError < TestTasksError
|
106
|
+
def to_s; 'Must set JEKYLL to point at patched Jekyll installation'; end
|
107
|
+
end
|
62
108
|
|
63
|
-
|
64
|
-
|
109
|
+
class NotFoundError < TestTasksError
|
110
|
+
def to_s; "Jekyll installation not found at `#{dir}'"; end
|
111
|
+
end
|
65
112
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
Jekyll::TestTasks.setup_env
|
70
|
-
Jekyll::TestTasks.run_jekyll_task t
|
113
|
+
class UnpatchedError < TestTasksError
|
114
|
+
def payload; "\n" + JEKYLL_PATCH; end
|
115
|
+
def to_s; "Jekyll must be patched in order to run with this plugin loaded\n[Found Jekyll at `#{dir}']"; end
|
71
116
|
end
|
72
|
-
|
117
|
+
|
118
|
+
end
|
73
119
|
|
74
120
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'jekyll/testtasks'
|
2
|
+
|
3
|
+
# Install test tasks for Rake.
|
4
|
+
namespace :jekyll do
|
5
|
+
|
6
|
+
task :setup_env do
|
7
|
+
Jekyll::TestTasks.setup_env
|
8
|
+
end
|
9
|
+
|
10
|
+
Jekyll::TestTasks::TASKS.each { |t|
|
11
|
+
desc "Run Jekyll's original #{t} task with this plugin loaded"
|
12
|
+
task t => :setup_env do
|
13
|
+
Jekyll::TestTasks.run_jekyll_task(t)
|
14
|
+
end
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run Jekyll's test tasks (#{Jekyll::TestTasks::TASKS.join(', ')})"
|
19
|
+
task :jekyll => Jekyll::TestTasks::TASKS.map { |t| "jekyll:#{t}" }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-testtasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jens Wille
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-02 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -30,7 +30,9 @@ extra_rdoc_files:
|
|
30
30
|
- ChangeLog
|
31
31
|
- README
|
32
32
|
files:
|
33
|
+
- lib/jekyll/testtasks/helper.rb
|
33
34
|
- lib/jekyll/testtasks/version.rb
|
35
|
+
- lib/jekyll/testtasks/rake.rb
|
34
36
|
- lib/jekyll/testtasks.rb
|
35
37
|
- README
|
36
38
|
- ChangeLog
|