carrot-top 0.0.1.alpha → 0.0.2.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ task :default => "test"
5
+
6
+ Rake::TestTask.new do |test|
7
+ test.pattern = "test/*_test.rb"
8
+ end
data/carrot-top.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "carrot-top"
6
- s.version = "0.0.1.alpha"
6
+ s.version = "0.0.2.alpha"
7
7
  s.authors = ["Sean Porter"]
8
8
  s.email = ["portertech@gmail.com"]
9
9
  s.homepage = "https://github.com/portertech/carrot-top"
@@ -18,4 +18,5 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_dependency "json"
20
20
  s.add_development_dependency "minitest"
21
+ s.add_development_dependency "webmock"
21
22
  end
data/lib/carrot-top.rb CHANGED
@@ -10,14 +10,14 @@ class CarrotTop
10
10
  end
11
11
  @ssl = options[:ssl] || false
12
12
  protocol = @ssl ? "https" : "http"
13
- @rabbitmq_api = "#{protocol}://#{host}:#{port}/api"
13
+ @rabbitmq_api = "#{protocol}://#{options[:host]}:#{options[:port]}/api"
14
14
  @user = options[:user]
15
15
  @password = options[:password]
16
16
  end
17
17
 
18
18
  def query_api(options={})
19
19
  raise "You must supply an API path" if options[:path].nil?
20
- URI.parse(@rabbitmq_api + options[:path])
20
+ uri = URI.parse(@rabbitmq_api + options[:path])
21
21
  http = Net::HTTP.new(uri.host, uri.port)
22
22
  if options[:ssl] == true
23
23
  http.use_ssl = true
@@ -29,7 +29,7 @@ class CarrotTop
29
29
  http.request(request)
30
30
  end
31
31
 
32
- def self.method_missing(method, *args, &block)
32
+ def method_missing(method, *args, &block)
33
33
  response = self.query_api(:path => "/#{method}")
34
34
  JSON.parse(response.body)
35
35
  end
@@ -0,0 +1,25 @@
1
+ $: << "#{File.dirname(__FILE__)}/../lib" unless $:.include?("#{File.dirname(__FILE__)}/../lib/")
2
+ require "rubygems" if RUBY_VERSION < "1.9.0"
3
+ gem "minitest"
4
+ require "minitest/autorun"
5
+ require "webmock/minitest"
6
+ require "carrot-top"
7
+
8
+ class TestCarrotTop < MiniTest::Unit::TestCase
9
+ def setup
10
+ stub_request(:get, /.*user:password@localhost:55672.*/).
11
+ with(:headers => {'content-type'=>'application/json'}).
12
+ to_return(:status => 200, :body => '{"status": "success"}', :headers => {'content-type'=>'application/json'})
13
+ @rabbitmq_info = CarrotTop.new(:host => "localhost", :port => 55672, :user => "user", :password => "password")
14
+ end
15
+
16
+ def test_channels
17
+ response = @rabbitmq_info.channels
18
+ assert response["status"] == "success"
19
+ end
20
+
21
+ def test_queues
22
+ response = @rabbitmq_info.queues
23
+ assert response["status"] == "success"
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrot-top
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha
4
+ version: 0.0.2.alpha
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70093417920820 !ruby/object:Gem::Requirement
16
+ requirement: &70340034362080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70093417920820
24
+ version_requirements: *70340034362080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70093417920000 !ruby/object:Gem::Requirement
27
+ requirement: &70340034360660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,18 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70093417920000
35
+ version_requirements: *70340034360660
36
+ - !ruby/object:Gem::Dependency
37
+ name: webmock
38
+ requirement: &70340034358580 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70340034358580
36
47
  description: A Ruby library for querying the RabbitMQ Management API
37
48
  email:
38
49
  - portertech@gmail.com
@@ -45,6 +56,7 @@ files:
45
56
  - Rakefile
46
57
  - carrot-top.gemspec
47
58
  - lib/carrot-top.rb
59
+ - test/carrot-top_test.rb
48
60
  homepage: https://github.com/portertech/carrot-top
49
61
  licenses: []
50
62
  post_install_message:
@@ -69,4 +81,5 @@ rubygems_version: 1.8.10
69
81
  signing_key:
70
82
  specification_version: 3
71
83
  summary: A Ruby library for querying the RabbitMQ Management API
72
- test_files: []
84
+ test_files:
85
+ - test/carrot-top_test.rb