hot_reloader 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ec0e3c1431bef973f80a63c492edc79bae5eb435fd280d8b0594323d10ff0396
4
+ data.tar.gz: 5496d56ab76af81abbe464317f02c56758a72d297702e47068ebe5375351b35a
5
+ SHA512:
6
+ metadata.gz: a3bd2875289eaf879180477d43b1d924febdcef2dc1caf3aaedda22a43718343cfa2411e425fecd8ac3de4b35d5596d250c55a6b23902f53c6a050b8ee730e30
7
+ data.tar.gz: 7fff7f4d9b5e4e86a9e72dafc73e795215e661785e13e52577aaa69d089d2454a92abb99bcf18f4a04f9fd975a8284fc65aeebf8b69d114d93922f0d45d1a2ae
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019 Billy.Zheng
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # HotReloader [![Build Status](https://travis-ci.org/zw963/hot_reloader.svg?branch=master)](https://travis-ci.org/zw963/hot_reloader) [![Gem Version](https://badge.fury.io/rb/hot_reloader.svg)](http://badge.fury.io/rb/hot_reloader)
2
+
3
+ A dead simple ruby code hot reloader wrap around [zeitwerk](https://github.com/fxn/zeitwerk) and [listen](https://github.com/guard/listen).
4
+
5
+ See README for those gems for usage.
6
+
7
+ ## Getting Started
8
+
9
+ Install via Rubygems
10
+
11
+ $ gem install hot_reloader
12
+
13
+ OR ...
14
+
15
+ Add to your Gemfile
16
+
17
+ gem 'hot_reloader'
18
+
19
+ ## Usage
20
+
21
+ Following is a example for use hot_reloader with [Roda](https://github.com/jeremyevans/roda):
22
+
23
+ ```rb
24
+ # config.ru
25
+
26
+ require 'roda'
27
+ require 'hot_reloader'
28
+
29
+ if ENV['RACK_ENV'] == 'production'
30
+ HotReloader.will_listen(__dir__)
31
+ run ->(env) {
32
+ App.call(env)
33
+ }
34
+ else
35
+ run App
36
+ end
37
+ ```
38
+
39
+ Then create app.rb in ROOT directory.
40
+
41
+ ```rb
42
+ # app.rb
43
+
44
+ class App < Roda
45
+ articles = []
46
+
47
+ route do |r|
48
+ r.post "articles" do
49
+ articles << r.params["content"]
50
+ "Count: #{articles.count}"
51
+ end
52
+ end
53
+ end
54
+ ```
55
+
56
+ Directory structure is like this:
57
+
58
+ ```
59
+ ├── app.rb
60
+ ├── config.ru
61
+ ├── Gemfile
62
+ └── Gemfile.lock
63
+ ```
64
+
65
+ Change code in app.rb, **all constant get removed from memory, and app.rb evaluated again**!
66
+
67
+ ## Support
68
+
69
+ * MRI 2.4.4+
70
+ * JRuby
71
+
72
+ ## Dependency
73
+
74
+ zeitwerk https://github.com/fxn/zeitwerk
75
+ listen https://github.com/guard/listen
76
+
77
+ ## Contributing
78
+
79
+ * [Bug reports](https://github.com/zw963/hot_reloader/issues)
80
+ * [Source](https://github.com/zw963/hot_reloader)
81
+ * Patches:
82
+ * Fork on Github.
83
+ * Run `gem install --dev hot_reloader` or `bundle install`.
84
+ * Create your feature branch: `git checkout -b my-new-feature`.
85
+ * Commit your changes: `git commit -am 'Add some feature'`.
86
+ * Push to the branch: `git push origin my-new-feature`.
87
+ * Send a pull request :D.
88
+
89
+ ## license
90
+
91
+ Released under the MIT license, See [LICENSE](https://github.com/zw963/hot_reloader/blob/master/LICENSE) for details.
@@ -0,0 +1,9 @@
1
+ module HotReloader
2
+ VERSION = [0, 1, 0]
3
+
4
+ class << VERSION
5
+ def to_s
6
+ join('.')
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ require 'zeitwerk'
2
+ require 'listen'
3
+
4
+ module HotReloader
5
+ module_function
6
+
7
+ def will_listen(*directories, logger: method(:puts))
8
+ loader = Zeitwerk::Loader.new
9
+ loader.logger = logger
10
+ directories.each {|directory| loader.push_dir(directory) }
11
+ loader.setup
12
+ Listen.to(*directories) { loader.reload }.start
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hot_reloader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Billy.Zheng(zw963)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: zeitwerk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: listen
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: A dead simple ruby code hot reloader wrap around zeitwerk and listen.
42
+ email:
43
+ - vil963@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE
49
+ - README.md
50
+ - lib/hot_reloader.rb
51
+ - lib/hot_reloader/version.rb
52
+ homepage: http://github.com/zw963/hot_reloader
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.4.4
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubygems_version: 3.0.1
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: A dead simple ruby code hot reloader wrap around zeitwerk and listen.
75
+ test_files: []