capistrano-ext-params 0.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.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/.gemtest ADDED
File without changes
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2011-09-05
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday! :required added to task options. ensured before task execution.
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,6 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/capistrano/ext/params.rb
data/README.txt ADDED
@@ -0,0 +1,73 @@
1
+ = capistrano-ext-params
2
+
3
+ http://github.com/andynu/capistrano-ext-params
4
+
5
+ == DESCRIPTION:
6
+
7
+ This package adds optional and required params to capistrano.
8
+
9
+ All required parameters are ensured to have a non-null value before the task executes, and all optional parameters will be validated against their :values.
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ * PROBLEM: not released
14
+
15
+ == SYNOPSIS:
16
+
17
+ # please wait until 1.0
18
+ # this is the goal, not the current state of things.
19
+
20
+ task :name, :roles => :server,
21
+ :required => {
22
+ :first_param => {
23
+ :type => :string,
24
+ :values => %w[ value_one value_two value_three]
25
+ }
26
+ },
27
+ :optional => {
28
+ :second_param => {
29
+ :type => :number
30
+ }
31
+ } do
32
+
33
+ == REQUIREMENTS:
34
+
35
+ * capistrano
36
+
37
+ == INSTALL:
38
+
39
+ * gem install 'capistrano-ext-required-params'
40
+
41
+ == DEVELOPERS:
42
+
43
+ After checking out the source, run:
44
+
45
+ $ rake newb
46
+
47
+ This task will install any missing dependencies, run the tests/specs,
48
+ and generate the RDoc.
49
+
50
+ == LICENSE:
51
+
52
+ (The MIT License)
53
+
54
+ Copyright (c) 2011 FIX
55
+
56
+ Permission is hereby granted, free of charge, to any person obtaining
57
+ a copy of this software and associated documentation files (the
58
+ 'Software'), to deal in the Software without restriction, including
59
+ without limitation the rights to use, copy, modify, merge, publish,
60
+ distribute, sublicense, and/or sell copies of the Software, and to
61
+ permit persons to whom the Software is furnished to do so, subject to
62
+ the following conditions:
63
+
64
+ The above copyright notice and this permission notice shall be
65
+ included in all copies or substantial portions of the Software.
66
+
67
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
68
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
69
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
70
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
71
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
72
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
73
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ # Hoe.plugin :compiler
7
+ # Hoe.plugin :gem_prelude_sucks
8
+ # Hoe.plugin :inline
9
+ # Hoe.plugin :racc
10
+ # Hoe.plugin :rubyforge
11
+ Hoe.plugin :gemcutter
12
+
13
+ Hoe.spec 'capistrano-ext-params' do
14
+ developer('Andrew Nutter-Upham', 'andynu@.com')
15
+
16
+ # self.rubyforge_name = 'capistrano-ext-paramsx' # if different than 'capistrano-ext-params'
17
+ extra_deps << ['capistrano','>= 0']
18
+ extra_deps << ['capistrano-ext-set-helpers',' >= 0']
19
+ end
20
+
21
+ # vim: syntax=ruby
@@ -0,0 +1,121 @@
1
+ require 'capistrano'
2
+ class CapistranoExtParams
3
+ VERSION = '0.1.0'
4
+ end
5
+
6
+ module Capistrano
7
+ class TaskDefinition
8
+ alias_method :original_brief_description, :brief_description
9
+ def brief_description(max_length=nil)
10
+ brief = original_brief_description(max_length)
11
+ unless @options.nil? || @options[:required_params].nil? || @options[:required_params].empty?
12
+ brief << " " * (max_length-brief.length) if max_length > brief.length
13
+ brief << "requires " + @options[:required_params].join(",")
14
+ end
15
+ brief
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+ module Capistrano
22
+ class Configuration
23
+ module Execution
24
+
25
+ def ensure_params(params=[])
26
+ params = [ params ].flatten
27
+
28
+ # Query user for any undefined variables
29
+ params.each do |param|
30
+ param_desc = $parameter_descriptions[param] || "value for #{param}"
31
+ unless exists?(param)
32
+ set_ask( param, "#{param} - #{param_desc}: " )
33
+ end
34
+
35
+ puts " %s: %s" % [param, fetch(param)]
36
+ end
37
+ end
38
+
39
+ alias_method :original_execute_task, :execute_task
40
+ def execute_task(task)
41
+ puts " options #{task.options}"
42
+ ensure_params(task.options[:required_params]) if task.options[:required_params]
43
+ original_execute_task(task)
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+ end
50
+
51
+ module Capistrano
52
+ class CLI
53
+ module Help
54
+ #alias_method :original_explain_task, :explain_task
55
+
56
+ def explain_task(config,name)
57
+
58
+ def print( task )
59
+ puts "-"*HEADER_LEN
60
+ puts "Usage:\n\tcap %s %s %s" % [
61
+ $recipe,
62
+ task.fully_qualified_name,
63
+ [
64
+ [task.options[:required_params]].flatten.compact.map {|param| " %s=ARG" % [param] },
65
+ [task.options[:optional_params]].flatten.compact.map {|param| " [%s=ARG]" % [param] }
66
+ ].flatten.join()
67
+ ]
68
+ puts "-"*HEADER_LEN
69
+ puts format_text(task.description)
70
+ puts "-"*HEADER_LEN
71
+ if task.options[:required_params]
72
+ puts "Required Parameters"
73
+ task.options[:required_params].each do |param|
74
+ param_desc = $parameter_descriptions[param] || param
75
+ puts "\t#{param} - #{param_desc}"
76
+ end
77
+ end
78
+ if task.options[:optional_params]
79
+ puts "Optional Parameters"
80
+ task.options[:optional_params].each do |param|
81
+ param_details = $optional_parameter_descriptions[param]
82
+ if param_details
83
+ param_desc = "#{param_details[:desc]} (default=#{param_details[:default]})"
84
+ else
85
+ param_desc = param
86
+ end
87
+ puts "\t#{param} - #{param_desc}"
88
+ end
89
+ end
90
+ end
91
+
92
+ task = config.find_task(name)
93
+
94
+ # if name is for a namespace, then explain all tasks in namespace
95
+ if task.nil?
96
+ # Following logic adapted from Namespaces#find_task
97
+ parts = name.to_s.split(/:/)
98
+
99
+ ns = config
100
+ until parts.empty?
101
+ next_part = parts.shift
102
+ ns = next_part.empty? ? nil : ns.namespaces[next_part.to_sym]
103
+ return nil if ns.nil?
104
+ end
105
+
106
+ # print each task
107
+ ns.tasks.each do |_name,_task|
108
+ print( task )
109
+ puts "\n\n"
110
+ end
111
+
112
+ else
113
+ print( task )
114
+ end
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+
121
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-ext-params
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Nutter-Upham
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: &11150400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *11150400
25
+ - !ruby/object:Gem::Dependency
26
+ name: capistrano-ext-set-helpers
27
+ requirement: &11149740 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *11149740
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ requirement: &11148980 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.12'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *11148980
47
+ description: ! 'This package adds optional and required params to capistrano.
48
+
49
+
50
+ All required parameters are ensured to have a non-null value before the task executes,
51
+ and all optional parameters will be validated against their :values.'
52
+ email:
53
+ - andynu@.com
54
+ executables: []
55
+ extensions: []
56
+ extra_rdoc_files:
57
+ - History.txt
58
+ - Manifest.txt
59
+ - README.txt
60
+ files:
61
+ - .autotest
62
+ - History.txt
63
+ - Manifest.txt
64
+ - README.txt
65
+ - Rakefile
66
+ - lib/capistrano/ext/params.rb
67
+ - .gemtest
68
+ homepage: http://github.com/andynu/capistrano-ext-params
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --main
73
+ - README.txt
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project: capistrano-ext-params
90
+ rubygems_version: 1.8.10
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: This package adds optional and required params to capistrano
94
+ test_files: []