2013-05-11 2 views
1

나는 레이크 작업을 Octopress Rakefile에 추가하려고하는데, 다른 레이크 파일에 작업을 넣고 싶습니다. 그러나 레이크 파일을 가져올 때, 레이크 파일의 맨 위에있는 상수에 액세스 할 수 없습니다. 레이크 파일. 이것은 내가 아이 파일에서 읽을 수 아니에요 설정의 종류rakefile을 깨는 방법?

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

입니다 :

내가 함께 자식 rakefile을 수입하고있어 여기에

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') 

오류입니다 :

rake aborted! undefined local variable or method `source_dir' for main:Object

답변

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') 
+0

휴식 그런 종류의 Octopress에서 Rakefile의 수정을 피할 수있는 내 목표 상수. 그러나 그것이 어떻게 작동하는지 알 수 있습니다. 로컬 변수를 내보내는 일반적인 방법은 무엇입니까? – justingordon