daemon-kit 0.1.7.12 → 0.1.8pre
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/History.txt +7 -0
- data/Manifest.txt +4 -0
- data/README.rdoc +11 -9
- data/Rakefile +0 -1
- data/TODO.txt +1 -2
- data/bin/daemon-kit +11 -11
- data/daemon-kit.gemspec +109 -78
- data/lib/daemon_kit.rb +7 -10
- data/lib/daemon_kit/abstract_logger.rb +22 -14
- data/lib/daemon_kit/application.rb +0 -1
- data/lib/daemon_kit/arguments.rb +1 -6
- data/lib/daemon_kit/commands/destroy.rb +10 -0
- data/lib/daemon_kit/commands/generate.rb +10 -0
- data/lib/daemon_kit/config.rb +7 -2
- data/lib/daemon_kit/generators.rb +67 -0
- data/lib/daemon_kit/generators/base.rb +60 -0
- data/lib/daemon_kit/initializer.rb +1 -1
- data/lib/daemon_kit/jabber.rb +1 -0
- data/lib/daemon_kit/tasks/framework.rake +6 -1
- data/lib/daemon_kit/vendor/thor-0.12.3/CHANGELOG.rdoc +80 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/LICENSE +20 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/README.rdoc +234 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/Thorfile +64 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor.rb +242 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions.rb +274 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/create_file.rb +103 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/directory.rb +91 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/empty_directory.rb +134 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/file_manipulation.rb +223 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/inject_into_file.rb +101 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/base.rb +515 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/error.rb +27 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/group.rb +271 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/invocation.rb +178 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser.rb +4 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser/argument.rb +67 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser/arguments.rb +145 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser/option.rb +132 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser/options.rb +142 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/rake_compat.rb +66 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/runner.rb +303 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/shell.rb +78 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/shell/basic.rb +239 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/shell/color.rb +108 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/task.rb +111 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/util.rb +233 -0
- data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/version.rb +3 -0
- data/lib/daemon_kit/xmpp.rb +75 -6
- data/{daemon_generators → lib/generators/daemon_kit}/amqp/USAGE +0 -0
- data/lib/generators/daemon_kit/amqp/amqp_generator.rb +24 -0
- data/{daemon_generators → lib/generators/daemon_kit}/amqp/templates/config/amqp.yml +0 -0
- data/{daemon_generators/amqp/templates/config/initializers → lib/generators/daemon_kit/amqp/templates/config/pre-daemonize}/amqp.rb +0 -0
- data/{daemon_generators/amqp/templates/libexec/daemon.rb → lib/generators/daemon_kit/amqp/templates/libexec/%app_name%-daemon.rb} +0 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/USAGE +0 -0
- data/lib/generators/daemon_kit/app/app_generator.rb +140 -0
- data/lib/generators/daemon_kit/app/templates/Gemfile +8 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/README +0 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/Rakefile +0 -0
- data/lib/generators/daemon_kit/app/templates/bin/daemon.tt +7 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/config/arguments.rb +0 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/config/boot.rb +10 -3
- data/{app_generators/daemon_kit/templates/config/environment.rb → lib/generators/daemon_kit/app/templates/config/environment.rb.tt} +1 -1
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/config/environments/development.rb +0 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/config/environments/production.rb +0 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/config/environments/test.rb +0 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/config/post-daemonize/readme +0 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/config/pre-daemonize/readme +0 -0
- data/{app_generators/daemon_kit/templates/lib/daemon.rb → lib/generators/daemon_kit/app/templates/lib/%app_name%.rb} +0 -0
- data/{app_generators/daemon_kit/templates/libexec/daemon.erb → lib/generators/daemon_kit/app/templates/libexec/%app_name%-daemon.rb} +0 -0
- data/{app_generators/daemon_kit → lib/generators/daemon_kit/app}/templates/script/console +0 -0
- data/lib/generators/daemon_kit/app/templates/script/destroy +2 -0
- data/lib/generators/daemon_kit/app/templates/script/generate +2 -0
- data/lib/generators/daemon_kit/capistrano/capistrano_generator.rb +21 -0
- data/{daemon_generators/deploy_capistrano → lib/generators/daemon_kit/capistrano}/templates/Capfile +0 -0
- data/{daemon_generators/deploy_capistrano → lib/generators/daemon_kit/capistrano}/templates/USAGE +0 -0
- data/{daemon_generators/deploy_capistrano/templates/config/deploy.rb → lib/generators/daemon_kit/capistrano/templates/config/deploy.rb.tt} +1 -1
- data/lib/generators/daemon_kit/capistrano/templates/config/deploy/production.rb.tt +6 -0
- data/lib/generators/daemon_kit/capistrano/templates/config/deploy/staging.rb.tt +6 -0
- data/{daemon_generators/deploy_capistrano → lib/generators/daemon_kit/capistrano}/templates/config/environments/staging.rb +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/cron/USAGE +0 -0
- data/lib/generators/daemon_kit/cron/cron_generator.rb +24 -0
- data/{daemon_generators/cron/templates/config/initializers → lib/generators/daemon_kit/cron/templates/config/pre-daemonize}/cron.rb +0 -0
- data/{daemon_generators/cron/templates/libexec/daemon.rb → lib/generators/daemon_kit/cron/templates/libexec/%app_name%-daemon.rb} +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/cucumber/USAGE +0 -0
- data/lib/generators/daemon_kit/cucumber/cucumber_generator.rb +45 -0
- data/{daemon_generators/cucumber/templates/cucumber_environment.rb → lib/generators/daemon_kit/cucumber/templates/config/environments/cucumber.rb} +0 -0
- data/lib/generators/daemon_kit/cucumber/templates/features/step_definitions/.empty_directory +0 -0
- data/{daemon_generators/cucumber/templates → lib/generators/daemon_kit/cucumber/templates/features/support}/env.rb +0 -0
- data/{daemon_generators/cucumber/templates → lib/generators/daemon_kit/cucumber/templates/script}/cucumber +1 -2
- data/{daemon_generators/cucumber/templates → lib/generators/daemon_kit/cucumber/templates/tasks}/cucumber.rake +0 -0
- data/{daemon_generators/jabber → lib/generators/daemon_kit/nanite_agent}/USAGE +0 -0
- data/lib/generators/daemon_kit/nanite_agent/nanite_agent_generator.rb +29 -0
- data/{daemon_generators → lib/generators/daemon_kit}/nanite_agent/templates/config/nanite.yml +0 -0
- data/{daemon_generators/nanite_agent/templates/config/initializers → lib/generators/daemon_kit/nanite_agent/templates/config/pre-daemonize}/nanite_agent.rb +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/nanite_agent/templates/lib/actors/sample.rb +0 -0
- data/{daemon_generators/nanite_agent/templates/libexec/daemon.rb → lib/generators/daemon_kit/nanite_agent/templates/libexec/%app_name%-daemon.rb} +0 -0
- data/{daemon_generators/nanite_agent → lib/generators/daemon_kit/rspec}/USAGE +0 -0
- data/lib/generators/daemon_kit/rspec/rspec_generator.rb +20 -0
- data/{daemon_generators/rspec/templates/spec.rb → lib/generators/daemon_kit/rspec/templates/spec/%app_name%_spec.rb} +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/rspec/templates/spec/spec.opts +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/rspec/templates/spec/spec_helper.rb +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/rspec/templates/tasks/rspec.rake +0 -0
- data/{daemon_generators/rspec → lib/generators/daemon_kit/ruote}/USAGE +0 -0
- data/lib/generators/daemon_kit/ruote/ruote_generator.rb +29 -0
- data/{daemon_generators → lib/generators/daemon_kit}/ruote/templates/config/amqp.yml +0 -0
- data/{daemon_generators/ruote/templates/config/initializers → lib/generators/daemon_kit/ruote/templates/config/pre-daemonize}/ruote.rb +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/ruote/templates/config/ruote.yml +0 -0
- data/{daemon_generators/ruote/templates/lib/daemon.rb → lib/generators/daemon_kit/ruote/templates/lib/%app_name%.rb} +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/ruote/templates/lib/sample.rb +0 -0
- data/{daemon_generators/ruote/templates/libexec/daemon.rb → lib/generators/daemon_kit/ruote/templates/libexec/%app_name%-daemon.rb} +0 -0
- data/{daemon_generators/ruote → lib/generators/daemon_kit/test_unit}/USAGE +0 -0
- data/{daemon_generators → lib/generators/daemon_kit}/test_unit/templates/tasks/test_unit.rake +0 -0
- data/{daemon_generators/test_unit/templates/test/test.rb → lib/generators/daemon_kit/test_unit/templates/test/%app_name%_test.rb.tt} +1 -1
- data/{daemon_generators → lib/generators/daemon_kit}/test_unit/templates/test/test_helper.rb +0 -0
- data/lib/generators/daemon_kit/test_unit/test_unit_generator.rb +20 -0
- data/lib/generators/daemon_kit/xmpp/templates/config/pre-daemonize/xmpp.rb +6 -0
- data/{daemon_generators/jabber/templates/config/jabber.yml → lib/generators/daemon_kit/xmpp/templates/config/xmpp.yml} +5 -2
- data/lib/generators/daemon_kit/xmpp/templates/libexec/%app_name%-daemon.rb +27 -0
- data/lib/generators/daemon_kit/xmpp/xmpp_generator.rb +24 -0
- data/spec/argument_spec.rb +1 -1
- data/spec/config_spec.rb +7 -3
- metadata +110 -86
- data/app_generators/daemon_kit/daemon_kit_generator.rb +0 -178
- data/app_generators/daemon_kit/templates/bin/daemon.erb +0 -7
- data/app_generators/daemon_kit/templates/script/destroy +0 -14
- data/app_generators/daemon_kit/templates/script/generate +0 -14
- data/daemon_generators/amqp/amqp_generator.rb +0 -65
- data/daemon_generators/cron/cron_generator.rb +0 -64
- data/daemon_generators/cucumber/cucumber_generator.rb +0 -38
- data/daemon_generators/deploy_capistrano/deploy_capistrano_generator.rb +0 -35
- data/daemon_generators/deploy_capistrano/templates/config/deploy/production.rb +0 -6
- data/daemon_generators/deploy_capistrano/templates/config/deploy/staging.rb +0 -6
- data/daemon_generators/jabber/jabber_generator.rb +0 -65
- data/daemon_generators/jabber/templates/config/initializers/jabber.rb +0 -7
- data/daemon_generators/jabber/templates/libexec/daemon.rb +0 -27
- data/daemon_generators/nanite_agent/nanite_agent_generator.rb +0 -68
- data/daemon_generators/rspec/rspec_generator.rb +0 -55
- data/daemon_generators/ruote/ruote_generator.rb +0 -67
- data/daemon_generators/test_unit/USAGE +0 -5
- data/daemon_generators/test_unit/test_unit_generator.rb +0 -51
- data/test/test_jabber_generator.rb +0 -49
data/lib/daemon_kit/arguments.rb
CHANGED
|
@@ -19,15 +19,10 @@ module DaemonKit
|
|
|
19
19
|
'run'
|
|
20
20
|
]
|
|
21
21
|
|
|
22
|
-
# We don't parse arguments by default
|
|
23
|
-
@parser_available = false
|
|
24
|
-
|
|
25
22
|
class << self
|
|
26
23
|
|
|
27
24
|
attr_reader :default_command, :commands
|
|
28
25
|
|
|
29
|
-
attr_accessor :parser_available
|
|
30
|
-
|
|
31
26
|
# Parse the argument values and return an array with the command
|
|
32
27
|
# name, config values and argument values
|
|
33
28
|
def parse( argv )
|
|
@@ -88,7 +83,7 @@ module DaemonKit
|
|
|
88
83
|
next
|
|
89
84
|
end
|
|
90
85
|
|
|
91
|
-
if argv[i] == "--
|
|
86
|
+
if argv[i] == "--pidfile"
|
|
92
87
|
argv.delete_at( i )
|
|
93
88
|
configs << "pid_file=#{argv.delete_at(i)}"
|
|
94
89
|
next
|
data/lib/daemon_kit/config.rb
CHANGED
|
@@ -59,8 +59,13 @@ module DaemonKit
|
|
|
59
59
|
|
|
60
60
|
def method_missing( method_name, *args ) #:nodoc:
|
|
61
61
|
unless method_name.to_s =~ /[\w_]+=$/
|
|
62
|
-
if @data.keys.include?( method_name.to_s )
|
|
62
|
+
#if @data.keys.include?( method_name.to_s )
|
|
63
|
+
# return @data.send( method_name.to_s )
|
|
64
|
+
#end
|
|
65
|
+
if @data.respond_to?( method_name.to_s )
|
|
63
66
|
return @data.send( method_name.to_s )
|
|
67
|
+
elsif @date.respond_to?( method_name.to_s.gsub(/\-/, '_') )
|
|
68
|
+
return @data.send( method_name.to_s.gsub(/\-/, '_') )
|
|
64
69
|
end
|
|
65
70
|
end
|
|
66
71
|
|
|
@@ -92,7 +97,7 @@ module DaemonKit
|
|
|
92
97
|
def extend_hash( hash )
|
|
93
98
|
hash.keys.each do |k|
|
|
94
99
|
hash.instance_eval <<-KEY
|
|
95
|
-
def #{k}
|
|
100
|
+
def #{k.gsub(/\-/, '_')}
|
|
96
101
|
fetch("#{k}")
|
|
97
102
|
end
|
|
98
103
|
KEY
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# TODO: Don't always depend on bundled thor
|
|
2
|
+
$:.unshift File.dirname(__FILE__) + '/vendor/thor-0.12.3/lib'
|
|
3
|
+
|
|
4
|
+
require 'daemon_kit/generators/base'
|
|
5
|
+
|
|
6
|
+
module DaemonKit
|
|
7
|
+
module Generators
|
|
8
|
+
autoload :AppGenerator, 'generators/daemon_kit/app/app_generator'
|
|
9
|
+
autoload :CucumberGenerator, 'generators/daemon_kit/cucumber/cucumber_generator'
|
|
10
|
+
autoload :AmqpGenerator, 'generators/daemon_kit/amqp/amqp_generator'
|
|
11
|
+
autoload :CronGenerator, 'generators/daemon_kit/cron/cron_generator'
|
|
12
|
+
autoload :CapistranoGenerator, 'generators/daemon_kit/capistrano/capistrano_generator'
|
|
13
|
+
autoload :NaniteAgentGenerator, 'generators/daemon_kit/nanite_agent/nanite_agent_generator'
|
|
14
|
+
autoload :SpecGenerator, 'generators/daemon_kit/rspec/rspec_generator'
|
|
15
|
+
autoload :TestUnitGenerator, 'generators/daemon_kit/test_unit/test_unit_generator'
|
|
16
|
+
autoload :RuoteGenerator, 'generators/daemon_kit/ruote/ruote_generator'
|
|
17
|
+
autoload :XmppGenerator, 'generators/daemon_kit/xmpp/xmpp_generator'
|
|
18
|
+
|
|
19
|
+
class << self
|
|
20
|
+
|
|
21
|
+
def configure!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def invoke( namespace, args = ARGV, config = {} )
|
|
25
|
+
klass_name = constants.detect do |sym|
|
|
26
|
+
klass = const_get( sym )
|
|
27
|
+
klass.respond_to?( :namespace ) && klass.namespace == namespace
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if klass_name.nil?
|
|
31
|
+
raise Error, "Could not find generator #{namespace}."
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
klass = const_get( klass_name )
|
|
35
|
+
|
|
36
|
+
args << '--help' if args.empty? && klass.arguments.any? { |a| a.required? }
|
|
37
|
+
klass.start( args, config )
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def help
|
|
41
|
+
namespaces = constants.inject([]) do |list, sym|
|
|
42
|
+
unless sym == :Base || sym == :AppGenerator
|
|
43
|
+
klass = const_get( sym )
|
|
44
|
+
list << klass.namespace if klass.respond_to?( :namespace )
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
list
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
puts "Usage:"
|
|
51
|
+
puts " script/generate GENERATOR [args] [options]"
|
|
52
|
+
puts
|
|
53
|
+
puts "General options:"
|
|
54
|
+
puts " -h, [--help] # Print generators options and usage"
|
|
55
|
+
puts " -p, [--pretend] # Run but do not make any changes"
|
|
56
|
+
puts " -f, [--force] # Overwrite files that already exist"
|
|
57
|
+
puts " -s, [--skip] # Skip files that already exist"
|
|
58
|
+
puts " -q, [--quiet] # Supress status output"
|
|
59
|
+
puts
|
|
60
|
+
puts "Available generators:"
|
|
61
|
+
|
|
62
|
+
namespaces.each { |ns| puts " " + ns }
|
|
63
|
+
puts
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
|
|
3
|
+
module DaemonKit
|
|
4
|
+
module Generators
|
|
5
|
+
class Error < Thor::Error
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class Base < Thor::Group
|
|
9
|
+
include Thor::Actions
|
|
10
|
+
|
|
11
|
+
add_runtime_options!
|
|
12
|
+
|
|
13
|
+
# Tries to get the description from a USAGE file one folder above the source
|
|
14
|
+
# root otherwise uses a default description.
|
|
15
|
+
def self.desc(description=nil)
|
|
16
|
+
return super if description
|
|
17
|
+
usage = File.expand_path(File.join(source_root, "..", "USAGE"))
|
|
18
|
+
|
|
19
|
+
@desc ||= if File.exist?(usage)
|
|
20
|
+
File.read(usage)
|
|
21
|
+
else
|
|
22
|
+
"Description:\n Create #{base_name.humanize.downcase} files for #{generator_name} generator."
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
protected
|
|
27
|
+
|
|
28
|
+
def app_name
|
|
29
|
+
@app_name = File.basename( destination_root )
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Small macro to add ruby as an option to the generator with proper
|
|
33
|
+
# default value plus an instance helper method called shebang.
|
|
34
|
+
#
|
|
35
|
+
def self.add_shebang_option!
|
|
36
|
+
class_option :ruby, :type => :string, :aliases => "-r", :default => Thor::Util.ruby_command,
|
|
37
|
+
:desc => "Path to the Ruby binary of your choice", :banner => "PATH"
|
|
38
|
+
|
|
39
|
+
no_tasks {
|
|
40
|
+
define_method :shebang do
|
|
41
|
+
@shebang ||= begin
|
|
42
|
+
command = if options[:ruby] == Thor::Util.ruby_command
|
|
43
|
+
"/usr/bin/env #{File.basename(Thor::Util.ruby_command)}"
|
|
44
|
+
else
|
|
45
|
+
options[:ruby]
|
|
46
|
+
end
|
|
47
|
+
"#!#{command}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.namespace(name = nil)
|
|
54
|
+
return super if name
|
|
55
|
+
@namespace ||= super.sub(/_generator$/, '').sub(/:generators:/, ':').sub(/^daemon_kit:/, '')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -445,7 +445,7 @@ module DaemonKit
|
|
|
445
445
|
# arguments to be parsed cause they will interfere with the
|
|
446
446
|
# script encapsulating DaemonKit, like capistrano
|
|
447
447
|
def own_args?
|
|
448
|
-
|
|
448
|
+
!%w( rake cap spec cucumber ).include?( File.basename( $0 ) )
|
|
449
449
|
end
|
|
450
450
|
end
|
|
451
451
|
|
data/lib/daemon_kit/jabber.rb
CHANGED
|
@@ -76,7 +76,7 @@ namespace :daemon_kit do
|
|
|
76
76
|
desc "Upgrade your local files for a daemon after upgrading daemon-kit"
|
|
77
77
|
task :upgrade => 'environment' do
|
|
78
78
|
# Run these
|
|
79
|
-
%w{ initializers rakefile scripts }.each do |t|
|
|
79
|
+
%w{ initializers rakefile scripts gemfile }.each do |t|
|
|
80
80
|
Rake::Task["daemon_kit:upgrade:#{t}"].invoke
|
|
81
81
|
end
|
|
82
82
|
|
|
@@ -111,6 +111,11 @@ namespace :daemon_kit do
|
|
|
111
111
|
copy_framework_template( "script", s )
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
|
+
|
|
115
|
+
# Upgrade the Gemfile
|
|
116
|
+
task :gemfile do
|
|
117
|
+
copy_framework_template( 'Gemfile' )
|
|
118
|
+
end
|
|
114
119
|
end
|
|
115
120
|
end
|
|
116
121
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
== 0.12, released 2010-01-02
|
|
2
|
+
|
|
3
|
+
* Removed rr in favor to rspec mock framework
|
|
4
|
+
* Improved output for thor -T
|
|
5
|
+
* [#7] Do not force white color on status
|
|
6
|
+
* [#8] Yield a block with the filename on directory
|
|
7
|
+
|
|
8
|
+
== 0.11, released 2009-07-01
|
|
9
|
+
|
|
10
|
+
* Added a rake compatibility layer. It allows you to use spec and rdoc tasks on
|
|
11
|
+
Thor classes.
|
|
12
|
+
|
|
13
|
+
* BACKWARDS INCOMPATIBLE: aliases are not generated automatically anymore
|
|
14
|
+
since it wrong behavior to the invocation system.
|
|
15
|
+
|
|
16
|
+
* thor help now show information about any class/task. All those calls are
|
|
17
|
+
possible:
|
|
18
|
+
|
|
19
|
+
thor help describe
|
|
20
|
+
thor help describe:amazing
|
|
21
|
+
|
|
22
|
+
Or even with default namespaces:
|
|
23
|
+
|
|
24
|
+
thor help :spec
|
|
25
|
+
|
|
26
|
+
* Thor::Runner now invokes the default task if none is supplied:
|
|
27
|
+
|
|
28
|
+
thor describe # invokes the default task, usually help
|
|
29
|
+
|
|
30
|
+
* Thor::Runner now works with mappings:
|
|
31
|
+
|
|
32
|
+
thor describe -h
|
|
33
|
+
|
|
34
|
+
* Added some documentation and code refactoring.
|
|
35
|
+
|
|
36
|
+
== 0.9.8, released 2008-10-20
|
|
37
|
+
|
|
38
|
+
* Fixed some tiny issues that were introduced lately.
|
|
39
|
+
|
|
40
|
+
== 0.9.7, released 2008-10-13
|
|
41
|
+
|
|
42
|
+
* Setting global method options on the initialize method works as expected:
|
|
43
|
+
All other tasks will accept these global options in addition to their own.
|
|
44
|
+
* Added 'group' notion to Thor task sets (class Thor); by default all tasks
|
|
45
|
+
are in the 'standard' group. Running 'thor -T' will only show the standard
|
|
46
|
+
tasks - adding --all will show all tasks. You can also filter on a specific
|
|
47
|
+
group using the --group option: thor -T --group advanced
|
|
48
|
+
|
|
49
|
+
== 0.9.6, released 2008-09-13
|
|
50
|
+
|
|
51
|
+
* Generic improvements
|
|
52
|
+
|
|
53
|
+
== 0.9.5, released 2008-08-27
|
|
54
|
+
|
|
55
|
+
* Improve Windows compatibility
|
|
56
|
+
* Update (incorrect) README and task.thor sample file
|
|
57
|
+
* Options hash is now frozen (once returned)
|
|
58
|
+
* Allow magic predicates on options object. For instance: `options.force?`
|
|
59
|
+
* Add support for :numeric type
|
|
60
|
+
* BACKWARDS INCOMPATIBLE: Refactor Thor::Options. You cannot access shorthand forms in options hash anymore (for instance, options[:f])
|
|
61
|
+
* Allow specifying optional args with default values: method_options(:user => "mislav")
|
|
62
|
+
* Don't write options for nil or false values. This allows, for example, turning color off when running specs.
|
|
63
|
+
* Exit with the status of the spec command to help CI stuff out some.
|
|
64
|
+
|
|
65
|
+
== 0.9.4, released 2008-08-13
|
|
66
|
+
|
|
67
|
+
* Try to add Windows compatibility.
|
|
68
|
+
* BACKWARDS INCOMPATIBLE: options hash is now accessed as a property in your class and is not passed as last argument anymore
|
|
69
|
+
* Allow options at the beginning of the argument list as well as the end.
|
|
70
|
+
* Make options available with symbol keys in addition to string keys.
|
|
71
|
+
* Allow true to be passed to Thor#method_options to denote a boolean option.
|
|
72
|
+
* If loading a thor file fails, don't give up, just print a warning and keep going.
|
|
73
|
+
* Make sure that we re-raise errors if they happened further down the pipe than we care about.
|
|
74
|
+
* Only delete the old file on updating when the installation of the new one is a success
|
|
75
|
+
* Make it Ruby 1.8.5 compatible.
|
|
76
|
+
* Don't raise an error if a boolean switch is defined multiple times.
|
|
77
|
+
* Thor::Options now doesn't parse through things that look like options but aren't.
|
|
78
|
+
* Add URI detection to install task, and make sure we don't append ".thor" to URIs
|
|
79
|
+
* Add rake2thor to the gem binfiles.
|
|
80
|
+
* Make sure local Thorfiles override system-wide ones.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 Yehuda Katz
|
|
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.
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
= thor
|
|
2
|
+
|
|
3
|
+
Map options to a class. Simply create a class with the appropriate annotations
|
|
4
|
+
and have options automatically map to functions and parameters.
|
|
5
|
+
|
|
6
|
+
Example:
|
|
7
|
+
|
|
8
|
+
class App < Thor # [1]
|
|
9
|
+
map "-L" => :list # [2]
|
|
10
|
+
|
|
11
|
+
desc "install APP_NAME", "install one of the available apps" # [3]
|
|
12
|
+
method_options :force => :boolean, :alias => :string # [4]
|
|
13
|
+
def install(name)
|
|
14
|
+
user_alias = options[:alias]
|
|
15
|
+
if options.force?
|
|
16
|
+
# do something
|
|
17
|
+
end
|
|
18
|
+
# other code
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc "list [SEARCH]", "list all of the available apps, limited by SEARCH"
|
|
22
|
+
def list(search="")
|
|
23
|
+
# list everything
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Thor automatically maps commands as such:
|
|
28
|
+
|
|
29
|
+
thor app:install myname --force
|
|
30
|
+
|
|
31
|
+
That gets converted to:
|
|
32
|
+
|
|
33
|
+
App.new.install("myname")
|
|
34
|
+
# with {'force' => true} as options hash
|
|
35
|
+
|
|
36
|
+
1. Inherit from Thor to turn a class into an option mapper
|
|
37
|
+
2. Map additional non-valid identifiers to specific methods. In this case, convert -L to :list
|
|
38
|
+
3. Describe the method immediately below. The first parameter is the usage information, and the second parameter is the description
|
|
39
|
+
4. Provide any additional options that will be available the instance method options.
|
|
40
|
+
|
|
41
|
+
== Types for <tt>method_options</tt>
|
|
42
|
+
|
|
43
|
+
* :boolean - is parsed as <tt>--option</tt> or <tt>--option=true</tt>
|
|
44
|
+
* :string - is parsed as <tt>--option=VALUE</tt>
|
|
45
|
+
* :numeric - is parsed as <tt>--option=N</tt>
|
|
46
|
+
* :array - is parsed as <tt>--option=one two three</tt>
|
|
47
|
+
* :hash - is parsed as <tt>--option=name:string age:integer</tt>
|
|
48
|
+
|
|
49
|
+
Besides, method_option allows a default value to be given, examples:
|
|
50
|
+
|
|
51
|
+
method_options :force => false
|
|
52
|
+
#=> Creates a boolean option with default value false
|
|
53
|
+
|
|
54
|
+
method_options :alias => "bar"
|
|
55
|
+
#=> Creates a string option with default value "bar"
|
|
56
|
+
|
|
57
|
+
method_options :threshold => 3.0
|
|
58
|
+
#=> Creates a numeric option with default value 3.0
|
|
59
|
+
|
|
60
|
+
You can also supply <tt>:option => :required</tt> to mark an option as required. The
|
|
61
|
+
type is assumed to be string. If you want a required hash with default values
|
|
62
|
+
as option, you can use <tt>method_option</tt> which uses a more declarative style:
|
|
63
|
+
|
|
64
|
+
method_option :attributes, :type => :hash, :default => {}, :required => true
|
|
65
|
+
|
|
66
|
+
All arguments can be set to nil (except required arguments), by suppling a no or
|
|
67
|
+
skip variant. For example:
|
|
68
|
+
|
|
69
|
+
thor app name --no-attributes
|
|
70
|
+
|
|
71
|
+
In previous versions, aliases for options were created automatically, but now
|
|
72
|
+
they should be explicit. You can supply aliases in both short and declarative
|
|
73
|
+
styles:
|
|
74
|
+
|
|
75
|
+
method_options %w( force -f ) => :boolean
|
|
76
|
+
|
|
77
|
+
Or:
|
|
78
|
+
|
|
79
|
+
method_option :force, :type => :boolean, :aliases => "-f"
|
|
80
|
+
|
|
81
|
+
You can supply as many aliases as you want.
|
|
82
|
+
|
|
83
|
+
NOTE: Type :optional available in Thor 0.9.0 was deprecated. Use :string or :boolean instead.
|
|
84
|
+
|
|
85
|
+
== Namespaces
|
|
86
|
+
|
|
87
|
+
By default, your Thor tasks are invoked using Ruby namespace. In the example
|
|
88
|
+
above, tasks are invoked as:
|
|
89
|
+
|
|
90
|
+
thor app:install name --force
|
|
91
|
+
|
|
92
|
+
However, you could namespace your class as:
|
|
93
|
+
|
|
94
|
+
module Sinatra
|
|
95
|
+
class App < Thor
|
|
96
|
+
# tasks
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
And then you should invoke your tasks as:
|
|
101
|
+
|
|
102
|
+
thor sinatra:app:install name --force
|
|
103
|
+
|
|
104
|
+
If desired, you can change the namespace:
|
|
105
|
+
|
|
106
|
+
module Sinatra
|
|
107
|
+
class App < Thor
|
|
108
|
+
namespace :myapp
|
|
109
|
+
# tasks
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
And then your tasks hould be invoked as:
|
|
114
|
+
|
|
115
|
+
thor myapp:install name --force
|
|
116
|
+
|
|
117
|
+
== Invocations
|
|
118
|
+
|
|
119
|
+
Thor comes with a invocation-dependency system as well which allows a task to be
|
|
120
|
+
invoked only once. For example:
|
|
121
|
+
|
|
122
|
+
class Counter < Thor
|
|
123
|
+
desc "one", "Prints 1, 2, 3"
|
|
124
|
+
def one
|
|
125
|
+
puts 1
|
|
126
|
+
invoke :two
|
|
127
|
+
invoke :three
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
desc "two", "Prints 2, 3"
|
|
131
|
+
def two
|
|
132
|
+
puts 2
|
|
133
|
+
invoke :three
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
desc "three", "Prints 3"
|
|
137
|
+
def three
|
|
138
|
+
puts 3
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
When invoking the task one:
|
|
143
|
+
|
|
144
|
+
thor counter:one
|
|
145
|
+
|
|
146
|
+
The output is "1 2 3", which means that the three task was invoked only once.
|
|
147
|
+
You can even invoke tasks from another class, so be sure to check the
|
|
148
|
+
documentation.
|
|
149
|
+
|
|
150
|
+
== Thor::Group
|
|
151
|
+
|
|
152
|
+
Thor has a special class called Thor::Group. The main difference to Thor class
|
|
153
|
+
is that it invokes all tasks at once. The example above could be rewritten in
|
|
154
|
+
Thor::Group as this:
|
|
155
|
+
|
|
156
|
+
class Counter < Thor::Group
|
|
157
|
+
desc "Prints 1, 2, 3"
|
|
158
|
+
|
|
159
|
+
def one
|
|
160
|
+
puts 1
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def two
|
|
164
|
+
puts 2
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def three
|
|
168
|
+
puts 3
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
When invoked:
|
|
173
|
+
|
|
174
|
+
thor counter
|
|
175
|
+
|
|
176
|
+
It prints "1 2 3" as well. Notice you should describe (using the method <tt>desc</tt>)
|
|
177
|
+
only the class and not each task anymore. Thor::Group is a great tool to create
|
|
178
|
+
generators, since you can define several steps which are invoked in the order they
|
|
179
|
+
are defined (Thor::Group is the tool use in generators in Rails 3.0).
|
|
180
|
+
|
|
181
|
+
Besides, Thor::Group can parse arguments and options as Thor tasks:
|
|
182
|
+
|
|
183
|
+
class Counter < Thor::Group
|
|
184
|
+
# number will be available as attr_accessor
|
|
185
|
+
argument :number, :type => :numeric, :desc => "The number to start counting"
|
|
186
|
+
desc "Prints the 'number' given upto 'number+2'"
|
|
187
|
+
|
|
188
|
+
def one
|
|
189
|
+
puts number + 0
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def two
|
|
193
|
+
puts number + 1
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def three
|
|
197
|
+
puts number + 2
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
The counter above expects one parameter and has the folling outputs:
|
|
202
|
+
|
|
203
|
+
thor counter 5
|
|
204
|
+
# Prints "5 6 7"
|
|
205
|
+
|
|
206
|
+
thor counter 11
|
|
207
|
+
# Prints "11 12 13"
|
|
208
|
+
|
|
209
|
+
You can also give options to Thor::Group, but instead of using <tt>method_option</tt>
|
|
210
|
+
and <tt>method_options</tt>, you should use <tt>class_option</tt> and <tt>class_options</tt>.
|
|
211
|
+
Both argument and class_options methods are available to Thor class as well.
|
|
212
|
+
|
|
213
|
+
== Actions
|
|
214
|
+
|
|
215
|
+
Thor comes with several actions which helps with script and generator tasks. You
|
|
216
|
+
might be familiar with them since some came from Rails Templates. They are:
|
|
217
|
+
<tt>say</tt>, <tt>ask</tt>, <tt>yes?</tt>, <tt>no?</tt>, <tt>add_file</tt>,
|
|
218
|
+
<tt>remove_file</tt>, <tt>copy_file</tt>, <tt>template</tt>, <tt>directory</tt>,
|
|
219
|
+
<tt>inside</tt>, <tt>run</tt>, <tt>inject_into_file</tt> and a couple more.
|
|
220
|
+
|
|
221
|
+
To use them, you just need to include Thor::Actions in your Thor classes:
|
|
222
|
+
|
|
223
|
+
class App < Thor
|
|
224
|
+
include Thor::Actions
|
|
225
|
+
# tasks
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
Some actions like copy file requires that a class method called source_root is
|
|
229
|
+
defined in your class. This is the directory where your templates should be
|
|
230
|
+
placed. Be sure to check the documentation.
|
|
231
|
+
|
|
232
|
+
== License
|
|
233
|
+
|
|
234
|
+
See MIT LICENSE.
|