1

Octopress Rakefile にいくつかの rake タスクを追加しようとしています。タスクを別の子 rakefile に入れたいのですが、子 rakefile をインポートすると、rakefile の先頭にある定数にアクセスできません。

子rakefileを次のようにインポートしています:

Dir.glob('rakefiles/*.rake').each { |r| import r }

これは、子ファイルで読み取ることができない種類の構成です。

public_dir      = "public"    # compiled site directory
source_dir      = "source"    # source file directory
blog_index_dir  = 'source'    # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')

エラーは次のとおりです。

レーキが中止されました! main:Object の未定義のローカル変数またはメソッド「source_dir」

4

1 に答える 1

2

次のようなクラス変数を使用する必要があります

@public_dir      = "public"    # compiled site directory
@source_dir      = "source"    # source file directory
@blog_index_dir  = 'source'    # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')

または定数

PUBLIC_DIR      = "public"    # compiled site directory
SOURCE_DIR      = "source"    # source file directory
BLOG_INDEX_DIR  = 'source'    # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')
于 2013-05-11T09:45:03.420 に答える