jekylltask 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/jekylltask.gemspec +7 -2
  2. data/lib/jekylltask.rb +62 -39
  3. metadata +4 -27
@@ -15,7 +15,7 @@
15
15
 
16
16
  Gem::Specification.new do |spec|
17
17
  spec.name = 'jekylltask'
18
- spec.version = '1.0.2'
18
+ spec.version = '1.1.0'
19
19
  spec.author = 'Jekyll Rake Task'
20
20
  spec.email = "antoine@lunar-ocean.com"
21
21
  spec.homepage = "http://www.github.com/atoulme/jekylltask"
@@ -25,8 +25,13 @@ A Rake task to run jekyll over your textile files.
25
25
  TEXT
26
26
 
27
27
  spec.files = Dir['lib/**/*', '*.{gemspec}', 'LICENSE', 'README.rdoc']
28
+
29
+ # Rakefile needs to create spec for both platforms (ruby and java), using the
30
+ # $platform global variable. In all other cases, we figure it out from RUBY_PLATFORM.
31
+ spec.platform = $platform || RUBY_PLATFORM[/java/] || 'ruby'
28
32
 
29
33
  # Tested against these dependencies.
30
34
  spec.add_dependency 'rake', '>= 0.8.7'
31
- spec.add_dependency 'jekyll', '>= 0.6.2'
35
+ spec.add_dependency 'jekyll', '>= 0.6.2' unless spec.platform.to_s == 'java'
36
+ spec.add_dependency 'realityforge-jekyll', '>= 0.7.1' if spec.platform.to_s == 'java'
32
37
  end
@@ -14,60 +14,83 @@
14
14
  # the License.
15
15
 
16
16
  require 'rake/tasklib'
17
- require 'jekyll'
18
17
 
18
+ module Kernel
19
+ def suppress_warnings
20
+ original_verbosity = $VERBOSE
21
+ $VERBOSE = nil
22
+ result = yield
23
+ $VERBOSE = original_verbosity
24
+ return result
25
+ end
26
+ end
27
+
28
+ suppress_warnings { require 'liquid' }
29
+ require 'jekyll'
19
30
 
20
31
  class JekyllTask < Rake::TaskLib
21
- def initialize(name=:jekyll) # :yield: self
32
+ def initialize(name) # :yield: self
22
33
  @name = name
23
- @source = name
24
- @target = name
34
+ @source = nil
35
+ @target = nil
36
+ @auto = false
37
+ @description = nil
25
38
  yield self if block_given?
26
- task name, :auto, :needs=>[@source] do |task, args|
27
- generate args.auto
28
- end
29
- if @source != @target
30
- file @target=>FileList["#{@source}/**/*"] do
31
- generate
32
- end
33
- task 'clobber' do
34
- rm_rf @target
35
- end
36
- end
39
+ raise "User must specify source directory" unless self.source
40
+ raise "User must specify target directory" unless self.target
41
+ generate
37
42
  end
38
43
 
44
+ attr_reader :name
39
45
  attr_accessor :source
40
46
  attr_accessor :target
47
+ attr_accessor :auto
48
+ attr_accessor :description
41
49
 
42
- def generate(auto = false)
43
- options = { 'source'=>source, 'destination'=>target }
44
- options = Jekyll.configuration(options)
45
- site = Jekyll::Site.new(options)
50
+ private
46
51
 
47
- if auto
48
- require 'directory_watcher'
49
- puts "Auto generating: just edit a page and save, watch the console to see when we're done regenerating pages"
50
- dw = DirectoryWatcher.new(source)
51
- dw.interval = 1
52
- dw.glob = Dir.chdir(source) do
53
- dirs = Dir['*'].select { |x| File.directory?(x) }
54
- dirs -= [target]
55
- dirs = dirs.map { |x| "#{x}/**/*" }
56
- dirs += ['*']
52
+ def generate
53
+ desc self.description if self.description
54
+ if self.auto
55
+ task self.name do
56
+ require 'directory_watcher'
57
+ puts "Auto generating: just edit a page and save, watch the console to see when we're done regenerating pages"
58
+ dw = DirectoryWatcher.new(source)
59
+ dw.interval = 1
60
+ dw.glob = Dir.chdir(source) do
61
+ dirs = Dir['*'].select { |x| File.directory?(x) }
62
+ dirs -= [target]
63
+ dirs = dirs.map { |x| "#{x}/**/*" }
64
+ dirs += ['*']
65
+ end
66
+ dw.start
67
+ site = init_jekyll
68
+ dw.add_observer do |*args|
69
+ t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
70
+ puts "[#{t}] regeneration: #{args.size} files changed"
71
+ site.process
72
+ puts "Done"
73
+ end
74
+ loop { sleep 1 }
57
75
  end
58
- dw.start
59
- dw.add_observer do |*args|
60
- t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
61
- puts "[#{t}] regeneration: #{args.size} files changed"
76
+ else
77
+ task self.name => self.target
78
+ file self.target => FileList["#{self.source}/**/*"] do
79
+ puts "Generating documentation in #{target}"
80
+ site = init_jekyll
62
81
  site.process
63
- puts "Done"
82
+ touch target
64
83
  end
65
- loop { sleep 1 }
66
- else
67
- puts "Generating documentation in #{target}"
68
- site.process
69
- touch target
70
84
  end
85
+ task 'clobber' do
86
+ rm_rf self.target
87
+ end
88
+ end
89
+
90
+ def init_jekyll
91
+ options = {'source' => self.source, 'destination' => self.target}
92
+ options = Jekyll.configuration(options)
93
+ Jekyll::Site.new(options)
71
94
  end
72
95
  end
73
96
 
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekylltask
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 0
9
- - 2
10
- version: 1.0.2
4
+ prerelease:
5
+ version: 1.1.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Jekyll Rake Task
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-08-15 00:00:00 -07:00
19
- default_executable:
13
+ date: 2011-07-22 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: rake
@@ -26,11 +20,6 @@ dependencies:
26
20
  requirements:
27
21
  - - ">="
28
22
  - !ruby/object:Gem::Version
29
- hash: 49
30
- segments:
31
- - 0
32
- - 8
33
- - 7
34
23
  version: 0.8.7
35
24
  type: :runtime
36
25
  version_requirements: *id001
@@ -42,11 +31,6 @@ dependencies:
42
31
  requirements:
43
32
  - - ">="
44
33
  - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- - 6
49
- - 2
50
34
  version: 0.6.2
51
35
  type: :runtime
52
36
  version_requirements: *id002
@@ -65,7 +49,6 @@ files:
65
49
  - jekylltask.gemspec
66
50
  - LICENSE
67
51
  - README.rdoc
68
- has_rdoc: true
69
52
  homepage: http://www.github.com/atoulme/jekylltask
70
53
  licenses: []
71
54
 
@@ -79,23 +62,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
62
  requirements:
80
63
  - - ">="
81
64
  - !ruby/object:Gem::Version
82
- hash: 3
83
- segments:
84
- - 0
85
65
  version: "0"
86
66
  required_rubygems_version: !ruby/object:Gem::Requirement
87
67
  none: false
88
68
  requirements:
89
69
  - - ">="
90
70
  - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
71
  version: "0"
95
72
  requirements: []
96
73
 
97
74
  rubyforge_project:
98
- rubygems_version: 1.3.7
75
+ rubygems_version: 1.8.5
99
76
  signing_key:
100
77
  specification_version: 3
101
78
  summary: A Rake task to run jekyll