superbolt-http 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ca96b3a19a16883dca62fd2b236a03eb816e14e3
4
+ data.tar.gz: 9afe7c13c3e4eb1a7fa1e3c6586f8df29f8906c3
5
+ SHA512:
6
+ metadata.gz: 20cf111562fdad4824c5a940dc14690cb76009632ce9f8e295c3e24139901c45a69821e17e454db5c301a9320877e9977ce441b4411982b4793d15f56c5f3427
7
+ data.tar.gz: d898b71eff4c5d920bc373d86961e1f0f6fcf048c0ef7c08cac70468e2317d0d2ea6667d484a80dc7ad1e9e0b592784e828f356c4598a4d9b3218cd9aec4079b
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in superbolt-http.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 socialchorus
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Superbolt::Http
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'superbolt-http'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install superbolt-http
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ module Superbolt
2
+ module Http
3
+ class Channel
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,45 @@
1
+ module Superbolt
2
+ module Http
3
+ class Connection < OpenStruct
4
+ class << self
5
+ attr_accessor :url
6
+ end
7
+
8
+ def self.all
9
+ raise NoConnectionUrl unless url
10
+ rest_client_get(base_url).map do |conn|
11
+ new conn
12
+ end
13
+ end
14
+
15
+ def self.get(name)
16
+ raise NoConnectionUrl unless url
17
+ new rest_client_get(base_url + "/#{name}")
18
+ end
19
+
20
+ def self.delete(name)
21
+ raise NoConnectionUrl unless url
22
+ rest_client_delete(base_url + "/#{name}")
23
+ end
24
+
25
+
26
+ private
27
+
28
+ def self.base_url
29
+ "#{url}/api/connections"
30
+ end
31
+
32
+ def self.rest_client_get(uri)
33
+ JSON.parse(
34
+ RestClient.get(URI.escape(uri))
35
+ )
36
+ end
37
+
38
+ def self.rest_client_delete(uri)
39
+ RestClient.delete URI.escape(uri)
40
+ end
41
+
42
+ class NoConnectionUrl < StandardError; end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ module Superbolt
2
+ module Http
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'ostruct'
2
+ require 'json'
3
+ require 'uri'
4
+
5
+ require 'rest-client'
6
+
7
+ require "superbolt/http/version"
8
+ require "superbolt/http/connection"
File without changes
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'bunny'
3
+
4
+ describe Superbolt::Http::Connection, 'functional specs' do
5
+ let(:url) { 'http://guest:guest@localhost:15672' }
6
+
7
+ before do
8
+ Superbolt::Http::Connection.url = url
9
+ end
10
+
11
+ it ".all should return two connections" do
12
+ Bunny.new.start
13
+ Bunny.new.start
14
+ expect(Superbolt::Http::Connection.all.count).to eq(2)
15
+ end
16
+
17
+ it ".delete should reduce the connections" do
18
+ # all_connections = Superbolt::Http::Connection.all
19
+ # Superbolt::Http::Connection.delete(all_connections[0].name)
20
+ end
21
+ end
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+ require 'bunny'
3
+
4
+ describe Superbolt::Http::Connection do
5
+ let(:url) { 'http://guest:guest@localhost:15672' }
6
+ let(:single_connection) { "{\"name\": \"somename\"}" }
7
+ let(:multiple_connections) { "[ {\"name\": \"firstconnection\"} ]" }
8
+
9
+ describe '.all' do
10
+ let(:connections) { Superbolt::Http::Connection.all }
11
+
12
+ context 'when a url is not defined' do
13
+ before do
14
+ Superbolt::Http::Connection.url = nil
15
+ end
16
+
17
+ it "should raise an error" do
18
+ expect { connections }.to raise_error(Superbolt::Http::Connection::NoConnectionUrl)
19
+ end
20
+ end
21
+
22
+ context 'when a url is defined' do
23
+ before do
24
+ Superbolt::Http::Connection.url = url
25
+ RestClient.should_receive(:get)
26
+ .with("http://guest:guest@localhost:15672/api/connections")
27
+ .and_return(multiple_connections)
28
+ end
29
+
30
+ it 'returns an array of connection elements wrapped with Superbolt::Http::Connection' do
31
+ connections.should be_a Array
32
+ connections.first.should be_a Superbolt::Http::Connection
33
+ end
34
+
35
+ it "returns a list of all open connections with the right content" do
36
+ connections[0].name.should == "firstconnection"
37
+ connections[0].should be_an_instance_of(Superbolt::Http::Connection)
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ describe '.get' do
44
+ let(:get_connection) { Superbolt::Http::Connection.get('somename') }
45
+
46
+ context 'when a url is not defined' do
47
+ before do
48
+ Superbolt::Http::Connection.url = nil
49
+ end
50
+
51
+ it "should raise an error" do
52
+ expect { get_connection }.to raise_error(Superbolt::Http::Connection::NoConnectionUrl)
53
+ end
54
+ end
55
+
56
+ context 'when a url is defined' do
57
+ before do
58
+ Superbolt::Http::Connection.url = url
59
+ RestClient.should_receive(:get)
60
+ .with("http://guest:guest@localhost:15672/api/connections/somename")
61
+ .and_return(single_connection)
62
+ end
63
+
64
+ it 'returns a single connection specified by the name' do
65
+ get_connection.name.should == "somename"
66
+ get_connection.should be_an_instance_of(Superbolt::Http::Connection)
67
+ end
68
+ end
69
+ end
70
+
71
+
72
+ describe '.delete' do
73
+ let(:delete_connection) { Superbolt::Http::Connection.delete('somename') }
74
+
75
+ context 'when a url is not defined' do
76
+ before do
77
+ Superbolt::Http::Connection.url = nil
78
+ end
79
+
80
+ it "should raise an error" do
81
+ expect { delete_connection }.to raise_error(Superbolt::Http::Connection::NoConnectionUrl)
82
+ end
83
+ end
84
+
85
+ context "when a url is defined" do
86
+ before do
87
+ Superbolt::Http::Connection.url = url
88
+ end
89
+
90
+ it 'sends a delete request to the right url' do
91
+ RestClient.should_receive(:delete)
92
+ .with("http://guest:guest@localhost:15672/api/connections/somename")
93
+ delete_connection
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,19 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require_relative '../lib/superbolt/http'
8
+
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'superbolt/http/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "superbolt-http"
8
+ spec.version = Superbolt::Http::VERSION
9
+ spec.authors = ["Sowjanya Mudunuri"]
10
+ spec.email = ["developers@socialchorus.com"]
11
+ spec.description = %q{An easy http interface for RabbitMQ}
12
+ spec.summary = %q{An easy http interface for RabbitMQ}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "superbolt"
22
+ spec.add_runtime_dependency "rest-client"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency 'rspec'
27
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: superbolt-http
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sowjanya Mudunuri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: superbolt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: An easy http interface for RabbitMQ
84
+ email:
85
+ - developers@socialchorus.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/superbolt/http.rb
97
+ - lib/superbolt/http/channel.rb
98
+ - lib/superbolt/http/connection.rb
99
+ - lib/superbolt/http/version.rb
100
+ - spec/channel_spec.rb
101
+ - spec/connection_functional_spec.rb
102
+ - spec/connection_spec.rb
103
+ - spec/spec_helper.rb
104
+ - superbolt-http.gemspec
105
+ homepage: ''
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.0.7
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: An easy http interface for RabbitMQ
129
+ test_files:
130
+ - spec/channel_spec.rb
131
+ - spec/connection_functional_spec.rb
132
+ - spec/connection_spec.rb
133
+ - spec/spec_helper.rb