eye 0.8.celluloid15 → 0.8.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -5
- data/CHANGES.md +3 -7
- data/README.md +2 -5
- data/Rakefile +6 -6
- data/bin/leye +4 -9
- data/bin/loader_eye +15 -14
- data/examples/delayed_job.eye +3 -3
- data/examples/dependency.eye +11 -10
- data/examples/notify.eye +4 -3
- data/examples/plugin/main.eye +5 -5
- data/examples/plugin/plugin.rb +2 -10
- data/examples/process_thin.rb +8 -8
- data/examples/processes/em.rb +12 -18
- data/examples/processes/forking.rb +5 -5
- data/examples/processes/sample.rb +44 -46
- data/examples/puma.eye +8 -9
- data/examples/rbenv.eye +5 -5
- data/examples/sidekiq.eye +3 -3
- data/examples/stress_test.eye +4 -4
- data/examples/syslog.eye +1 -1
- data/examples/test.eye +2 -1
- data/examples/thin-farm.eye +8 -7
- data/examples/triggers.eye +15 -13
- data/examples/unicorn.eye +13 -12
- data/eye.gemspec +14 -16
- data/lib/eye.rb +3 -2
- data/lib/eye/application.rb +6 -5
- data/lib/eye/checker.rb +25 -44
- data/lib/eye/checker/children_count.rb +1 -1
- data/lib/eye/checker/file_ctime.rb +1 -1
- data/lib/eye/checker/http.rb +15 -13
- data/lib/eye/checker/nop.rb +0 -1
- data/lib/eye/checker/socket.rb +63 -60
- data/lib/eye/checker/ssl_socket.rb +5 -5
- data/lib/eye/child_process.rb +4 -6
- data/lib/eye/cli.rb +46 -74
- data/lib/eye/cli/commands.rb +5 -4
- data/lib/eye/cli/render.rb +41 -61
- data/lib/eye/cli/server.rb +16 -19
- data/lib/eye/client.rb +0 -1
- data/lib/eye/config.rb +33 -36
- data/lib/eye/controller.rb +3 -2
- data/lib/eye/controller/commands.rb +1 -1
- data/lib/eye/controller/helpers.rb +2 -2
- data/lib/eye/controller/load.rb +17 -19
- data/lib/eye/controller/options.rb +5 -1
- data/lib/eye/controller/send_command.rb +23 -21
- data/lib/eye/controller/status.rb +15 -17
- data/lib/eye/dsl.rb +1 -6
- data/lib/eye/dsl/application_opts.rb +3 -4
- data/lib/eye/dsl/chain.rb +2 -2
- data/lib/eye/dsl/child_process_opts.rb +3 -3
- data/lib/eye/dsl/config_opts.rb +7 -7
- data/lib/eye/dsl/group_opts.rb +3 -3
- data/lib/eye/dsl/helpers.rb +1 -1
- data/lib/eye/dsl/main.rb +3 -4
- data/lib/eye/dsl/opts.rb +28 -31
- data/lib/eye/dsl/process_opts.rb +7 -13
- data/lib/eye/dsl/pure_opts.rb +9 -13
- data/lib/eye/dsl/validation.rb +35 -48
- data/lib/eye/group.rb +8 -23
- data/lib/eye/group/chain.rb +6 -6
- data/lib/eye/loader.rb +3 -3
- data/lib/eye/local.rb +4 -9
- data/lib/eye/logger.rb +4 -11
- data/lib/eye/notify.rb +6 -10
- data/lib/eye/notify/jabber.rb +1 -1
- data/lib/eye/notify/mail.rb +2 -2
- data/lib/eye/notify/slack.rb +3 -4
- data/lib/eye/process.rb +0 -2
- data/lib/eye/process/children.rb +4 -4
- data/lib/eye/process/commands.rb +39 -38
- data/lib/eye/process/config.rb +16 -22
- data/lib/eye/process/controller.rb +19 -5
- data/lib/eye/process/data.rb +9 -11
- data/lib/eye/process/monitor.rb +76 -86
- data/lib/eye/process/notify.rb +10 -10
- data/lib/eye/process/scheduler.rb +31 -36
- data/lib/eye/process/states.rb +5 -7
- data/lib/eye/process/states_history.rb +3 -9
- data/lib/eye/process/system.rb +20 -35
- data/lib/eye/process/trigger.rb +5 -1
- data/lib/eye/process/watchers.rb +9 -12
- data/lib/eye/reason.rb +1 -4
- data/lib/eye/server.rb +1 -2
- data/lib/eye/system.rb +15 -22
- data/lib/eye/system_resources.rb +9 -18
- data/lib/eye/trigger.rb +16 -18
- data/lib/eye/trigger/check_dependency.rb +4 -7
- data/lib/eye/trigger/flapping.rb +7 -24
- data/lib/eye/trigger/starting_guard.rb +6 -7
- data/lib/eye/trigger/stop_children.rb +2 -2
- data/lib/eye/trigger/transition.rb +1 -1
- data/lib/eye/trigger/wait_dependency.rb +2 -3
- data/lib/eye/utils.rb +3 -4
- data/lib/eye/utils/alive_array.rb +4 -9
- data/lib/eye/utils/celluloid_chain.rb +10 -12
- data/lib/eye/utils/leak_19.rb +10 -0
- data/lib/eye/utils/mini_active_support.rb +16 -16
- data/lib/eye/utils/pmap.rb +0 -2
- data/lib/eye/utils/tail.rb +2 -2
- metadata +8 -39
- data/.rubocop.yml +0 -141
- data/examples/custom_check.eye +0 -24
- data/examples/custom_trigger.eye +0 -30
- data/examples/leye_example/Eyefile +0 -10
@@ -2,20 +2,19 @@ module Eye::Controller::Status
|
|
2
2
|
|
3
3
|
def debug_data(*args)
|
4
4
|
h = args.extract_options!
|
5
|
-
actors = Celluloid::Actor.all.map
|
6
|
-
actors = actors.map { |k, v| [k, v.size] }.sort_by { |a| a[1] }.reverse
|
5
|
+
actors = Celluloid::Actor.all.map{|actor| actor.wrapped_object.class.to_s }.group_by{|a| a}.map{|k,v| [k, v.size]}.sort_by{ |a| a[1] }.reverse
|
7
6
|
|
8
7
|
res = {
|
9
|
-
about
|
10
|
-
resources
|
11
|
-
ruby
|
12
|
-
gems
|
13
|
-
logger
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
:about => Eye::ABOUT,
|
9
|
+
:resources => Eye::SystemResources.resources($$),
|
10
|
+
:ruby => RUBY_DESCRIPTION,
|
11
|
+
:gems => %w|Celluloid Celluloid::IO StateMachine NIO Timers Sigar|.map{|c| gem_version(c) },
|
12
|
+
:logger => Eye::Logger.args.present? ? [Eye::Logger.dev.to_s, *Eye::Logger.args] : Eye::Logger.dev.to_s,
|
13
|
+
:dir => Eye::Local.dir,
|
14
|
+
:pid_path => Eye::Local::pid_path,
|
15
|
+
:sock_path => Eye::Local::socket_path,
|
16
|
+
:actors => actors,
|
17
|
+
:celluloid_backported => $CELLULOID_BACKPORTED
|
19
18
|
}
|
20
19
|
|
21
20
|
res[:config_yaml] = YAML.dump(current_config.to_h) if h[:config].present?
|
@@ -24,18 +23,17 @@ module Eye::Controller::Status
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def info_data(*args)
|
27
|
-
|
28
|
-
{ subtree: info_objects(*args).map { |a| a.status_data(h) } }
|
26
|
+
{:subtree => info_objects(*args).map{|a| a.status_data } }
|
29
27
|
end
|
30
28
|
|
31
29
|
def short_data(*args)
|
32
|
-
{
|
30
|
+
{:subtree => info_objects(*args).select{ |o| o.class == Eye::Application }.map{|a| a.status_data_short } }
|
33
31
|
end
|
34
32
|
|
35
33
|
def history_data(*args)
|
36
34
|
res = {}
|
37
35
|
history_objects(*args).each do |process|
|
38
|
-
res[process.full_name] = process.schedule_history.reject
|
36
|
+
res[process.full_name] = process.schedule_history.reject{|c| c[:state] == :check_crash }
|
39
37
|
end
|
40
38
|
res
|
41
39
|
end
|
@@ -45,7 +43,7 @@ private
|
|
45
43
|
def info_objects(*args)
|
46
44
|
res = []
|
47
45
|
return @applications if args.empty?
|
48
|
-
matched_objects(*args)
|
46
|
+
matched_objects(*args){|obj| res << obj }
|
49
47
|
res
|
50
48
|
end
|
51
49
|
|
data/lib/eye/dsl.rb
CHANGED
@@ -18,7 +18,6 @@ class Eye::Dsl
|
|
18
18
|
class Error < Exception; end
|
19
19
|
|
20
20
|
class << self
|
21
|
-
|
22
21
|
attr_accessor :verbose
|
23
22
|
|
24
23
|
def debug(msg = '')
|
@@ -37,9 +36,7 @@ class Eye::Dsl
|
|
37
36
|
|
38
37
|
Eye.parsed_config.transform!
|
39
38
|
Eye.parsed_config.validate!
|
40
|
-
|
41
|
-
Eye.parsed_config = nil # remove object for better GC
|
42
|
-
parsed_config
|
39
|
+
Eye.parsed_config
|
43
40
|
end
|
44
41
|
|
45
42
|
def parse_apps(*args)
|
@@ -49,9 +46,7 @@ class Eye::Dsl
|
|
49
46
|
def check_name(name)
|
50
47
|
raise Error, "':' is not allowed in name '#{name}'" if name.to_s.include?(':')
|
51
48
|
end
|
52
|
-
|
53
49
|
end
|
54
|
-
|
55
50
|
end
|
56
51
|
|
57
52
|
# extend here global module
|
@@ -30,11 +30,10 @@ class Eye::Dsl::ApplicationOpts < Eye::Dsl::Opts
|
|
30
30
|
|
31
31
|
def process(name, &block)
|
32
32
|
res = nil
|
33
|
-
group('__default__')
|
33
|
+
group('__default__'){ res = process(name.to_s, &block) }
|
34
34
|
res
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
alias xgroup nop
|
38
|
+
alias xprocess nop
|
40
39
|
end
|
data/lib/eye/dsl/chain.rb
CHANGED
@@ -2,12 +2,12 @@ class Eye::Dsl::ChildProcessOpts < Eye::Dsl::Opts
|
|
2
2
|
|
3
3
|
def allow_options
|
4
4
|
[:stop_command, :restart_command, :children_update_period,
|
5
|
-
|
5
|
+
:stop_signals, :stop_grace, :stop_timeout, :restart_timeout]
|
6
6
|
end
|
7
7
|
|
8
|
-
def triggers(*
|
8
|
+
def triggers(*args)
|
9
9
|
raise Eye::Dsl::Error, 'triggers not allowed in monitor_children'
|
10
10
|
end
|
11
|
-
|
11
|
+
alias trigger triggers
|
12
12
|
|
13
13
|
end
|
data/lib/eye/dsl/config_opts.rb
CHANGED
@@ -10,13 +10,13 @@ class Eye::Dsl::ConfigOpts < Eye::Dsl::PureOpts
|
|
10
10
|
@config[:logger] = args
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
alias logger= logger
|
14
14
|
|
15
15
|
def syslog(name = 'eye', *args)
|
16
16
|
require 'syslog/logger'
|
17
17
|
Syslog::Logger.new(name, *args)
|
18
18
|
rescue LoadError
|
19
|
-
raise Eye::Dsl::Error,
|
19
|
+
raise Eye::Dsl::Error, "logger syslog requires Ruby >= 2.0"
|
20
20
|
end
|
21
21
|
|
22
22
|
# ==== contact options ==============================
|
@@ -24,7 +24,7 @@ class Eye::Dsl::ConfigOpts < Eye::Dsl::PureOpts
|
|
24
24
|
create_options_methods([type], Hash)
|
25
25
|
|
26
26
|
define_method("set_#{type}") do |value|
|
27
|
-
value = value.merge(type
|
27
|
+
value = value.merge(:type => type)
|
28
28
|
super(value)
|
29
29
|
Eye::Notify.validate!(value)
|
30
30
|
end
|
@@ -36,14 +36,14 @@ class Eye::Dsl::ConfigOpts < Eye::Dsl::PureOpts
|
|
36
36
|
raise Eye::Dsl::Error, "unknown contact_type #{contact_type}" unless Eye::Notify::TYPES[contact_type]
|
37
37
|
raise Eye::Dsl::Error, 'contact should be a String' unless contact.is_a?(String)
|
38
38
|
|
39
|
-
notify_hash = @config[contact_type] || (@parent && @parent.config[contact_type]) || Eye
|
40
|
-
validate_hash = notify_hash.merge(contact_opts).merge(type
|
39
|
+
notify_hash = @config[contact_type] || (@parent && @parent.config[contact_type]) || Eye::parsed_config.settings[contact_type] || {}
|
40
|
+
validate_hash = notify_hash.merge(contact_opts).merge(:type => contact_type)
|
41
41
|
|
42
42
|
Eye::Notify.validate!(validate_hash)
|
43
43
|
|
44
44
|
@config[:contacts] ||= {}
|
45
|
-
@config[:contacts][contact_name.to_s] = {
|
46
|
-
|
45
|
+
@config[:contacts][contact_name.to_s] = {name: contact_name.to_s, type: contact_type,
|
46
|
+
contact: contact, opts: contact_opts}
|
47
47
|
end
|
48
48
|
|
49
49
|
def contact_group(contact_group_name, &block)
|
data/lib/eye/dsl/group_opts.rb
CHANGED
data/lib/eye/dsl/helpers.rb
CHANGED
data/lib/eye/dsl/main.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module Eye::Dsl::Main
|
2
|
-
|
3
2
|
attr_accessor :parsed_config, :parsed_filename, :parsed_default_app
|
4
3
|
|
5
4
|
def application(name, &block)
|
@@ -20,8 +19,8 @@ module Eye::Dsl::Main
|
|
20
19
|
Eye::Dsl.debug { "<= app: #{name}" }
|
21
20
|
end
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
alias project application
|
23
|
+
alias app application
|
25
24
|
|
26
25
|
def load(glob = '')
|
27
26
|
return if glob.blank?
|
@@ -54,7 +53,7 @@ module Eye::Dsl::Main
|
|
54
53
|
Eye::Dsl.debug { '<= config' }
|
55
54
|
end
|
56
55
|
|
57
|
-
|
56
|
+
alias settings config
|
58
57
|
|
59
58
|
def shared
|
60
59
|
require 'ostruct'
|
data/lib/eye/dsl/opts.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
class Eye::Dsl::Opts < Eye::Dsl::PureOpts
|
2
2
|
|
3
|
-
STR_OPTIONS = [:pid_file, :working_dir, :stdout, :stderr, :stdall, :stdin, :start_command,
|
4
|
-
|
3
|
+
STR_OPTIONS = [ :pid_file, :working_dir, :stdout, :stderr, :stdall, :stdin, :start_command,
|
4
|
+
:stop_command, :restart_command, :uid, :gid ]
|
5
5
|
create_options_methods(STR_OPTIONS, String)
|
6
6
|
|
7
|
-
BOOL_OPTIONS = [:daemonize, :keep_alive, :auto_start, :stop_on_delete, :clear_pid, :preserve_fds, :use_leaf_child,
|
8
|
-
:clear_env, :check_identity]
|
7
|
+
BOOL_OPTIONS = [ :daemonize, :keep_alive, :auto_start, :stop_on_delete, :clear_pid, :preserve_fds, :use_leaf_child, :clear_env ]
|
9
8
|
create_options_methods(BOOL_OPTIONS, [TrueClass, FalseClass])
|
10
9
|
|
11
|
-
INTERVAL_OPTIONS = [:check_alive_period, :start_timeout, :restart_timeout, :stop_timeout, :start_grace,
|
12
|
-
|
13
|
-
|
10
|
+
INTERVAL_OPTIONS = [ :check_alive_period, :start_timeout, :restart_timeout, :stop_timeout, :start_grace,
|
11
|
+
:restart_grace, :stop_grace, :children_update_period, :restore_in,
|
12
|
+
:auto_update_pidfile_grace, :revert_fuckup_pidfile_grace ]
|
14
13
|
create_options_methods(INTERVAL_OPTIONS, [Fixnum, Float])
|
15
14
|
|
16
15
|
create_options_methods([:environment], Hash)
|
17
16
|
create_options_methods([:umask], Fixnum)
|
18
17
|
|
18
|
+
|
19
19
|
def initialize(name = nil, parent = nil)
|
20
20
|
super(name, parent)
|
21
21
|
|
22
22
|
@config[:application] = parent.name if parent.is_a?(Eye::Dsl::ApplicationOpts) && parent.name != '__default__'
|
23
23
|
@config[:group] = parent.name if parent.is_a?(Eye::Dsl::GroupOpts)
|
24
24
|
|
25
|
-
#
|
25
|
+
# hack for full name
|
26
26
|
@full_name = parent.full_name if @name == '__default__' && parent.respond_to?(:full_name)
|
27
27
|
end
|
28
28
|
|
@@ -62,10 +62,10 @@ class Eye::Dsl::Opts < Eye::Dsl::PureOpts
|
|
62
62
|
@config[:triggers].try :delete, nac[:name]
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
alias check checks
|
66
|
+
alias nocheck nochecks
|
67
|
+
alias trigger triggers
|
68
|
+
alias notrigger notriggers
|
69
69
|
|
70
70
|
def command(cmd, arg)
|
71
71
|
@config[:user_commands] ||= {}
|
@@ -95,14 +95,16 @@ class Eye::Dsl::Opts < Eye::Dsl::PureOpts
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def set_stop_command(cmd)
|
98
|
-
raise Eye::Dsl::Error,
|
98
|
+
raise Eye::Dsl::Error, "cannot use both stop_signals and stop_command" if @config[:stop_signals]
|
99
99
|
super
|
100
100
|
end
|
101
101
|
|
102
102
|
def stop_signals(*args)
|
103
|
-
raise Eye::Dsl::Error,
|
103
|
+
raise Eye::Dsl::Error, "cannot use both stop_signals and stop_command" if @config[:stop_command]
|
104
104
|
|
105
|
-
|
105
|
+
if args.count == 0
|
106
|
+
return @config[:stop_signals]
|
107
|
+
end
|
106
108
|
|
107
109
|
signals = Array(args).flatten
|
108
110
|
validate_signals(signals)
|
@@ -119,8 +121,8 @@ class Eye::Dsl::Opts < Eye::Dsl::PureOpts
|
|
119
121
|
@config[:environment].merge!(value)
|
120
122
|
end
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
+
alias dir working_dir
|
125
|
+
alias env environment
|
124
126
|
|
125
127
|
def set_stdall(value)
|
126
128
|
super
|
@@ -148,7 +150,7 @@ class Eye::Dsl::Opts < Eye::Dsl::PureOpts
|
|
148
150
|
end
|
149
151
|
|
150
152
|
def scoped(&block)
|
151
|
-
h = self.class.new(name, self)
|
153
|
+
h = self.class.new(self.name, self)
|
152
154
|
h.instance_eval(&block)
|
153
155
|
Eye::Utils.deep_merge!(config, h.config, [:groups, :processes])
|
154
156
|
end
|
@@ -164,7 +166,7 @@ class Eye::Dsl::Opts < Eye::Dsl::PureOpts
|
|
164
166
|
host = Eye::Local.host
|
165
167
|
|
166
168
|
if glob.is_a?(Array)
|
167
|
-
on_server = !!glob.any?
|
169
|
+
on_server = !!glob.any?{|elem| elem == host}
|
168
170
|
elsif glob.is_a?(Regexp)
|
169
171
|
on_server = !!host.match(glob)
|
170
172
|
elsif glob.is_a?(String) || glob.is_a?(Symbol)
|
@@ -181,15 +183,15 @@ class Eye::Dsl::Opts < Eye::Dsl::PureOpts
|
|
181
183
|
|
182
184
|
def load_env(filename = '~/.env', raise_when_no_file = true)
|
183
185
|
fnames = [File.expand_path(filename, @config[:working_dir]),
|
184
|
-
|
186
|
+
File.expand_path(filename)].uniq
|
185
187
|
filenames = fnames.select { |f| File.exist?(f) }
|
186
188
|
|
187
189
|
if filenames.size < 1
|
188
|
-
|
189
|
-
raise Eye::Dsl::Error, "load_env not found in #{fnames}"
|
190
|
-
else
|
190
|
+
unless raise_when_no_file
|
191
191
|
warn "load_env not found file: '#{filenames.first}'"
|
192
192
|
return
|
193
|
+
else
|
194
|
+
raise Eye::Dsl::Error, "load_env not found in #{fnames}"
|
193
195
|
end
|
194
196
|
end
|
195
197
|
raise Eye::Dsl::Error, "load_env conflict filenames: #{filenames}" if filenames.size > 1
|
@@ -211,18 +213,13 @@ private
|
|
211
213
|
|
212
214
|
def validate_signals(signals = nil)
|
213
215
|
return unless signals
|
214
|
-
raise Eye::Dsl::Error,
|
216
|
+
raise Eye::Dsl::Error, "signals should be Array" unless signals.is_a?(Array)
|
215
217
|
s = signals.clone
|
216
218
|
while s.present?
|
217
219
|
sig = s.shift
|
218
220
|
timeout = s.shift
|
219
|
-
if sig && ![String, Symbol, Fixnum].include?(sig.class)
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
if timeout && ![Fixnum, Float].include?(timeout.class)
|
224
|
-
raise Eye::Dsl::Error, "signal sleep should be Numeric, not #{timeout.inspect}"
|
225
|
-
end
|
221
|
+
raise Eye::Dsl::Error, "signal should be String, Symbol, Fixnum, not #{sig.inspect}" if sig && ![String, Symbol, Fixnum].include?(sig.class)
|
222
|
+
raise Eye::Dsl::Error, "signal sleep should be Numeric, not #{timeout.inspect}" if timeout && ![Fixnum, Float].include?(timeout.class)
|
226
223
|
end
|
227
224
|
end
|
228
225
|
|
data/lib/eye/dsl/process_opts.rb
CHANGED
@@ -7,21 +7,21 @@ class Eye::Dsl::ProcessOpts < Eye::Dsl::Opts
|
|
7
7
|
Eye::Utils.deep_merge!(@config[:monitor_children], opts.config)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
alias xmonitor_children nop
|
11
11
|
|
12
12
|
def application
|
13
13
|
parent.try(:parent)
|
14
14
|
end
|
15
|
-
|
16
|
-
|
15
|
+
alias app application
|
16
|
+
alias group parent
|
17
17
|
|
18
18
|
def depend_on(names, opts = {})
|
19
19
|
names = Array(names).map(&:to_s)
|
20
|
-
trigger("wait_dependency_#{unique_num}", {
|
20
|
+
trigger("wait_dependency_#{unique_num}", {:names => names}.merge(opts))
|
21
21
|
nm = @config[:name]
|
22
22
|
names.each do |name|
|
23
23
|
parent.process(name) do
|
24
|
-
trigger("check_dependency_#{unique_num}", names
|
24
|
+
trigger("check_dependency_#{unique_num}", :names => [ nm ] )
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -31,14 +31,8 @@ class Eye::Dsl::ProcessOpts < Eye::Dsl::Opts
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def unique_num
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
class << self
|
39
|
-
|
40
|
-
attr_accessor :unique_num
|
41
|
-
|
34
|
+
$unique_num ||= 0
|
35
|
+
$unique_num += 1
|
42
36
|
end
|
43
37
|
|
44
38
|
end
|
data/lib/eye/dsl/pure_opts.rb
CHANGED
@@ -11,7 +11,7 @@ class Eye::Dsl::PureOpts
|
|
11
11
|
end
|
12
12
|
|
13
13
|
if types
|
14
|
-
good_type = Array(types).any?
|
14
|
+
good_type = Array(types).any?{|type| arg.is_a?(type) } || arg.nil?
|
15
15
|
raise Eye::Dsl::Error, "bad :#{opt} value #{arg.inspect}, type should be #{types.inspect}" unless good_type
|
16
16
|
end
|
17
17
|
|
@@ -19,7 +19,7 @@ class Eye::Dsl::PureOpts
|
|
19
19
|
end
|
20
20
|
|
21
21
|
define_method("get_#{opt}") do
|
22
|
-
@config[opt.to_sym]
|
22
|
+
@config[ opt.to_sym ]
|
23
23
|
end
|
24
24
|
|
25
25
|
define_method(opt) do |*args|
|
@@ -37,7 +37,7 @@ class Eye::Dsl::PureOpts
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
send :include, m
|
40
|
+
self.send :include, m
|
41
41
|
end
|
42
42
|
|
43
43
|
attr_reader :name, :full_name
|
@@ -50,7 +50,7 @@ class Eye::Dsl::PureOpts
|
|
50
50
|
if parent
|
51
51
|
@parent = parent
|
52
52
|
if merge_parent_config
|
53
|
-
@config = Eye::Utils
|
53
|
+
@config = Eye::Utils::deep_clone(parent.config)
|
54
54
|
parent.not_seed_options.each { |opt| @config.delete(opt) }
|
55
55
|
else
|
56
56
|
@config = {}
|
@@ -76,7 +76,7 @@ class Eye::Dsl::PureOpts
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def with_condition(cond = true, &block)
|
79
|
-
instance_eval(&block) if cond && block
|
79
|
+
self.instance_eval(&block) if cond && block
|
80
80
|
end
|
81
81
|
|
82
82
|
def use(proc, *args)
|
@@ -84,18 +84,18 @@ class Eye::Dsl::PureOpts
|
|
84
84
|
self.class.with_parsed_file(proc) do |path|
|
85
85
|
if File.exist?(path)
|
86
86
|
Eye::Dsl.debug { "=> load #{path}" }
|
87
|
-
instance_eval(File.read(path))
|
87
|
+
self.instance_eval(File.read(path))
|
88
88
|
Eye::Dsl.debug { "<= load #{path}" }
|
89
89
|
end
|
90
90
|
end
|
91
91
|
else
|
92
92
|
ie = if args.present?
|
93
|
-
|
93
|
+
lambda{|i| proc[i, *args] }
|
94
94
|
else
|
95
95
|
proc
|
96
96
|
end
|
97
97
|
|
98
|
-
instance_eval(&ie)
|
98
|
+
self.instance_eval(&ie)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -104,12 +104,8 @@ class Eye::Dsl::PureOpts
|
|
104
104
|
def self.with_parsed_file(file_name)
|
105
105
|
saved_parsed_filename = Eye.parsed_filename
|
106
106
|
|
107
|
-
real_filename = if Eye.parsed_filename && File.symlink?(Eye.parsed_filename)
|
108
|
-
File.readlink(Eye.parsed_filename)
|
109
|
-
else
|
110
|
-
Eye.parsed_filename
|
111
|
-
end
|
112
107
|
|
108
|
+
real_filename = Eye.parsed_filename && File.symlink?(Eye.parsed_filename) ? File.readlink(Eye.parsed_filename) : Eye.parsed_filename
|
113
109
|
dirname = File.dirname(real_filename) rescue nil
|
114
110
|
path = File.expand_path(file_name, dirname)
|
115
111
|
|