made filename munging more idiomatic, rake tasks work properly again
This commit is contained in:
parent
3af16f3afe
commit
1978a5fe98
@ -83,8 +83,7 @@ Dir.mkdir output_dir if !File.directory?(output_dir)
|
|||||||
# Run each file through Rocco and write output.
|
# Run each file through Rocco and write output.
|
||||||
sources.each do |filename|
|
sources.each do |filename|
|
||||||
rocco = Rocco.new(filename, sources, options)
|
rocco = Rocco.new(filename, sources, options)
|
||||||
fnparts = filename.split('.')
|
dest = filename.split('.')[0..-2].join('.') + '.html'
|
||||||
dest = fnparts.slice(0, fnparts.length - 1).join('.') + '.html'
|
|
||||||
puts "rocco: #{filename} -> #{dest}"
|
puts "rocco: #{filename} -> #{dest}"
|
||||||
File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) }
|
File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) }
|
||||||
end
|
end
|
||||||
|
@ -28,11 +28,10 @@ class Rocco::Layout < Mustache
|
|||||||
|
|
||||||
def sources
|
def sources
|
||||||
@doc.sources.sort.map do |source|
|
@doc.sources.sort.map do |source|
|
||||||
srcparts = File.basename(source).split('.')
|
|
||||||
{
|
{
|
||||||
:path => source,
|
:path => source,
|
||||||
:basename => File.basename(source),
|
:basename => File.basename(source),
|
||||||
:url => srcparts.slice(0, srcparts.length - 1).join('.') + '.html'
|
:url => File.basename(source).split('.')[0..-2].join('.') + '.html'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -51,8 +51,8 @@ require 'rocco'
|
|||||||
# of sugar over `Rocco::Task.new`. If you want your Rake task to be named
|
# of sugar over `Rocco::Task.new`. If you want your Rake task to be named
|
||||||
# something other than `:rocco`, you can use `Rocco::Task` directly.
|
# something other than `:rocco`, you can use `Rocco::Task` directly.
|
||||||
class Rocco
|
class Rocco
|
||||||
def self.make(dest='docs/', source_files='lib/**/*.rb')
|
def self.make(dest='docs/', source_files='lib/**/*.rb', options={})
|
||||||
Task.new(:rocco, dest, source_files)
|
Task.new(:rocco, dest, source_files, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
# `Rocco::Task.new` takes a task name, the destination directory docs
|
# `Rocco::Task.new` takes a task name, the destination directory docs
|
||||||
@ -70,7 +70,7 @@ class Rocco
|
|||||||
# Run over the source file list, constructing destination filenames
|
# Run over the source file list, constructing destination filenames
|
||||||
# and defining file tasks.
|
# and defining file tasks.
|
||||||
@sources.each do |source_file|
|
@sources.each do |source_file|
|
||||||
dest_file = File.basename(source_file, '.rb') + '.html'
|
dest_file = File.basename(source_file).split('.')[0..-2].join('.') + '.html'
|
||||||
define_file_task source_file, "#{@dest}#{dest_file}"
|
define_file_task source_file, "#{@dest}#{dest_file}"
|
||||||
|
|
||||||
# If `rake/clean` was required, add the generated files to the list.
|
# If `rake/clean` was required, add the generated files to the list.
|
||||||
|
Loading…
Reference in New Issue
Block a user