Class: ReloaderGem
- Inherits:
-
Object
- Object
- ReloaderGem
- Defined in:
- lib/reloader_gem.rb,
lib/reloader_gem/version.rb
Constant Summary collapse
- VERSION =
"0.2.2"
Instance Method Summary collapse
-
#initialize(gem_name_path, time = 0.5) ⇒ ReloaderGem
constructor
A new instance of ReloaderGem.
-
#listen ⇒ Object
listen the gem.
-
#load(regexp) ⇒ Object
load all files from gem which match into variable regexp.
Constructor Details
#initialize(gem_name_path, time = 0.5) ⇒ ReloaderGem
Returns a new instance of ReloaderGem.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/reloader_gem.rb', line 9 def initialize(gem_name_path, time = 0.5) @logger = Logger.new(STDOUT) if gem_name_path.split("/").last == gem_name_path @gem_name = gem_name_path @gem_path = Gem::Specification.find_by_name(@gem_name).gem_dir else @gem_name = gem_name_path.split("/").last @gem_path = gem_name_path end @check_sum = md5_gem @time = time @load_files =[] end |
Instance Method Details
#listen ⇒ Object
listen the gem
26 27 28 29 30 31 32 33 34 |
# File 'lib/reloader_gem.rb', line 26 def listen load_files Thread.new do while true sleep @time update_files end end end |
#load(regexp) ⇒ Object
load all files from gem which match into variable regexp
37 38 39 40 |
# File 'lib/reloader_gem.rb', line 37 def load(regexp) @load_files += Dir[File.join(@gem_path, regexp)] self end |