method_reload 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY ADDED
@@ -0,0 +1,2 @@
1
+ * 11/4/2011
2
+ 0.1.0 release!
@@ -0,0 +1,86 @@
1
+ method_reload
2
+ ===========
3
+
4
+ (C) John Mair (banisterfiend) 2011
5
+
6
+ _fine grained code reloading_
7
+
8
+ `method_reload` enables you to reload method code on the fly. It
9
+ precisely targets the code of the method - it does not
10
+ reload the entire file.
11
+
12
+ `method_reload` provides the `Method#reload` and
13
+ `UnboundMethod#reload` methods.
14
+
15
+ * Install the [gem](https://rubygems.org/gems/method_reload): `gem install method_reload`
16
+ * Read the [documentation](http://rdoc.info/github/banister/method_reload/master/file/README.md)
17
+ * See the [source code](http://github.com/banister/method_reload)
18
+
19
+ Example: Example
20
+ --------
21
+
22
+ class Hello
23
+ def hello
24
+ puts "hello world"
25
+ end
26
+ end
27
+
28
+ Hello.new.hello #=> "hello world"
29
+
30
+ # file edited here and "hello world" changed to "goodbye"
31
+
32
+ # now we reload
33
+ Hello.instance_method(:hello).reload
34
+
35
+ # now we test
36
+ Hello.new.hello #=> "goodbye"
37
+
38
+ Features and limitations
39
+ -------------------------
40
+
41
+ ### Features:
42
+
43
+ * Only reloads the code for the method.
44
+ * Works with any kind of method: class methods, instance methods.
45
+ * Fast.
46
+
47
+ ### Limitations:
48
+
49
+ * Updated method definition must start on exactly the same line as the
50
+ original. This limitation will be overcome in a later version.
51
+ * Not tested in JRuby with 1.9 support, but should work. Will not work in JRuby
52
+ running Ruby 1.8.
53
+ * No tests, coming soon!
54
+
55
+
56
+ Contact
57
+ -------
58
+
59
+ Problems or questions contact me at [github](http://github.com/banister)
60
+
61
+
62
+ License
63
+ -------
64
+
65
+ (The MIT License)
66
+
67
+ Copyright (c) 2011 John Mair (banisterfiend)
68
+
69
+ Permission is hereby granted, free of charge, to any person obtaining
70
+ a copy of this software and associated documentation files (the
71
+ 'Software'), to deal in the Software without restriction, including
72
+ without limitation the rights to use, copy, modify, merge, publish,
73
+ distribute, sublicense, and/or sell copies of the Software, and to
74
+ permit persons to whom the Software is furnished to do so, subject to
75
+ the following conditions:
76
+
77
+ The above copyright notice and this permission notice shall be
78
+ included in all copies or substantial portions of the Software.
79
+
80
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
81
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
82
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
83
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
84
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
85
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
86
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,61 @@
1
+ dlext = Config::CONFIG['DLEXT']
2
+ direc = File.dirname(__FILE__)
3
+
4
+ PROJECT_NAME = "method_reload"
5
+
6
+ require 'rake/clean'
7
+ require 'rake/gempackagetask'
8
+ require "#{direc}/lib/#{PROJECT_NAME}/version"
9
+
10
+ CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
11
+ CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
12
+ "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
13
+ "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake")
14
+
15
+ def apply_spec_defaults(s)
16
+ s.name = PROJECT_NAME
17
+ s.summary = "fine grained code reloading"
18
+ s.version = MethodReload::VERSION
19
+ s.date = Time.now.strftime '%Y-%m-%d'
20
+ s.author = "John Mair (banisterfiend)"
21
+ s.email = 'jrmair@gmail.com'
22
+ s.description = s.summary
23
+ s.add_dependency("method_source",">=0.4.1")
24
+ s.require_path = 'lib'
25
+ s.homepage = "http://banisterfiend.wordpress.com"
26
+ s.has_rdoc = 'yard'
27
+ s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb",
28
+ "test/*.rb", "HISTORY", "README.md", "Rakefile"]
29
+ end
30
+
31
+ desc "run tests"
32
+ task :test do
33
+ sh "bacon -k #{direc}/test/test.rb"
34
+ end
35
+
36
+ namespace :ruby do
37
+ spec = Gem::Specification.new do |s|
38
+ apply_spec_defaults(s)
39
+ s.platform = Gem::Platform::RUBY
40
+ end
41
+
42
+ Rake::GemPackageTask.new(spec) do |pkg|
43
+ pkg.need_zip = false
44
+ pkg.need_tar = false
45
+ end
46
+ end
47
+
48
+ desc "build all platform gems at once"
49
+ task :gems => [:clean, :rmgems, "ruby:gem"]
50
+
51
+ desc "remove all platform gems"
52
+ task :rmgems => ["ruby:clobber_package"]
53
+
54
+ desc "build and push latest gems"
55
+ task :pushgems => :gems do
56
+ chdir("#{direc}/pkg") do
57
+ Dir["*.gem"].each do |gemfile|
58
+ sh "gem push #{gemfile}"
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,26 @@
1
+ direc = File.expand_path(File.dirname(__FILE__))
2
+
3
+ require "method_source"
4
+ require "#{direc}/method_reload/version"
5
+
6
+ module MethodReload
7
+ module MethodExtensions
8
+
9
+ # Reload the code for the method from disk.
10
+ # @example method
11
+ # method(:hello).reload
12
+ # @example instance method
13
+ # instance_method(:goodbye)
14
+ def reload
15
+ owner.module_eval source, *source_location
16
+ end
17
+ end
18
+ end
19
+
20
+ class Method
21
+ include MethodReload::MethodExtensions
22
+ end
23
+
24
+ class UnboundMethod
25
+ include MethodReload::MethodExtensions
26
+ end
@@ -0,0 +1,3 @@
1
+ module MethodReload
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1 @@
1
+ def method_test; :method_test; end
@@ -0,0 +1,12 @@
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/method_reload"
5
+ require 'bacon'
6
+
7
+ puts "Testing method_reload version #{MethodReload::VERSION}..."
8
+ puts "Ruby version: #{RUBY_VERSION}"
9
+
10
+ describe MethodReload do
11
+ end
12
+
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: method_reload
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - John Mair (banisterfiend)
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-11 00:00:00 +12:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: method_source
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 0
32
+ - 4
33
+ - 1
34
+ version: 0.4.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: fine grained code reloading
38
+ email: jrmair@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - lib/method_reload/version.rb
47
+ - lib/method_reload.rb
48
+ - test/test.rb
49
+ - test/method_test_helper.rb
50
+ - HISTORY
51
+ - README.md
52
+ - Rakefile
53
+ has_rdoc: yard
54
+ homepage: http://banisterfiend.wordpress.com
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.3.7
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: fine grained code reloading
87
+ test_files: []
88
+