我正在编写一个gem,当从rubygems下载gem时,我需要将library(ggplot2)
library(Cairo) # For nicer ggplot2 output when deployed on Linux
library(shiny)
ui <- fluidPage(
fluidRow(
column(width = 8, class = "well",
h4("Left plot controls right plot"),
fluidRow(
column(width = 6,
plotOutput("plot2", height = 300,
brush = brushOpts(
id = "plot2_brush",
resetOnNew = TRUE
),
#add the hover options
hover = hoverOpts(
id = "plot2_hover",
nullOutside = TRUE
)
)
),
column(width = 6,
#the second plot will be hidden if the user's mouse is not on the first one
conditionalPanel(
condition = "input.plot2_hover != null",
plotOutput("plot3", height = 300)
)
)
)
)
)
)
server <- function(input, output) {
ranges2 <- reactiveValues(x = NULL, y = NULL)
output$plot2 <- renderPlot({
ggplot(mtcars, aes(wt, mpg)) +
geom_point()
})
output$plot3 <- renderPlot({
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
coord_cartesian(xlim = ranges2$x, ylim = ranges2$y)
})
# When a double-click happens, check if there's a brush on the plot.
# If so, zoom to the brush bounds; if not, reset the zoom.
observe({
brush <- input$plot2_brush
print(input$plot2_hover)
if (!is.null(brush)) {
ranges2$x <- c(brush$xmin, brush$xmax)
ranges2$y <- c(brush$ymin, brush$ymax)
} else {
ranges2$x <- NULL
ranges2$y <- NULL
}
})
}
shinyApp(ui, server)
文件安装到.bat
中。
rails gem似乎做了类似的事情,因为在运行bin
之后,gem install rails
文件显示在我的ruby安装目录中(我在Windows上,但我确定相当于shell脚本显示在* nix系统上)
我的问题是,rails.bat
如何进入bin目录,当用户安装我的gem时,如何模仿此操作以将rails.bat
文件放入bin?
答案 0 :(得分:1)
在gemspec中,您可以使用executables
选项添加二进制文件。
Rails通过添加rails可执行文件在railties.gemspec
中执行此操作:
s.executables = ['rails']
RubyGems指南有section on "Adding an executable"
gem install <gem-name>
负责在Ruby .bat
文件夹中创建bin
文件