require_reloader 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f99ac277b896b3dc347c2be0195edb4d9d9dfa7
4
+ data.tar.gz: 0c43c9c7187d3b857fc9a37c49f69d8f9e73ab58
5
+ SHA512:
6
+ metadata.gz: d7643d31465ca0f496aa6cd0c9544092462207e448c632a76f0301377c71c8a9c2bd94269de3e973778bd2e33f636912edbc2cdb5442c20dc1faf7f812ab0ae5
7
+ data.tar.gz: d90c175222c87e55d9102727cee57dd7d112e68fc020f77276521871caf45365c2c652a5c7a31f6fe280ae36142e1588de9d0226a29e43faebff67af666e389c
data/README.md CHANGED
@@ -17,7 +17,7 @@ Given a `Gemfile`
17
17
 
18
18
  # Gemfile
19
19
  gem 'my_gem', :path => '~/work/my_gem'
20
- gem 'my_gem2', :path => '~/fun/my_gem2'
20
+ gem 'my_gem2', :path => '~/fun/my_gem2', :module_name => 'MYGEM2'
21
21
 
22
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)):
@@ -39,6 +39,10 @@ You can also **reload a `.rb` file in `lib`** or any directory:
39
39
 
40
40
  The `:path` option is *optional*. In **Rails 3.2**, `:path` value is added into `watchable_dirs`. Rails 3.1 and 3.0 ignore this value.
41
41
 
42
+ The `:module_name` option is *optional*. By default, it is assumed that the top-level module is a CamelCase version of the gem name.
43
+ If this is not the case, you can pass this option, a String. This value will also be picked up if included in the metadata of the gemspec,
44
+ as in `spec.metadata = {'module_name' => 'MYMOD'}`.
45
+
42
46
  RequireReloader adds `lib` into `watchable_dirs`. So, specify `:path`
43
47
  only if it is not specified in `Gemfile` and the file is located in other directory.
44
48
 
@@ -71,9 +75,11 @@ This gem is forked from Colin Young's [gem_reloader](https://github.com/colinyou
71
75
 
72
76
  ### Contributors
73
77
  - @sven-winkler: trigger callback after gem reloaded (issue #2)
78
+ - @aceofspades: support gem metadata :module_name in Gemfile (issue #4)
74
79
 
75
80
  ## Changelog
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).
81
+ - v0.2.0: Support module_name option/spec-metadata
82
+ - 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).
77
83
  - v0.1.5: properly guess top-level module name based on gem name
78
84
  pattern, only watch git repo if it's local.
79
85
  - v0.1.4: remove 'vendor/gems' from watchable_dirs & autoload_paths, as local gem path is already specified in Gemfile.
@@ -14,9 +14,9 @@ module RequireReloader
14
14
  def watch_local_gems!
15
15
  local_gems.each do |gem|
16
16
  # never reload itself for now, causing error raised in integration test
17
- next if gem[:name] == 'require_reloader'
17
+ next if gem.name == 'require_reloader'
18
18
 
19
- watch gem[:name], :path => gem[:path]
19
+ watch gem.name, :path => gem.source.path.to_s, :module_name => gem.metadata['module_name']
20
20
  end
21
21
  end
22
22
 
@@ -47,7 +47,11 @@ module RequireReloader
47
47
  # based on Tim Cardenas's solution:
48
48
  # http://timcardenas.com/automatically-reload-gems-in-rails-327-on-eve
49
49
  ActionDispatch::Callbacks.to_prepare do
50
- helper.remove_module_if_defined(gem)
50
+ if opts[:module_name]
51
+ helper.remove_module_if_defined(opts[:module_name])
52
+ else
53
+ helper.remove_gem_module_if_defined(gem)
54
+ end
51
55
  $".delete_if {|s| s.include?(gem)}
52
56
  require gem
53
57
  opts[:callback].call(gem) if opts[:callback]
@@ -59,16 +63,15 @@ module RequireReloader
59
63
 
60
64
  def expanded_gem_path(gem, preferred_path)
61
65
  return File.expand_path(preferred_path) if preferred_path
62
- local_gem = local_gems.find {|g| g[:name] == gem}
63
- local_gem ? File.expand_path(local_gem[:path]) : false
66
+ local_gem = local_gems.find {|g| g.name == gem}
67
+ local_gem ? File.expand_path(local_gem.source.path.to_s) : false
64
68
  end
65
69
 
66
70
  # returns only local gems, local git repo
67
71
  def local_gems
68
72
  Bundler.definition.specs.
69
73
  select{|s| s.source.is_a?(Bundler::Source::Path) }.
70
- delete_if{|s| s.source.is_a?(Bundler::Source::Git) && !s.source.send(:local?) }.
71
- map{|s| {:name => s.name, :path => s.source.path.to_s} }
74
+ delete_if{|s| s.source.is_a?(Bundler::Source::Git) && !s.source.send(:local?) }
72
75
  end
73
76
  end
74
77
  end
@@ -50,9 +50,13 @@ module RequireReloader
50
50
  class Helper
51
51
  include ActionPackInfectorMethods
52
52
 
53
- def remove_module_if_defined(gem_name)
54
- full_name = full_qualified_name(gem_name)
55
- remove_module(full_name) if module_defined?(full_name)
53
+ def remove_gem_module_if_defined(gem_name)
54
+ mod_name = full_qualified_name(gem_name)
55
+ remove_module_if_defined(mod_name)
56
+ end
57
+
58
+ def remove_module_if_defined(mod_name)
59
+ remove_module(mod_name) if module_defined?(mod_name)
56
60
  end
57
61
 
58
62
  def module_defined?(full_name)
@@ -1,3 +1,3 @@
1
1
  module RequireReloader
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_reloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Colin Young
@@ -10,22 +9,20 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-03-04 00:00:00.000000000 Z
12
+ date: 2014-01-15 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: minitest
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  description: Auto-reload require files or local gems without restarting server during
@@ -49,26 +46,26 @@ files:
49
46
  - require_reloader.gemspec
50
47
  homepage: https://github.com/teohm/require_reloader
51
48
  licenses: []
49
+ metadata: {}
52
50
  post_install_message:
53
51
  rdoc_options: []
54
52
  require_paths:
55
53
  - lib
56
54
  required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
55
  requirements:
59
- - - ! '>='
56
+ - - '>='
60
57
  - !ruby/object:Gem::Version
61
58
  version: '0'
62
59
  required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
60
  requirements:
65
- - - ! '>='
61
+ - - '>='
66
62
  - !ruby/object:Gem::Version
67
63
  version: '0'
68
64
  requirements: []
69
65
  rubyforge_project:
70
- rubygems_version: 1.8.25
66
+ rubygems_version: 2.2.0
71
67
  signing_key:
72
- specification_version: 3
68
+ specification_version: 4
73
69
  summary: Auto-reload require files or local gems without restarting Rails server.
74
70
  test_files: []
71
+ has_rdoc: