william 0.3.1
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +31 -0
- data/Rakefile +3 -0
- data/bin/will +12 -0
- data/lib/william/commands.rb +55 -0
- data/lib/william/runner.rb +30 -0
- data/lib/william/version.rb +3 -0
- data/lib/william.rb +4 -0
- data/william.gemspec +21 -0
- metadata +75 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
William
|
2
|
+
=======
|
3
|
+
|
4
|
+
A DSL to interact with your server via SSH
|
5
|
+
|
6
|
+
Example
|
7
|
+
-------
|
8
|
+
|
9
|
+
Here is an example Willfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
$remotes = ['user@host.com']
|
13
|
+
|
14
|
+
def deploy
|
15
|
+
test
|
16
|
+
puts "I'm deploying!!!"
|
17
|
+
run "ls -la"
|
18
|
+
local "ls -la"
|
19
|
+
end
|
20
|
+
|
21
|
+
def test
|
22
|
+
puts "I'm testing!!!"
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
Run the 'deploy' task with `will deploy` , or just the 'test' task with (you've
|
27
|
+
guessed it) `will test`.
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
data/Rakefile
ADDED
data/bin/will
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module William
|
2
|
+
class Commands
|
3
|
+
|
4
|
+
def initialize(host, debug=false)
|
5
|
+
@debug = debug
|
6
|
+
@host = host
|
7
|
+
@current_command = nil
|
8
|
+
@current_command_type = nil
|
9
|
+
@start_pwd = @current_pwd = _get_pwd
|
10
|
+
end
|
11
|
+
|
12
|
+
def local(command)
|
13
|
+
@command_argument = command
|
14
|
+
_output(:localhost, :local, "#{command}")
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(command)
|
18
|
+
@command_argument = command
|
19
|
+
_output(@host, :run, "ssh #{@host} 'cd #{@current_pwd} && #{command}'")
|
20
|
+
end
|
21
|
+
|
22
|
+
def cd(directory)
|
23
|
+
command = "cd #{directory}"
|
24
|
+
|
25
|
+
@command_argument = directory
|
26
|
+
_output(@host, :cd, "ssh #{@host} '#{command}'")
|
27
|
+
|
28
|
+
@current_pwd = directory
|
29
|
+
yield if block_given?
|
30
|
+
@current_pwd = @start_pwd
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def _execute(command)
|
36
|
+
`#{command}`
|
37
|
+
end
|
38
|
+
|
39
|
+
def _output(host, cmd_type, command)
|
40
|
+
puts "[#{host}] #{cmd_type}: #{@command_argument}"
|
41
|
+
@current_command_type = cmd_type
|
42
|
+
@current_command = command
|
43
|
+
output = _execute(command)
|
44
|
+
puts output.split("\n").map{|line| "[#{host}] out: #{line}" }
|
45
|
+
output # return the output!
|
46
|
+
end
|
47
|
+
|
48
|
+
def _get_pwd
|
49
|
+
`ssh #{@host} 'echo $PWD'`.strip
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module William
|
2
|
+
class Runner
|
3
|
+
def initialize(file_path, debug=false)
|
4
|
+
@debug = debug
|
5
|
+
@file_path = file_path
|
6
|
+
end
|
7
|
+
|
8
|
+
def run(args)
|
9
|
+
file_content = File.open(@file_path).read
|
10
|
+
|
11
|
+
create_class "MyCommands", Commands do
|
12
|
+
self.class_eval file_content
|
13
|
+
end
|
14
|
+
|
15
|
+
$remotes.each do |remote|
|
16
|
+
args.each do |arg|
|
17
|
+
commander = MyCommands.new(remote, @debug)
|
18
|
+
commander.send arg.to_sym
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_class(class_name, superclass, &block)
|
24
|
+
klass = Class.new superclass, &block
|
25
|
+
Object.const_set class_name, klass
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/lib/william.rb
ADDED
data/william.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "william/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "william"
|
7
|
+
s.version = William::VERSION
|
8
|
+
s.authors = ["Julien Desrosiers"]
|
9
|
+
s.email = ["juliend2@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A DSL to interact with your server via SSH}
|
12
|
+
s.description = %q{William is a DSL to interact with your server via SSH}
|
13
|
+
|
14
|
+
s.rubyforge_project = "william"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.executables = ['will']
|
18
|
+
s.default_executable = 'will'
|
19
|
+
s.bindir = 'bin'
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: william
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Julien Desrosiers
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-12-03 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: William is a DSL to interact with your server via SSH
|
22
|
+
email:
|
23
|
+
- juliend2@gmail.com
|
24
|
+
executables:
|
25
|
+
- will
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- README.md
|
34
|
+
- Rakefile
|
35
|
+
- bin/will
|
36
|
+
- lib/william.rb
|
37
|
+
- lib/william/commands.rb
|
38
|
+
- lib/william/runner.rb
|
39
|
+
- lib/william/version.rb
|
40
|
+
- william.gemspec
|
41
|
+
homepage: ""
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project: william
|
70
|
+
rubygems_version: 1.8.12
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: A DSL to interact with your server via SSH
|
74
|
+
test_files: []
|
75
|
+
|