rabbitmqadmin-cli 1.0.1-java → 1.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,58 +4,61 @@ class RabbitMqAdminCli
4
4
  def initialize admin_user = 'guest', admin_password = 'guest'
5
5
  @admin_user = admin_user
6
6
  @admin_password = admin_password
7
+ @verbose = false
7
8
  end
8
9
 
10
+ attr_accessor :verbose
11
+
9
12
  def delete_exchanges
10
- list_exchanges.each { |exchange| `#{run vhost} delete exchange name=#{exchange[:name]}` }
13
+ list_exchanges.each { |exchange| execute "#{stub vhost} delete exchange name=#{exchange[:name]}" }
11
14
  end
12
15
 
13
16
  def delete_queues
14
- list_queues.each { |queue| `#{run vhost} delete queue name=#{queue[:name]}` }
17
+ list_queues.each { |queue| execute "#{stub vhost} delete queue name=#{queue[:name]}" }
15
18
  end
16
19
 
17
20
  def initialize_user vhost, user, password, tags = ''
18
21
  raise "Can't initialize the admin user '#{user}' without crippling your access" if user == @admin_user
19
22
 
20
- `#{run} delete user name=#{user}` if user_exists? user
21
- `#{run} declare user name=#{user} password=#{password} tags=#{tags}`
23
+ execute "#{stub} delete user name=#{user}" if user_exists? user
24
+ execute "#{stub} declare user name=#{user} password=#{password} tags=#{tags}"
22
25
  add_user_to_vhost vhost, user
23
26
  end
24
27
 
25
28
  def initialize_vhost vhost
26
- `#{run} delete vhost name=#{vhost}` if vhost_exists? vhost
27
- `#{run} declare vhost name=#{vhost}`
29
+ execute "#{stub} delete vhost name=#{vhost}" if vhost_exists? vhost
30
+ execute "#{stub} declare vhost name=#{vhost}"
28
31
  add_user_to_vhost vhost, @admin_user
29
32
  end
30
33
 
31
- def run vhost = nil
34
+ def stub vhost = nil
32
35
  vhost_arg = vhost.nil? ? '' : "-V #{vhost}"
33
36
 
34
37
  "rabbitmqadmin -u #{@admin_user} -p #{@admin_password} -f raw_json #{vhost_arg}"
35
38
  end
36
39
 
37
40
  def list_bindings vhost
38
- parse `#{run vhost} list bindings`
41
+ parse execute("#{stub vhost} list bindings")
39
42
  end
40
43
 
41
44
  def list_exchanges vhost
42
- parse `#{run vhost} list exchanges`
45
+ parse execute("#{stub vhost} list exchanges")
43
46
  end
44
47
 
45
48
  def list_queues vhost
46
- parse `#{run vhost} list queues`
49
+ parse execute("#{stub vhost} list queues")
47
50
  end
48
51
 
49
52
  def list_users
50
- parse `#{run} list users`
53
+ parse execute("#{stub} list users")
51
54
  end
52
55
 
53
56
  def list_vhosts
54
- parse `#{run} list vhosts`
57
+ parse execute("#{stub} list vhosts")
55
58
  end
56
59
 
57
60
  def purge_queues
58
- list_queues.each { |queue| `#{run vhost} purge queue name=#{queue[:name]}` }
61
+ list_queues.each { |queue| execute "#{stub vhost} purge queue name=#{queue[:name]}" }
59
62
  end
60
63
 
61
64
  def user_exists? user
@@ -68,11 +71,16 @@ class RabbitMqAdminCli
68
71
 
69
72
  private
70
73
 
71
- def parse json
72
- JSON.parse json, :symbolize_names => true
74
+ def add_user_to_vhost vhost, user
75
+ execute "#{stub} -V #{vhost} declare permission vhost=#{vhost} user=#{user} configure=\"\.\*\" write=\"\.\*\" read=\"\.\*\""
73
76
  end
74
77
 
75
- def add_user_to_vhost vhost, user
76
- `#{run} -V #{vhost} declare permission vhost=#{vhost} user=#{user} configure=\"\.\*\" write=\"\.\*\" read=\"\.\*\"`
78
+ def execute command
79
+ puts command if @verbose
80
+ `#{command}`
81
+ end
82
+
83
+ def parse json
84
+ JSON.parse json, :symbolize_names => true
77
85
  end
78
86
  end
@@ -1,3 +1,3 @@
1
1
  module RabbitMqAdminCli
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rabbitmqadmin-cli'
3
- s.version = '1.0.1'
3
+ s.version = '1.0.2'
4
4
  s.platform = RUBY_PLATFORM.to_s == 'java' ? 'java' : Gem::Platform::RUBY
5
5
  s.authors = ['Lee Henson', 'Guy Boertje']
6
6
  s.email = ['lee.m.henson@gmail.com', 'guyboertje@gmail.com']
metadata CHANGED
@@ -1,66 +1,73 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rabbitmqadmin-cli
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.2
6
6
  platform: java
7
- authors:
8
- - Lee Henson
9
- - Guy Boertje
10
- autorequire:
7
+ authors:
8
+ - Lee Henson
9
+ - Guy Boertje
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-28 00:00:00.000000000 +01:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: json-jruby
18
- version_requirements: &2172 !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '0'
23
- none: false
24
- requirement: *2172
25
- prerelease: false
26
- type: :runtime
13
+
14
+ date: 2011-10-02 00:00:00 +01:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: json-jruby
19
+ prerelease: false
20
+ requirement: &id001 !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: "0"
26
+ type: :runtime
27
+ version_requirements: *id001
27
28
  description: Requires rabbitmqadmin to be in your path
28
- email:
29
- - lee.m.henson@gmail.com
30
- - guyboertje@gmail.com
29
+ email:
30
+ - lee.m.henson@gmail.com
31
+ - guyboertje@gmail.com
31
32
  executables: []
33
+
32
34
  extensions: []
35
+
33
36
  extra_rdoc_files: []
34
- files:
35
- - Gemfile
36
- - Rakefile
37
- - lib/rabbitmqadmin-cli.rb
38
- - lib/rabbitmqadmin-cli/version.rb
39
- - rabbitmqadmin-cli.gemspec
37
+
38
+ files:
39
+ - Gemfile
40
+ - Rakefile
41
+ - lib/rabbitmqadmin-cli.rb
42
+ - lib/rabbitmqadmin-cli/version.rb
43
+ - rabbitmqadmin-cli.gemspec
40
44
  has_rdoc: true
41
45
  homepage: http://github.com/leemhenson/rabbitmqadmin-cli
42
46
  licenses: []
43
- post_install_message:
47
+
48
+ post_install_message:
44
49
  rdoc_options: []
45
- require_paths:
46
- - lib
47
- required_ruby_version: !ruby/object:Gem::Requirement
48
- requirements:
49
- - - ! '>='
50
- - !ruby/object:Gem::Version
51
- version: '0'
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
52
54
  none: false
53
- required_rubygems_version: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ! '>='
56
- - !ruby/object:Gem::Version
57
- version: '0'
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
60
  none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
59
65
  requirements: []
60
- rubyforge_project:
66
+
67
+ rubyforge_project:
61
68
  rubygems_version: 1.5.1
62
- signing_key:
69
+ signing_key:
63
70
  specification_version: 3
64
71
  summary: Ruby wrapper for calling out the rabbitmqadmin cli script
65
72
  test_files: []
66
- ...
73
+