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.
@@ -1,80 +0,0 @@
1
- layout: template
2
-
3
- --- markdown
4
-
5
- # you don't have to restart your program
6
-
7
-
8
- ## What Is It?
9
-
10
- Autoreload reloads libraries automatically at regular intervals
11
- when files are updated.
12
-
13
-
14
- ## Installing
15
-
16
- <pre syntax="ruby">$ gem install autoreload</pre>
17
-
18
-
19
- ## The Basics
20
-
21
- --- html
22
-
23
- <pre class="ruby">
24
- # foo.rb
25
- def foo
26
- 1
27
- end
28
- </pre>
29
-
30
- <pre class="ruby">
31
- # sample1.rb
32
- require 'autoreload'
33
-
34
- autoreload(:interval=>1, :verbose=>true) do
35
- require 'foo'
36
- end
37
-
38
- loop {
39
- puts foo
40
- sleep 1
41
- }
42
- </pre>
43
-
44
- --- markdown
45
-
46
- In this situation, run the script `sample1.rb`. You see that the
47
- number 1 is shown repeatedly. Then, while that is still running,
48
- update the file `foo.rb`. For example, change the number 1 to 2
49
- and save it. Then, the library automatically check the update
50
- and reload it. You'll see the number 2 is shown.
51
-
52
-
53
- ## Documentation
54
-
55
- * [RubyDoc.info](http://rubydoc.info/gems/autoreload/frames)
56
-
57
-
58
- ## Repository
59
-
60
- This project is hosted on [GitHub.com](http://rubyworks.github.com/autoreload).
61
-
62
- The repository is <code>git://github.com/rubyworks/autoreload.git</code>
63
- for anonymous access.
64
-
65
-
66
- ## Copying
67
-
68
- (FreeBSD License)
69
-
70
- Copyright (c) 2010 Thomas Sawyer
71
-
72
- Copyright (c) 2003 Kouichirou Eto
73
-
74
-
75
- ## Contact
76
-
77
- Comments are welcome. Send an email to Trans "transfire _at_ gmail _dot_ org".
78
-
79
- Autoreload is a [RubyWorks](http://rubyworks.github.com) project.
80
-
@@ -1,77 +0,0 @@
1
- ---
2
- stencil: erb
3
-
4
- --- html
5
- <%
6
- require 'pom'
7
- project = POM::Project.new('..')
8
- version = project.version
9
- title = project.metadata.title
10
- download = project.metadata.resources.gem
11
- %>
12
-
13
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
14
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
15
- <head>
16
- <link rel="icon" type="image/png" href="assets/icon.png" />
17
- <link rel="stylesheet" href="assets/screen.css" type="text/css" media="screen" />
18
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19
- <title><%= title %></title>
20
- <style>
21
- #rubyworks{ position: fixed; bottom: 0; right: 3px; padding: 0; opacity: 0.2; }
22
- </style>
23
- <script type="text/javascript">
24
- window.onload = function() {
25
- settings = {
26
- tl: { radius: 10 },
27
- tr: { radius: 10 },
28
- bl: { radius: 10 },
29
- br: { radius: 10 },
30
- antiAlias: true,
31
- autoPad: true,
32
- validTags: ["div"]
33
- }
34
- var versionBox = new curvyCorners(settings, document.getElementById("version"));
35
- versionBox.applyCornersToAll();
36
- }
37
- </script>
38
- </head>
39
- <body>
40
-
41
- <div id="main">
42
- <h1 class="title"><%= title %></h1>
43
- <div id="version" class="clickable" onclick='document.location = "<%= download %>"; return false'>
44
- <p>Get Version</p>
45
- <a href="<%= download %>" class="numbers"><%= version %></a>
46
- </div>
47
- <%= yield %>
48
- <p class="coda">
49
- <a href="mailto:transfire@gmail.com">Trans</a>, <%= Time.now.strftime("%Y-%m-%d") %><br>
50
- Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
51
- </p>
52
- </div>
53
-
54
- <div style="margin: 40px auto; width: 730px;">
55
- <script type="text/javascript"><!--
56
- google_ad_client = "ca-pub-1126154564663472";
57
- /* RUBYWORKS 09-10-02 728x90 */
58
- google_ad_slot = "0788888658";
59
- google_ad_width = 728;
60
- google_ad_height = 90;
61
- //-->
62
- </script>
63
- <script type="text/javascript"
64
- src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
65
- </script>
66
- </div>
67
-
68
- <!-- insert site tracking codes here, like Google Urchin -->
69
-
70
- <div id="rubyworks">
71
- <a href="http://rubyworks.github.com">
72
- <img src="http://rubyworks.github.com/assets/images/seal.png" height="175px" />
73
- </a>
74
- </div>
75
-
76
- </body>
77
- </html>
@@ -1,115 +0,0 @@
1
- module Kernel
2
-
3
- # Autoreload feature files.
4
- #
5
- # Automatically reload, at regular intervals, any previously loaded features,
6
- # and/or other files not already loaded, if they have been modified since the last
7
- # interval check. A numeric parameter sets the reload interval in seconds
8
- # and the file parameter can either be a glob string or an array
9
- # of file paths. If a glob string, it is expanded only once on the initial
10
- # method call. Supplying a boolean parameter of 'false' will force autreload to
11
- # skip previously loaded features and only reload the specified files.
12
- # Also keeps a "dirty" flag.
13
- #
14
- # Copyright (c) 2003 Michael Neumann
15
-
16
- def autoreload( *args )
17
-
18
- check_interval=10
19
- include_features = true
20
- files = nil
21
-
22
- args.each do |arg|
23
- case arg
24
- when Numeric
25
- check_interval = arg
26
- when String
27
- files = Dir.glob( arg )
28
- when Array
29
- files = arg
30
- when TrueClass, FalseClass
31
- include_features = arg
32
- end
33
- end
34
-
35
- file_mtime = {}
36
-
37
- Thread.new(Time.now) do |start_time|
38
- loop do
39
- sleep check_interval
40
-
41
- if include_features
42
- feature_files = $LOADED_FEATURES.collect { |feature|
43
- $LOAD_PATH.each { |lp| file = File.join(lp, feature) }
44
- }.flatten
45
-
46
- feature_files.each { |file|
47
- if File.exists?(file) and (mtime = File.stat(file).mtime) > (file_mtime[file] || start_time)
48
- $autoreload_dirty = true
49
- file_mtime[file] = mtime
50
- STDERR.puts "File '#{ file }' reloaded"
51
- begin
52
- load(file)
53
- rescue Exception => e
54
- STDERR.puts e.inspect
55
- end
56
- end
57
- }
58
- end
59
-
60
- if files
61
- files.each do |file|
62
- if File.exists?(file) and (mtime = File.stat(file).mtime) > (file_mtime[file] || start_time)
63
- $autoreload_dirty = true
64
- file_mtime[file] = mtime
65
- STDERR.puts "File '#{ file }' changed"
66
- end
67
- end
68
- end
69
-
70
- end
71
- end
72
-
73
- end
74
-
75
- # Same as #autoreload, but does not include previously loaded features.
76
- # This is equivalent to as adding a 'false' parameter to #autoreload.
77
- #
78
- def autoreload_files(*args)
79
- autoreload(false, *args)
80
- end
81
-
82
- # deprecated
83
- #def autoreload_glob(*args)
84
- # warn "autoreload_glob will be deprecated. Use autoreload_files instead."
85
- # autoreload_files(*args)
86
- #end
87
- end
88
-
89
- #--
90
- # # OLD VERSION
91
- # def autoreload(check_interval=10)
92
- # Thread.new(Time.now) { |start_time|
93
- # file_mtime = {}
94
- # loop {
95
- # sleep check_interval
96
- # $LOADED_FEATURES.each { |feature|
97
- # $LOAD_PATH.each { |lp|
98
- # file = File.join(lp, feature)
99
- # if (File.exists?(file) and
100
- # File.stat(file).mtime > (file_mtime[file] || start_time))
101
- # file_mtime[file] = File.stat(file).mtime
102
- # STDERR.puts "reload #{ file }"
103
- # begin
104
- # load(file)
105
- # rescue Exception => e
106
- # STDERR.puts e.inspect
107
- # end
108
- # end
109
- # }
110
- # }
111
- # }
112
- # }
113
- # end
114
- #++
115
-
@@ -1,115 +0,0 @@
1
- module Kernel
2
-
3
- # Autoreload feature files.
4
- #
5
- # Automatically reload, at regular intervals, any previously loaded features,
6
- # and/or other files not already loaded, if they have been modified since the last
7
- # interval check. A numeric parameter sets the reload interval in seconds
8
- # and the file parameter can either be a glob string or an array
9
- # of file paths. If a glob string, it is expanded only once on the initial
10
- # method call. Supplying a boolean parameter of 'false' will force autreload to
11
- # skip previously loaded features and only reload the specified files.
12
- # Also keeps a "dirty" flag.
13
- #
14
- # Copyright (c) 2003 Michael Neumann
15
-
16
- def autoreload( *args )
17
-
18
- check_interval=10
19
- include_features = true
20
- files = nil
21
-
22
- args.each do |arg|
23
- case arg
24
- when Numeric
25
- check_interval = arg
26
- when String
27
- files = Dir.glob( arg )
28
- when Array
29
- files = arg
30
- when TrueClass, FalseClass
31
- include_features = arg
32
- end
33
- end
34
-
35
- file_mtime = {}
36
-
37
- Thread.new(Time.now) do |start_time|
38
- loop do
39
- sleep check_interval
40
-
41
- if include_features
42
- feature_files = $LOADED_FEATURES.collect { |feature|
43
- $LOAD_PATH.each { |lp| file = File.join(lp, feature) }
44
- }.flatten
45
-
46
- feature_files.each { |file|
47
- if File.exists?(file) and (mtime = File.stat(file).mtime) > (file_mtime[file] || start_time)
48
- $autoreload_dirty = true
49
- file_mtime[file] = mtime
50
- STDERR.puts "File '#{ file }' reloaded"
51
- begin
52
- load(file)
53
- rescue Exception => e
54
- STDERR.puts e.inspect
55
- end
56
- end
57
- }
58
- end
59
-
60
- if files
61
- files.each do |file|
62
- if File.exists?(file) and (mtime = File.stat(file).mtime) > (file_mtime[file] || start_time)
63
- $autoreload_dirty = true
64
- file_mtime[file] = mtime
65
- STDERR.puts "File '#{ file }' changed"
66
- end
67
- end
68
- end
69
-
70
- end
71
- end
72
-
73
- end
74
-
75
- # Same as #autoreload, but does not include previously loaded features.
76
- # This is equivalent to as adding a 'false' parameter to #autoreload.
77
- #
78
- def autoreload_files(*args)
79
- autoreload(false, *args)
80
- end
81
-
82
- # deprecated
83
- #def autoreload_glob(*args)
84
- # warn "autoreload_glob will be deprecated. Use autoreload_files instead."
85
- # autoreload_files(*args)
86
- #end
87
- end
88
-
89
- #--
90
- # # OLD VERSION
91
- # def autoreload(check_interval=10)
92
- # Thread.new(Time.now) { |start_time|
93
- # file_mtime = {}
94
- # loop {
95
- # sleep check_interval
96
- # $LOADED_FEATURES.each { |feature|
97
- # $LOAD_PATH.each { |lp|
98
- # file = File.join(lp, feature)
99
- # if (File.exists?(file) and
100
- # File.stat(file).mtime > (file_mtime[file] || start_time))
101
- # file_mtime[file] = File.stat(file).mtime
102
- # STDERR.puts "reload #{ file }"
103
- # begin
104
- # load(file)
105
- # rescue Exception => e
106
- # STDERR.puts e.inspect
107
- # end
108
- # end
109
- # }
110
- # }
111
- # }
112
- # }
113
- # end
114
- #++
115
-
@@ -1,56 +0,0 @@
1
- == 2007-07-07
2
-
3
- * lib/autoreload.rb: Do not use @thread.
4
-
5
- == 2007-07-06
6
-
7
- * Rakefile: To use Chages.txt
8
-
9
- == 2007-07-05
10
-
11
- * Changes.txt: New file. Moved from ChangeLog.
12
- * ChangeLog: Deleted.
13
-
14
- * bin: Deleted.
15
-
16
- * lib/autoreload.rb: Make it start from class method.
17
-
18
- * lib/autoreload/version.rb: Removed.
19
-
20
- * lib/autoreload.rb: Reformat.
21
-
22
- * examples/sample1.rb: New file.
23
- * examples/foo.rb: New file.
24
-
25
- * default_task.rb: New file. Splited from Rakefile.
26
- * Rakefile: Follow.
27
- * script/lib-txt2html.rb: New file.
28
- * script/makemanifest.rb: New file.
29
-
30
- * License.txt: Update license to Ruby license.
31
-
32
- * test/test_autoreload.rb: Sometimes test is failed.
33
-
34
- * default_task.rb: Check file exist in chmod task.
35
-
36
- * default_task.rb: Specify version and download.
37
- * scripts/lib-txt2html.rb: Remove dependency.
38
- * scripts/txt2html: Follow.
39
-
40
- == 2007-07-04
41
-
42
- * License.txt: created.
43
- * README.txt: created.
44
-
45
- * lib/autoreload/version.rb: Truncated.
46
- * Rakefile: Ditto.
47
-
48
- * lib/autoreload.rb: Created.
49
- * test/test_autoreload.rb: Ditto.
50
-
51
- * lib/autoreload.rb: Refactoring.
52
-
53
- == 2007-07-04
54
-
55
- * Init.
56
-
@@ -1,80 +0,0 @@
1
- require 'fileutils'
2
- include FileUtils
3
- require File.join(File.dirname(__FILE__), 'default_task')
4
- require File.join(File.dirname(__FILE__), 'lib', 'autoreload')
5
-
6
- AUTHOR = 'FIXME full name' # can also be an array of Authors
7
- EMAIL = "FIXME email"
8
- DESCRIPTION = "description of gem"
9
- GEM_NAME = 'autoreload' # what ppl will type to install your gem
10
-
11
- @config_file = "~/.rubyforge/user-config.yml"
12
- @config = nil
13
- def rubyforge_username
14
- unless @config
15
- begin
16
- @config = YAML.load(File.read(File.expand_path(@config_file)))
17
- rescue
18
- puts <<-EOS
19
- ERROR: No rubyforge config file found: #{@config_file}"
20
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
21
- - See http://newgem.rubyforge.org/rubyforge.html for more details
22
- EOS
23
- # "
24
- exit
25
- end
26
- end
27
- @rubyforge_username ||= @config["username"]
28
- end
29
-
30
- RUBYFORGE_PROJECT = 'autoreload' # The unix name for your project
31
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
32
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
33
-
34
- NAME = "autoreload"
35
- REV = nil
36
- # UNCOMMENT IF REQUIRED:
37
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
38
- VERS = AutoReload::VERSION::STRING + (REV ? ".#{REV}" : "")
39
- CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
40
- RDOC_OPTS = ['--quiet', '--title', 'autoreload documentation',
41
- "--opname", "index.html",
42
- "--line-numbers",
43
- "--main", "README",
44
- "--inline-source"]
45
-
46
- # Generate all the Rake tasks
47
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
48
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
49
- p.author = AUTHOR
50
- p.description = DESCRIPTION
51
- p.email = EMAIL
52
- p.summary = DESCRIPTION
53
- p.url = HOMEPATH
54
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
55
- p.test_globs = ["test/**/test_*.rb"]
56
- p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
57
-
58
- # == Optional
59
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
60
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
61
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
62
- end
63
-
64
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
65
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
66
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
67
-
68
- # clear current task
69
- t = Rake.application.lookup(:install_gem)
70
- t.clear_actions if t
71
-
72
- # redefine task
73
- task :install_gem => [:clean, :package] do
74
- if /mswin32/ =~ RUBY_PLATFORM || /cygwin/ =~ RUBY_PLATFORM
75
- sh "gem.cmd install pkg/*.gem" # for Cygwin
76
- else
77
- sh "sudo gem install pkg/*.gem"
78
- end
79
- end
80
-