msgr 1.0.0.1.b211 → 1.0.0.1.b212
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 +4 -4
- data/bin/msgr +5 -0
- data/lib/msgr/cli.rb +84 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1497787bbc583596de15c5d0e3b91b5a16a27e4e4fd81a189283eda405c31c01
|
|
4
|
+
data.tar.gz: a06deacd9799b13840a8332171cd64bd7340ea6789d9e5e422b603bc9a800042
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cfae96e47df43178849bac7ed11e27956a76091322eb272a59beadb3aea3722a4473770db14a660976abb261d063b9377156fc7c47e1a41a9a4f32c4c56d35bb
|
|
7
|
+
data.tar.gz: f982f1db02c5703ac3bd8d68659fd384fba876ee374113ba229325e0d6f67e0fe7571265e7baf4c606ea7ce48c6893412c6023656de4e9ea0190b03a790b4783
|
data/bin/msgr
ADDED
data/lib/msgr/cli.rb
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'optionparser'
|
|
2
|
+
|
|
3
|
+
module Msgr
|
|
4
|
+
class CLI
|
|
5
|
+
attr_reader :options
|
|
6
|
+
|
|
7
|
+
def initialize(options)
|
|
8
|
+
@options = options
|
|
9
|
+
|
|
10
|
+
if !File.exist?(options[:require]) ||
|
|
11
|
+
(File.directory?(options[:require]) && !File.exist?("#{options[:require]}/config/application.rb"))
|
|
12
|
+
raise <<~ERR
|
|
13
|
+
Rails application or required ruby file not found: #{options[:require]}
|
|
14
|
+
ERR
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def run
|
|
19
|
+
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = options[:environment]
|
|
20
|
+
|
|
21
|
+
if File.directory?(options[:require])
|
|
22
|
+
require 'rails'
|
|
23
|
+
if ::Rails::VERSION::MAJOR == 4
|
|
24
|
+
require File.expand_path("#{options[:require]}/config/application.rb")
|
|
25
|
+
::Rails::Application.initializer "msgr.eager_load" do
|
|
26
|
+
::Rails.application.config.eager_load = true
|
|
27
|
+
end
|
|
28
|
+
require 'msgr/railtie'
|
|
29
|
+
require File.expand_path("#{options[:require]}/config/environment.rb")
|
|
30
|
+
else
|
|
31
|
+
require 'msgr/railtie'
|
|
32
|
+
require File.expand_path("#{options[:require]}/config/environment.rb")
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
require(options[:require])
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
r, w = IO.pipe
|
|
39
|
+
|
|
40
|
+
Signal.trap('INT') { w.puts 'INT' }
|
|
41
|
+
Signal.trap('TERM') { w.puts 'TERM' }
|
|
42
|
+
|
|
43
|
+
Msgr.logger = Logger.new(STDOUT)
|
|
44
|
+
Msgr.client.start
|
|
45
|
+
|
|
46
|
+
while readable = IO.select([r])
|
|
47
|
+
case readable.first[0].gets.strip
|
|
48
|
+
when 'INT', 'TERM'
|
|
49
|
+
Msgr.client.stop
|
|
50
|
+
break
|
|
51
|
+
else
|
|
52
|
+
exit 1
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class << self
|
|
58
|
+
def run(argv)
|
|
59
|
+
new(parse(argv)).run
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def parse(argv)
|
|
65
|
+
options = {
|
|
66
|
+
require: Dir.pwd,
|
|
67
|
+
environment: 'development'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
OptionParser.new do |o|
|
|
71
|
+
o.on '-r', '--require [PATH|DIR]', 'Location of Rails application (default to current directory)' do |arg|
|
|
72
|
+
options[:require] = arg
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
o.on '-e', '--environment [env]', 'Rails environment (default to development)' do |arg|
|
|
76
|
+
options[:environment] = arg
|
|
77
|
+
end
|
|
78
|
+
end.parse!
|
|
79
|
+
|
|
80
|
+
options
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: msgr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.0.1.
|
|
4
|
+
version: 1.0.0.1.b212
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Graichen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-06-
|
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -75,7 +75,8 @@ dependencies:
|
|
|
75
75
|
description: 'Msgr: Rails-like Messaging Framework'
|
|
76
76
|
email:
|
|
77
77
|
- jg@altimos.de
|
|
78
|
-
executables:
|
|
78
|
+
executables:
|
|
79
|
+
- msgr
|
|
79
80
|
extensions: []
|
|
80
81
|
extra_rdoc_files: []
|
|
81
82
|
files:
|
|
@@ -87,6 +88,7 @@ files:
|
|
|
87
88
|
- LICENSE.txt
|
|
88
89
|
- README.md
|
|
89
90
|
- Rakefile
|
|
91
|
+
- bin/msgr
|
|
90
92
|
- gemfiles/Gemfile.rails-4-2
|
|
91
93
|
- gemfiles/Gemfile.rails-5-0
|
|
92
94
|
- gemfiles/Gemfile.rails-5-1
|
|
@@ -94,6 +96,7 @@ files:
|
|
|
94
96
|
- lib/msgr.rb
|
|
95
97
|
- lib/msgr/binding.rb
|
|
96
98
|
- lib/msgr/channel.rb
|
|
99
|
+
- lib/msgr/cli.rb
|
|
97
100
|
- lib/msgr/client.rb
|
|
98
101
|
- lib/msgr/connection.rb
|
|
99
102
|
- lib/msgr/consumer.rb
|