apphunkd 0.9.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.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +78 -0
- data/TODO +1 -0
- data/VERSION +1 -0
- data/apphunkd.gemspec +258 -0
- data/bin/apphunkd +4 -0
- data/config/arguments.rb +12 -0
- data/config/boot.rb +68 -0
- data/config/environment.rb +23 -0
- data/config/environments/development.rb +2 -0
- data/config/environments/production.rb +2 -0
- data/config/environments/test.rb +2 -0
- data/config/post-daemonize/readme +5 -0
- data/config/pre-daemonize/readme +12 -0
- data/config/pre-daemonize/requires.rb +2 -0
- data/lib/apphunkd.rb +25 -0
- data/lib/apphunkd/api.rb +5 -0
- data/lib/apphunkd/api/service.rb +27 -0
- data/lib/apphunkd/queue.rb +96 -0
- data/lib/apphunkd/remote.rb +29 -0
- data/lib/apphunkd/remote/result.rb +15 -0
- data/libexec/apphunkd-daemon.rb +13 -0
- data/script/console +3 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/lib/apphunkd/api/service_spec.rb +47 -0
- data/spec/lib/apphunkd/queue_spec.rb +129 -0
- data/spec/lib/apphunkd/remote_spec.rb +61 -0
- data/spec/lib/apphunkd_spec.rb +50 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +13 -0
- data/support/apphunkd.initd +47 -0
- data/support/apphunkd.monitrc +3 -0
- data/tasks/rspec.rake +21 -0
- data/vendor/daemon-kit/Configuration.txt +102 -0
- data/vendor/daemon-kit/Deployment.txt +113 -0
- data/vendor/daemon-kit/History.txt +97 -0
- data/vendor/daemon-kit/Logging.txt +92 -0
- data/vendor/daemon-kit/Manifest.txt +166 -0
- data/vendor/daemon-kit/PostInstall.txt +6 -0
- data/vendor/daemon-kit/README.rdoc +130 -0
- data/vendor/daemon-kit/Rakefile +37 -0
- data/vendor/daemon-kit/RuoteParticipants.txt +113 -0
- data/vendor/daemon-kit/TODO.txt +37 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/USAGE +7 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/daemon_kit_generator.rb +161 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/README +48 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/Rakefile +6 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/bin/daemon.erb +7 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/arguments.rb +12 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/boot.rb +68 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environment.rb +23 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/development.rb +2 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/production.rb +2 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/environments/test.rb +2 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/post-daemonize/readme +5 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/config/pre-daemonize/readme +12 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/lib/daemon.rb +2 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/libexec/daemon.erb +18 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/console +3 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/destroy +14 -0
- data/vendor/daemon-kit/app_generators/daemon_kit/templates/script/generate +14 -0
- data/vendor/daemon-kit/bin/daemon_kit +18 -0
- data/vendor/daemon-kit/daemon_generators/amqp/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/amqp/amqp_generator.rb +65 -0
- data/vendor/daemon-kit/daemon_generators/amqp/templates/config/amqp.yml +28 -0
- data/vendor/daemon-kit/daemon_generators/amqp/templates/config/initializers/amqp.rb +7 -0
- data/vendor/daemon-kit/daemon_generators/amqp/templates/libexec/daemon.rb +37 -0
- data/vendor/daemon-kit/daemon_generators/cron/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/cron/cron_generator.rb +64 -0
- data/vendor/daemon-kit/daemon_generators/cron/templates/config/initializers/cron.rb +11 -0
- data/vendor/daemon-kit/daemon_generators/cron/templates/libexec/daemon.rb +43 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/USAGE +11 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/cucumber_generator.rb +38 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber +8 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber.rake +13 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/templates/cucumber_environment.rb +2 -0
- data/vendor/daemon-kit/daemon_generators/cucumber/templates/env.rb +7 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +35 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/Capfile +10 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/USAGE +10 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy.rb +53 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +6 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +6 -0
- data/vendor/daemon-kit/daemon_generators/deploy_capistrano/templates/config/environments/staging.rb +0 -0
- data/vendor/daemon-kit/daemon_generators/jabber/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/jabber/jabber_generator.rb +65 -0
- data/vendor/daemon-kit/daemon_generators/jabber/templates/config/initializers/jabber.rb +7 -0
- data/vendor/daemon-kit/daemon_generators/jabber/templates/config/jabber.yml +26 -0
- data/vendor/daemon-kit/daemon_generators/jabber/templates/libexec/daemon.rb +27 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/nanite_agent_generator.rb +68 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/config/initializers/nanite_agent.rb +6 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/config/nanite.yml +35 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/lib/actors/sample.rb +11 -0
- data/vendor/daemon-kit/daemon_generators/nanite_agent/templates/libexec/daemon.rb +31 -0
- data/vendor/daemon-kit/daemon_generators/rspec/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/rspec/rspec_generator.rb +55 -0
- data/vendor/daemon-kit/daemon_generators/rspec/templates/spec.rb +11 -0
- data/vendor/daemon-kit/daemon_generators/rspec/templates/spec/spec.opts +1 -0
- data/vendor/daemon-kit/daemon_generators/rspec/templates/spec/spec_helper.rb +21 -0
- data/vendor/daemon-kit/daemon_generators/rspec/templates/tasks/rspec.rake +21 -0
- data/vendor/daemon-kit/daemon_generators/ruote/USAGE +5 -0
- data/vendor/daemon-kit/daemon_generators/ruote/ruote_generator.rb +67 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/config/amqp.yml +30 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/config/initializers/ruote.rb +13 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/config/ruote.yml +23 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/lib/daemon.rb +4 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/lib/sample.rb +26 -0
- data/vendor/daemon-kit/daemon_generators/ruote/templates/libexec/daemon.rb +33 -0
- data/vendor/daemon-kit/lib/daemon_kit.rb +54 -0
- data/vendor/daemon-kit/lib/daemon_kit/abstract_logger.rb +235 -0
- data/vendor/daemon-kit/lib/daemon_kit/amqp.rb +38 -0
- data/vendor/daemon-kit/lib/daemon_kit/application.rb +187 -0
- data/vendor/daemon-kit/lib/daemon_kit/arguments.rb +165 -0
- data/vendor/daemon-kit/lib/daemon_kit/commands/console.rb +38 -0
- data/vendor/daemon-kit/lib/daemon_kit/config.rb +108 -0
- data/vendor/daemon-kit/lib/daemon_kit/console_daemon.rb +2 -0
- data/vendor/daemon-kit/lib/daemon_kit/core_ext.rb +1 -0
- data/vendor/daemon-kit/lib/daemon_kit/core_ext/configurable.rb +96 -0
- data/vendor/daemon-kit/lib/daemon_kit/core_ext/string.rb +22 -0
- data/vendor/daemon-kit/lib/daemon_kit/cron.rb +48 -0
- data/vendor/daemon-kit/lib/daemon_kit/cucumber/world.rb +38 -0
- data/vendor/daemon-kit/lib/daemon_kit/deployment/capistrano.rb +482 -0
- data/vendor/daemon-kit/lib/daemon_kit/em.rb +43 -0
- data/vendor/daemon-kit/lib/daemon_kit/error_handlers/base.rb +32 -0
- data/vendor/daemon-kit/lib/daemon_kit/error_handlers/hoptoad.rb +61 -0
- data/vendor/daemon-kit/lib/daemon_kit/error_handlers/mail.rb +85 -0
- data/vendor/daemon-kit/lib/daemon_kit/exceptions.rb +8 -0
- data/vendor/daemon-kit/lib/daemon_kit/initializer.rb +438 -0
- data/vendor/daemon-kit/lib/daemon_kit/jabber.rb +170 -0
- data/vendor/daemon-kit/lib/daemon_kit/nanite.rb +7 -0
- data/vendor/daemon-kit/lib/daemon_kit/nanite/agent.rb +56 -0
- data/vendor/daemon-kit/lib/daemon_kit/pid_file.rb +61 -0
- data/vendor/daemon-kit/lib/daemon_kit/ruote_participants.rb +119 -0
- data/vendor/daemon-kit/lib/daemon_kit/ruote_pseudo_participant.rb +68 -0
- data/vendor/daemon-kit/lib/daemon_kit/ruote_workitem.rb +169 -0
- data/vendor/daemon-kit/lib/daemon_kit/safety.rb +85 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks.rb +2 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/environment.rake +10 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/framework.rake +120 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/god.rake +62 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/log.rake +8 -0
- data/vendor/daemon-kit/lib/daemon_kit/tasks/monit.rake +29 -0
- data/vendor/daemon-kit/script/console +10 -0
- data/vendor/daemon-kit/script/destroy +14 -0
- data/vendor/daemon-kit/script/generate +14 -0
- data/vendor/daemon-kit/script/txt2html +71 -0
- data/vendor/daemon-kit/spec/abstract_logger_spec.rb +126 -0
- data/vendor/daemon-kit/spec/argument_spec.rb +70 -0
- data/vendor/daemon-kit/spec/config_spec.rb +79 -0
- data/vendor/daemon-kit/spec/configurable_spec.rb +56 -0
- data/vendor/daemon-kit/spec/daemon_kit_spec.rb +7 -0
- data/vendor/daemon-kit/spec/error_handlers_spec.rb +23 -0
- data/vendor/daemon-kit/spec/fixtures/env.yml +15 -0
- data/vendor/daemon-kit/spec/fixtures/noenv.yml +4 -0
- data/vendor/daemon-kit/spec/initializer_spec.rb +26 -0
- data/vendor/daemon-kit/spec/spec.opts +1 -0
- data/vendor/daemon-kit/spec/spec_helper.rb +27 -0
- data/vendor/daemon-kit/tasks/rspec.rake +21 -0
- data/vendor/daemon-kit/templates/god/god.erb +69 -0
- data/vendor/daemon-kit/templates/monit/monit.erb +14 -0
- data/vendor/daemon-kit/test/test_amqp_generator.rb +48 -0
- data/vendor/daemon-kit/test/test_cron_generator.rb +45 -0
- data/vendor/daemon-kit/test/test_daemon-kit_generator.rb +84 -0
- data/vendor/daemon-kit/test/test_daemon_kit_config.rb +28 -0
- data/vendor/daemon-kit/test/test_deploy_capistrano_generator.rb +48 -0
- data/vendor/daemon-kit/test/test_generator_helper.rb +29 -0
- data/vendor/daemon-kit/test/test_helper.rb +7 -0
- data/vendor/daemon-kit/test/test_jabber_generator.rb +49 -0
- data/vendor/daemon-kit/test/test_nanite_agent_generator.rb +49 -0
- data/vendor/daemon-kit/test/test_ruote_generator.rb +45 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail.rb +5 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/address.rb +426 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/attachments.rb +46 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/base64.rb +46 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/compat.rb +41 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/config.rb +67 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/core_extensions.rb +63 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/encode.rb +581 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/header.rb +960 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/index.rb +9 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/interface.rb +1130 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/loader.rb +3 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mail.rb +578 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mailbox.rb +495 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/main.rb +6 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/mbox.rb +3 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/net.rb +248 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/obsolete.rb +132 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/parser.rb +1476 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/port.rb +379 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/quoting.rb +118 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/scanner.rb +49 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/scanner_r.rb +261 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/stringio.rb +280 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/utils.rb +337 -0
- data/vendor/daemon-kit/vendor/tmail-1.2.3/tmail/version.rb +39 -0
- data/vendor/daemon-kit/vendor/tmail.rb +13 -0
- metadata +281 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'erb'
|
|
2
|
+
|
|
3
|
+
namespace :monit do
|
|
4
|
+
desc "Generate a stub monit config file template for the daemon"
|
|
5
|
+
task :template => 'environment' do
|
|
6
|
+
# Preserve local changes
|
|
7
|
+
if File.exists?( "#{DaemonKit.root}/config/monit.erb" ) && ENV['FORCE'].nil?
|
|
8
|
+
puts "Template already exists, use FORCE=1 to overwrite."
|
|
9
|
+
exit 1
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
cp "#{DaemonKit.framework_root}/templates/monit/monit.erb", "#{DaemonKit.root}/config/monit.erb"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "Parse the monit config template into a monit config file"
|
|
16
|
+
task :generate => 'environment' do
|
|
17
|
+
|
|
18
|
+
unless File.exists?( "#{DaemonKit.root}/config/monit.erb" )
|
|
19
|
+
Rake::Task["monit:template"].invoke
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
File.open( "#{DaemonKit.root}/config/monit.conf", "w+" ) do |f|
|
|
23
|
+
t = File.read( "#{DaemonKit.root}/config/monit.erb" )
|
|
24
|
+
f.write( ERB.new( t ).result( binding ) )
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
puts "Monit config generated in config/monit.conf"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# File: script/console
|
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
|
4
|
+
|
|
5
|
+
libs = " -r irb/completion"
|
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/daemon-kit.rb'}"
|
|
9
|
+
puts "Loading daemon-kit gem"
|
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/destroy'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/generate'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
load File.dirname(__FILE__) + "/../Rakefile"
|
|
4
|
+
require 'rubyforge'
|
|
5
|
+
require 'redcloth'
|
|
6
|
+
require 'syntax/convertors/html'
|
|
7
|
+
require 'erb'
|
|
8
|
+
|
|
9
|
+
download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
|
|
10
|
+
version = $hoe.version
|
|
11
|
+
|
|
12
|
+
def rubyforge_project_id
|
|
13
|
+
RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Fixnum
|
|
17
|
+
def ordinal
|
|
18
|
+
# teens
|
|
19
|
+
return 'th' if (10..19).include?(self % 100)
|
|
20
|
+
# others
|
|
21
|
+
case self % 10
|
|
22
|
+
when 1: return 'st'
|
|
23
|
+
when 2: return 'nd'
|
|
24
|
+
when 3: return 'rd'
|
|
25
|
+
else return 'th'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Time
|
|
31
|
+
def pretty
|
|
32
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def convert_syntax(syntax, source)
|
|
37
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
if ARGV.length >= 1
|
|
41
|
+
src, template = ARGV
|
|
42
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
|
43
|
+
else
|
|
44
|
+
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
|
45
|
+
exit!
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
template = ERB.new(File.open(template).read)
|
|
49
|
+
|
|
50
|
+
title = nil
|
|
51
|
+
body = nil
|
|
52
|
+
File.open(src) do |fsrc|
|
|
53
|
+
title_text = fsrc.readline
|
|
54
|
+
body_text_template = fsrc.read
|
|
55
|
+
body_text = ERB.new(body_text_template).result(binding)
|
|
56
|
+
syntax_items = []
|
|
57
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
|
58
|
+
ident = syntax_items.length
|
|
59
|
+
element, syntax, source = $1, $2, $3
|
|
60
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
|
61
|
+
"syntax-temp-#{ident}"
|
|
62
|
+
}
|
|
63
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
|
64
|
+
body = RedCloth.new(body_text).to_html
|
|
65
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
|
66
|
+
end
|
|
67
|
+
stat = File.stat(src)
|
|
68
|
+
created = stat.ctime
|
|
69
|
+
modified = stat.mtime
|
|
70
|
+
|
|
71
|
+
$stdout << template.result(binding)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaemonKit::AbstractLogger do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@log_file = "#{DAEMON_ROOT}/log/spec.log"
|
|
7
|
+
@logger = DaemonKit::AbstractLogger.new( @log_file )
|
|
8
|
+
@logger.level = :debug
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should have a log level" do
|
|
12
|
+
@logger.level.should == :debug
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should have a backend logger" do
|
|
16
|
+
@logger.logger.should_not be_nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should accept a different backend" do
|
|
20
|
+
l = Logger.new('/dev/null')
|
|
21
|
+
@logger.logger = l
|
|
22
|
+
@logger.logger.should == l
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should be able to log to STDOUT as well" do
|
|
26
|
+
@logger.copy_to_stdout = true
|
|
27
|
+
|
|
28
|
+
STDOUT.expects(:puts).with(regexp_matches(/test/))
|
|
29
|
+
|
|
30
|
+
@logger.debug "test"
|
|
31
|
+
IO.readlines( @log_file ).last.should match(/test/)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should log debug level messages" do
|
|
35
|
+
@logger.debug( "Debug test" )
|
|
36
|
+
|
|
37
|
+
IO.readlines( @log_file ).last.should match(/\[DEBUG\].*Debug test/)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should log info level messages" do
|
|
41
|
+
@logger.info( "Info test" )
|
|
42
|
+
|
|
43
|
+
IO.readlines( @log_file ).last.should match(/\[INFO\].*Info test/)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should log warn level messages" do
|
|
47
|
+
@logger.warn( "Warn test" )
|
|
48
|
+
|
|
49
|
+
IO.readlines( @log_file ).last.should match(/\[WARN\].*Warn test/)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should log error level messages" do
|
|
53
|
+
@logger.error( "Err test" )
|
|
54
|
+
|
|
55
|
+
IO.readlines( @log_file ).last.should match(/\[ERROR\].*Err test/)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should log fatal level messages" do
|
|
59
|
+
@logger.fatal( "Fatal test" )
|
|
60
|
+
|
|
61
|
+
IO.readlines( @log_file ).last.should match(/\[FATAL\].*Fatal test/)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should log unknown level messages" do
|
|
65
|
+
@logger.unknown( "Unknown test" )
|
|
66
|
+
|
|
67
|
+
IO.readlines( @log_file ).last.should match(/\[ANY\].*Unknown test/)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should log the caller file and line number" do
|
|
71
|
+
f = File.basename(__FILE__)
|
|
72
|
+
l = __LINE__ + 2
|
|
73
|
+
|
|
74
|
+
@logger.info( "Caller test" )
|
|
75
|
+
|
|
76
|
+
IO.readlines( @log_file ).last.should match(/#{f}:#{l}:/)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should log exceptions with daemon traces" do
|
|
80
|
+
fake_trace = [
|
|
81
|
+
"/home/kenneth/daemon/libexec/daemon-daemon.rb:1:in `foo'",
|
|
82
|
+
"/usr/lib/ruby/gems/1.8/gems/daemon-kit-0.0.1/lib/daemon_kit/abstract_logger.rb:49: in `info'"
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
e = RuntimeError.new( 'Test error' )
|
|
86
|
+
e.set_backtrace( fake_trace )
|
|
87
|
+
|
|
88
|
+
@logger.exception( e )
|
|
89
|
+
|
|
90
|
+
IO.readlines( @log_file ).last.should match(/EXCEPTION: Test error/)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "should log exceptions without framework traces" do
|
|
94
|
+
fake_trace = [
|
|
95
|
+
"/home/kenneth/daemon/libexec/daemon-daemon.rb:1:in `foo'",
|
|
96
|
+
"/usr/lib/ruby/gems/1.8/gems/daemon-kit-0.0.1/lib/daemon_kit/abstract_logger.rb:49: in `info'"
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
clean_trace = @logger.clean_trace( fake_trace )
|
|
100
|
+
|
|
101
|
+
clean_trace.should include("/home/kenneth/daemon/libexec/daemon-daemon.rb:1:in `foo'")
|
|
102
|
+
clean_trace.should_not include("/usr/lib/ruby/gems/1.8/gems/daemon-kit-0.0.1/lib/daemon_kit/abstract_logger.rb:49: in `info'")
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should support reopening log files" do
|
|
106
|
+
@logger.close
|
|
107
|
+
|
|
108
|
+
FileUtils.rm( @log_file )
|
|
109
|
+
|
|
110
|
+
@logger.info( 'Reopen')
|
|
111
|
+
IO.readlines( @log_file ).last.should match(/Reopen/)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "should support silencing" do
|
|
115
|
+
@logger.silence do |logger|
|
|
116
|
+
logger.info "This should never be logged"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
@logger.info "This should be logged"
|
|
120
|
+
|
|
121
|
+
log = IO.readlines( @log_file )
|
|
122
|
+
|
|
123
|
+
log.detect { |l| l =~ /This should never be logged/ }.should be_nil
|
|
124
|
+
log.detect { |l| l =~ /This should be logged/ }.should_not be_nil
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaemonKit::Arguments do
|
|
4
|
+
|
|
5
|
+
describe "parsing ARGV" do
|
|
6
|
+
|
|
7
|
+
it "should extract the given command" do
|
|
8
|
+
argv = [ 'start', '-f', 'foo' ]
|
|
9
|
+
res = DaemonKit::Arguments.parse( argv )
|
|
10
|
+
|
|
11
|
+
res.first.should == :start
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should have a default command if missing" do
|
|
15
|
+
argv = [ '-h' ]
|
|
16
|
+
res = DaemonKit::Arguments.parse( argv )
|
|
17
|
+
|
|
18
|
+
res.first.should == :run
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should extract explicit configuration options" do
|
|
22
|
+
argv = [ 'start', '--config', 'environment=development' ]
|
|
23
|
+
res = DaemonKit::Arguments.parse( argv )
|
|
24
|
+
|
|
25
|
+
res.shift
|
|
26
|
+
res.first.should == [ 'environment=development' ]
|
|
27
|
+
|
|
28
|
+
res.last.should == []
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should extract implicit configuration options" do
|
|
32
|
+
argv = [ '-e', 'production' ]
|
|
33
|
+
res = DaemonKit::Arguments.parse( argv )
|
|
34
|
+
|
|
35
|
+
res.shift
|
|
36
|
+
res.first.should == ['environment=production']
|
|
37
|
+
|
|
38
|
+
res.last.should == []
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should extract daemon options" do
|
|
42
|
+
argv = [ 'start', '-h' ]
|
|
43
|
+
res = DaemonKit::Arguments.parse( argv )
|
|
44
|
+
|
|
45
|
+
res.shift
|
|
46
|
+
res.first.should == []
|
|
47
|
+
|
|
48
|
+
res.last.should == [ '-h' ]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should handle different ordered configurations easily" do
|
|
52
|
+
argv = [ '--pid', '/tmp/piddy', '--log', '/tmp/loggy' ]
|
|
53
|
+
res = DaemonKit::Arguments.configuration( argv )
|
|
54
|
+
|
|
55
|
+
# No additional args
|
|
56
|
+
res.last.should be_empty
|
|
57
|
+
|
|
58
|
+
res.first[0].should == "pid_file=/tmp/piddy"
|
|
59
|
+
res.first[1].should == "log_path=/tmp/loggy"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should handle mixed configurations easily" do
|
|
63
|
+
argv = [ '--rest', 'yes', '-l', '/tmp/loggy', '-f', 'bar' ]
|
|
64
|
+
res = DaemonKit::Arguments.configuration( argv )
|
|
65
|
+
|
|
66
|
+
res.first.should == [ 'log_path=/tmp/loggy' ]
|
|
67
|
+
res.last.should == [ '--rest', 'yes', '-f', 'bar' ]
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaemonKit::Config do
|
|
4
|
+
|
|
5
|
+
describe "working with config data" do
|
|
6
|
+
before(:each) do
|
|
7
|
+
@config = DaemonKit::Config.new('foo' => 'bar', 'nes' => { 'ted' => 'value' })
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should have string key access to values" do
|
|
11
|
+
@config['foo'].should == 'bar'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should have symbol key access to values" do
|
|
15
|
+
@config[:foo].should == 'bar'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should have instance accessors to values" do
|
|
19
|
+
@config.foo.should == 'bar'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should have nested instance accessors to values" do
|
|
23
|
+
@config.nes.ted.should == 'value'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should return the config as a hash" do
|
|
27
|
+
@config.to_h.should == { 'foo' => 'bar', 'nes' => { 'ted' => 'value' } }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should be able to symbolize keys in returned hash" do
|
|
31
|
+
@config.to_h(true).should == { :foo => 'bar', :nes => { :ted => 'value' } }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "parsing files" do
|
|
36
|
+
before(:all) do
|
|
37
|
+
FileUtils.mkdir_p( DAEMON_ROOT + "/config" )
|
|
38
|
+
FileUtils.cp( File.dirname(__FILE__) + '/fixtures/env.yml', DAEMON_ROOT + '/config/' )
|
|
39
|
+
FileUtils.cp( File.dirname(__FILE__) + '/fixtures/noenv.yml', DAEMON_ROOT + '/config/' )
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should parse env keys correctly" do
|
|
43
|
+
config = DaemonKit::Config.load('env')
|
|
44
|
+
|
|
45
|
+
config.test.should == 'yes!'
|
|
46
|
+
config.array.should_not be_empty
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should not be worried about missing env keys" do
|
|
50
|
+
config = DaemonKit::Config.load('noenv')
|
|
51
|
+
|
|
52
|
+
config.string.should == 'value'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should accept symbol file names" do
|
|
56
|
+
config = DaemonKit::Config.load(:env)
|
|
57
|
+
config.test.should == 'yes!'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should bail on missing files" do
|
|
61
|
+
lambda {
|
|
62
|
+
DaemonKit::Config.load('missing')
|
|
63
|
+
}.should raise_error(ArgumentError)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should give direct hash access to a config" do
|
|
67
|
+
config = DaemonKit::Config.hash(:env)
|
|
68
|
+
|
|
69
|
+
config.should be_a_kind_of(Hash)
|
|
70
|
+
config.keys.should include('test')
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should give direct symbolized hash access to a config" do
|
|
74
|
+
config = DaemonKit::Config.hash(:env, true)
|
|
75
|
+
|
|
76
|
+
config.keys.should include(:test)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
2
|
+
|
|
3
|
+
class FooConfig
|
|
4
|
+
include DaemonKit::Configurable
|
|
5
|
+
|
|
6
|
+
configurable :has_default, true
|
|
7
|
+
configurable :no_default
|
|
8
|
+
configurable :has_lock, :locked => true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe DaemonKit::Configurable do
|
|
12
|
+
|
|
13
|
+
before(:each) do
|
|
14
|
+
@foo = FooConfig.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should support default values" do
|
|
18
|
+
lambda {
|
|
19
|
+
@foo.has_default.should be_true
|
|
20
|
+
}.should_not raise_error( NoMethodError )
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should support overwriting unlocked defaults" do
|
|
24
|
+
lambda {
|
|
25
|
+
@foo.has_default = false
|
|
26
|
+
@foo.has_default.should be_false
|
|
27
|
+
}.should_not raise_error
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should support no default values" do
|
|
31
|
+
lambda {
|
|
32
|
+
@foo.no_default.should be_nil
|
|
33
|
+
}.should_not raise_error( NoMethodError )
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should allow setting locked values once" do
|
|
37
|
+
lambda {
|
|
38
|
+
@foo.has_lock = 1
|
|
39
|
+
@foo.has_lock.should == 1
|
|
40
|
+
|
|
41
|
+
@foo.has_lock = 2
|
|
42
|
+
@foo.has_lock.should == 1
|
|
43
|
+
}.should_not raise_error
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should allow bypassing the lock explicitly" do
|
|
47
|
+
lambda {
|
|
48
|
+
@foo.has_lock = 1
|
|
49
|
+
@foo.has_lock.should == 1
|
|
50
|
+
|
|
51
|
+
@foo.set(:has_lock, 2)
|
|
52
|
+
@foo.has_lock.should == 2
|
|
53
|
+
}.should_not raise_error
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|