sprout 0.7.220-x86-darwin-10
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprout might be problematic. Click here for more details.
- data/MIT-LICENSE +20 -0
- data/TODO +12 -0
- data/bin/sprout +128 -0
- data/doc/Bundle +14 -0
- data/doc/Generator +35 -0
- data/doc/Library +63 -0
- data/doc/Task +21 -0
- data/doc/Tool +20 -0
- data/lib/platform.rb +109 -0
- data/lib/progress_bar.rb +354 -0
- data/lib/sprout/archive_unpacker.rb +225 -0
- data/lib/sprout/builder.rb +44 -0
- data/lib/sprout/commands/generate.rb +9 -0
- data/lib/sprout/dynamic_accessors.rb +34 -0
- data/lib/sprout/general_tasks.rb +6 -0
- data/lib/sprout/generator/base_mixins.rb +186 -0
- data/lib/sprout/generator/named_base.rb +227 -0
- data/lib/sprout/generator.rb +7 -0
- data/lib/sprout/log.rb +46 -0
- data/lib/sprout/process_runner.rb +111 -0
- data/lib/sprout/project_model.rb +278 -0
- data/lib/sprout/remote_file_loader.rb +71 -0
- data/lib/sprout/remote_file_target.rb +151 -0
- data/lib/sprout/simple_resolver.rb +88 -0
- data/lib/sprout/tasks/erb_resolver.rb +118 -0
- data/lib/sprout/tasks/gem_wrap_task.rb +200 -0
- data/lib/sprout/tasks/git_task.rb +134 -0
- data/lib/sprout/tasks/library_task.rb +118 -0
- data/lib/sprout/tasks/sftp_task.rb +248 -0
- data/lib/sprout/tasks/ssh_task.rb +153 -0
- data/lib/sprout/tasks/tool_task.rb +793 -0
- data/lib/sprout/tasks/zip_task.rb +158 -0
- data/lib/sprout/template_resolver.rb +207 -0
- data/lib/sprout/user.rb +383 -0
- data/lib/sprout/version.rb +12 -0
- data/lib/sprout/version_file.rb +89 -0
- data/lib/sprout/zip_util.rb +61 -0
- data/lib/sprout.rb +496 -0
- data/rakefile.rb +150 -0
- data/samples/gem_wrap/rakefile.rb +17 -0
- metadata +174 -0
@@ -0,0 +1,153 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2007 Pattern Park
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
This class has been commented out because the termios feature
|
24
|
+
that allows users to more securely enter passwords does not
|
25
|
+
work in a DOS shell.
|
26
|
+
|
27
|
+
It would be greatly appreciate if someone refactored this to either:
|
28
|
+
a) Get the same functionality in a cross-platform manner
|
29
|
+
b) Only require and use termios on systems that allow it
|
30
|
+
=end
|
31
|
+
|
32
|
+
#gem 'net-ssh', '1.1.4'
|
33
|
+
#gem 'net-sftp', '1.1.1'
|
34
|
+
|
35
|
+
require 'net/ssh'
|
36
|
+
require 'net/sftp'
|
37
|
+
#require 'termios'
|
38
|
+
|
39
|
+
module Sprout
|
40
|
+
class SSHError < StandardError #:nodoc:
|
41
|
+
end
|
42
|
+
|
43
|
+
# The SSHTask allows you to execute arbitrary commands on a remote host.
|
44
|
+
#
|
45
|
+
# ssh :update_gem_index do |t|
|
46
|
+
# t.host = 'dev.projectsprouts.com'
|
47
|
+
# t.username = 'someUser'
|
48
|
+
# t.commands << 'cd /var/www/projectsprouts/current/gems'
|
49
|
+
# t.commands << 'gem generate_index -d .'
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
class SSHTask < Rake::Task
|
53
|
+
|
54
|
+
# Host name of the server to connect to with no protocol prefix, like: sub.yourhost.com
|
55
|
+
attr_accessor :host
|
56
|
+
# Array of commands that will be executed on the remote machine
|
57
|
+
attr_accessor :commands
|
58
|
+
# Username to send to the remote host. You will be prompted for this value if it is left null.
|
59
|
+
attr_accessor :username
|
60
|
+
# Password to send to the remote host. You will be prompted for this value if it is left null.
|
61
|
+
#
|
62
|
+
# NOTE: You should never check a file into version control with this field filled in, it is
|
63
|
+
# provided here as a convenience for getting set up.
|
64
|
+
attr_accessor :password
|
65
|
+
|
66
|
+
def initialize(task_name, app)
|
67
|
+
super(task_name, app)
|
68
|
+
@name = name
|
69
|
+
@host = nil
|
70
|
+
@queue = []
|
71
|
+
@commands = []
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.define_task(args, &block) # :nodoc:
|
75
|
+
t = super
|
76
|
+
yield t if block_given?
|
77
|
+
end
|
78
|
+
|
79
|
+
def execute(*args) # :nodoc:
|
80
|
+
if(@host.nil?)
|
81
|
+
throw SSHError.new('SSH requires a valid host parameter')
|
82
|
+
end
|
83
|
+
|
84
|
+
if(@username.nil?)
|
85
|
+
print "Username: "
|
86
|
+
@username = $stdin.gets.chomp!
|
87
|
+
raise SFTPError.new('SFTP requires username parameter') unless @username
|
88
|
+
end
|
89
|
+
|
90
|
+
if(@password.nil?)
|
91
|
+
print "Password: "
|
92
|
+
@password = $stdin.gets.chomp!
|
93
|
+
# @password = Password.get
|
94
|
+
raise SFTPError.new('SFTP requires password parameter') unless @password
|
95
|
+
end
|
96
|
+
|
97
|
+
puts ">> Connecting to Remote Server: #{@username}@#{@host}:#{@remote_path}"
|
98
|
+
Net::SSH.start(@host, @username, @password) do |session|
|
99
|
+
session.open_channel do |channel|
|
100
|
+
commands.each do |command|
|
101
|
+
puts ">> #{command}"
|
102
|
+
channel.exec command
|
103
|
+
end
|
104
|
+
channel.close
|
105
|
+
end
|
106
|
+
session.loop
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
=begin
|
113
|
+
# The following implementation does not work at all on DOS machines,
|
114
|
+
# is there a cross-platform way to solve the secure password prompt problem?
|
115
|
+
# Password handling snippet found at: http://www.caliban.org/ruby/ruby-password.shtml
|
116
|
+
class Password
|
117
|
+
|
118
|
+
def Password.get(message="Password: ")
|
119
|
+
begin
|
120
|
+
if $stdin.tty?
|
121
|
+
Password.echo false
|
122
|
+
print message if message
|
123
|
+
end
|
124
|
+
|
125
|
+
return $stdin.gets.chomp
|
126
|
+
ensure
|
127
|
+
if $stdin.tty?
|
128
|
+
Password.echo true
|
129
|
+
print "\n"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def Password.echo(on=true, masked=false)
|
135
|
+
term = Termios::getattr( $stdin )
|
136
|
+
|
137
|
+
if on
|
138
|
+
term.c_lflag |= ( Termios::ECHO | Termios::ICANON )
|
139
|
+
else # off
|
140
|
+
term.c_lflag &= ~Termios::ECHO
|
141
|
+
term.c_lflag &= ~Termios::ICANON if masked
|
142
|
+
end
|
143
|
+
|
144
|
+
Termios::setattr( $stdin, Termios::TCSANOW, term )
|
145
|
+
end
|
146
|
+
end
|
147
|
+
=end
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
def ssh(args, &block)
|
152
|
+
Sprout::SSHTask.define_task(args, &block)
|
153
|
+
end
|