a9s_rabbitmq 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6622e9635f3a915a644f886d6e5f3612d0f23828
4
+ data.tar.gz: ed80baa57a5d5f0e03dcf6c22b08767e56142022
5
+ SHA512:
6
+ metadata.gz: f861d707a0931d06ffda400b25421452d70b43bcab86ccba0eee47b8285e921389b3c2ee46a009dc075a72d6e86d3d994574eece18ef5a26ca100661bbdbcb62
7
+ data.tar.gz: 657f90179924fa9c1dc33745eaf83a0c370697408e839c696bb0e37ef3899da3cd3135b1d5ef3124b840bf9c580858889bcc9550351cd50f60f239ab664130fe
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.0"
12
+ gem "jeweler", "~> 2.0.1"
13
+ gem "simplecov", ">= 0"
14
+ end
@@ -0,0 +1,81 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (4.0.4)
5
+ i18n (~> 0.6, >= 0.6.9)
6
+ minitest (~> 4.2)
7
+ multi_json (~> 1.3)
8
+ thread_safe (~> 0.1)
9
+ tzinfo (~> 0.3.37)
10
+ addressable (2.3.5)
11
+ atomic (1.1.15)
12
+ builder (3.2.2)
13
+ descendants_tracker (0.0.3)
14
+ docile (1.1.3)
15
+ faraday (0.9.0)
16
+ multipart-post (>= 1.2, < 3)
17
+ git (1.2.6)
18
+ github_api (0.11.3)
19
+ addressable (~> 2.3)
20
+ descendants_tracker (~> 0.0.1)
21
+ faraday (~> 0.8, < 0.10)
22
+ hashie (>= 1.2)
23
+ multi_json (>= 1.7.5, < 2.0)
24
+ nokogiri (~> 1.6.0)
25
+ oauth2
26
+ hashie (2.0.5)
27
+ highline (1.6.21)
28
+ i18n (0.6.9)
29
+ jeweler (2.0.1)
30
+ builder
31
+ bundler (>= 1.0)
32
+ git (>= 1.2.5)
33
+ github_api
34
+ highline (>= 1.6.15)
35
+ nokogiri (>= 1.5.10)
36
+ rake
37
+ rdoc
38
+ json (1.8.1)
39
+ jwt (0.1.11)
40
+ multi_json (>= 1.5)
41
+ mini_portile (0.5.3)
42
+ minitest (4.7.5)
43
+ multi_json (1.9.2)
44
+ multi_xml (0.5.5)
45
+ multipart-post (2.0.0)
46
+ nokogiri (1.6.1)
47
+ mini_portile (~> 0.5.0)
48
+ oauth2 (0.9.3)
49
+ faraday (>= 0.8, < 0.10)
50
+ jwt (~> 0.1.8)
51
+ multi_json (~> 1.3)
52
+ multi_xml (~> 0.5)
53
+ rack (~> 1.2)
54
+ rack (1.5.2)
55
+ rake (10.2.2)
56
+ rdoc (3.12.2)
57
+ json (~> 1.4)
58
+ shoulda (3.5.0)
59
+ shoulda-context (~> 1.0, >= 1.0.1)
60
+ shoulda-matchers (>= 1.4.1, < 3.0)
61
+ shoulda-context (1.1.6)
62
+ shoulda-matchers (2.5.0)
63
+ activesupport (>= 3.0.0)
64
+ simplecov (0.8.2)
65
+ docile (~> 1.1.0)
66
+ multi_json
67
+ simplecov-html (~> 0.8.0)
68
+ simplecov-html (0.8.0)
69
+ thread_safe (0.3.1)
70
+ atomic (>= 1.1.7, < 2)
71
+ tzinfo (0.3.39)
72
+
73
+ PLATFORMS
74
+ ruby
75
+
76
+ DEPENDENCIES
77
+ bundler (~> 1.0)
78
+ jeweler (~> 2.0.1)
79
+ rdoc (~> 3.12)
80
+ shoulda
81
+ simplecov
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Julian Weber
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # a9s_rabbitmq
2
+
3
+ The a9s_rabbitmq gem simplifies the configuration of ruby applications using the anynines RabbitMQ service.
4
+ It provides methods for generating configuration hashes for
5
+ * the amqp gem - https://github.com/ruby-amqp/amqp
6
+ * the bunny gem - https://github.com/ruby-amqp/bunny
7
+
8
+ If you would like to use other gems for connecting to the the RabbitMQ service you are also able to retrieve a standard credentials hash (see below).
9
+
10
+
11
+ ## Usage
12
+
13
+ ### AMQP gem
14
+
15
+ AMQP.start(Anynines::RabbitMQ::Utility.amqp_hash) do |connection|
16
+ ...
17
+ end
18
+
19
+ ### bunny gem
20
+
21
+ conn = Bunny.new(Anynines::RabbitMQ::Utility.bunny_hash)
22
+
23
+ ### Other rabbitmq gems
24
+
25
+ credentials_hash = Anynines::RabbitMQ::Utility.credentials_hash # => returns a Hash
26
+
27
+ ## Contributing to a9s_rabbitmq
28
+
29
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
30
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
31
+ * Fork the project.
32
+ * Start a feature/bugfix branch.
33
+ * Commit and push until you are happy with your contribution.
34
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
35
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
36
+
37
+ ## Copyright
38
+
39
+ Copyright (c) 2014 Julian Weber. See LICENSE.txt for
40
+ further details.
41
+
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "a9s_rabbitmq"
18
+ gem.homepage = "http://github.com/anynines/a9s_rabbitmq"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{a9s_rabbitmq is a small utility gem to ease up the usage of the anyines.com rabbitmq service within your applications.}
21
+ gem.description = %Q{a9s_rabbitmq is a small utility gem to ease up the usage of the anyines.com rabbitmq service within your applications.}
22
+ gem.email = "jweber@anynines.com"
23
+ gem.authors = ["Julian Weber"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ desc "Code coverage detail"
36
+ task :simplecov do
37
+ ENV['COVERAGE'] = "true"
38
+ Rake::Task['test'].execute
39
+ end
40
+
41
+ task :default => :test
42
+
43
+ require 'rdoc/task'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "a9s_rabbitmq #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
52
+
53
+ desc 'Run an irb console session'
54
+ task :irb_console do
55
+ exec("irb -r ./lib/a9s_rabbitmq.rb")
56
+ end
57
+
58
+ task irb: :irb_console
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "a9s_rabbitmq"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Julian Weber"]
12
+ s.date = "2014-04-08"
13
+ s.description = "a9s_rabbitmq is a small utility gem to ease up the usage of the anyines.com rabbitmq service within your applications."
14
+ s.email = "jweber@anynines.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "a9s_rabbitmq.gemspec",
28
+ "lib/a9s_rabbitmq.rb",
29
+ "lib/a9s_rabbitmq/utility.rb",
30
+ "test/helper.rb",
31
+ "test/test_a9s_rabbitmq.rb"
32
+ ]
33
+ s.homepage = "http://github.com/anynines/a9s_rabbitmq"
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "2.0.6"
37
+ s.summary = "a9s_rabbitmq is a small utility gem to ease up the usage of the anyines.com rabbitmq service within your applications."
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 4
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
44
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
45
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
46
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
47
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
48
+ else
49
+ s.add_dependency(%q<shoulda>, [">= 0"])
50
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
51
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
52
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
53
+ s.add_dependency(%q<simplecov>, [">= 0"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<shoulda>, [">= 0"])
57
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
58
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
60
+ s.add_dependency(%q<simplecov>, [">= 0"])
61
+ end
62
+ end
63
+
@@ -0,0 +1,10 @@
1
+ module Anynines
2
+ module RabbitMQ
3
+ autoload :Utility, File.expand_path('../a9s_rabbitmq/utility', __FILE__)
4
+
5
+ def self.version
6
+ file = File.open(File.expand_path("../../VERSION", __FILE__))
7
+ return file.read.to_s.tr("\n","")
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,82 @@
1
+ require 'json'
2
+
3
+ module Anynines
4
+ module RabbitMQ
5
+ class Utility
6
+ # Returns a credentials hash for the rabbitmq service
7
+ def self.credentials_hash
8
+ # parse the VCAP_SERVICES environment variable
9
+ services = JSON.parse(ENV["VCAP_SERVICES"])
10
+ raise "Couldn't find the VCAP_SERVICE env variable! Are you running within an anynines environment?" if services.nil?
11
+ raise "Couldn't access the a9s rabbitmq service credentials from env! Have you bound a rabbitmq service instance to the application?" if services["rabbitmq-2.8"].nil?
12
+ rabbit_service = services["rabbitmq-2.8"].first
13
+
14
+ return {
15
+ name: rabbit_service["credentials"]["name"],
16
+ hostname: rabbit_service["credentials"]["hostname"],
17
+ host: rabbit_service["credentials"]["host"],
18
+ port: rabbit_service["credentials"]["port"],
19
+ admin_port: rabbit_service["credentials"]["admin_port"],
20
+ vhost: rabbit_service["credentials"]["vhost"],
21
+ username: rabbit_service["credentials"]["username"],
22
+ user: rabbit_service["credentials"]["user"],
23
+ password: rabbit_service["credentials"]["password"],
24
+ pass: rabbit_service["credentials"]["pass"],
25
+ url: rabbit_service["credentials"]["url"]
26
+ }
27
+ end
28
+
29
+ # returns an amqp gem compatible hash
30
+ # takes an optional hash for specifying additional options like:
31
+ # :ssl (Hash) — TLS (SSL) parameters to use.
32
+ # :heartbeat (Fixnum) — default: 0 — Connection heartbeat, in seconds. 0 means no heartbeat. Can also be configured server-side starting with RabbitMQ 3.0.
33
+ # :on_tcp_connection_failure (#call) — A callable object that will be run if connection to server fails
34
+ # :on_possible_authentication_failure (#call) — A callable object that will be run if authentication fails (see Authentication failure section)
35
+ #
36
+ # @param additional_options [Hash] - additional options hash
37
+ # @returns [Hash] an amqp session hash
38
+ def self.amqp_hash(additional_options = {})
39
+ creds = credentials_hash
40
+
41
+ hash = {
42
+ host: creds[:host],
43
+ port: creds[:port],
44
+ vhost: creds[:vhost],
45
+ username: creds[:username],
46
+ password: creds[:password]
47
+ }
48
+
49
+ hash = additional_options.merge hash
50
+ return hash
51
+ end
52
+
53
+
54
+ # returns a bunny compatible hash
55
+ # takes an optional hash for specifying additional options like:
56
+ # :heartbeat or :heartbeat_interval, in seconds, default is 0 (no heartbeats). :server means "use the value from RabbitMQ config"
57
+ # :log_level (symbol or integer, default: Logger::WARN): log level to use.
58
+ # :log_file (string or IO): log file or IO object to use. Defaults to STDOUT.
59
+ # :automatically_recover (boolean, default: true): when false, will disable automatic network failure recovery
60
+ # :network_recovery_interval (number, default: ``): interval between reconnection attempts
61
+ # :threaded (boolean): switches to single-threaded connections when set to false. Only recommended for apps that only publish messages.
62
+ # :continuation_timeout (integer): timeout for client operations that expect a response (e.g. Bunny::Queue#get), in milliseconds. Default is 4000 ms.
63
+ #
64
+ # @param additional_options [Hash] - additional options hash
65
+ # @returns [Hash] a bunny session hash
66
+ def self.bunny_hash(additional_options = {})
67
+ creds = credentials_hash
68
+
69
+ hash = {
70
+ host: creds[:host],
71
+ port: creds[:port],
72
+ vhost: creds[:vhost],
73
+ username: creds[:username],
74
+ password: creds[:password],
75
+ }
76
+
77
+ hash = additional_options.merge hash
78
+ return hash
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,34 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ require 'rubygems'
18
+ require 'bundler'
19
+ begin
20
+ Bundler.setup(:default, :development)
21
+ rescue Bundler::BundlerError => e
22
+ $stderr.puts e.message
23
+ $stderr.puts "Run `bundle install` to install missing gems"
24
+ exit e.status_code
25
+ end
26
+ require 'test/unit'
27
+ require 'shoulda'
28
+
29
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
30
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
31
+ require 'a9s_rabbitmq'
32
+
33
+ class Test::Unit::TestCase
34
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestA9sRabbitmq < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: a9s_rabbitmq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Julian Weber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: shoulda
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
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.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
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: a9s_rabbitmq is a small utility gem to ease up the usage of the anyines.com
84
+ rabbitmq service within your applications.
85
+ email: jweber@anynines.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files:
89
+ - LICENSE.txt
90
+ - README.md
91
+ files:
92
+ - .document
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - VERSION
99
+ - a9s_rabbitmq.gemspec
100
+ - lib/a9s_rabbitmq.rb
101
+ - lib/a9s_rabbitmq/utility.rb
102
+ - test/helper.rb
103
+ - test/test_a9s_rabbitmq.rb
104
+ homepage: http://github.com/anynines/a9s_rabbitmq
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.0.6
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: a9s_rabbitmq is a small utility gem to ease up the usage of the anyines.com
128
+ rabbitmq service within your applications.
129
+ test_files: []