marcinbunsch-bolt 0.1.0 → 0.1.4

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.
@@ -10,7 +10,7 @@ module Bolt
10
10
  attr_accessor :files, :interval, :busy, :notifier, :parent, :mappings
11
11
 
12
12
  def initialize
13
- self.interval = 2 # decrease the CPU load by increasing the interval
13
+ self.interval = 1 # decrease the CPU load by increasing the interval
14
14
  self.busy = false
15
15
  end
16
16
 
@@ -24,7 +24,9 @@ module Bolt
24
24
  $".delete(filename)
25
25
  $".delete(File.join(Dir.pwd, filename))
26
26
 
27
- klassname = filename.sub('app/controllers', '').sub('app/models', '').sub('lib/', '')
27
+ =begin
28
+ # FIXME: This does not work well against a real project.
29
+ klassname = filename.sub('app/controllers/', '').sub('app/models/', '').sub('lib/', '')
28
30
  test_class = klassname.sub('.rb', '').gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
29
31
  root_klass = test_class.split('::').first
30
32
 
@@ -32,6 +34,7 @@ module Bolt
32
34
  # this is required to rebuild classes before test run
33
35
  # one limitation - Spec/Test cannot be reloaded or it will crash
34
36
  Object.send(:remove_const, root_klass) unless root_klass == 'Spec' or root_klass == 'Test'
37
+ =end
35
38
 
36
39
  if filename.include?('app/controllers') or filename.include?('app/models') or filename.include?('lib/')
37
40
  begin
@@ -36,7 +36,29 @@ module Bolt
36
36
  # force reload of file
37
37
  $".delete(file)
38
38
  $".delete(File.join(Dir.pwd, file))
39
+ =begin
40
+ # FIXME: This does not work well against a real project.
41
+ klassname = file.sub('app/controllers/', '').sub('app/models/', '').sub('lib/', '')
42
+ puts klassname
43
+ test_class = klassname.sub('.rb', '').gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
44
+
45
+ target_class = Object
46
+ target_classes = []
47
+ test_class.split('::').each do |c|
48
+ target_class = target_class.const_get(c)
49
+ target_classes << target_class
50
+ end
39
51
 
52
+ # remove the top constant/class from memory
53
+ # this is required to rebuild classes before test run
54
+ # one limitation - Spec/Test cannot be reloaded or it will crash
55
+ if target_classes.size >= 2
56
+ puts 'removing ' + target_classes[-1].to_s.split('::').last.to_s + ' from ' + target_classes[-2].to_s
57
+ target_classes[-2].send(:remove_const, target_classes[-1].to_s.split('::').last.to_s)
58
+ else
59
+ Object.send(:remove_const, target_classes.first.to_s) unless target_classes.first.to_s == 'Test'
60
+ end
61
+ =end
40
62
  if file.include?('app/controllers') or file.include?('app/models') or file.include?('lib/')
41
63
  begin
42
64
  require File.join(Dir.pwd, file)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marcinbunsch-bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bunsch