lre 0.3.0 → 0.3.1
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.
- checksums.yaml +15 -0
- data/.document +5 -5
- data/.rspec +1 -1
- data/Gemfile +14 -14
- data/Gemfile.lock +59 -22
- data/LICENSE.txt +20 -20
- data/README.md +67 -67
- data/Rakefile +50 -60
- data/VERSION +1 -1
- data/bin/lre +4 -4
- data/lib/lre.rb +59 -59
- data/lib/lre/file_reload.rb +83 -83
- data/lib/lre/rake_ext.rb +21 -21
- data/lib/lre/watchr_ext.rb +14 -0
- data/lre.gemspec +85 -91
- data/spec/lre_spec.rb +8 -8
- data/spec/spec_helper.rb +12 -12
- data/spec/test_dir/bar.rb +2 -2
- data/spec/test_dir/foo.rb +2 -2
- metadata +70 -54
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/bin/lre
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__)+"/../lib")+"/lre.rb"
|
4
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__)+"/../lib")+"/lre.rb"
|
4
|
+
|
5
5
|
LRE.from_cli!(ARGV[0])
|
data/lib/lre.rb
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'fattr'
|
3
|
-
%w(file_reload rake_ext).each do |f|
|
4
|
-
require File.expand_path(File.dirname(__FILE__)) + "/lre/#{f}.rb"
|
5
|
-
end
|
6
|
-
|
7
|
-
module LRE
|
8
|
-
class << self
|
9
|
-
fattr(:watch_dirs) do
|
10
|
-
["."]
|
11
|
-
end
|
12
|
-
def add_watch_dir(*ds)
|
13
|
-
[ds].flatten.each do |d|
|
14
|
-
self.watch_dirs << d
|
15
|
-
end
|
16
|
-
end
|
17
|
-
def load_config!
|
18
|
-
config_files = ["~/.lre","#{Dir.getwd}/.lre"]
|
19
|
-
config_files.each do |f|
|
20
|
-
load(f) if FileTest.exists?(f)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
def start_irb!
|
24
|
-
return if @start_irb
|
25
|
-
require 'irb'
|
26
|
-
@start_irb = true
|
27
|
-
IRB.start
|
28
|
-
end
|
29
|
-
def from_cli!(f)
|
30
|
-
if f
|
31
|
-
load_config!
|
32
|
-
load(f)
|
33
|
-
else
|
34
|
-
start!
|
35
|
-
end
|
36
|
-
end
|
37
|
-
def start!
|
38
|
-
load_config!
|
39
|
-
FileReload.run!
|
40
|
-
|
41
|
-
start_irb!
|
42
|
-
end
|
43
|
-
def stop!
|
44
|
-
FileReload.stop!
|
45
|
-
end
|
46
|
-
def watch(pattern,&b)
|
47
|
-
FileReload.watches[pattern] = b
|
48
|
-
end
|
49
|
-
def on_every_file(&b)
|
50
|
-
FileReload.on_every_file = b
|
51
|
-
end
|
52
|
-
def name(n=nil)
|
53
|
-
if n
|
54
|
-
FileReload.instance_name = n
|
55
|
-
else
|
56
|
-
FileReload.instance_name
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
1
|
+
require 'rake'
|
2
|
+
require 'fattr'
|
3
|
+
%w(file_reload rake_ext watchr_ext).each do |f|
|
4
|
+
require File.expand_path(File.dirname(__FILE__)) + "/lre/#{f}.rb"
|
5
|
+
end
|
6
|
+
|
7
|
+
module LRE
|
8
|
+
class << self
|
9
|
+
fattr(:watch_dirs) do
|
10
|
+
["."]
|
11
|
+
end
|
12
|
+
def add_watch_dir(*ds)
|
13
|
+
[ds].flatten.each do |d|
|
14
|
+
self.watch_dirs << d
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def load_config!
|
18
|
+
config_files = ["~/.lre","#{Dir.getwd}/.lre"]
|
19
|
+
config_files.each do |f|
|
20
|
+
load(f) if FileTest.exists?(f)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
def start_irb!
|
24
|
+
return if @start_irb
|
25
|
+
require 'irb'
|
26
|
+
@start_irb = true
|
27
|
+
IRB.start
|
28
|
+
end
|
29
|
+
def from_cli!(f)
|
30
|
+
if f
|
31
|
+
load_config!
|
32
|
+
load(f)
|
33
|
+
else
|
34
|
+
start!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def start!
|
38
|
+
load_config!
|
39
|
+
FileReload.run!
|
40
|
+
|
41
|
+
start_irb!
|
42
|
+
end
|
43
|
+
def stop!
|
44
|
+
FileReload.stop!
|
45
|
+
end
|
46
|
+
def watch(pattern,&b)
|
47
|
+
FileReload.watches[pattern] = b
|
48
|
+
end
|
49
|
+
def on_every_file(&b)
|
50
|
+
FileReload.on_every_file = b
|
51
|
+
end
|
52
|
+
def name(n=nil)
|
53
|
+
if n
|
54
|
+
FileReload.instance_name = n
|
55
|
+
else
|
56
|
+
FileReload.instance_name
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
60
|
end
|
data/lib/lre/file_reload.rb
CHANGED
@@ -1,83 +1,83 @@
|
|
1
|
-
module FileReload
|
2
|
-
def self.method_missing(sym,*args,&b)
|
3
|
-
Base.instance.send(sym,*args,&b)
|
4
|
-
end
|
5
|
-
class Base
|
6
|
-
class << self
|
7
|
-
fattr(:instance) { new }
|
8
|
-
end
|
9
|
-
attr_accessor :script, :on_every_file, :instance_name
|
10
|
-
fattr(:threads) { [] }
|
11
|
-
def should_load?(f)
|
12
|
-
str = File.read(f)
|
13
|
-
if str =~ /--dontload({.+})?/
|
14
|
-
if !$1
|
15
|
-
false
|
16
|
-
else
|
17
|
-
n = $1[1..-2]
|
18
|
-
!(instance_name.to_s == n)
|
19
|
-
end
|
20
|
-
elsif str =~ /--onlyload{(.+)}/
|
21
|
-
$1 == instance_name.to_s
|
22
|
-
else
|
23
|
-
true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
def process_file(f,&b)
|
27
|
-
if !FileTest.exists?(f)
|
28
|
-
puts "file doesn't exist #{f}"
|
29
|
-
return
|
30
|
-
end
|
31
|
-
if should_load?(f)
|
32
|
-
on_every_file[File.expand_path(f)] if on_every_file
|
33
|
-
puts "loading #{f}"
|
34
|
-
b[f]
|
35
|
-
else
|
36
|
-
puts "didn't load #{f}"
|
37
|
-
end
|
38
|
-
print ">"
|
39
|
-
rescue => exp
|
40
|
-
puts "error loading #{f}"
|
41
|
-
puts exp.message + "\n" + exp.backtrace.join("\n")
|
42
|
-
rescue SyntaxError => exp
|
43
|
-
puts "syntax error loading #{f}"
|
44
|
-
puts exp.message + "\n" + exp.backtrace.join("\n")
|
45
|
-
rescue RuntimeError => exp
|
46
|
-
puts "runtime error"
|
47
|
-
puts exp.message
|
48
|
-
end
|
49
|
-
def stop!
|
50
|
-
self.threads.each { |x| x.kill }
|
51
|
-
self.threads = []
|
52
|
-
end
|
53
|
-
fattr(:watches) do
|
54
|
-
res = {}
|
55
|
-
res[".*\.rb$"] = lambda do |f|
|
56
|
-
load f
|
57
|
-
end
|
58
|
-
res
|
59
|
-
end
|
60
|
-
def run!
|
61
|
-
require 'watchr'
|
62
|
-
require 'pathname'
|
63
|
-
self.script = Watchr::Script.new
|
64
|
-
watches.each do |file_match,proc|
|
65
|
-
script.watch(file_match) do |md|
|
66
|
-
f = md[0]
|
67
|
-
process_file(f,&proc)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
self.threads.each { |x| x.kill }
|
72
|
-
self.threads = []
|
73
|
-
|
74
|
-
LRE.watch_dirs.uniq.each do |d|
|
75
|
-
c = Watchr::Controller.new(script, Watchr.handler.new)
|
76
|
-
c.base_path = d
|
77
|
-
puts "adding thread #{d}"
|
78
|
-
self.threads << Thread.new { c.run }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
1
|
+
module FileReload
|
2
|
+
def self.method_missing(sym,*args,&b)
|
3
|
+
Base.instance.send(sym,*args,&b)
|
4
|
+
end
|
5
|
+
class Base
|
6
|
+
class << self
|
7
|
+
fattr(:instance) { new }
|
8
|
+
end
|
9
|
+
attr_accessor :script, :on_every_file, :instance_name
|
10
|
+
fattr(:threads) { [] }
|
11
|
+
def should_load?(f)
|
12
|
+
str = File.read(f)
|
13
|
+
if str =~ /--dontload({.+})?/
|
14
|
+
if !$1
|
15
|
+
false
|
16
|
+
else
|
17
|
+
n = $1[1..-2]
|
18
|
+
!(instance_name.to_s == n)
|
19
|
+
end
|
20
|
+
elsif str =~ /--onlyload{(.+)}/
|
21
|
+
$1 == instance_name.to_s
|
22
|
+
else
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def process_file(f,&b)
|
27
|
+
if !FileTest.exists?(f)
|
28
|
+
puts "file doesn't exist #{f}"
|
29
|
+
return
|
30
|
+
end
|
31
|
+
if should_load?(f)
|
32
|
+
on_every_file[File.expand_path(f)] if on_every_file
|
33
|
+
puts "loading #{f}"
|
34
|
+
b[f]
|
35
|
+
else
|
36
|
+
puts "didn't load #{f}"
|
37
|
+
end
|
38
|
+
print ">"
|
39
|
+
rescue => exp
|
40
|
+
puts "error loading #{f}"
|
41
|
+
puts exp.message + "\n" + exp.backtrace.join("\n")
|
42
|
+
rescue SyntaxError => exp
|
43
|
+
puts "syntax error loading #{f}"
|
44
|
+
puts exp.message + "\n" + exp.backtrace.join("\n")
|
45
|
+
rescue RuntimeError => exp
|
46
|
+
puts "runtime error"
|
47
|
+
puts exp.message
|
48
|
+
end
|
49
|
+
def stop!
|
50
|
+
self.threads.each { |x| x.kill }
|
51
|
+
self.threads = []
|
52
|
+
end
|
53
|
+
fattr(:watches) do
|
54
|
+
res = {}
|
55
|
+
res[".*\.rb$"] = lambda do |f|
|
56
|
+
load f
|
57
|
+
end
|
58
|
+
res
|
59
|
+
end
|
60
|
+
def run!
|
61
|
+
require 'watchr'
|
62
|
+
require 'pathname'
|
63
|
+
self.script = Watchr::Script.new
|
64
|
+
watches.each do |file_match,proc|
|
65
|
+
script.watch(file_match) do |md|
|
66
|
+
f = md[0]
|
67
|
+
process_file(f,&proc)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
self.threads.each { |x| x.kill }
|
72
|
+
self.threads = []
|
73
|
+
|
74
|
+
LRE.watch_dirs.uniq.each do |d|
|
75
|
+
c = Watchr::Controller.new(script, Watchr.handler.new)
|
76
|
+
c.base_path = d
|
77
|
+
puts "adding thread #{d}"
|
78
|
+
self.threads << Thread.new { c.run }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
data/lib/lre/rake_ext.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require 'rake'
|
2
|
-
module Rake
|
3
|
-
class Task
|
4
|
-
def actions=(x)
|
5
|
-
@actions = x
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def gt(n)
|
11
|
-
t = Rake::Task[n]
|
12
|
-
#puts "action size #{t.actions.size}"
|
13
|
-
t.actions = t.actions[-1..-1] if t.actions.size > 1
|
14
|
-
t.invoke
|
15
|
-
end
|
16
|
-
|
17
|
-
def gte(n)
|
18
|
-
t = Rake::Task[n]
|
19
|
-
#puts "action size #{t.actions.size}"
|
20
|
-
t.actions = t.actions[-1..-1] if t.actions.size > 1
|
21
|
-
t.execute
|
1
|
+
require 'rake'
|
2
|
+
module Rake
|
3
|
+
class Task
|
4
|
+
def actions=(x)
|
5
|
+
@actions = x
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def gt(n)
|
11
|
+
t = Rake::Task[n]
|
12
|
+
#puts "action size #{t.actions.size}"
|
13
|
+
t.actions = t.actions[-1..-1] if t.actions.size > 1
|
14
|
+
t.invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
def gte(n)
|
18
|
+
t = Rake::Task[n]
|
19
|
+
#puts "action size #{t.actions.size}"
|
20
|
+
t.actions = t.actions[-1..-1] if t.actions.size > 1
|
21
|
+
t.execute
|
22
22
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'watchr'
|
2
|
+
|
3
|
+
Watchr::Controller.class_eval do
|
4
|
+
attr_accessor :base_path
|
5
|
+
def monitored_paths
|
6
|
+
p = base_path ? "#{base_path}/**/*" : "**/*"
|
7
|
+
paths = Dir[p].select do |path|
|
8
|
+
@script.patterns.any? {|p| path.match(p) }
|
9
|
+
end
|
10
|
+
paths.push(@script.path).compact!
|
11
|
+
paths.map {|path| Pathname(path).expand_path }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
data/lre.gemspec
CHANGED
@@ -1,91 +1,85 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
s.
|
9
|
-
|
10
|
-
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
".
|
24
|
-
"
|
25
|
-
"Gemfile
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"
|
32
|
-
"lib/lre
|
33
|
-
"lib/lre/
|
34
|
-
"lre.
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"spec/
|
38
|
-
"spec/
|
39
|
-
"spec/test_dir
|
40
|
-
"spec/test_dir/
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
s.
|
45
|
-
s.
|
46
|
-
s.
|
47
|
-
s.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
s.
|
60
|
-
s.
|
61
|
-
s.
|
62
|
-
|
63
|
-
s.
|
64
|
-
s.
|
65
|
-
s.
|
66
|
-
s.
|
67
|
-
s.
|
68
|
-
|
69
|
-
s.add_dependency(%q<
|
70
|
-
s.add_dependency(%q<
|
71
|
-
s.add_dependency(%q<
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
s.add_dependency(%q<
|
81
|
-
s.add_dependency(%q<
|
82
|
-
s.add_dependency(%q<
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
87
|
-
s.add_dependency(%q<github-markup>, [">= 0"])
|
88
|
-
s.add_dependency(%q<rdiscount>, [">= 0"])
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: lre 0.3.1 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "lre"
|
9
|
+
s.version = "0.3.1"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["mharris717"]
|
14
|
+
s.date = "2014-04-29"
|
15
|
+
s.description = "lre"
|
16
|
+
s.email = "mharris717@gmail.com"
|
17
|
+
s.executables = ["lre"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE.txt",
|
20
|
+
"README.md"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".document",
|
24
|
+
".rspec",
|
25
|
+
"Gemfile",
|
26
|
+
"Gemfile.lock",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.md",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"bin/lre",
|
32
|
+
"lib/lre.rb",
|
33
|
+
"lib/lre/file_reload.rb",
|
34
|
+
"lib/lre/rake_ext.rb",
|
35
|
+
"lib/lre/watchr_ext.rb",
|
36
|
+
"lre.gemspec",
|
37
|
+
"spec/lre_spec.rb",
|
38
|
+
"spec/spec_helper.rb",
|
39
|
+
"spec/test_dir/.lre",
|
40
|
+
"spec/test_dir/bar.rb",
|
41
|
+
"spec/test_dir/file.rb",
|
42
|
+
"spec/test_dir/foo.rb"
|
43
|
+
]
|
44
|
+
s.homepage = "http://github.com/mharris717/lre"
|
45
|
+
s.licenses = ["MIT"]
|
46
|
+
s.rubygems_version = "2.2.2"
|
47
|
+
s.summary = "lre"
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
s.specification_version = 4
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<fattr>, [">= 0"])
|
54
|
+
s.add_runtime_dependency(%q<watchr>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<mharris_ext>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
57
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
58
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0"])
|
59
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
60
|
+
s.add_development_dependency(%q<github-markup>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<rdiscount>, [">= 0"])
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<fattr>, [">= 0"])
|
64
|
+
s.add_dependency(%q<watchr>, [">= 0"])
|
65
|
+
s.add_dependency(%q<mharris_ext>, [">= 0"])
|
66
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
67
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
68
|
+
s.add_dependency(%q<bundler>, [">= 1.0"])
|
69
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
70
|
+
s.add_dependency(%q<github-markup>, [">= 0"])
|
71
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
72
|
+
end
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<fattr>, [">= 0"])
|
75
|
+
s.add_dependency(%q<watchr>, [">= 0"])
|
76
|
+
s.add_dependency(%q<mharris_ext>, [">= 0"])
|
77
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
78
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
79
|
+
s.add_dependency(%q<bundler>, [">= 1.0"])
|
80
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
81
|
+
s.add_dependency(%q<github-markup>, [">= 0"])
|
82
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|