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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
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
@@ -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
+
@@ -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
+
@@ -1,91 +1,85 @@
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
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{lre}
8
- s.version = "0.3.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["mharris717"]
12
- s.date = %q{2011-10-19}
13
- s.default_executable = %q{lre}
14
- s.description = %q{lre}
15
- s.email = %q{mharris717@gmail.com}
16
- s.executables = ["lre"]
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.md"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".rspec",
24
- "Gemfile",
25
- "Gemfile.lock",
26
- "LICENSE.txt",
27
- "README.md",
28
- "Rakefile",
29
- "VERSION",
30
- "bin/lre",
31
- "lib/lre.rb",
32
- "lib/lre/file_reload.rb",
33
- "lib/lre/rake_ext.rb",
34
- "lre.gemspec",
35
- "spec/lre_spec.rb",
36
- "spec/spec_helper.rb",
37
- "spec/test_dir/.lre",
38
- "spec/test_dir/bar.rb",
39
- "spec/test_dir/file.rb",
40
- "spec/test_dir/foo.rb"
41
- ]
42
- s.homepage = %q{http://github.com/mharris717/lre}
43
- s.licenses = ["MIT"]
44
- s.require_paths = ["lib"]
45
- s.rubygems_version = %q{1.5.2}
46
- s.summary = %q{lre}
47
- s.test_files = [
48
- "spec/lre_spec.rb",
49
- "spec/spec_helper.rb",
50
- "spec/test_dir/bar.rb",
51
- "spec/test_dir/file.rb",
52
- "spec/test_dir/foo.rb"
53
- ]
54
-
55
- if s.respond_to? :specification_version then
56
- s.specification_version = 3
57
-
58
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
- s.add_runtime_dependency(%q<fattr>, [">= 0"])
60
- s.add_runtime_dependency(%q<watchr>, [">= 0"])
61
- s.add_runtime_dependency(%q<mharris_ext>, [">= 0"])
62
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
63
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
64
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
65
- s.add_development_dependency(%q<rcov>, [">= 0"])
66
- s.add_development_dependency(%q<github-markup>, [">= 0"])
67
- s.add_development_dependency(%q<rdiscount>, [">= 0"])
68
- else
69
- s.add_dependency(%q<fattr>, [">= 0"])
70
- s.add_dependency(%q<watchr>, [">= 0"])
71
- s.add_dependency(%q<mharris_ext>, [">= 0"])
72
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
73
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
74
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
75
- s.add_dependency(%q<rcov>, [">= 0"])
76
- s.add_dependency(%q<github-markup>, [">= 0"])
77
- s.add_dependency(%q<rdiscount>, [">= 0"])
78
- end
79
- else
80
- s.add_dependency(%q<fattr>, [">= 0"])
81
- s.add_dependency(%q<watchr>, [">= 0"])
82
- s.add_dependency(%q<mharris_ext>, [">= 0"])
83
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
84
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
85
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
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
+