autoreload 1.0.0 → 1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d195b06220f6ebf62098971a806660fedf14608
4
+ data.tar.gz: 23585273514dc91e35cd8755f6e0ce65bdb5bbdd
5
+ SHA512:
6
+ metadata.gz: 4e9f3c074a1f8d160d05a24e497bd015432ba1ae9d85c8c02d04c1f5c6ebbcd4fa906f96e2dc07c79e11b4707863432d54b845f7c029bdaed02d9069932c84bc
7
+ data.tar.gz: 4b49181378e9e939019d6295cfd20696c78609dc953911b1e6fadc35aaff8de4eb33552fae7b081b947d5f23bf9447cec24bebdf1329f4d329d1885f049af23d
data/.index ADDED
@@ -0,0 +1,53 @@
1
+ ---
2
+ revision: 2013
3
+ type: ruby
4
+ sources:
5
+ - Indexfile
6
+ - Gemfile
7
+ authors:
8
+ - name: Thomas Sawyer
9
+ email: transfire@gmail.com
10
+ - name: Kouichirou Eto
11
+ organizations: []
12
+ requirements:
13
+ - groups:
14
+ - development
15
+ version: '>= 0'
16
+ name: rake
17
+ - groups:
18
+ - test
19
+ version: '>= 0'
20
+ name: minitest
21
+ conflicts: []
22
+ alternatives: []
23
+ resources:
24
+ - type: home
25
+ uri: http://rubyworks.github.com/autoreload
26
+ label: Homepage
27
+ - type: code
28
+ uri: http://github.com/rubyworks/autoreload
29
+ label: Source Code
30
+ - type: gems
31
+ uri: http://rubygems.org/gems/autoreload
32
+ repositories: []
33
+ categories: []
34
+ copyrights:
35
+ - holder: Thomas Sawyer
36
+ year: '2010'
37
+ license: BSD-2-Clause
38
+ - holder: Kouichiro Eto
39
+ year: '2003'
40
+ license: RUBY
41
+ customs: []
42
+ paths:
43
+ lib:
44
+ - lib
45
+ version: 1.1.0
46
+ name: autoreload
47
+ title: AutoReload
48
+ summary: Automatically reload library files
49
+ description: Autoreload automatically reloads library files when they have been updated.
50
+ It is especially useful when testing stateless services such as web applications.
51
+ created: '2007-07-01'
52
+ webcvs: https://github.com/rubyworks/autoreload/tree/master
53
+ date: '2014-11-08'
data/.yardopts CHANGED
@@ -1,5 +1,9 @@
1
+ --title AutoReload
2
+ --readme README.rdoc
3
+ --plugin tomdoc
1
4
  --private
2
5
  --protected
3
6
  lib/
4
7
  -
5
8
  [A-Z]*.*
9
+
@@ -1,6 +1,17 @@
1
- = RELEASE HISTORY
1
+ # RELEASE HISTORY
2
2
 
3
- == 1.0.0 (2011-07-15)
3
+ ## 1.1.0
4
+
5
+ This release is simply a maintenance release to bring the build
6
+ configuration up to date.
7
+
8
+ Changes:
9
+
10
+ * Modernize build configuration.
11
+ * Use interpolation on error message.
12
+
13
+
14
+ ## 1.0.0 (2011-07-16)
4
15
 
5
16
  This release overhauls the API. The #autoreload method now
6
17
  takes a block. All libraries required within this block
@@ -27,13 +38,13 @@ Changes:
27
38
  * Fix require of require issue.
28
39
 
29
40
 
30
- == 0.3.1 (2011-05-15)
41
+ ## 0.3.1 (2011-05-15)
31
42
 
32
43
  This release simply fixes licensing issues. Autoreload is licensed
33
44
  under the GPL v3.
34
45
 
35
46
 
36
- == 0.3.0 (2010-10-14)
47
+ ## 0.3.0 (2010-10-14)
37
48
 
38
49
  Changes:
39
50
 
@@ -41,21 +52,21 @@ Changes:
41
52
  * Switch testing framework to RSpec2.
42
53
 
43
54
 
44
- == 0.2.0 (2010-05-10)
55
+ ## 0.2.0 (2010-05-10)
45
56
 
46
57
  Changes:
47
58
 
48
59
  * Completely reworked API.
49
60
 
50
61
 
51
- == 0.1.0 (2010-05-01)
62
+ ## 0.1.0 (2010-05-01)
52
63
 
53
64
  Changes:
54
65
 
55
66
  * Same as original, but now a RubyWorks project.
56
67
 
57
68
 
58
- == 0.0.1 (2007-07-01)
69
+ ## 0.0.1 (2007-07-01)
59
70
 
60
71
  Changes:
61
72
 
@@ -0,0 +1,33 @@
1
+ Autoreload <http://rubyworks.github.com/autoreload>
2
+
3
+ Copyright (c) 2010 Rubyworks.
4
+ Copyright (c) 2003 Kouichirou Eto.
5
+
6
+ All rights reserved.
7
+
8
+ License (spdx) [BSD-2-Clause](http://spdx.org/licenses/bsd-2-clause)
9
+
10
+ Redistribution and use in source and binary forms, with or without modification, are
11
+ permitted provided that the following conditions are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright notice, this list of
14
+ conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
17
+ of conditions and the following disclaimer in the documentation and/or other materials
18
+ provided with the distribution.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY Thomas Sawyer ``AS IS'' AND ANY EXPRESS OR IMPLIED
21
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Thomas Sawyer OR
23
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ The views and conclusions contained in the software and documentation are those of the
31
+ authors and should not be interpreted as representing official policies, either expressed
32
+ or implied, of Thomas Sawyer.
33
+
@@ -0,0 +1,67 @@
1
+ # AutoReload
2
+
3
+ [Homepage](http://rubyworks.github.com/autoreload) |
4
+ [Development](http://github.com/rubyworks/autoreload) |
5
+ [Mailing List](http://groups.google.com/group/rubyworks-mailinglist)
6
+
7
+ [![Build Status](https://secure.travis-ci.org/rubyworks/autoreload.png)](http://travis-ci.org/rubyworks/autoreload)
8
+
9
+
10
+ ## Description
11
+
12
+ Autoreload automatically reloads library files after they
13
+ have been updated. It is especially useful when testing
14
+ stateless services such as web applications.
15
+
16
+ IMPORTANT! Version 1.0+ has a new API. It also works best
17
+ under Ruby 1.9 or above. Under Ruby 1.8 or older files are
18
+ reloaded regardless of whether they actually have changed
19
+ since the last load. Whereas in Ruby 1.9+, they only reload
20
+ if the mtime on the file is newer than the previous time.
21
+
22
+
23
+ ## Synopsis
24
+
25
+ Say we have a library <tt>foo.rb</tt> in our load path:
26
+
27
+ def foo
28
+ 1
29
+ end
30
+
31
+
32
+ We can then run the following script, <tt>example.rb</tt>:
33
+
34
+ require 'autoreload'
35
+
36
+ autoreload(:interval=>2, :verbose=>true) do
37
+ require 'foo.rb'
38
+ end
39
+
40
+ loop {
41
+ puts foo
42
+ sleep 2
43
+ }
44
+
45
+ While that's running we can change `foo.rb` and the change will
46
+ take effect in `example.rb` within two seconds of being made.
47
+
48
+ Note that autoreload only works with _required_ files. It cannot
49
+ monitor files that are brought in with `#load`. This is because
50
+ `$LOADED_FEATURES` is used to track which files are monitored.
51
+
52
+
53
+ ## Acknowledgements
54
+
55
+ The current version of Autoreload is a derviative of Kouichirou Eto's original
56
+ work which can still be found at http://autoreload.rubyforge.org.
57
+
58
+
59
+ ## License & Copyrights
60
+
61
+ Autoreload is released as free software under the BSD-2-Clause license.
62
+
63
+ * Copyright 2010 Rubyworks
64
+ * Copyright 2003 Kouichirou Eto
65
+
66
+ See LICENSE.md for details.
67
+
@@ -2,6 +2,14 @@ require 'autoreload/version'
2
2
  require 'autoreload/reloader'
3
3
 
4
4
  # Reload features automatically at given intervals.
5
+ #
6
+ # options - The Hash options used to refine the reloader (default: {}):
7
+ # :interval - Seconds between updates.
8
+ # :verbose - True provides reload warning.
9
+ # :reprime - Include $0 in reload list.
10
+ #
11
+ # Returns Thread that's taking care of reload loop.
5
12
  def autoreload(options={}, &block)
6
13
  AutoReload::Reloader.start(options, &block)
7
14
  end
15
+
@@ -7,26 +7,25 @@ module AutoReload
7
7
  #
8
8
  class Reloader
9
9
 
10
- # Shortcut for Reloader.new(*args).start.
10
+ # Public: Shortcut for Reloader.new(*args).start.
11
11
  def self.start(*args, &block)
12
12
  self.new(*args, &block).start
13
13
  end
14
14
 
15
- # Default interval is one second.
15
+ # Public: Default interval is one second.
16
16
  DEFAULT_INTERVAL = 1
17
17
 
18
18
  # New Reloader.
19
19
  #
20
- # === Options
21
- #
22
- # :interval - seconds between updates
23
- # :verbose - true provides reload warning
24
- # :reprime - include $0 in reload list
20
+ # options - The Hash options used to refine the reloader (default: {}):
21
+ # :interval - Seconds between updates.
22
+ # :verbose - True provides reload warning.
23
+ # :reprime - Include $0 in reload list.
25
24
  #
26
25
  def initialize(options={}, &block)
27
- @interval = options[:interval] || DEFAULT_INTERVAL
28
- @verbose = options[:verbose]
29
- @reprime = options[:reprime]
26
+ @interval = (options[:interval] || DEFAULT_INTERVAL).to_i
27
+ @verbose = (options[:verbose])
28
+ @reprime = (options[:reprime])
30
29
 
31
30
  @status = {}
32
31
 
@@ -39,7 +38,7 @@ module AutoReload
39
38
  end
40
39
  end
41
40
 
42
- # Start the reload thread.
41
+ # Public: Start the reload thread.
43
42
  def start
44
43
  update # prime the path loads
45
44
  @thread = Thread.new do
@@ -47,47 +46,51 @@ module AutoReload
47
46
  begin
48
47
  update
49
48
  rescue Exception
50
- warn 'autoreload failed unexpectedly: ' + $!
49
+ warn "autoreload failed unexpectedly: #{$!}"
51
50
  end
52
51
  sleep @interval
53
52
  end
54
53
  end
55
54
  @thread.abort_on_exception = true
55
+ @thread
56
56
  end
57
57
 
58
- # Kills the autoreload thread.
58
+ # Public: Kills the autoreload thread.
59
59
  def stop
60
60
  @thread.kill if @thread
61
61
  end
62
62
 
63
- #
63
+ # Public: References the reload thread.
64
64
  attr :thread
65
65
 
66
- # List of files provided to autoreload.
66
+ # Public: List of files provided to autoreload.
67
67
  attr :files
68
68
 
69
- # Status hash, used to track reloads.
69
+ # Public: Status hash, used to track reloads.
70
70
  attr :status
71
71
 
72
- # The periodic interval of reload.
72
+ # Public: The periodic interval of reload in seconds.
73
73
  attr :interval
74
74
 
75
- # Provide warning on reload.
75
+ # Public: Provide warning on reload.
76
+ #
77
+ # Returns true/false if versboe mode.
76
78
  def verbose?
77
79
  @verbose || $VERBOSE
78
80
  end
79
81
 
80
- # Put $0 in the reload list?
82
+ # Public: Put $0 in the reload list?
83
+ #
84
+ # Returns true/false whether to include $0.
81
85
  def reprime?
82
86
  @reprime
83
87
  end
84
88
 
85
89
  private
86
90
 
91
+ # TODO: Why include $0 in #libraries ?
92
+
87
93
  # The library files to autoreload.
88
- #--
89
- # ISSUE: Why include $0 ?
90
- #--
91
94
  def libraries
92
95
  if @files.empty?
93
96
  @reprime ? [$0] + $" : $"
@@ -101,20 +104,23 @@ module AutoReload
101
104
  libraries.each{ |lib| check(lib) }
102
105
  end
103
106
 
107
+ # Check status and reload if out-of-date.
108
+ #
104
109
  # We can't check mtime under 1.8 b/c $LOADED_FEATURES does not
105
110
  # store the full path.
106
- if RUBY_VERSION < '1.9'
107
- def check(lib)
111
+ #
112
+ # lib - A library file.
113
+ #
114
+ # Returns Array of [file, mtime].
115
+ def check(lib)
116
+ if RUBY_VERSION < '1.9'
108
117
  warn "reload: '#{lib}'" if verbose?
109
118
  begin
110
119
  load lib
111
120
  rescue LoadError
112
121
  # file has been removed
113
122
  end
114
- end
115
- else
116
- # Check status and reload if out-of-date.
117
- def check(lib)
123
+ else
118
124
  file, mtime = @status[lib]
119
125
  if file
120
126
  if FileTest.exist?(file)
@@ -134,6 +140,10 @@ module AutoReload
134
140
  end
135
141
 
136
142
  # Get library file status.
143
+ #
144
+ # file - The file path from which to get status.
145
+ #
146
+ # Returns Array of [file, mtime] or [nil, nil] if file not found.
137
147
  def get_status(file)
138
148
  if FileTest.exist?(file)
139
149
  [file, File.mtime(file).to_i]
@@ -149,4 +159,4 @@ module AutoReload
149
159
 
150
160
  end
151
161
 
152
- # Copyright (C) 2010 Thomas Sawyer (BSD-2-Clause)
162
+ # Copyright (C) 2010 Rubyworks (BSD-2-Clause)
@@ -1,3 +1,4 @@
1
1
  module AutoReload
2
- VERSION = '1.0.0'
2
+ # Public: Current release version.
3
+ VERSION = '1.1.0'
3
4
  end
@@ -1,5 +1,6 @@
1
- # Change this file during 'sample1.rb' is running.
1
+ # Change this file while `tryme.rb' is running.
2
2
 
3
3
  def message
4
4
  "Change Me!"
5
5
  end
6
+
@@ -1,6 +1,4 @@
1
- # sample1.rb
2
-
3
- # Run this script and change 'foo.rb' while this script is running.
1
+ puts "Edit 'changme.rb' while this script is still running."
4
2
 
5
3
  __dir__ = File.dirname(__FILE__)
6
4
 
@@ -10,7 +8,7 @@ library = './' + __dir__ + '/changeme.rb'
10
8
 
11
9
  require 'autoreload'
12
10
 
13
- autoreload(:interval=>1, :verbose=>true)
11
+ autoreload(:interval=>1, :verbose=>true) do
14
12
  require library
15
13
  end
16
14
 
metadata CHANGED
@@ -1,136 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: autoreload
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Thomas Sawyer
14
8
  - Kouichirou Eto
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2011-07-16 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: detroit
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
12
+ date: 2014-11-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
33
21
  type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: minitest
37
22
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: minitest
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
47
35
  type: :development
48
- version_requirements: *id002
49
- description: Autoreload automatically reloads library files when they have been updated. It is especially useful when testing stateless services such as web applications.
50
- email:
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: Autoreload automatically reloads library files when they have been updated.
43
+ It is especially useful when testing stateless services such as web applications.
44
+ email:
51
45
  - transfire@gmail.com
52
46
  executables: []
53
-
54
47
  extensions: []
55
-
56
- extra_rdoc_files:
57
- - HISTORY.rdoc
58
- - README.rdoc
59
- - COPYING.rdoc
60
- files:
61
- - .gitignore
62
- - .ruby
48
+ extra_rdoc_files:
49
+ - LICENSE.md
50
+ - README.md
51
+ - HISTORY.md
52
+ files:
53
+ - .index
63
54
  - .yardopts
64
- - Assembly
65
- - COPYING.rdoc
66
- - HISTORY.rdoc
67
- - MANIFEST
68
- - PROFILE
69
- - README.rdoc
70
- - Rakefile
71
- - VERSION
72
- - autoreload.gemspec
73
- - lib/autoreload.rb
74
55
  - lib/autoreload/reloader.rb
75
56
  - lib/autoreload/version.rb
76
- - site/assets/icon.png
77
- - site/assets/screen.css
78
- - site/index.html
79
- - site/index.page
80
- - site/template.layout
57
+ - lib/autoreload.rb
81
58
  - spec/autoreload_spec.rb
82
59
  - spec/helper.rb
83
60
  - spec/require_spec.rb
84
61
  - try/changeme.rb
85
- - try/start.rb
86
- - work/autoreload.rb
87
- - work/consider/autoreload.rb
88
- - work/deprecated/Changes.txt
89
- - work/deprecated/Rakefile
90
- - work/deprecated/default_task.rb
91
- - work/deprecated/lookup.rb
92
- - work/deprecated/meta/authors
93
- - work/deprecated/meta/description
94
- - work/deprecated/meta/name
95
- - work/deprecated/meta/summary
96
- - work/deprecated/meta/version
97
- - work/deprecated/scripts/lib-txt2html.rb
98
- - work/deprecated/scripts/makemanifest.rb
99
- - work/deprecated/scripts/txt2html
100
- - work/deprecated/setup.rb
62
+ - try/tryme.rb
63
+ - LICENSE.md
64
+ - HISTORY.md
65
+ - README.md
101
66
  homepage: http://rubyworks.github.com/autoreload
102
- licenses: []
103
-
67
+ licenses:
68
+ - BSD-2-Clause
69
+ - RUBY
70
+ metadata: {}
104
71
  post_install_message:
105
72
  rdoc_options: []
106
-
107
- require_paths:
73
+ require_paths:
108
74
  - lib
109
- required_ruby_version: !ruby/object:Gem::Requirement
110
- none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
125
- - 0
126
- version: "0"
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
127
85
  requirements: []
128
-
129
86
  rubyforge_project:
130
- rubygems_version: 1.8.2
87
+ rubygems_version: 2.0.3
131
88
  signing_key:
132
- specification_version: 3
89
+ specification_version: 4
133
90
  summary: Automatically reload library files
134
- test_files:
135
- - spec/require_spec.rb
91
+ test_files:
136
92
  - spec/autoreload_spec.rb
93
+ - spec/helper.rb
94
+ - spec/require_spec.rb
95
+ has_rdoc: