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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/msgr +5 -0
  3. data/lib/msgr/cli.rb +84 -0
  4. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cde9f7cd5be5cf590bf31c8b9b5584e09e51c60a2ab9b70919703c39cc04fa2f
4
- data.tar.gz: 7c9ca0dfde6ed942d1258ba46f118380460a3955bdd6209bf3dd4c38d40df9bb
3
+ metadata.gz: 1497787bbc583596de15c5d0e3b91b5a16a27e4e4fd81a189283eda405c31c01
4
+ data.tar.gz: a06deacd9799b13840a8332171cd64bd7340ea6789d9e5e422b603bc9a800042
5
5
  SHA512:
6
- metadata.gz: 9c30f917cd982cce21172707aa97f8c2a78990f622563aa29c3717d134e4c7cdd2da8f8705e3273e430d8aa4a306bf426a058d2b2d950243ce395af8feafe9a4
7
- data.tar.gz: f83ce762da71d6c919064367745f8d6b6d28269fa09640256442c5093154a077462a795d78457de4fdcd106a0c743b598ced98caa18212fb121de931b31755e4
6
+ metadata.gz: cfae96e47df43178849bac7ed11e27956a76091322eb272a59beadb3aea3722a4473770db14a660976abb261d063b9377156fc7c47e1a41a9a4f32c4c56d35bb
7
+ data.tar.gz: f982f1db02c5703ac3bd8d68659fd384fba876ee374113ba229325e0d6f67e0fe7571265e7baf4c606ea7ce48c6893412c6023656de4e9ea0190b03a790b4783
data/bin/msgr ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'msgr/cli'
4
+
5
+ Msgr::CLI.run(ARGV)
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.b211
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-14 00:00:00.000000000 Z
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