autoreload 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.index +53 -0
- data/.yardopts +4 -0
- data/{HISTORY.rdoc → HISTORY.md} +18 -7
- data/LICENSE.md +33 -0
- data/README.md +67 -0
- data/lib/autoreload.rb +8 -0
- data/lib/autoreload/reloader.rb +39 -29
- data/lib/autoreload/version.rb +2 -1
- data/try/changeme.rb +2 -1
- data/try/{start.rb → tryme.rb} +2 -4
- metadata +66 -107
- data/.gitignore +0 -6
- data/.ruby +0 -47
- data/Assembly +0 -40
- data/COPYING.rdoc +0 -379
- data/MANIFEST +0 -14
- data/PROFILE +0 -28
- data/README.rdoc +0 -61
- data/Rakefile +0 -9
- data/VERSION +0 -1
- data/autoreload.gemspec +0 -143
- data/site/assets/icon.png +0 -0
- data/site/assets/screen.css +0 -149
- data/site/index.html +0 -135
- data/site/index.page +0 -80
- data/site/template.layout +0 -77
- data/work/autoreload.rb +0 -115
- data/work/consider/autoreload.rb +0 -115
- data/work/deprecated/Changes.txt +0 -56
- data/work/deprecated/Rakefile +0 -80
- data/work/deprecated/default_task.rb +0 -129
- data/work/deprecated/lookup.rb +0 -174
- data/work/deprecated/meta/authors +0 -2
- data/work/deprecated/meta/description +0 -3
- data/work/deprecated/meta/name +0 -1
- data/work/deprecated/meta/summary +0 -1
- data/work/deprecated/meta/version +0 -1
- data/work/deprecated/scripts/lib-txt2html.rb +0 -133
- data/work/deprecated/scripts/makemanifest.rb +0 -20
- data/work/deprecated/scripts/txt2html +0 -10
- data/work/deprecated/setup.rb +0 -1585
@@ -1,129 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rake/testtask'
|
5
|
-
require 'rake/packagetask'
|
6
|
-
require 'rake/gempackagetask'
|
7
|
-
require 'rake/rdoctask'
|
8
|
-
require 'rake/contrib/rubyforgepublisher'
|
9
|
-
require 'hoe'
|
10
|
-
begin
|
11
|
-
require 'spec/rake/spectask'
|
12
|
-
rescue LoadError
|
13
|
-
puts 'To use rspec for testing you must install rspec gem:'
|
14
|
-
puts '$ sudo gem install rspec'
|
15
|
-
exit
|
16
|
-
end
|
17
|
-
|
18
|
-
class Hoe
|
19
|
-
def extra_deps
|
20
|
-
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Generate website files'
|
25
|
-
task :website_generate do
|
26
|
-
require 'scripts/lib-txt2html'
|
27
|
-
t2h = Txt2Html.new
|
28
|
-
Dir['website/**/*.txt'].each do |txt|
|
29
|
-
puts txt
|
30
|
-
version = VERS
|
31
|
-
download = DOWNLOAD_PATH
|
32
|
-
t2h.translate(txt, txt.gsub(/txt$/, 'html'), version, download)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# add chmod.
|
37
|
-
task :website_generate do
|
38
|
-
sh %{ chmod -R go+rx website }
|
39
|
-
end
|
40
|
-
|
41
|
-
desc 'Upload website files to rubyforge'
|
42
|
-
task :website_upload do
|
43
|
-
host = "#{rubyforge_username}@rubyforge.org"
|
44
|
-
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
45
|
-
local_dir = 'website'
|
46
|
-
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
47
|
-
end
|
48
|
-
|
49
|
-
desc 'Generate and upload website files'
|
50
|
-
task :website => [:website_generate, :website_upload, :publish_docs]
|
51
|
-
|
52
|
-
desc 'Release the website and new gem version'
|
53
|
-
task :deploy => [:check_version, :website, :release] do
|
54
|
-
puts "Remember to create SVN tag:"
|
55
|
-
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
56
|
-
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
57
|
-
puts "Suggested comment:"
|
58
|
-
puts "Tagging release #{CHANGES}"
|
59
|
-
end
|
60
|
-
|
61
|
-
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
62
|
-
task :local_deploy => [:website_generate, :install_gem]
|
63
|
-
|
64
|
-
task :check_version do
|
65
|
-
unless ENV['VERSION']
|
66
|
-
puts 'Must pass a VERSION=x.y.z release version'
|
67
|
-
exit
|
68
|
-
end
|
69
|
-
unless ENV['VERSION'] == VERS
|
70
|
-
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
71
|
-
exit
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
desc "Run the specs under spec/models"
|
76
|
-
Spec::Rake::SpecTask.new do |t|
|
77
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
78
|
-
t.spec_files = FileList['spec/*_spec.rb']
|
79
|
-
t.libs << "lib"
|
80
|
-
end
|
81
|
-
|
82
|
-
# add chmod.
|
83
|
-
task :docs do
|
84
|
-
sh %{ chmod -R go+rx doc }
|
85
|
-
end
|
86
|
-
|
87
|
-
# clear current task
|
88
|
-
module Rake
|
89
|
-
class Task
|
90
|
-
def clear_actions
|
91
|
-
@actions.clear
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
task :clean => [:chmod]
|
97
|
-
|
98
|
-
CHMOD644 = FileList[%w(
|
99
|
-
Rakefile Change*
|
100
|
-
**/*.txt
|
101
|
-
**/*.html
|
102
|
-
**/*.rhtml
|
103
|
-
**/*.js
|
104
|
-
**/*.css
|
105
|
-
**/*.rb
|
106
|
-
**/*.opts
|
107
|
-
)]
|
108
|
-
CHMOD755 = FileList[%w(scripts/*)]
|
109
|
-
|
110
|
-
desc 'Chmod all files.'
|
111
|
-
task :chmod do
|
112
|
-
CHMOD644.each {|f|
|
113
|
-
File.chmod 0644, f if File.exist? f
|
114
|
-
}
|
115
|
-
CHMOD755.each {|f|
|
116
|
-
File.chmod 0755, f if File.exist? f
|
117
|
-
}
|
118
|
-
end
|
119
|
-
|
120
|
-
desc 'Create Manifest.txt file.'
|
121
|
-
task :manifest => [:chmod, :clean] do
|
122
|
-
ruby "scripts/makemanifest.rb"
|
123
|
-
end
|
124
|
-
|
125
|
-
# Add tasks to gem
|
126
|
-
task :gem => [:manifest]
|
127
|
-
|
128
|
-
desc "Default task is to run specs"
|
129
|
-
task :default => [:spec]
|
data/work/deprecated/lookup.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
module AutoReload
|
2
|
-
|
3
|
-
# = Library Lookup
|
4
|
-
#
|
5
|
-
# This library is a slightly modified copy of the +plugin+ library.
|
6
|
-
#
|
7
|
-
module Lookup
|
8
|
-
|
9
|
-
extend self
|
10
|
-
|
11
|
-
# Find plugins, searching through standard $LOAD_PATH,
|
12
|
-
# Roll Libraries and RubyGems.
|
13
|
-
#
|
14
|
-
# Provide a +match+ file glob to find plugins.
|
15
|
-
#
|
16
|
-
# Lookup.find('syckle/*')
|
17
|
-
#
|
18
|
-
def find(match, options={})
|
19
|
-
plugins = []
|
20
|
-
plugins.concat find_roll(match, options)
|
21
|
-
plugins.concat find_loadpath(match, options)
|
22
|
-
plugins.concat find_gems(match, options)
|
23
|
-
plugins.uniq
|
24
|
-
end
|
25
|
-
|
26
|
-
# Shortcut for #find.
|
27
|
-
#
|
28
|
-
# Lookup['syckle/*']
|
29
|
-
#
|
30
|
-
alias_method :[], :find
|
31
|
-
|
32
|
-
# Search roll for current or latest libraries.
|
33
|
-
def find_roll(match, options={})
|
34
|
-
plugins = []
|
35
|
-
#directory = options[:directory] || DIRECTORY
|
36
|
-
if defined?(::Roll)
|
37
|
-
# Not ::Roll::Library ?
|
38
|
-
::Library.ledger.each do |name, lib|
|
39
|
-
lib = lib.sort.first if Array===lib
|
40
|
-
lib.loadpath.each do |path|
|
41
|
-
#find = File.join(lib.location, path, directory, match)
|
42
|
-
find = File.join(lib.location, path, match)
|
43
|
-
list = Dir.glob(find)
|
44
|
-
list = list.map{ |d| d.chomp('/') }
|
45
|
-
plugins.concat(list)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
plugins
|
50
|
-
end
|
51
|
-
|
52
|
-
# Search standard $LOAD_PATH.
|
53
|
-
#
|
54
|
-
# Activated gem versions are in here too.
|
55
|
-
|
56
|
-
def find_loadpath(match, options={})
|
57
|
-
plugins = []
|
58
|
-
#directory = options[:directory] || DIRECTORY
|
59
|
-
$LOAD_PATH.uniq.each do |path|
|
60
|
-
path = File.expand_path(path)
|
61
|
-
#list = Dir.glob(File.join(path, directory, match))
|
62
|
-
list = Dir.glob(File.join(path, match))
|
63
|
-
list = list.map{ |d| d.chomp('/') }
|
64
|
-
plugins.concat(list)
|
65
|
-
end
|
66
|
-
plugins
|
67
|
-
end
|
68
|
-
|
69
|
-
# # Search latest gem versions.
|
70
|
-
# #
|
71
|
-
# # TODO: Is there anyway to skip active gems?
|
72
|
-
#
|
73
|
-
# def find_gems(match, options={})
|
74
|
-
# plugins = []
|
75
|
-
# #directory = options[:directory] || DIRECTORY
|
76
|
-
# if defined?(::Gem)
|
77
|
-
# ::Gem.latest_load_paths do |path|
|
78
|
-
# #list = Dir.glob(File.join(path, directory, match))
|
79
|
-
# list = Dir.glob(File.join(path, match))
|
80
|
-
# list = list.map{ |d| d.chomp('/') }
|
81
|
-
# plugins.concat(list)
|
82
|
-
# end
|
83
|
-
# end
|
84
|
-
# plugins
|
85
|
-
# end
|
86
|
-
|
87
|
-
# Find the highest versions of unactived gems.
|
88
|
-
#
|
89
|
-
# TODO: Skip active gems.
|
90
|
-
#
|
91
|
-
# @returns Array<String>
|
92
|
-
def find_gems(match, options={})
|
93
|
-
#directory = options[:directory] || DIRECTORY
|
94
|
-
plugins = []
|
95
|
-
if defined?(::Gem)
|
96
|
-
latest_load_paths = []
|
97
|
-
Gem.path.each do |path|
|
98
|
-
libs = Dir[File.join(path, 'gems', '*', 'lib')]
|
99
|
-
latest_load_paths.concat(libs)
|
100
|
-
end
|
101
|
-
latest_load_paths.sort!{ |a,b| natcmp(a,b) }
|
102
|
-
# TODO: reduce latest_load_paths to highest versions
|
103
|
-
latest_load_paths.each do |path| #::Gem.latest_load_paths do |path|
|
104
|
-
#list = Dir.glob(File.join(path, directory, match))
|
105
|
-
list = Dir.glob(File.join(path, match))
|
106
|
-
list = list.map{ |d| d.chomp('/') }
|
107
|
-
plugins.concat(list)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
plugins
|
111
|
-
end
|
112
|
-
|
113
|
-
private
|
114
|
-
|
115
|
-
# 'Natural order' comparison of strings, e.g. ...
|
116
|
-
#
|
117
|
-
# "my_prog_v1.1.0" < "my_prog_v1.2.0" < "my_prog_v1.10.0"
|
118
|
-
#
|
119
|
-
# which does not follow alphabetically. A secondary
|
120
|
-
# parameter, if set to _true_, makes the comparison
|
121
|
-
# case insensitive.
|
122
|
-
#
|
123
|
-
# "Hello.1".natcmp("Hello.10") #=> -1
|
124
|
-
#
|
125
|
-
# TODO: Invert case flag?
|
126
|
-
#
|
127
|
-
# CREDIT: Alan Davies, Martin Pool
|
128
|
-
|
129
|
-
def natcmp(str1, str2, caseInsensitive=false)
|
130
|
-
str1 = str1.dup
|
131
|
-
str2 = str2.dup
|
132
|
-
compareExpression = /^(\D*)(\d*)(.*)$/
|
133
|
-
|
134
|
-
if caseInsensitive
|
135
|
-
str1.downcase!
|
136
|
-
str2.downcase!
|
137
|
-
end
|
138
|
-
|
139
|
-
# -- remove all whitespace
|
140
|
-
str1.gsub!(/\s*/, '')
|
141
|
-
str2.gsub!(/\s*/, '')
|
142
|
-
|
143
|
-
while (str1.length > 0) or (str2.length > 0) do
|
144
|
-
# -- extract non-digits, digits and rest of string
|
145
|
-
str1 =~ compareExpression
|
146
|
-
chars1, num1, str1 = $1.dup, $2.dup, $3.dup
|
147
|
-
str2 =~ compareExpression
|
148
|
-
chars2, num2, str2 = $1.dup, $2.dup, $3.dup
|
149
|
-
# -- compare the non-digits
|
150
|
-
case (chars1 <=> chars2)
|
151
|
-
when 0 # Non-digits are the same, compare the digits...
|
152
|
-
# If either number begins with a zero, then compare alphabetically,
|
153
|
-
# otherwise compare numerically
|
154
|
-
if (num1[0] != 48) and (num2[0] != 48)
|
155
|
-
num1, num2 = num1.to_i, num2.to_i
|
156
|
-
end
|
157
|
-
case (num1 <=> num2)
|
158
|
-
when -1 then return -1
|
159
|
-
when 1 then return 1
|
160
|
-
end
|
161
|
-
when -1 then return -1
|
162
|
-
when 1 then return 1
|
163
|
-
end # case
|
164
|
-
end # while
|
165
|
-
|
166
|
-
# -- strings are naturally equal
|
167
|
-
return 0
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
# Copyright (C) 2010 Thomas Sawyer
|
data/work/deprecated/meta/name
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
autoreload
|
@@ -1 +0,0 @@
|
|
1
|
-
Automatically reload library files.
|
@@ -1 +0,0 @@
|
|
1
|
-
0.2.0
|
@@ -1,133 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'redcloth'
|
5
|
-
require 'syntax/convertors/html'
|
6
|
-
require 'erb'
|
7
|
-
|
8
|
-
class Fixnum
|
9
|
-
def ordinal
|
10
|
-
# teens
|
11
|
-
return 'th' if (10..19).include?(self % 100)
|
12
|
-
# others
|
13
|
-
case self % 10
|
14
|
-
when 1: return 'st'
|
15
|
-
when 2: return 'nd'
|
16
|
-
when 3: return 'rd'
|
17
|
-
else return 'th'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Time
|
23
|
-
def pretty
|
24
|
-
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class Txt2Html
|
29
|
-
def self.main(argv)
|
30
|
-
self.new.main(argv)
|
31
|
-
end
|
32
|
-
|
33
|
-
DEFAULT_TEMPLATE = File.dirname(__FILE__) + '/../website/template.rhtml'
|
34
|
-
|
35
|
-
def main(argv)
|
36
|
-
if argv.length >= 1
|
37
|
-
src, template = argv
|
38
|
-
template ||= DEFAULT_TEMPLATE
|
39
|
-
else
|
40
|
-
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
41
|
-
exit!
|
42
|
-
end
|
43
|
-
|
44
|
-
version = VERS
|
45
|
-
download = DOWNLOAD_PATH
|
46
|
-
result = generate2(template, src, version, download)
|
47
|
-
$stdout << result
|
48
|
-
end
|
49
|
-
|
50
|
-
def translate(src, dest, version, download)
|
51
|
-
template = DEFAULT_TEMPLATE
|
52
|
-
result = generate2(template, src, version, download)
|
53
|
-
File.open(dest, 'wb') {|f| f.print result }
|
54
|
-
end
|
55
|
-
|
56
|
-
def generate2(template, src, version, download)
|
57
|
-
template_text = File.open(template).read
|
58
|
-
src_text = File.open(src) {|fsrc| fsrc.read }
|
59
|
-
modified = File.stat(src).mtime
|
60
|
-
result = generate(template_text, src_text, modified, version, download)
|
61
|
-
end
|
62
|
-
|
63
|
-
def generate(template_text, src_text, modified, version, download)
|
64
|
-
title_text, body_text = parse_title_body(src_text)
|
65
|
-
title = create_title(title_text)
|
66
|
-
body = create_body(body_text)
|
67
|
-
template = ERB.new(template_text)
|
68
|
-
result = template.result(binding)
|
69
|
-
return result
|
70
|
-
end
|
71
|
-
|
72
|
-
def parse_title_body(str)
|
73
|
-
/\A(.*?)\n(.*)/m =~ str
|
74
|
-
return $1, $2
|
75
|
-
end
|
76
|
-
|
77
|
-
def create_title(title_text)
|
78
|
-
return RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
79
|
-
end
|
80
|
-
|
81
|
-
def create_body(body_text)
|
82
|
-
syntax_items = []
|
83
|
-
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</>!m) {
|
84
|
-
ident = syntax_items.length
|
85
|
-
element, syntax, source = $1, $2, $3
|
86
|
-
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
87
|
-
"syntax-temp-#{ident}"
|
88
|
-
}
|
89
|
-
body = RedCloth.new(body_text).to_html
|
90
|
-
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
91
|
-
return body
|
92
|
-
end
|
93
|
-
|
94
|
-
def convert_syntax(syntax, source)
|
95
|
-
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!, '')
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
if $0 == __FILE__
|
100
|
-
require "test/unit"
|
101
|
-
$__test_txt2html__ = true
|
102
|
-
end
|
103
|
-
|
104
|
-
if defined?($__test_txt2html__) && $__test_txt2html__
|
105
|
-
class TestTxt2Html < Test::Unit::TestCase #:nodoc:
|
106
|
-
def test_fixnum_ordinal
|
107
|
-
assert_equal 'st', 1.ordinal
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_time_pretty
|
111
|
-
assert_equal '1st January 1970', Time.at(0).pretty
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_all
|
115
|
-
# test_txt2html
|
116
|
-
t2h = Txt2Html.new
|
117
|
-
|
118
|
-
# test_parse_title_body
|
119
|
-
assert_equal ["title", "body\n"], t2h.parse_title_body("title\nbody\n")
|
120
|
-
assert_equal ["title", "b\nb\n"], t2h.parse_title_body("title\nb\nb\n")
|
121
|
-
|
122
|
-
# test_create_title
|
123
|
-
assert_equal 'title', t2h.create_title('h1. title')
|
124
|
-
|
125
|
-
# test_create_body
|
126
|
-
assert_equal '<h2>body</h2>', t2h.create_body('h2. body')
|
127
|
-
|
128
|
-
# test_convert_syntax
|
129
|
-
assert_equal '<span class="number">0</span>',
|
130
|
-
t2h.convert_syntax('ruby', '0')
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|