Created
November 19, 2013 05:40
-
-
Save foloinfo/7540812 to your computer and use it in GitHub Desktop.
Rからerb記述が含まれるyamlを読み込む ref: http://qiita.com/foloinfo/items/9ce4662953f9ace094e1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> system('ruby -e "puts 1+1"', intern=TRUE) | |
[1] "2" | |
> system("ruby script.rb", intern=T) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
p ERB.new(File.read('database.yml')).result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yaml.load(yaml.load(system("ruby load_erb.rb", intern=T))) | |
$test | |
$test$adapter | |
[1] "sqlite3" | |
$test$database | |
[1] "db/test.sqlite3" | |
$test$pool | |
[1] 5 | |
$test$timeout | |
[1] 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eq <- "ruby -e 'require \"erb\"; p ERB.new(File.read(\"database.yml\")).result'" | |
yaml.load(yaml.load(system(eq, intern=T))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yaml.load_erb <- function(path){ | |
eq <- paste("ruby -e 'require \"erb\"; p ERB.new(File.read(\"", path,"\")).result'", collapse='', sep='') | |
yaml.load(yaml.load(system(eq, intern=T))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment