eye 0.8.celluloid15 → 0.8.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -5
  3. data/CHANGES.md +3 -7
  4. data/README.md +2 -5
  5. data/Rakefile +6 -6
  6. data/bin/leye +4 -9
  7. data/bin/loader_eye +15 -14
  8. data/examples/delayed_job.eye +3 -3
  9. data/examples/dependency.eye +11 -10
  10. data/examples/notify.eye +4 -3
  11. data/examples/plugin/main.eye +5 -5
  12. data/examples/plugin/plugin.rb +2 -10
  13. data/examples/process_thin.rb +8 -8
  14. data/examples/processes/em.rb +12 -18
  15. data/examples/processes/forking.rb +5 -5
  16. data/examples/processes/sample.rb +44 -46
  17. data/examples/puma.eye +8 -9
  18. data/examples/rbenv.eye +5 -5
  19. data/examples/sidekiq.eye +3 -3
  20. data/examples/stress_test.eye +4 -4
  21. data/examples/syslog.eye +1 -1
  22. data/examples/test.eye +2 -1
  23. data/examples/thin-farm.eye +8 -7
  24. data/examples/triggers.eye +15 -13
  25. data/examples/unicorn.eye +13 -12
  26. data/eye.gemspec +14 -16
  27. data/lib/eye.rb +3 -2
  28. data/lib/eye/application.rb +6 -5
  29. data/lib/eye/checker.rb +25 -44
  30. data/lib/eye/checker/children_count.rb +1 -1
  31. data/lib/eye/checker/file_ctime.rb +1 -1
  32. data/lib/eye/checker/http.rb +15 -13
  33. data/lib/eye/checker/nop.rb +0 -1
  34. data/lib/eye/checker/socket.rb +63 -60
  35. data/lib/eye/checker/ssl_socket.rb +5 -5
  36. data/lib/eye/child_process.rb +4 -6
  37. data/lib/eye/cli.rb +46 -74
  38. data/lib/eye/cli/commands.rb +5 -4
  39. data/lib/eye/cli/render.rb +41 -61
  40. data/lib/eye/cli/server.rb +16 -19
  41. data/lib/eye/client.rb +0 -1
  42. data/lib/eye/config.rb +33 -36
  43. data/lib/eye/controller.rb +3 -2
  44. data/lib/eye/controller/commands.rb +1 -1
  45. data/lib/eye/controller/helpers.rb +2 -2
  46. data/lib/eye/controller/load.rb +17 -19
  47. data/lib/eye/controller/options.rb +5 -1
  48. data/lib/eye/controller/send_command.rb +23 -21
  49. data/lib/eye/controller/status.rb +15 -17
  50. data/lib/eye/dsl.rb +1 -6
  51. data/lib/eye/dsl/application_opts.rb +3 -4
  52. data/lib/eye/dsl/chain.rb +2 -2
  53. data/lib/eye/dsl/child_process_opts.rb +3 -3
  54. data/lib/eye/dsl/config_opts.rb +7 -7
  55. data/lib/eye/dsl/group_opts.rb +3 -3
  56. data/lib/eye/dsl/helpers.rb +1 -1
  57. data/lib/eye/dsl/main.rb +3 -4
  58. data/lib/eye/dsl/opts.rb +28 -31
  59. data/lib/eye/dsl/process_opts.rb +7 -13
  60. data/lib/eye/dsl/pure_opts.rb +9 -13
  61. data/lib/eye/dsl/validation.rb +35 -48
  62. data/lib/eye/group.rb +8 -23
  63. data/lib/eye/group/chain.rb +6 -6
  64. data/lib/eye/loader.rb +3 -3
  65. data/lib/eye/local.rb +4 -9
  66. data/lib/eye/logger.rb +4 -11
  67. data/lib/eye/notify.rb +6 -10
  68. data/lib/eye/notify/jabber.rb +1 -1
  69. data/lib/eye/notify/mail.rb +2 -2
  70. data/lib/eye/notify/slack.rb +3 -4
  71. data/lib/eye/process.rb +0 -2
  72. data/lib/eye/process/children.rb +4 -4
  73. data/lib/eye/process/commands.rb +39 -38
  74. data/lib/eye/process/config.rb +16 -22
  75. data/lib/eye/process/controller.rb +19 -5
  76. data/lib/eye/process/data.rb +9 -11
  77. data/lib/eye/process/monitor.rb +76 -86
  78. data/lib/eye/process/notify.rb +10 -10
  79. data/lib/eye/process/scheduler.rb +31 -36
  80. data/lib/eye/process/states.rb +5 -7
  81. data/lib/eye/process/states_history.rb +3 -9
  82. data/lib/eye/process/system.rb +20 -35
  83. data/lib/eye/process/trigger.rb +5 -1
  84. data/lib/eye/process/watchers.rb +9 -12
  85. data/lib/eye/reason.rb +1 -4
  86. data/lib/eye/server.rb +1 -2
  87. data/lib/eye/system.rb +15 -22
  88. data/lib/eye/system_resources.rb +9 -18
  89. data/lib/eye/trigger.rb +16 -18
  90. data/lib/eye/trigger/check_dependency.rb +4 -7
  91. data/lib/eye/trigger/flapping.rb +7 -24
  92. data/lib/eye/trigger/starting_guard.rb +6 -7
  93. data/lib/eye/trigger/stop_children.rb +2 -2
  94. data/lib/eye/trigger/transition.rb +1 -1
  95. data/lib/eye/trigger/wait_dependency.rb +2 -3
  96. data/lib/eye/utils.rb +3 -4
  97. data/lib/eye/utils/alive_array.rb +4 -9
  98. data/lib/eye/utils/celluloid_chain.rb +10 -12
  99. data/lib/eye/utils/leak_19.rb +10 -0
  100. data/lib/eye/utils/mini_active_support.rb +16 -16
  101. data/lib/eye/utils/pmap.rb +0 -2
  102. data/lib/eye/utils/tail.rb +2 -2
  103. metadata +8 -39
  104. data/.rubocop.yml +0 -141
  105. data/examples/custom_check.eye +0 -24
  106. data/examples/custom_trigger.eye +0 -30
  107. 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 { |actor| actor.wrapped_object.class.to_s }.group_by { |a| a }
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: Eye::ABOUT,
10
- resources: Eye::SystemResources.resources($$),
11
- ruby: RUBY_DESCRIPTION,
12
- gems: %w[Celluloid Celluloid::IO StateMachine NIO Timers Sigar].map { |c| gem_version(c) },
13
- logger: Eye::Logger.args.present? ? [Eye::Logger.dev.to_s, *Eye::Logger.args] : Eye::Logger.dev.to_s,
14
- home: Eye::Local.home,
15
- dir: Eye::Local.dir,
16
- pid_path: Eye::Local.pid_path,
17
- sock_path: Eye::Local.socket_path,
18
- actors: actors
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
- h = args.extract_options!
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
- { subtree: info_objects(*args).select { |o| o.class == Eye::Application }.map(&:status_data_short) }
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 { |c| c[:state] == :check_crash }
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) { |obj| res << obj }
46
+ matched_objects(*args){|obj| res << obj }
49
47
  res
50
48
  end
51
49
 
@@ -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
- parsed_config = Eye.parsed_config
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__') { res = process(name.to_s, &block) }
33
+ group('__default__'){ res = process(name.to_s, &block) }
34
34
  res
35
35
  end
36
36
 
37
- alias_method :xgroup, :nop
38
- alias_method :xprocess, :nop
39
-
37
+ alias xgroup nop
38
+ alias xprocess nop
40
39
  end
@@ -5,8 +5,8 @@ module Eye::Dsl::Chain
5
5
 
6
6
  acts.each do |act|
7
7
  @config[:chain] ||= {}
8
- @config[:chain][act] = opts.merge(action: act)
8
+ @config[:chain][act] = opts.merge(:action => act)
9
9
  end
10
10
  end
11
11
 
12
- end
12
+ end
@@ -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
- :stop_signals, :stop_grace, :stop_timeout, :restart_timeout]
5
+ :stop_signals, :stop_grace, :stop_timeout, :restart_timeout]
6
6
  end
7
7
 
8
- def triggers(*_args)
8
+ def triggers(*args)
9
9
  raise Eye::Dsl::Error, 'triggers not allowed in monitor_children'
10
10
  end
11
- alias_method :trigger, :triggers
11
+ alias trigger triggers
12
12
 
13
13
  end
@@ -10,13 +10,13 @@ class Eye::Dsl::ConfigOpts < Eye::Dsl::PureOpts
10
10
  @config[:logger] = args
11
11
  end
12
12
  end
13
- alias_method :logger=, :logger
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, 'logger syslog requires Ruby >= 2.0'
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: 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.parsed_config.settings[contact_type] || {}
40
- validate_hash = notify_hash.merge(contact_opts).merge(type: contact_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] = { name: contact_name.to_s, type: contact_type,
46
- contact: contact, opts: contact_opts }
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)
@@ -25,8 +25,8 @@ class Eye::Dsl::GroupOpts < Eye::Dsl::Opts
25
25
  opts
26
26
  end
27
27
 
28
- alias_method :xprocess, :nop
29
- alias_method :application, :parent
30
- alias_method :app, :application
28
+ alias xprocess nop
29
+ alias application parent
30
+ alias app application
31
31
 
32
32
  end
@@ -14,7 +14,7 @@ end
14
14
  def example_process(proxy, name)
15
15
  proxy.process(name) do
16
16
  pid_file "/tmp/#{name}.pid"
17
- start_command 'sleep 100'
17
+ start_command "sleep 100"
18
18
  daemonize true
19
19
  end
20
20
  end
@@ -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
- alias_method :project, :application
24
- alias_method :app, :application
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
- alias_method :settings, :config
56
+ alias settings config
58
57
 
59
58
  def shared
60
59
  require 'ostruct'
@@ -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
- :stop_command, :restart_command, :uid, :gid]
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
- :restart_grace, :stop_grace, :children_update_period, :restore_in,
13
- :auto_update_pidfile_grace, :revert_fuckup_pidfile_grace, :check_identity_period, :check_identity_grace]
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
- # HACK: for full name
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
- alias_method :check, :checks
66
- alias_method :nocheck, :nochecks
67
- alias_method :trigger, :triggers
68
- alias_method :notrigger, :notriggers
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, 'cannot use both stop_signals and stop_command' if @config[:stop_signals]
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, 'cannot use both stop_signals and stop_command' if @config[:stop_command]
103
+ raise Eye::Dsl::Error, "cannot use both stop_signals and stop_command" if @config[:stop_command]
104
104
 
105
- return @config[:stop_signals] if args.count == 0
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
- alias_method :dir, :working_dir
123
- alias_method :env, :environment
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? { |elem| elem == host }
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
- File.expand_path(filename)].uniq
186
+ File.expand_path(filename)].uniq
185
187
  filenames = fnames.select { |f| File.exist?(f) }
186
188
 
187
189
  if filenames.size < 1
188
- if raise_when_no_file
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, 'signals should be Array' unless signals.is_a?(Array)
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
- raise Eye::Dsl::Error, "signal should be String, Symbol, Fixnum, not #{sig.inspect}"
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
 
@@ -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
- alias_method :xmonitor_children, :nop
10
+ alias xmonitor_children nop
11
11
 
12
12
  def application
13
13
  parent.try(:parent)
14
14
  end
15
- alias_method :app, :application
16
- alias_method :group, :parent
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}", { names: names }.merge(opts))
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: [nm])
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
- self.class.unique_num ||= 0
35
- self.class.unique_num += 1
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
@@ -11,7 +11,7 @@ class Eye::Dsl::PureOpts
11
11
  end
12
12
 
13
13
  if types
14
- good_type = Array(types).any? { |type| arg.is_a?(type) } || arg.nil?
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.deep_clone(parent.config)
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
- ->(i) { proc[i, *args] }
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