refrescar 0.4.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
+ SHA1:
3
+ metadata.gz: 6211fb34b81e1460d68e94509e732d7465f51131
4
+ data.tar.gz: 28501b90e36ac89cf2382eb480ca5180250d35b5
5
+ SHA512:
6
+ metadata.gz: f2f50e6d5a2c06240e03d28ff05ffff7a7c138779e841eadca3138c994041c6e8d358791b31657bc61f9874bba2735941664bfde751cb270ee092fa6e1caea8e
7
+ data.tar.gz: 51872f2ec34fb19faa143b5aed22ead850120ada5421b9e85ed89bbb77b2671fdbd564bcf3c0f217108f5cac136b81b7b413cb673763b77b95d7ef70f587b3f0
data/CHANGES.md ADDED
@@ -0,0 +1,4 @@
1
+ [HEAD]
2
+ -----
3
+
4
+ * Initial release of extracted code.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 digitalextremist //
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # `Abstractive::Refrescar`
2
+
3
+ Code reloader, implemented using Celluloid and rb-inotify.
4
+
5
+ This [currently](#Future) only runs on `Linux` because it uses `inotify`.
6
+
7
+
8
+ ## Usage
9
+
10
+ To use this gem, you need to initialize it like this:
11
+
12
+ ```
13
+ #de Example here.
14
+ ```
15
+
16
+
17
+ ## Future
18
+
19
+ Will update to detect and support `Mac OS X` ( using `FSEvent` versus `inotify` ) and other *nix operating systems.
@@ -0,0 +1,83 @@
1
+ require 'find'
2
+ require 'rb-inotify'
3
+ require 'abstractive/actor'
4
+
5
+ class Abstractive::Refrescar < Abstractive::Actor
6
+
7
+ def initialize(options={})
8
+ @running = false
9
+ @logger = options[:logger]
10
+ options[:root] ||= Dir.pwd
11
+ @root = Array[options[:root]]
12
+ @debug = options.fetch(:debug, false)
13
+ @announcing = options.fetch(:announcing, true)
14
+ @reschedule = options.fetch(:reschedule, false)
15
+ @after_reload = options.fetch(:after_reload, false)
16
+ @watcher = INotify::Notifier.new
17
+ @events = [
18
+ :close_write,
19
+ #de :modify #de This seems to fire twice in certain cases. Used :close_write instead.
20
+ ]
21
+ start if options.fetch(:autostart, true)
22
+ end
23
+
24
+ def add(root, relative=nil)
25
+ raise "Already running." if @running
26
+ root = File.expand_path(root, relative) if relative
27
+ @root << root
28
+ set_watchers(root)
29
+ end
30
+
31
+ def running?
32
+ @running === true
33
+ end
34
+
35
+ def reloading
36
+ @root.each { |root| set_watchers(root) }
37
+ debug("Started code reloading...") if @debug
38
+ @watcher.run
39
+ rescue => ex
40
+ exception(ex, "Trouble running reloader.")
41
+ raise
42
+ end
43
+
44
+ def start
45
+ async.reloading
46
+ @running = true
47
+ end
48
+
49
+ def set_watchers(path)
50
+ debug("Watching path: #{path}") if @debug
51
+ Find.find( path ) { |file|
52
+ if !File.extname(file) == '.rb' and !File.directory? file
53
+ Find.prune
54
+ else
55
+ begin
56
+ if File.extname(file) == '.rb'
57
+ debug("Will reload: #{file}") if @debug
58
+ @watcher.watch(file, *@events) { reload(file) }
59
+ end
60
+ rescue => ex
61
+ exception(ex, "Code Reloading > Trouble setting watchers.")
62
+ end
63
+ end
64
+ }
65
+ end
66
+
67
+ def reload(file)
68
+ begin
69
+ load(file)
70
+ console("Reloaded: #{file}") if @announcing
71
+ @watcher.watch(file, *@events) { reload file } if @reschedule
72
+ @after_reload.call(file) if @after_reload.is_a? Proc
73
+ rescue SyntaxError => ex
74
+ exception(ex, "Code Reloading > Syntax error in #{file}", console: false)
75
+ rescue LoadError => ex
76
+ exception(ex, "Code Reloading > Missing file: #{file}", console: false)
77
+ end
78
+ rescue => ex
79
+ exception(ex, "Trouble reloading file: #{file}", console: false)
80
+ end
81
+
82
+ end
83
+
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refrescar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - digitalextremist //
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '>='
17
+ - !ruby/object:Gem::Version
18
+ version: 0.17.0
19
+ name: celluloid
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.17.0
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ name: rb-inotify
34
+ prerelease: false
35
+ type: :runtime
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ name: abstractive
48
+ prerelease: false
49
+ type: :runtime
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Code reloader, implemented using Celluloid and rb-inotify.
56
+ email:
57
+ - code@extremist.digital
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGES.md
63
+ - LICENSE.txt
64
+ - README.md
65
+ - lib/abstractive/refrescar.rb
66
+ homepage: https://github.com/abstractive/refrescar
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: 1.9.2
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: 1.3.6
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.8
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Code reloader for Ruby, on Linux.
90
+ test_files: []