thor

how to distribute a ruby script via homebrew

喜你入骨 提交于 2019-12-01 12:11:14
How can I deploy a simple ruby script via homebrew? Here's what I tried Wrote formula in a GitHub repo named homebrew-foo # file https://github.com/foo/homebrew-foo/blob/master/foo.rb class Foo < Formula desc "A command line tool" url "https://github.com/foo/foo/archive/master.zip" version "5.0.1" def install bin.install "foo" lib.install Dir["lib/*"] end end The other repository contains the ruby script. These are the files ./foo ./lib/libfile1.rb here's what the script does #!/usr/bin/env ruby require './lib/libfile1.rb' puts "came here" The problem is that the require fails. $ brew install

how to distribute a ruby script via homebrew

余生长醉 提交于 2019-12-01 10:36:36
问题 How can I deploy a simple ruby script via homebrew? Here's what I tried Wrote formula in a GitHub repo named homebrew-foo # file https://github.com/foo/homebrew-foo/blob/master/foo.rb class Foo < Formula desc "A command line tool" url "https://github.com/foo/foo/archive/master.zip" version "5.0.1" def install bin.install "foo" lib.install Dir["lib/*"] end end The other repository contains the ruby script. These are the files ./foo ./lib/libfile1.rb here's what the script does #!/usr/bin/env

Thor & YAML outputting as binary?

南笙酒味 提交于 2019-11-30 17:50:40
I'm using Thor and trying to output YAML to a file. In irb I get what I expect. Plain text in YAML format. But when part of a method in Thor, its output is different... class Foo < Thor include Thor::Actions desc "bar", "test" def set test = {"name" => "Xavier", "age" => 30} puts test # {"name"=>"Xavier", "age"=>30} puts test.to_yaml # !binary "bmFtZQ==": !binary |- # WGF2aWVy # !binary "YWdl": 30 File.open("data/config.yml", "w") {|f| f.write(test.to_yaml) } end end Any ideas? All Ruby 1.9 strings have an encoding attached to them. YAML encodes some non-UTF8 strings as binary, even when they

Call task more than once in Rails 3 generator

流过昼夜 提交于 2019-11-30 07:07:04
I'm writing a Rails 3 generator that creates two different models. Here's a very simplified example of what I'm trying to do: def my_generator_task invoke "model", ["foo"] invoke "model", ["bar"] end The problem is that the Thor invoke method only invokes a task once, so the second call to the "model" task never happens and the "bar" model is never created. Does anyone know an elegant way to accomplish this, preferably in a way that doesn't break the ability to run "rails destroy" with the generator? One more thought, this way it is also possible to run multiple model generator without

Thor & YAML outputting as binary?

本小妞迷上赌 提交于 2019-11-30 01:51:53
问题 I'm using Thor and trying to output YAML to a file. In irb I get what I expect. Plain text in YAML format. But when part of a method in Thor, its output is different... class Foo < Thor include Thor::Actions desc "bar", "test" def set test = {"name" => "Xavier", "age" => 30} puts test # {"name"=>"Xavier", "age"=>30} puts test.to_yaml # !binary "bmFtZQ==": !binary |- # WGF2aWVy # !binary "YWdl": 30 File.open("data/config.yml", "w") {|f| f.write(test.to_yaml) } end end Any ideas? 回答1: All Ruby

Net::SSH sudo command hangs after entering password

余生颓废 提交于 2019-11-27 05:49:06
问题 I've been trying to write a small library using Thor to help assist me in quick creating new projects and sites. I wrote this small method: def ssh(cmd) Net::SSH.start( server_ip, user, :port => port) do |session| session.exec cmd end end to just assist me in running quick commands on remote servers when needed. The problem is when I need to run a command under sudo on the remote end, the script just seems to hang on me. For example when executing this... ssh("sudo cp #{file_from_path} #{file