require_reloader 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,7 +8,7 @@ during Rails development.
8
8
  Currently, it supports Rails 3+ and above, including 3.1 and 3.2.
9
9
 
10
10
  It uses `ActionDispatch::Callbacks.to_prepare` to reload the
11
- `require` files before each request. In Rails 3.2, it uses
11
+ `require` files before each request. In Rails 3.2, it uses
12
12
  `watchable_dirs` to reload only when you modify a file. More details in [this blog post](http://teohm.github.com/blog/2013/01/10/reload-required-files-in-rails/).
13
13
 
14
14
  ## Usage
@@ -19,7 +19,7 @@ Given a `Gemfile`
19
19
  gem 'my_gem', :path => '~/work/my_gem'
20
20
  gem 'my_gem2', :path => '~/fun/my_gem2'
21
21
 
22
- To reload all **local gems** (the ones with `:path` attribute,
22
+ To reload all **local gems** (the ones with `:path` attribute,
23
23
  or using [local git repo](http://gembundler.com/v1.2/git.html#local)):
24
24
 
25
25
  # config/environments/development.rb
@@ -29,7 +29,7 @@ or using [local git repo](http://gembundler.com/v1.2/git.html#local)):
29
29
  end
30
30
 
31
31
  To reload a specific local gem:
32
-
32
+
33
33
  RequireReloader.watch :my_gem
34
34
 
35
35
  You can also **reload a `.rb` file in `lib`** or any directory:
@@ -42,6 +42,9 @@ The `:path` option is *optional*. In **Rails 3.2**, `:path` value is added into
42
42
  RequireReloader adds `lib` into `watchable_dirs`. So, specify `:path`
43
43
  only if it is not specified in `Gemfile` and the file is located in other directory.
44
44
 
45
+ RequireReloader.watch :foo, :callback => lambda { |gem| puts "#{gem} got reloaded" }
46
+
47
+ You can supply a Proc with the *optional* `:callback` option. This proc gets called everytime after your gem got reloaded.
45
48
 
46
49
  ## Installation
47
50
 
@@ -66,9 +69,11 @@ And then execute:
66
69
 
67
70
  This gem is forked from Colin Young's [gem_reloader](https://github.com/colinyoung/gem_reloader), based on [a solution by Timothy Cardenas](http://timcardenas.com/automatically-reload-gems-in-rails-327-on-eve), inspired by [a post from Leitch](http://ileitch.github.com/2012/03/24/rails-32-code-reloading-from-lib.html).
68
71
 
72
+ ### Contributors
73
+ - @sven-winkler: trigger callback after gem reloaded (issue #2)
69
74
 
70
75
  ## Changelog
71
-
76
+ - v0.1.6: RequireReloader::watch accepts :callback, runs it after gem reloaded ([pull request](https://github.com/teohm/require_reloader/pull/2) from @sven-winkler).
72
77
  - v0.1.5: properly guess top-level module name based on gem name
73
78
  pattern, only watch git repo if it's local.
74
79
  - v0.1.4: remove 'vendor/gems' from watchable_dirs & autoload_paths, as local gem path is already specified in Gemfile.
@@ -50,6 +50,7 @@ module RequireReloader
50
50
  helper.remove_module_if_defined(gem)
51
51
  $".delete_if {|s| s.include?(gem)}
52
52
  require gem
53
+ opts[:callback].call(gem) if opts[:callback]
53
54
  end
54
55
  end
55
56
  end
@@ -1,3 +1,3 @@
1
1
  module RequireReloader
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_reloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-30 00:00:00.000000000 Z
13
+ date: 2013-03-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project:
70
- rubygems_version: 1.8.23
70
+ rubygems_version: 1.8.25
71
71
  signing_key:
72
72
  specification_version: 3
73
73
  summary: Auto-reload require files or local gems without restarting Rails server.