react-rails-hot-loader 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8f8205a8fecc4ea01e396791be7634c7ccc10d3
4
- data.tar.gz: 0f4723d12e64e9b90a3d661fb4790aad53541353
3
+ metadata.gz: 2ccd666621d038150005b210e1780351a32c3869
4
+ data.tar.gz: 3b162749ab5c6fc4dddf9c9afec34f9cb0588b83
5
5
  SHA512:
6
- metadata.gz: ca06352fe32da0f8bb4bd276768a30840d1fc0639f3041262063a7edfd35cf09d91dc2769808643205ec853e43cb926743537fecb45ddf2df444619866eb8cc7
7
- data.tar.gz: 9e163bd9b45976a684f438a8674c303602f6cbffae2140b7729560cdaa1d88fbed9d3f7c176fa386c6c1a43e6b10f9a77bc13f37d61e1a1ae19d4dca8fa2bd14
6
+ metadata.gz: 7b73516078d8c51f6cb23ee7525e29f5e4adfccd35e23f449884a5b5c1d8bc0de3c6fa3e071f6bdbf82872a469a6e63c6b0d75d40032b1476d994e94e48cb735
7
+ data.tar.gz: 98500e70dfe7c7d137a995cb63ae65ac349a90ccb29d4d34892d49a02b3a201d9a87873e602a4f79fb9797b95df937d23b024d6a7b710ac15971530f34577535
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /test/dummy/Gemfile.lock
data/README.md CHANGED
@@ -27,7 +27,7 @@ Or install it yourself as:
27
27
  - Add an initializer:
28
28
 
29
29
  ```ruby
30
- # app/config/initializers/react_rails_hot_loader.rb
30
+ # config/initializers/react_rails_hot_loader.rb
31
31
  if Rails.env.development?
32
32
  React::Rails::HotLoader.start()
33
33
  end
@@ -51,7 +51,7 @@ Or install it yourself as:
51
51
  If you notice that your assets are not being recompiled and hot loaded, it could be because they aren't being matched by the default asset glob used (`**/*.{js,coffee}*`). You can modify this asset glob like so:
52
52
 
53
53
  ```ruby
54
- # app/config/initializers/react_rails_hot_loader.rb
54
+ # config/initializers/react_rails_hot_loader.rb
55
55
  React::Rails::HotLoader::AssetChangeSet.asset_glob = "**/*.{js,rb}*" # I <3 Opal
56
56
  ```
57
57
 
@@ -62,7 +62,6 @@ React::Rails::HotLoader::AssetChangeSet.asset_glob = "**/*.{js,rb}*" # I <3 Opal
62
62
  - __does__ set up a WebSocket server & client
63
63
  - __does__ reload JS assets when they change (from `/app/assets/javascripts/*.{js,coffee}*`)
64
64
  - __does__ remount components (via `ReactRailsUJS`) after reloading assets
65
- - __does__ preserve state & props (because `React.render` does that out of the box)
66
65
  - __doesn't__ reload Rails view files (`html`, `erb`, `slim`, etc)
67
66
  - __doesn't__ reload CSS (although that could be fixed)
68
67
 
@@ -15,8 +15,9 @@ module React
15
15
  @changed_files = Dir.glob(asset_glob).select { |f| File.mtime(f) >= since }
16
16
  @changed_file_names = changed_files.map { |f| f.split("/").last }
17
17
  @changed_asset_contents = changed_files.map do |f|
18
- logical_path = f.sub(path.to_s, "").sub(/^\//, '')
19
- ::Rails.application.assets[logical_path].to_s
18
+ logical_path = to_logical_path(f)
19
+ asset = ::Rails.application.assets[logical_path]
20
+ asset.to_s
20
21
  end
21
22
  end
22
23
 
@@ -32,6 +33,15 @@ module React
32
33
  changed_asset_contents: changed_asset_contents,
33
34
  }
34
35
  end
36
+
37
+ private
38
+
39
+ def to_logical_path(asset_path)
40
+ asset_path
41
+ .sub(@path, "") # remove the basepath
42
+ .sub(/^\//, '') # remove any leading /
43
+ .sub(/\.js.*/, '.js') # replace any file extension with `.js`
44
+ end
35
45
  end
36
46
  end
37
47
  end
@@ -1,7 +1,7 @@
1
1
  module React
2
2
  module Rails
3
3
  module HotLoader
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,4 @@
1
+ require 'react-rails'
1
2
  require 'hot_loader'
2
3
  require 'hot_loader/asset_change_set'
3
4
  require 'hot_loader/asset_path'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react-rails-hot-loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-07 00:00:00.000000000 Z
11
+ date: 2016-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-websocket