auser-reloadable 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +25 -0
- data/lib/reloadable.rb +30 -0
- data/test/dummy.rb +0 -0
- data/test/reloadable_test.rb +14 -0
- data/test/test_helper.rb +10 -0
- metadata +60 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Ari Lerner
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= reloadable
|
2
|
+
|
3
|
+
Reloading files is useful... sometimes. This makes it easy to reload files you define.
|
4
|
+
|
5
|
+
How?
|
6
|
+
|
7
|
+
class PunkyBrewster
|
8
|
+
include Reloadable
|
9
|
+
|
10
|
+
# Require her friends and register that we might be reloading them later
|
11
|
+
require_reloadable_files "edward.rb"
|
12
|
+
require_reloadable_files "frank.rb"
|
13
|
+
|
14
|
+
def say_hello
|
15
|
+
reload_files! if should_reload? # should_reload? is your own method
|
16
|
+
puts "Hello"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
That's it!
|
21
|
+
|
22
|
+
|
23
|
+
== Copyright
|
24
|
+
|
25
|
+
Copyright (c) 2009 Ari Lerner. See LICENSE for details.
|
data/lib/reloadable.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Reloadable
|
2
|
+
# Force reload of this file
|
3
|
+
module ClassMethods
|
4
|
+
def reload_files!
|
5
|
+
@reloading = true
|
6
|
+
reloadable_files.each do |f|
|
7
|
+
$LOADED_FEATURES.delete(f)
|
8
|
+
::Kernel.load f
|
9
|
+
end
|
10
|
+
@reloading = false
|
11
|
+
end
|
12
|
+
|
13
|
+
def require_reloadable_files *files
|
14
|
+
files.each do |a|
|
15
|
+
fpath = File.expand_path(a.index(".rb") ? a : "#{a}.rb")
|
16
|
+
reloadable_files << fpath
|
17
|
+
require fpath
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def reloadable_files
|
22
|
+
@reloadable_files ||= []
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.included(receiver)
|
27
|
+
receiver.extend ClassMethods
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/test/dummy.rb
ADDED
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class ReloadableTester
|
3
|
+
include Reloadable
|
4
|
+
end
|
5
|
+
|
6
|
+
class ReloadableTest < Test::Unit::TestCase
|
7
|
+
should "respond to reload_files!" do;assert ReloadableTester.respond_to?(:reload_files!);end
|
8
|
+
should "respond to require_reloadable_files" do;assert ReloadableTester.respond_to?(:require_reloadable_files);end
|
9
|
+
should "respond to reloadable_files" do;assert ReloadableTester.respond_to?(:reloadable_files);end
|
10
|
+
should "add to the reloadable files when require_reloadable_files" do
|
11
|
+
ReloadableTester.require_reloadable_files "dummy.rb"
|
12
|
+
assert ReloadableTester.reloadable_files.include?(File.expand_path("dummy.rb"))
|
13
|
+
end
|
14
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: auser-reloadable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ari Lerner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-04 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: arilerner@mac.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- LICENSE
|
25
|
+
files:
|
26
|
+
- README.rdoc
|
27
|
+
- lib/reloadable.rb
|
28
|
+
- test/dummy.rb
|
29
|
+
- test/reloadable_test.rb
|
30
|
+
- test/test_helper.rb
|
31
|
+
- LICENSE
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://github.com/auser/reloadable
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options:
|
36
|
+
- --inline-source
|
37
|
+
- --charset=UTF-8
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.2.0
|
56
|
+
signing_key:
|
57
|
+
specification_version: 2
|
58
|
+
summary: TODO
|
59
|
+
test_files: []
|
60
|
+
|