mq_publisher 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60b0604d4231ac72119613472565349e3d5a0588
4
+ data.tar.gz: 565460f3d20fe973ee229023d4324e98531b2c8e
5
+ SHA512:
6
+ metadata.gz: 14524914b076d01e7c489bcb84176063e8c068e48c9f9c5b043edf03521395c1db01a989fe8c7dc0ca1396b01fae67e126228ccec97c11fc9c8f66daf1cbe18f
7
+ data.tar.gz: cc5a1b3b1d833a167da60c801b24471cf340ec9e7ef5aa01a9f95bce6be09fef503c321c84485848a66bd6ed10e4618c5021376ef6dbb0556e7d30c29b6ca6d5
data/.gitignore ADDED
@@ -0,0 +1,51 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
13
+ mkmf.log
14
+
15
+ dump.rdb
16
+ /db/*.sqlite3
17
+ /db/*.sqlite3-journal
18
+ /db/*.yml
19
+ /db/schema.rb
20
+ /db/sphinx
21
+ dump.rdb
22
+
23
+ /log
24
+ /test/fe_fixtures
25
+ /test/*.yml
26
+
27
+ *.sql
28
+ .*.swp
29
+ .*.swo
30
+ *~
31
+ *.bak
32
+ *.log
33
+ *.tar.bz2
34
+ *.gz
35
+ *.zip
36
+ *.gem
37
+ *.pid
38
+ nohup.out
39
+
40
+ nbproject/
41
+ .settings/
42
+ .svn
43
+ .project
44
+ .pydevproject
45
+ *.sassc
46
+ .sass-cache
47
+ .idea
48
+ sandi_meter
49
+ *.pid
50
+ .ruby-version
51
+ .ruby-gemset
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # source 'https://rubygems.org'
2
+ source 'https://ruby.taobao.org'
3
+
4
+ # Specify your gem's dependencies in mq_publisher.gemspec
5
+ gemspec
6
+
7
+ # gem "guard-minitest"
8
+ gem 'byebug'
9
+ gem 'pry'
10
+ gem 'pry-byebug'
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mq_publisher (0.0.1)
5
+ activesupport
6
+ bunny
7
+
8
+ GEM
9
+ remote: https://ruby.taobao.org/
10
+ specs:
11
+ activesupport (4.2.1)
12
+ i18n (~> 0.7)
13
+ json (~> 1.7, >= 1.7.7)
14
+ minitest (~> 5.1)
15
+ thread_safe (~> 0.3, >= 0.3.4)
16
+ tzinfo (~> 1.1)
17
+ amq-protocol (1.9.2)
18
+ bunny (1.7.0)
19
+ amq-protocol (>= 1.9.2)
20
+ byebug (4.0.5)
21
+ columnize (= 0.9.0)
22
+ coderay (1.1.0)
23
+ columnize (0.9.0)
24
+ i18n (0.7.0)
25
+ json (1.8.2)
26
+ method_source (0.8.2)
27
+ minitest (5.6.1)
28
+ pry (0.10.1)
29
+ coderay (~> 1.1.0)
30
+ method_source (~> 0.8.1)
31
+ slop (~> 3.4)
32
+ pry-byebug (3.1.0)
33
+ byebug (~> 4.0)
34
+ pry (~> 0.10)
35
+ rake (10.4.2)
36
+ slop (3.6.0)
37
+ thread_safe (0.3.5)
38
+ tzinfo (1.2.2)
39
+ thread_safe (~> 0.1)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ bundler
46
+ byebug
47
+ mq_publisher!
48
+ pry
49
+ pry-byebug
50
+ rake
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Andersen Fan
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,31 @@
1
+ # MqPublisher
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mq_publisher'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install mq_publisher
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/mq_publisher/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/setup"
2
+ require "bundler/gem_tasks"
3
+ # require "rake/testtask"
4
+ require "json"
5
+ require "yaml"
6
+ require "pry"
7
+
8
+ desc "Open console"
9
+ task :console do
10
+ require "mq_publisher"
11
+ pry
12
+ end
13
+
@@ -0,0 +1,14 @@
1
+ require "bundler/setup"
2
+ require "active_support/all"
3
+ require "logger"
4
+ require "bunny"
5
+ require "json"
6
+
7
+ module MqPublisher
8
+ end
9
+
10
+ MqPublisher::LIB_PATH = File.dirname(File.absolute_path(__FILE__))
11
+
12
+ Dir.glob(MqPublisher::LIB_PATH + "/mq_publisher/*.rb").each{ |f| require f }
13
+ Dir.glob(MqPublisher::LIB_PATH + "/mq_publisher/*/**/*.rb").each{ |f| require f }
14
+ # require "mq_publisher/version"
@@ -0,0 +1,36 @@
1
+ module MqPublisher
2
+ class Publisher
3
+ attr_reader :connection, :channel, :exchange
4
+
5
+ def initialize(options={})
6
+ setup_connection(options.slice(:host, :port, :username, :password, :heartbeat, :vhost))
7
+ setup_channel
8
+ setup_exchange(options.slice(:exchange_name, :exchange_type, :exchange_auto_delete, :exchange_durable))
9
+ end
10
+
11
+ def publish(message="{}", options={})
12
+ exchange.publish message, options
13
+ end
14
+
15
+ def setup_connection(options={})
16
+ @connection ||= Bunny.new(options).tap{ |c| c.start }
17
+ end
18
+
19
+ def setup_channel
20
+ @channel ||= connection.create_channel
21
+ end
22
+
23
+ def setup_exchange(options={})
24
+ @exchange ||= Bunny::Exchange.new \
25
+ channel,
26
+ options[:exchange_type] || :fanout,
27
+ options[:exchange_name],
28
+ auto_delete: (options[:exchange_auto_delete].nil? ? false : options[:exchange_auto_delete]),
29
+ durable: (options[:exchange_durable].nil? ? false : options[:exchange_durable])
30
+ end
31
+
32
+ def destroy
33
+ connection.close
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module MqPublisher
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mq_publisher/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mq_publisher"
8
+ spec.version = MqPublisher::VERSION
9
+ spec.authors = ["Andersen Fan"]
10
+ spec.email = ["as181920@hotmail.com"]
11
+ spec.summary = %q{Publisher throubh message queue}
12
+ spec.description = %q{Publisher throubh message queue}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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 "activesupport"
22
+ spec.add_runtime_dependency "bunny"
23
+
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake"
26
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mq_publisher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andersen Fan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
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: bunny
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
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
+ description: Publisher throubh message queue
70
+ email:
71
+ - as181920@hotmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/mq_publisher.rb
83
+ - lib/mq_publisher/publisher.rb
84
+ - lib/mq_publisher/version.rb
85
+ - mq_publisher.gemspec
86
+ homepage: ''
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.4.8
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Publisher throubh message queue
110
+ test_files: []