gluez 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/gluez.sh +85 -0
- data/lib/gluez/string.rb +43 -0
- data/lib/gluez.rb +2 -44
- metadata +4 -2
data/bin/gluez.sh
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "thor"
|
3
|
+
require "fileutils"
|
4
|
+
require "gluez/string"
|
5
|
+
|
6
|
+
class GluezCommand < Thor
|
7
|
+
desc "create", "creates an gluez project"
|
8
|
+
method_option :users, :aliases => "-u", :type => :array, :default => [], :desc => "add users to created project (separated by space)"
|
9
|
+
method_option :apps, :aliases => "-a", :type => :array, :default => [], :desc => "add apps to created project (separated by space)"
|
10
|
+
|
11
|
+
def create
|
12
|
+
["gluez", "gluez/users", "gluez/recipes"].each do |folder|
|
13
|
+
FileUtils.mkdir folder unless File.exists?(folder)
|
14
|
+
end
|
15
|
+
public_key_file = ENV['HOME'] + "/.ssh/id_rsa.pub"
|
16
|
+
|
17
|
+
public_key = File.exists?(public_key_file) ? File.read(public_key_file) : ""
|
18
|
+
|
19
|
+
s = <<-EOF
|
20
|
+
#!/usr/bin/env ruby
|
21
|
+
require 'gluez'
|
22
|
+
|
23
|
+
$simulate = false
|
24
|
+
|
25
|
+
authorized_keys = [
|
26
|
+
"#{public_key.strip}"
|
27
|
+
]
|
28
|
+
|
29
|
+
context do
|
30
|
+
EOF
|
31
|
+
|
32
|
+
|
33
|
+
uid = 2001
|
34
|
+
options[:users].each do |name|
|
35
|
+
s += <<-EOF
|
36
|
+
include_user "#{name}" do
|
37
|
+
set :uid, #{uid}
|
38
|
+
set :authorized_keys, authorized_keys
|
39
|
+
set :sudo, false
|
40
|
+
end
|
41
|
+
EOF
|
42
|
+
|
43
|
+
File.open "gluez/users/#{name}.rb", "w" do |f|
|
44
|
+
user_data = <<-EOF
|
45
|
+
user do
|
46
|
+
end
|
47
|
+
EOF
|
48
|
+
|
49
|
+
f.puts(user_data.multiline_strip)
|
50
|
+
end
|
51
|
+
|
52
|
+
uid += 1
|
53
|
+
end
|
54
|
+
|
55
|
+
s += <<-EOF
|
56
|
+
end
|
57
|
+
EOF
|
58
|
+
|
59
|
+
File.open "gluez/server.rb", "w" do |f|
|
60
|
+
f.puts(s.multiline_strip)
|
61
|
+
end
|
62
|
+
|
63
|
+
File.open "gluez/Vagrantfile", "w" do |f|
|
64
|
+
code = <<-EOF
|
65
|
+
Vagrant::Config.run do |config|
|
66
|
+
config.vm.box = "my-ubuntu-10.10"
|
67
|
+
end
|
68
|
+
EOF
|
69
|
+
f.puts(code.multiline_strip)
|
70
|
+
end
|
71
|
+
|
72
|
+
File.open "gluez/users/root.rb", "w" do |f|
|
73
|
+
root_data = <<-EOF
|
74
|
+
user do
|
75
|
+
end
|
76
|
+
EOF
|
77
|
+
|
78
|
+
f.puts(root_data.multiline_strip)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
GluezCommand.start
|
data/lib/gluez/string.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Gluez does a lot of text processing and maniputation. The string class is extended to dry up code.
|
2
|
+
class String
|
3
|
+
|
4
|
+
# Return the string as underscored version e.g. SomeTextValue becomes some_text_value.
|
5
|
+
def underscore
|
6
|
+
word = self.dup
|
7
|
+
word.gsub!(/::/, '/')
|
8
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
9
|
+
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
10
|
+
word.tr!("-", "_")
|
11
|
+
word.downcase!
|
12
|
+
word
|
13
|
+
end
|
14
|
+
|
15
|
+
def multiline_strip
|
16
|
+
lines = self.split("\n")
|
17
|
+
first = lines[0]
|
18
|
+
|
19
|
+
idx = 0
|
20
|
+
while first[idx] == ' '
|
21
|
+
idx += 1
|
22
|
+
end
|
23
|
+
|
24
|
+
if idx > 0
|
25
|
+
lines = lines.map do |line|
|
26
|
+
line[idx, line.length]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
lines.join("\n")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Return the string as camelcased version e.g. some_text_value becomes SomeTextValue.
|
34
|
+
def camelize(first_letter_in_uppercase=true)
|
35
|
+
word = self.dup
|
36
|
+
if first_letter_in_uppercase
|
37
|
+
word.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
38
|
+
else
|
39
|
+
word.to_s[0].chr.downcase + word.camelize[1..-1]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/lib/gluez.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'gluez/string'
|
2
|
+
|
1
3
|
class Object
|
2
4
|
def context(&block)
|
3
5
|
Gluez::Context.new(&block)
|
@@ -13,50 +15,6 @@ class Object
|
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
# Gluez does a lot of text processing and maniputation. The string class is extended to dry up code.
|
17
|
-
class String
|
18
|
-
|
19
|
-
# Return the string as underscored version e.g. SomeTextValue becomes some_text_value.
|
20
|
-
def underscore
|
21
|
-
word = self.dup
|
22
|
-
word.gsub!(/::/, '/')
|
23
|
-
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
24
|
-
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
25
|
-
word.tr!("-", "_")
|
26
|
-
word.downcase!
|
27
|
-
word
|
28
|
-
end
|
29
|
-
|
30
|
-
def multiline_strip
|
31
|
-
lines = self.split("\n")
|
32
|
-
first = lines[0]
|
33
|
-
|
34
|
-
idx = 0
|
35
|
-
while first[idx] == ' '
|
36
|
-
idx += 1
|
37
|
-
end
|
38
|
-
|
39
|
-
if idx > 0
|
40
|
-
lines = lines.map do |line|
|
41
|
-
line[idx, line.length]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
lines.join("\n")
|
46
|
-
end
|
47
|
-
|
48
|
-
# Return the string as camelcased version e.g. some_text_value becomes SomeTextValue.
|
49
|
-
def camelize(first_letter_in_uppercase=true)
|
50
|
-
word = self.dup
|
51
|
-
if first_letter_in_uppercase
|
52
|
-
word.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
53
|
-
else
|
54
|
-
word.to_s[0].chr.downcase + word.camelize[1..-1]
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
18
|
module Gluez
|
61
19
|
|
62
20
|
def self.args()
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gluez
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: a server configuration toolkit
|
15
15
|
email: jan.zimmek@web.de
|
@@ -39,8 +39,10 @@ files:
|
|
39
39
|
- lib/gluez/resources/stop.rb
|
40
40
|
- lib/gluez/resources/transfer.rb
|
41
41
|
- lib/gluez/resources/umount.rb
|
42
|
+
- lib/gluez/string.rb
|
42
43
|
- lib/gluez/templates/profile.erb
|
43
44
|
- lib/gluez.rb
|
45
|
+
- bin/gluez.sh
|
44
46
|
homepage:
|
45
47
|
licenses: []
|
46
48
|
post_install_message:
|