zashoku 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35663a0571ac59386c29a85223b2b3f75690dd70
4
- data.tar.gz: 26a5bba70e214f1f059a58014b418c5dbd9a2d84
3
+ metadata.gz: 770d3ee1cf2f87e16048ee6b4e85c5386396ac57
4
+ data.tar.gz: 4eba5da2106507d67008149dd0ed87538dd3e8e0
5
5
  SHA512:
6
- metadata.gz: 509a76eccd21d5f1d46c02f24dc35e99e4bd5aa93fa17694d058bea5316ff59a945ca738ff261ca77a570a0a7f372e384f4579b0d355192b6fc61cc3035710b5
7
- data.tar.gz: 5b20daf5028f0983ddc42de1ce01c99bed88e7408cc763bfbe75b8ee09bd6e7f4fd6bc7e083936080cd372386abadafaad62f3f2456b506c8a99604b31e72a0a
6
+ metadata.gz: 8be103708b5a862b9c26200c18c3eff09eab154efe10f7fd88b9bc7a704ee4997b148cd624aee1105cb6fdb2562b0d3841c1a3e4b76e2f4cb8ebcf02adf91698
7
+ data.tar.gz: 1aeec1a3e41021aa32d36d0e88536680df6ca666e343d1c0f8551961049d1740e147b0fb6d2d37eb7e1ec57316a1f72e6f7a5026b25e2144978a7318d58e43ad
data/lib/constants.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require_relative 'core/util/util'
4
4
 
5
5
  module Zashoku
6
- Version = [1, 5, 4].freeze
6
+ Version = [1, 5, 5].freeze
7
7
 
8
8
  Root = File.expand_path('../', __dir__)
9
9
 
@@ -9,7 +9,7 @@ module Zashoku
9
9
  class Client
10
10
  attr_accessor :callbacks
11
11
 
12
- def initialize(port, host = Zashoku::CConf[:app][:net][:host])
12
+ def initialize(host, port)
13
13
  @host, @port = host, port
14
14
  @socket = connect(@host, @port)
15
15
  @alive = true
data/lib/core/options.rb CHANGED
@@ -11,7 +11,8 @@ module Zashoku
11
11
  server_command: nil,
12
12
  generate: false,
13
13
  template: nil,
14
- generate_name: nil
14
+ generate_name: nil,
15
+ host: {}
15
16
  }
16
17
 
17
18
  parser = OptionParser.new do |opts|
@@ -33,6 +34,11 @@ module Zashoku
33
34
  end
34
35
  end
35
36
 
37
+ opts.on('-H HOST', '--host HOST', 'specify host') do |host|
38
+ options[:host][:host] = host.split(':').first
39
+ options[:host][:port] = host.split(':').last
40
+ end
41
+
36
42
  opts.on_tail('-h', '--help', 'Show this message') do
37
43
  puts opts
38
44
  exit
data/lib/daemon.rb CHANGED
@@ -32,7 +32,8 @@ module Zashoku
32
32
  end
33
33
 
34
34
  class Daemon
35
- def initialize
35
+ def initialize(port:)
36
+ @port = port
36
37
  @semaphore = Mutex.new
37
38
 
38
39
  Zashoku.logger = Logger.new(STDOUT)
@@ -52,7 +53,7 @@ module Zashoku
52
53
 
53
54
  def listen
54
55
  lay_traps!
55
- @server = Net::Server.new(Zashoku::CConf[:app][:net][:port])
56
+ @server = Net::Server.new(@port)
56
57
  @server.handler = method(:respond)
57
58
  Zashoku.logger.info('server listening')
58
59
  sleep
data/lib/viewer.rb CHANGED
@@ -51,7 +51,8 @@ module Zashoku
51
51
 
52
52
  COMMANDS = Zashoku::CConf[:core][:commands].merge(Zashoku::CConf[:app][:commands])
53
53
 
54
- def initialize
54
+ def initialize(host:, port:)
55
+ @host, @port = host, port
55
56
  @semaphore = Mutex.new
56
57
 
57
58
  Zashoku.logger = Logger.new(
@@ -66,7 +67,7 @@ module Zashoku
66
67
  Zashoku.conf.reload
67
68
 
68
69
  # note: start daemon if not running
69
- Zashoku.client = Net::Client.new(Zashoku::CConf[:app][:net][:port])
70
+ Zashoku.client = Net::Client.new(host, port)
70
71
  Zashoku.client.callbacks << method(:handle_event)
71
72
 
72
73
  @server_modules = Zashoku.client.command('modules')
data/lib/zashoku.rb CHANGED
@@ -18,49 +18,51 @@ module Zashoku
18
18
  modules[message[:mod]].send(message[:meth], *message[:args])
19
19
  end
20
20
 
21
+
21
22
  def self.main(args)
22
23
  @options = Options.parse(args)
24
+ host = @options[:host].key?(:host) ? @options[:host][:host] : Zashoku::CConf[:app][:net][:host]
25
+ port = @options[:host].key?(:port) ? @options[:host][:port] : Zashoku::CConf[:app][:net][:port]
26
+
23
27
  Zashoku.modules = []
24
28
 
25
29
  if @options[:generate]
26
30
  Generator.generate(@options[:template], @options[:generate_name])
27
31
  elsif @options[:server_command]
28
- print command_server(@options[:server_command])[:payload]
32
+ print command_server(@options[:server_command], host, port)[:payload]
29
33
  else
30
- unless command_server('up?')[:status]
34
+ unless command_server('up?', host, port)[:status]
31
35
  @options[:daemon] = true
32
- command_server('start')
33
- sleep(0.2) until command_server('up?')[:status]
36
+ command_server('start', host, port)
37
+ sleep(0.2) until command_server('up?', host, port)[:status]
34
38
  end
35
- Viewer.new.run
39
+ Viewer.new(host: host, port: port)
36
40
  end
37
41
  end
38
42
 
39
- def self.start_daemon
43
+ def self.start_daemon(port)
40
44
  if @options[:daemon]
41
45
  fork {
42
46
  Process.daemon()
43
- Daemon.new.listen
47
+ d = Daemon.new(port: port)
48
+ d.listen
44
49
  }
45
50
  else
46
- Daemon.new.listen
51
+ d = Daemon.new(port: port)
52
+ d.listen
47
53
  end
48
54
  end
49
55
 
50
- def self.command_server(command)
56
+ def self.command_server(command, host, port)
51
57
  case command
52
58
  when 'start'
53
- start_daemon
59
+ start_daemon(port)
54
60
  when 'restart'
55
61
  command_server('stop')
56
62
  start_daemon
57
63
  else
58
64
  require_relative 'core/net/client'
59
- Net::Client.command(
60
- Zashoku::CConf[:app][:net][:host],
61
- Zashoku::CConf[:app][:net][:port],
62
- command
63
- )
65
+ Net::Client.command(host, port, command)
64
66
  end
65
67
  end
66
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zashoku
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - annacrombie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-30 00:00:00.000000000 Z
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses