Class: BugsBunny::CLI
- Inherits:
-
Object
- Object
- BugsBunny::CLI
- Defined in:
- lib/bugs_bunny/cli.rb
Constant Summary collapse
- CONFIG_FILE =
"rabbitmq.yml"
Instance Method Summary collapse
-
#config ⇒ Object
Write down a yml in ./ or config/ for ease use with bugs and on the.
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #seed ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bugs_bunny/cli.rb', line 17 def initialize(argv) if respond_to?(argv[0]) send(*argv) else parse_config rb = BugsBunny::Rabbit.new unless rb.respond_to?(argv[0]) puts "Can`t do that."; exit end log "Connecting to rabbitmq #{Opt[:rabbit][:vhost]}" AMQP.start(Opt[:rabbit]) { rb.start!(argv) } end end |
Instance Method Details
#config ⇒ Object
Write down a yml in ./ or config/ for ease use with bugs and on the
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bugs_bunny/cli.rb', line 33 def config path = "./" path = "config/" if File.exists?("config/") if config_exists?(path) && !Opt[:force] puts "Config file already exists" exit else FileUtils.copy(File.dirname(__FILE__) + "/#{CONFIG_FILE}", path) puts "Copied config file to #{path}" end end |
#seed ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/bugs_bunny/cli.rb', line 45 def seed parse_config puts "Creating user and vhost" puts `rabbitmqctl add_user #{Opt[:rabbit][:user]} #{Opt[:rabbit][:pass]}` puts `rabbitmqctl add_vhost #{Opt[:rabbit][:vhost]}` puts `rabbitmqctl set_permissions -p #{Opt[:rabbit][:vhost]} #{Opt[:rabbit][:user]} ".*" ".*" ".*"` end |