Sha256: 7f1c36a9e3a466d85f8292a710a4f0ee2331f4951b90715a010f33004d03291e

Contents?: true

Size: 1.62 KB

Versions: 6

Compression:

Stored size: 1.62 KB

Contents

module Legion
  class Cli
    module Lex
      class Queue < Thor
        include Thor::Actions

        def self.source_root
          File.dirname(__FILE__)
        end

        no_commands do
          def lex
            Dir.pwd.split('/').last.split('-').last
          end
        end

        desc 'create :name', 'creates a new queue'
        def create(name)
          template('templates/queue_helper.erb', 'spec/queue_helper.rb')
          template('templates/queue.erb',
                   "lib/legion/extensions/#{lex}/transport/queues/#{name}.rb",
                   { name: name, lex: lex })
          template('templates/queue_spec.erb', "spec/queues/#{name}_spec.rb", { name: name, lex: lex })
        end

        desc 'delete :name', 'deletes a queue config file'
        def delete(name)
          remove_file("lib/legion/extensions/#{lex}/transport/queues/#{name}.rb")
          remove_file("spec/queues/#{name}_spec.rb")
          remove_file("spec/transport/queues/#{name}_spec.rb")

          # puts Dir.pwd # /Users/miverso2/Rubymine/lex/wip/lex-conflux
          if Dir.exist? "#{Dir.pwd}/lib/legion/extensions/#{lex}/transport/queues/"
            remove_dir("#{Dir.pwd}/lib/legion/extensions/#{lex}/transport/queues") if Dir.empty?("#{Dir.pwd}/lib/legion/extensions/#{lex}/transport/queues/")
            remove_dir("#{Dir.pwd}/lib/legion/extensions/#{lex}/transport") if Dir.empty?("#{Dir.pwd}/lib/legion/extensions/#{lex}/transport")
          end

          remove_dir("#{Dir.pwd}/spec/queues") if Dir.exist?("#{Dir.pwd}/spec/queues") && Dir.empty?("#{Dir.pwd}/spec/queues")

          nil
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
legionio-1.2.1 lib/legion/cli/lex/queue.rb
legionio-1.2.0 lib/legion/cli/lex/queue.rb
legionio-0.4.3 lib/legion/cli/lex/queue.rb
legionio-0.4.2 lib/legion/cli/lex/queue.rb
legionio-0.4.1 lib/legion/cli/lex/queue.rb
legionio-0.4.0 lib/legion/cli/lex/queue.rb