zashoku 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/hello/README.md +17 -0
- data/examples/hello/config/daemon.yml +1 -0
- data/examples/hello/config/view.yml +1 -0
- data/examples/hello/modules/hello/README.md +1 -0
- data/examples/hello/modules/hello/config/daemon.yml +1 -0
- data/examples/hello/modules/hello/config/view.yml +13 -0
- data/examples/hello/modules/hello/lib/hello.rb +21 -0
- data/examples/hello/modules/hello/lib/hello/hello_controller.rb +22 -0
- data/examples/hello/modules/hello/lib/hello/hello_item.rb +8 -0
- data/examples/hello/modules/hello/lib/hello/hello_view.rb +23 -0
- data/lib/constants.rb +5 -1
- data/lib/core/module.rb +2 -2
- data/lib/core/modules/conf/config/view.yml +12 -0
- data/lib/core/net/client.rb +18 -7
- data/lib/core/net/server.rb +2 -1
- data/lib/core/options.rb +6 -4
- data/lib/core/statusline/statusline.rb +1 -2
- data/lib/core/util/readline.rb +1 -1
- data/lib/core/util/util.rb +1 -1
- data/lib/core/view.rb +1 -2
- data/lib/daemon.rb +2 -1
- data/lib/generator.rb +3 -1
- data/lib/viewer.rb +9 -6
- data/templates/app/README.md +1 -0
- data/templates/app/config/daemon.yml +1 -0
- data/templates/app/config/view.yml +1 -0
- data/templates/app/lib/<name>.rb +3 -0
- data/templates/module/README.md +1 -0
- data/templates/module/config/daemon.yml +1 -0
- data/templates/module/config/view.yml +13 -0
- data/templates/module/lib/<name>.rb +21 -0
- data/templates/module/lib/<name>/<name>_controller.rb +10 -0
- data/templates/module/lib/<name>/<name>_item.rb +8 -0
- data/templates/module/lib/<name>/<name>_view.rb +23 -0
- metadata +24 -4
- data/lib/core/util/folder_listen.rb +0 -53
- data/lib/core/util/matcher.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f452ac173dc980027b942716bd56472cb40a8770
|
4
|
+
data.tar.gz: ba9020e54e6db010d51ea17a7514053514363edf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fbce4a8509ff7a4138348221ef43b82fe37355903f5716ddc4443ba92683154becca9fc98d7bf2ced0fe6384508935035053aa77a654697edafdc3fa8dd7794
|
7
|
+
data.tar.gz: 0ed5d01d23a2549742becf9c089b25f7641b13201e3c583814a164ee595efe41a53b520e6d10cf0e2f61fa182d6de0891d26237a260158228adf1e7515f3b288
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1 @@
|
|
1
|
+
# README for hello
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zashoku
|
4
|
+
module Hello
|
5
|
+
extend Zashoku::Module
|
6
|
+
|
7
|
+
Version = [1, 0, 0].freeze
|
8
|
+
Root = File.expand_path('../', __dir__)
|
9
|
+
|
10
|
+
autoload :HelloController, File.join(Root, 'lib/hello/hello_controller')
|
11
|
+
autoload :HelloView, File.join(Root, 'lib/hello/hello_view')
|
12
|
+
|
13
|
+
def self.view
|
14
|
+
HelloView.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.controller
|
18
|
+
HelloController.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'hello_item'
|
4
|
+
|
5
|
+
module Zashoku
|
6
|
+
module Hello
|
7
|
+
class HelloController < Zashoku::Controller
|
8
|
+
def items
|
9
|
+
{
|
10
|
+
HelloItem.new(title: 'hello', lang: 'en') => [
|
11
|
+
HelloItem.new(title: 'おはようございます', lang: 'jp'),
|
12
|
+
HelloItem.new(title: 'こんにちは', lang: 'jp')
|
13
|
+
],
|
14
|
+
HelloItem.new(title: 'world', lang: 'en') => [
|
15
|
+
HelloItem.new(title: 'earth', lang: 'en'),
|
16
|
+
HelloItem.new(title: '世界', lang: 'jp')
|
17
|
+
]
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'hello_item'
|
4
|
+
|
5
|
+
module Zashoku
|
6
|
+
module Hello
|
7
|
+
class HelloView < Zashoku::View
|
8
|
+
def refresh_attributes
|
9
|
+
@attributes = {
|
10
|
+
't' => Zashoku.conf.get(%w[title hello]),
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def refresh_items
|
15
|
+
Zashoku.command(mod: 'remote::hello', meth: 'items')
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_format
|
19
|
+
Zashoku.conf.get(%w[format hello])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
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,
|
6
|
+
Version = [1, 5, 3].freeze
|
7
7
|
|
8
8
|
Root = File.expand_path('../', __dir__)
|
9
9
|
|
@@ -16,6 +16,10 @@ module Zashoku
|
|
16
16
|
viewer: [],
|
17
17
|
daemon: [],
|
18
18
|
},
|
19
|
+
log_level: {
|
20
|
+
viewer: :warn,
|
21
|
+
daemon: :info
|
22
|
+
},
|
19
23
|
save_config: false,
|
20
24
|
save_history: false,
|
21
25
|
persistent_daemon: false,
|
data/lib/core/module.rb
CHANGED
@@ -26,10 +26,10 @@ module Zashoku
|
|
26
26
|
def self.require_all(modules)
|
27
27
|
modules.map do |mod|
|
28
28
|
if require_module(mod)
|
29
|
-
Zashoku.logger.
|
29
|
+
Zashoku.logger.info("loaded module #{mod}")
|
30
30
|
Zashoku.const_get(mod)
|
31
31
|
else
|
32
|
-
Zashoku.logger.
|
32
|
+
Zashoku.logger.error("failed to load module #{mod}")
|
33
33
|
nil
|
34
34
|
end
|
35
35
|
end.compact
|
data/lib/core/net/client.rb
CHANGED
@@ -4,8 +4,6 @@ require 'socket'
|
|
4
4
|
require 'json'
|
5
5
|
require 'thread'
|
6
6
|
|
7
|
-
require 'pry'
|
8
|
-
|
9
7
|
module Zashoku
|
10
8
|
module Net
|
11
9
|
class Client
|
@@ -16,6 +14,8 @@ module Zashoku
|
|
16
14
|
@socket = connect(@host, @port)
|
17
15
|
@alive = true
|
18
16
|
|
17
|
+
@timeout = 2
|
18
|
+
|
19
19
|
@callbacks = []
|
20
20
|
|
21
21
|
@command_queue = Queue.new
|
@@ -39,6 +39,7 @@ module Zashoku
|
|
39
39
|
@events_thread&.exit
|
40
40
|
end
|
41
41
|
|
42
|
+
|
42
43
|
def self.command(host, port, msg, args = {})
|
43
44
|
sock = TCPSocket.new(host, port)
|
44
45
|
sock.puts(JSON.generate({'msg' => msg}.merge(args)))
|
@@ -78,7 +79,7 @@ module Zashoku
|
|
78
79
|
def lost_connection
|
79
80
|
@alive = false
|
80
81
|
@socket.close
|
81
|
-
Zashoku.logger.
|
82
|
+
Zashoku.logger.warn('lost connection')
|
82
83
|
Util.alert('no connection')
|
83
84
|
stop_threads
|
84
85
|
end
|
@@ -97,7 +98,16 @@ module Zashoku
|
|
97
98
|
payload = { 'msg' => msg }.merge(args)
|
98
99
|
@command_queue << JSON.generate(payload)
|
99
100
|
|
100
|
-
result =
|
101
|
+
result = nil
|
102
|
+
start = Time.now
|
103
|
+
thread = Thread.new do
|
104
|
+
result = @result_queue.pop
|
105
|
+
end
|
106
|
+
sleep 0.1 until result || (Time.now - start) > @timeout
|
107
|
+
thread.exit
|
108
|
+
|
109
|
+
result ||= {}
|
110
|
+
|
101
111
|
result.keys.length == 1 ? result['response'] : result
|
102
112
|
}
|
103
113
|
end
|
@@ -119,16 +129,17 @@ module Zashoku
|
|
119
129
|
end
|
120
130
|
|
121
131
|
def distribute_results!
|
122
|
-
|
132
|
+
raw = @socket.readline
|
133
|
+
response = JSON.parse(raw)
|
123
134
|
if response['event']
|
124
135
|
@event_queue << response
|
125
136
|
else
|
126
137
|
@result_queue << response
|
127
138
|
end
|
128
139
|
rescue JSON::ParserError
|
129
|
-
Zashoku.logger.
|
140
|
+
Zashoku.logger.error("discarding #{raw}, JSON::ParserError")
|
130
141
|
rescue EOFError
|
131
|
-
Zashoku.logger.
|
142
|
+
Zashoku.logger.error('eof error')
|
132
143
|
lost_connection
|
133
144
|
rescue IOError
|
134
145
|
Util.alert("error: socket#{@socket}")
|
data/lib/core/net/server.rb
CHANGED
@@ -50,6 +50,7 @@ module Zashoku
|
|
50
50
|
break unless response
|
51
51
|
end
|
52
52
|
end
|
53
|
+
Zashoku.logger.info("client #{client.hash} disconnected")
|
53
54
|
@clients.delete(client)
|
54
55
|
@client_queue.delete(client)
|
55
56
|
client.close
|
@@ -59,7 +60,7 @@ module Zashoku
|
|
59
60
|
Thread.abort_on_exception = true
|
60
61
|
loop do
|
61
62
|
Thread.start(@server.accept) do |client|
|
62
|
-
Zashoku.logger.
|
63
|
+
Zashoku.logger.info("got client (hash: #{client.hash})")
|
63
64
|
@clients << client
|
64
65
|
@client_queue[client] = Queue.new
|
65
66
|
handle(client)
|
data/lib/core/options.rb
CHANGED
@@ -15,7 +15,7 @@ module Zashoku
|
|
15
15
|
}
|
16
16
|
|
17
17
|
parser = OptionParser.new do |opts|
|
18
|
-
opts.banner =
|
18
|
+
opts.banner = "Usage: #{Zashoku::CConf[:app][:name]} [options]"
|
19
19
|
|
20
20
|
opts.on('-s [COMMAND]', '--server [COMMAND]', 'pass commands to the server') do |cmd|
|
21
21
|
options[:server] = true
|
@@ -26,9 +26,11 @@ module Zashoku
|
|
26
26
|
options[:daemon] = true
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
if Zashoku::CConf[:app][:name] == 'zashoku'
|
30
|
+
opts.on('-g TEMPLATE', '--generate TEMPLATE', 'generate a template') do |template|
|
31
|
+
options[:template] = template
|
32
|
+
options[:generate] = true
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
opts.on_tail('-h', '--help', 'Show this message') do
|
@@ -5,7 +5,6 @@ require_relative 'widget'
|
|
5
5
|
module Zashoku
|
6
6
|
module Statusline
|
7
7
|
def self.new
|
8
|
-
Zashoku.logger.debug('statusline.new')
|
9
8
|
Zashoku::Statusline::Statusline.new
|
10
9
|
end
|
11
10
|
|
@@ -16,7 +15,7 @@ module Zashoku
|
|
16
15
|
@widgets = Zashoku.modules.keys.zip(Zashoku.modules.map do |_k, m|
|
17
16
|
m.widgets if m.respond_to?(:widgets)
|
18
17
|
end).to_h.compact
|
19
|
-
Zashoku.logger.
|
18
|
+
Zashoku.logger.info("loaded widgets for #{@widgets.keys.join(', ')}")
|
20
19
|
refresh
|
21
20
|
end
|
22
21
|
|
data/lib/core/util/readline.rb
CHANGED
data/lib/core/util/util.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'base64'
|
4
|
-
require_relative 'readline'
|
5
4
|
|
6
5
|
module Zashoku
|
7
6
|
module Util
|
@@ -10,6 +9,7 @@ module Zashoku
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.decode_object(e)
|
12
|
+
return e if e.class == Hash
|
13
13
|
Marshal.load(Base64.decode64(e))
|
14
14
|
rescue ArgumentError
|
15
15
|
{}
|
data/lib/core/view.rb
CHANGED
@@ -27,7 +27,7 @@ module Zashoku
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def dirty_all_lines
|
30
|
-
@dirty_lines = 0.step(
|
30
|
+
@dirty_lines = 0.step(get_len).to_a
|
31
31
|
end
|
32
32
|
|
33
33
|
def next_match
|
@@ -66,7 +66,6 @@ module Zashoku
|
|
66
66
|
|
67
67
|
matches
|
68
68
|
end.flatten(1) #.sort.reverse
|
69
|
-
Zashoku.logger.debug(@matches)
|
70
69
|
next_match
|
71
70
|
end
|
72
71
|
|
data/lib/daemon.rb
CHANGED
@@ -36,6 +36,7 @@ module Zashoku
|
|
36
36
|
@semaphore = Mutex.new
|
37
37
|
|
38
38
|
Zashoku.logger = Logger.new(STDOUT)
|
39
|
+
Zashoku.logger.level = Zashoku::CConf[:app][:log_level][:daemon]
|
39
40
|
# Load conf
|
40
41
|
Zashoku.conf = DaemonConfig.new
|
41
42
|
# Load modules
|
@@ -53,7 +54,7 @@ module Zashoku
|
|
53
54
|
lay_traps!
|
54
55
|
@server = Net::Server.new(Zashoku::CConf[:app][:net][:port])
|
55
56
|
@server.handler = method(:respond)
|
56
|
-
Zashoku.logger.
|
57
|
+
Zashoku.logger.info('server listening')
|
57
58
|
sleep
|
58
59
|
end
|
59
60
|
|
data/lib/generator.rb
CHANGED
data/lib/viewer.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative 'core/controller'
|
|
12
12
|
require_relative 'core/config/view_config'
|
13
13
|
require_relative 'core/net/client'
|
14
14
|
require_relative 'core/statusline/statusline'
|
15
|
+
require_relative 'core/util/readline'
|
15
16
|
require_relative 'core/util/term'
|
16
17
|
require_relative 'core/util/util'
|
17
18
|
require_relative 'core/formatter'
|
@@ -34,7 +35,6 @@ module Zashoku
|
|
34
35
|
message[:mod] = message[:mod].gsub('remote::', '')
|
35
36
|
Zashoku.logger.debug("sending message #{message}")
|
36
37
|
msg = Zashoku::Util.decode_object(client.command('fwd', message))
|
37
|
-
Zashoku.logger.debug('got it')
|
38
38
|
msg
|
39
39
|
else
|
40
40
|
modules[message[:mod]].send(message[:meth], *message[:args])
|
@@ -57,6 +57,7 @@ module Zashoku
|
|
57
57
|
Zashoku.logger = Logger.new(
|
58
58
|
File.join(Zashoku::CConf[:app][:root], "#{Zashoku::CConf[:app][:name]}.log")
|
59
59
|
)
|
60
|
+
Zashoku.logger.level = Zashoku::CConf[:app][:log_level][:viewer]
|
60
61
|
|
61
62
|
Zashoku.conf = ViewConfig.new
|
62
63
|
|
@@ -75,9 +76,7 @@ module Zashoku
|
|
75
76
|
end).to_h
|
76
77
|
@view = @views.keys.first
|
77
78
|
|
78
|
-
Zashoku.logger.debug('initializing statusline')
|
79
79
|
@statusline = Statusline.new
|
80
|
-
Zashoku.logger.debug(@statusline)
|
81
80
|
@statusline.add_observer(self, :draw_statusline)
|
82
81
|
|
83
82
|
@cmdline = Util::Readline.new(
|
@@ -148,8 +147,12 @@ module Zashoku
|
|
148
147
|
def cleanup
|
149
148
|
Zashoku.client.disconnect
|
150
149
|
@key_thread&.exit
|
151
|
-
Zashoku.command_server('stop') if Zashoku::CConf[:app][:persistent_daemon]
|
152
150
|
Curses.close_screen
|
151
|
+
|
152
|
+
unless Zashoku::CConf[:app][:persistent_daemon]
|
153
|
+
Zashoku.command_server('stop')
|
154
|
+
end
|
155
|
+
|
153
156
|
if Zashoku::Conf.save?
|
154
157
|
Util.put_yaml(CMD_HISTORY, @cmdline.history)
|
155
158
|
Util.put_yaml(SRCH_HISTORY, @searchline.history)
|
@@ -185,7 +188,7 @@ module Zashoku
|
|
185
188
|
raise "no such command" if cmd.split.length == 1
|
186
189
|
command(*cmd.split) unless cmd.empty?
|
187
190
|
rescue StandardError => e
|
188
|
-
Zashoku.logger.
|
191
|
+
Zashoku.logger.error("#{cmd.split} raised an error '#{e}'")
|
189
192
|
Util.alert("Error: #{e}")
|
190
193
|
end
|
191
194
|
|
@@ -250,7 +253,7 @@ module Zashoku
|
|
250
253
|
begin
|
251
254
|
command(mod, meth, *args)
|
252
255
|
rescue Exception => e
|
253
|
-
Zashoku.logger.
|
256
|
+
Zashoku.logger.error("#{[mod, meth, args].join(', ')} raised #{e}")
|
254
257
|
end
|
255
258
|
end
|
256
259
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# readme for <name>
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1 @@
|
|
1
|
+
# README for <name>
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zashoku
|
4
|
+
module <Name>
|
5
|
+
extend Zashoku::Module
|
6
|
+
|
7
|
+
Version = [1, 0, 0].freeze
|
8
|
+
Root = File.expand_path('../', __dir__)
|
9
|
+
|
10
|
+
autoload :<Name>Controller, File.join(Root, 'lib/<name>/<name>_controller')
|
11
|
+
autoload :<Name>View, File.join(Root, 'lib/<name>/<name>_view')
|
12
|
+
|
13
|
+
def self.view
|
14
|
+
<Name>View.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.controller
|
18
|
+
<Name>Controller.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '<name>_item'
|
4
|
+
|
5
|
+
module Zashoku
|
6
|
+
module <Name>
|
7
|
+
class <Name>View < Zashoku::View
|
8
|
+
def refresh_attributes
|
9
|
+
@attributes = {
|
10
|
+
't' => Zashoku.conf.get(%w[title <name>]),
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def refresh_items
|
15
|
+
Zashoku.command(mod: 'remote::<name>', meth: 'items')
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_format
|
19
|
+
Zashoku.conf.get(%w[format <name>])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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
|
+
version: 1.5.3
|
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-
|
11
|
+
date: 2017-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -100,6 +100,16 @@ files:
|
|
100
100
|
- "./README.md"
|
101
101
|
- "./config/daemon.yml"
|
102
102
|
- "./config/view.yml"
|
103
|
+
- "./examples/hello/README.md"
|
104
|
+
- "./examples/hello/config/daemon.yml"
|
105
|
+
- "./examples/hello/config/view.yml"
|
106
|
+
- "./examples/hello/modules/hello/README.md"
|
107
|
+
- "./examples/hello/modules/hello/config/daemon.yml"
|
108
|
+
- "./examples/hello/modules/hello/config/view.yml"
|
109
|
+
- "./examples/hello/modules/hello/lib/hello.rb"
|
110
|
+
- "./examples/hello/modules/hello/lib/hello/hello_controller.rb"
|
111
|
+
- "./examples/hello/modules/hello/lib/hello/hello_item.rb"
|
112
|
+
- "./examples/hello/modules/hello/lib/hello/hello_view.rb"
|
103
113
|
- "./lib/constants.rb"
|
104
114
|
- "./lib/core/config/config.rb"
|
105
115
|
- "./lib/core/config/daemon_config.rb"
|
@@ -108,6 +118,7 @@ files:
|
|
108
118
|
- "./lib/core/formatter.rb"
|
109
119
|
- "./lib/core/item.rb"
|
110
120
|
- "./lib/core/module.rb"
|
121
|
+
- "./lib/core/modules/conf/config/view.yml"
|
111
122
|
- "./lib/core/modules/conf/lib/conf.rb"
|
112
123
|
- "./lib/core/modules/conf/lib/conf/config_view.rb"
|
113
124
|
- "./lib/core/net/client.rb"
|
@@ -115,8 +126,6 @@ files:
|
|
115
126
|
- "./lib/core/options.rb"
|
116
127
|
- "./lib/core/statusline/statusline.rb"
|
117
128
|
- "./lib/core/statusline/widget.rb"
|
118
|
-
- "./lib/core/util/folder_listen.rb"
|
119
|
-
- "./lib/core/util/matcher.rb"
|
120
129
|
- "./lib/core/util/readline.rb"
|
121
130
|
- "./lib/core/util/term.rb"
|
122
131
|
- "./lib/core/util/util.rb"
|
@@ -127,6 +136,17 @@ files:
|
|
127
136
|
- "./lib/generator/module_generator.rb"
|
128
137
|
- "./lib/viewer.rb"
|
129
138
|
- "./lib/zashoku.rb"
|
139
|
+
- "./templates/app/README.md"
|
140
|
+
- "./templates/app/config/daemon.yml"
|
141
|
+
- "./templates/app/config/view.yml"
|
142
|
+
- "./templates/app/lib/<name>.rb"
|
143
|
+
- "./templates/module/README.md"
|
144
|
+
- "./templates/module/config/daemon.yml"
|
145
|
+
- "./templates/module/config/view.yml"
|
146
|
+
- "./templates/module/lib/<name>.rb"
|
147
|
+
- "./templates/module/lib/<name>/<name>_controller.rb"
|
148
|
+
- "./templates/module/lib/<name>/<name>_item.rb"
|
149
|
+
- "./templates/module/lib/<name>/<name>_view.rb"
|
130
150
|
- bin/zashoku
|
131
151
|
homepage: https://github.com/zashoku/zashoku/
|
132
152
|
licenses:
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# watch for changes in a folder's existance
|
2
|
-
|
3
|
-
module Zashoku
|
4
|
-
module Util
|
5
|
-
module FolderListen
|
6
|
-
|
7
|
-
def self.to(dirs, &block)
|
8
|
-
Listener.new(dirs, &block)
|
9
|
-
end
|
10
|
-
|
11
|
-
##
|
12
|
-
## @brief Similar to Listen gem but uses polling and is only intended
|
13
|
-
## to be used on a small number of files. the Listen gem
|
14
|
-
## wouldn't support watching an individual FOLDER to see if
|
15
|
-
## the folder went away so this is that!
|
16
|
-
##
|
17
|
-
class Listener
|
18
|
-
def initialize(dirs, &block)
|
19
|
-
@dirs = dirs
|
20
|
-
@block = block
|
21
|
-
@sleep_duration = 1
|
22
|
-
@dir_hash = dir_hash
|
23
|
-
end
|
24
|
-
|
25
|
-
def dir_hash
|
26
|
-
@dirs.map { |dir| [dir, File.exist?(dir)]}.to_h
|
27
|
-
end
|
28
|
-
|
29
|
-
def changed?
|
30
|
-
@dir_hash != dir_hash
|
31
|
-
end
|
32
|
-
|
33
|
-
def stop
|
34
|
-
@listen_thread.exit if @listen_thread
|
35
|
-
end
|
36
|
-
|
37
|
-
def start
|
38
|
-
Thread.abort_on_exception = true
|
39
|
-
@listen_thread = Thread.new do
|
40
|
-
while true
|
41
|
-
if changed?
|
42
|
-
@block.call
|
43
|
-
@dir_hash = dir_hash
|
44
|
-
end
|
45
|
-
sleep 1
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/core/util/matcher.rb
DELETED
File without changes
|