astrails-safe 0.1.4 → 0.1.6
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/README.markdown +19 -19
- data/Rakefile +9 -17
- data/VERSION.yml +1 -1
- data/examples/example_helper.rb +19 -0
- data/examples/unit/config_example.rb +126 -0
- data/examples/unit/stream_example.rb +33 -0
- data/lib/astrails/safe/config/builder.rb +3 -1
- data/lib/astrails/safe/source.rb +1 -1
- data/lib/astrails/safe/stream.rb +3 -3
- metadata +15 -6
data/README.markdown
CHANGED
@@ -72,28 +72,28 @@ The procedure to create and transfer the key is as follows:
|
|
72
72
|
no way to know its yours and can be trusted.
|
73
73
|
To fix that we can sign it with other trusted key, or just directly modify its
|
74
74
|
trust level in gpg (use level 5):
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
</pre>
|
75
|
+
<pre>
|
76
|
+
$ gpg --edit-key test@example.com
|
77
|
+
...
|
78
|
+
Command> trust
|
79
|
+
...
|
80
|
+
1 = I don't know or won't say
|
81
|
+
2 = I do NOT trust
|
82
|
+
3 = I trust marginally
|
83
|
+
4 = I trust fully
|
84
|
+
5 = I trust ultimately
|
85
|
+
m = back to the main menu
|
86
|
+
|
87
|
+
Your decision? 5
|
88
|
+
...
|
89
|
+
Command> quit
|
90
|
+
</pre>
|
92
91
|
|
93
92
|
6. export your secret key for backup
|
94
93
|
(we recommend to print it on paper and burn to a CD/DVD and store in a safe place):
|
95
|
-
|
96
|
-
|
94
|
+
<pre>
|
95
|
+
$ gpg -a --export-secret-key test@example.com > test@example.com.key
|
96
|
+
</pre>
|
97
97
|
|
98
98
|
|
99
99
|
Example configuration
|
data/Rakefile
CHANGED
@@ -20,28 +20,20 @@ rescue LoadError
|
|
20
20
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
21
21
|
end
|
22
22
|
|
23
|
-
require '
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
test.verbose = true
|
23
|
+
require 'micronaut/rake_task'
|
24
|
+
Micronaut::RakeTask.new(:examples) do |examples|
|
25
|
+
examples.pattern = 'examples/**/*_example.rb'
|
26
|
+
examples.ruby_opts << '-Ilib -Iexamples'
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
test.pattern = 'test/**/*_test.rb'
|
35
|
-
test.verbose = true
|
36
|
-
end
|
37
|
-
rescue LoadError
|
38
|
-
task :rcov do
|
39
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
-
end
|
29
|
+
Micronaut::RakeTask.new(:rcov) do |examples|
|
30
|
+
examples.pattern = 'examples/**/*_example.rb'
|
31
|
+
examples.rcov_opts = '-Ilib -Iexamples'
|
32
|
+
examples.rcov = true
|
41
33
|
end
|
42
34
|
|
43
35
|
|
44
|
-
task :default => :
|
36
|
+
task :default => :examples
|
45
37
|
|
46
38
|
require 'rake/rdoctask'
|
47
39
|
Rake::RDocTask.new do |rdoc|
|
data/VERSION.yml
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'micronaut'
|
3
|
+
require 'ruby-debug'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
|
8
|
+
require 'astrails/safe'
|
9
|
+
|
10
|
+
def not_in_editor?
|
11
|
+
!(ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM'))
|
12
|
+
end
|
13
|
+
|
14
|
+
Micronaut.configure do |c|
|
15
|
+
c.color_enabled = not_in_editor?
|
16
|
+
c.filter_run :focused => true
|
17
|
+
c.mock_with :rr
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../example_helper')
|
2
|
+
|
3
|
+
describe Astrails::Safe::Config do
|
4
|
+
it "foo" do
|
5
|
+
config = Astrails::Safe::Config::Node.new do
|
6
|
+
local do
|
7
|
+
path "path"
|
8
|
+
end
|
9
|
+
|
10
|
+
s3 do
|
11
|
+
key "s3 key"
|
12
|
+
secret "secret"
|
13
|
+
bucket "bucket"
|
14
|
+
path "path1"
|
15
|
+
end
|
16
|
+
|
17
|
+
gpg do
|
18
|
+
key "gpg-key"
|
19
|
+
password "astrails"
|
20
|
+
end
|
21
|
+
|
22
|
+
keep do
|
23
|
+
local 4
|
24
|
+
s3 20
|
25
|
+
end
|
26
|
+
|
27
|
+
mysqldump do
|
28
|
+
options "-ceKq --single-transaction --create-options"
|
29
|
+
|
30
|
+
user "astrails"
|
31
|
+
password ""
|
32
|
+
host "localhost"
|
33
|
+
port 3306
|
34
|
+
socket "/var/run/mysqld/mysqld.sock"
|
35
|
+
|
36
|
+
database :blog
|
37
|
+
|
38
|
+
database :production do
|
39
|
+
keep :local => 3
|
40
|
+
|
41
|
+
gpg do
|
42
|
+
password "custom-production-pass"
|
43
|
+
end
|
44
|
+
|
45
|
+
skip_tables [:logger_exceptions, :request_logs]
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
tar do
|
52
|
+
archive "git-repositories" do
|
53
|
+
files "/home/git/repositories"
|
54
|
+
end
|
55
|
+
|
56
|
+
archive "etc-files" do
|
57
|
+
files "/etc"
|
58
|
+
exclude "/etc/puppet/other"
|
59
|
+
end
|
60
|
+
|
61
|
+
archive "dot-configs" do
|
62
|
+
files "/home/*/.[^.]*"
|
63
|
+
end
|
64
|
+
|
65
|
+
archive "blog" do
|
66
|
+
files "/var/www/blog.astrails.com/"
|
67
|
+
exclude ["/var/www/blog.astrails.com/log", "/var/www/blog.astrails.com/tmp"]
|
68
|
+
end
|
69
|
+
|
70
|
+
archive :misc do
|
71
|
+
files [ "/backup/*.rb" ]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
expected = {
|
78
|
+
"local" => {"path" => "path"},
|
79
|
+
|
80
|
+
"s3" => {
|
81
|
+
"key" => "s3 key",
|
82
|
+
"secret" => "secret",
|
83
|
+
"bucket" => "bucket",
|
84
|
+
"path" => "path1",
|
85
|
+
},
|
86
|
+
|
87
|
+
"gpg" => {"password" => "astrails", "key" => "gpg-key"},
|
88
|
+
|
89
|
+
"keep" => {"s3" => 20, "local" => 4},
|
90
|
+
|
91
|
+
"mysqldump" => {
|
92
|
+
"options" => "-ceKq --single-transaction --create-options",
|
93
|
+
"user" => "astrails",
|
94
|
+
"password" => "",
|
95
|
+
"host" => "localhost",
|
96
|
+
"port" => 3306,
|
97
|
+
"socket" => "/var/run/mysqld/mysqld.sock",
|
98
|
+
|
99
|
+
"databases" => {
|
100
|
+
"blog" => {},
|
101
|
+
"production" => {
|
102
|
+
"keep" => {"local" => 3},
|
103
|
+
"gpg" => {"password" => "custom-production-pass"},
|
104
|
+
"skip_tables" => ["logger_exceptions", "request_logs"],
|
105
|
+
},
|
106
|
+
},
|
107
|
+
},
|
108
|
+
"tar" => {
|
109
|
+
"archives" => {
|
110
|
+
"git-repositories" => {"files" => "/home/git/repositories"},
|
111
|
+
"etc-files" => {"files" => "/etc", "exclude" => "/etc/puppet/other"},
|
112
|
+
"dot-configs" => {"files" => "/home/*/.[^.]*"},
|
113
|
+
"blog" => {
|
114
|
+
"files" => "/var/www/blog.astrails.com/",
|
115
|
+
"exclude" => ["/var/www/blog.astrails.com/log", "/var/www/blog.astrails.com/tmp"],
|
116
|
+
},
|
117
|
+
"misc" => { "files" => ["/backup/*.rb"] },
|
118
|
+
},
|
119
|
+
},
|
120
|
+
}
|
121
|
+
|
122
|
+
config.to_hash.should == expected
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../example_helper')
|
2
|
+
|
3
|
+
describe Astrails::Safe::Stream do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@parent = Object.new
|
7
|
+
@stream = Astrails::Safe::Stream.new(@parent)
|
8
|
+
@r = rand(10)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.it_delegates_to_parent(prop)
|
12
|
+
it "delegates #{prop} to parent if not set" do
|
13
|
+
mock(@parent).__send__(prop) {@r}
|
14
|
+
@stream.send(prop).should == @r
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.it_delegates_to_parent_with_cache(prop)
|
19
|
+
it_delegates_to_parent(prop)
|
20
|
+
|
21
|
+
it "uses cached value for #{prop}" do
|
22
|
+
dont_allow(@parent).__send__(prop)
|
23
|
+
@stream.instance_variable_set "@#{prop}", @r + 1
|
24
|
+
@stream.send(prop).should == @r + 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it_delegates_to_parent_with_cache :id
|
29
|
+
it_delegates_to_parent_with_cache :config
|
30
|
+
|
31
|
+
it_delegates_to_parent :filename
|
32
|
+
|
33
|
+
end
|
@@ -4,7 +4,7 @@ module Astrails
|
|
4
4
|
class Builder
|
5
5
|
COLLECTIONS = %w/database archive/
|
6
6
|
ITEMS = %w/s3 key secret bucket path gpg password keep local mysqldump options
|
7
|
-
user socket tar files exclude filename/
|
7
|
+
user host port socket skip_tables tar files exclude filename/
|
8
8
|
NAMES = COLLECTIONS + ITEMS
|
9
9
|
def initialize(node)
|
10
10
|
@node = node
|
@@ -23,6 +23,8 @@ module Astrails
|
|
23
23
|
id_or_value = args.shift # nil for args == []
|
24
24
|
end
|
25
25
|
|
26
|
+
id_or_value = id_or_value.map {|v| v.to_s} if id_or_value.is_a?(Array)
|
27
|
+
|
26
28
|
# do we have data hash?
|
27
29
|
if data = args.shift
|
28
30
|
die "#{sym}: hash expected: #{data.inspect}" unless data.is_a?(Hash)
|
data/lib/astrails/safe/source.rb
CHANGED
data/lib/astrails/safe/stream.rb
CHANGED
@@ -24,12 +24,12 @@ module Astrails
|
|
24
24
|
|
25
25
|
protected
|
26
26
|
|
27
|
-
def
|
28
|
-
|
27
|
+
def self.human_name
|
28
|
+
name.split('::').last.downcase
|
29
29
|
end
|
30
30
|
|
31
31
|
def kind
|
32
|
-
@parent ? @parent.kind :
|
32
|
+
@parent ? @parent.kind : self.class.human_name
|
33
33
|
end
|
34
34
|
|
35
35
|
def expand(path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astrails-safe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Astrails Ltd.
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-16 00:00:00 -07:00
|
13
13
|
default_executable: astrails-safe
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -29,16 +29,20 @@ executables:
|
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
|
-
- LICENSE
|
33
32
|
- README.markdown
|
34
|
-
files:
|
35
33
|
- LICENSE
|
34
|
+
files:
|
36
35
|
- README.markdown
|
37
|
-
- Rakefile
|
38
36
|
- VERSION.yml
|
39
37
|
- bin/astrails-safe
|
40
|
-
-
|
38
|
+
- examples/example_helper.rb
|
39
|
+
- examples/unit
|
40
|
+
- examples/unit/config_example.rb
|
41
|
+
- examples/unit/stream_example.rb
|
42
|
+
- lib/astrails
|
43
|
+
- lib/astrails/safe
|
41
44
|
- lib/astrails/safe/archive.rb
|
45
|
+
- lib/astrails/safe/config
|
42
46
|
- lib/astrails/safe/config/builder.rb
|
43
47
|
- lib/astrails/safe/config/node.rb
|
44
48
|
- lib/astrails/safe/gpg.rb
|
@@ -51,12 +55,17 @@ files:
|
|
51
55
|
- lib/astrails/safe/source.rb
|
52
56
|
- lib/astrails/safe/stream.rb
|
53
57
|
- lib/astrails/safe/tmp_file.rb
|
58
|
+
- lib/astrails/safe.rb
|
59
|
+
- lib/extensions
|
54
60
|
- lib/extensions/mktmpdir.rb
|
55
61
|
- templates/script.rb
|
62
|
+
- Rakefile
|
63
|
+
- LICENSE
|
56
64
|
has_rdoc: true
|
57
65
|
homepage: http://github.com/astrails/safe
|
58
66
|
post_install_message:
|
59
67
|
rdoc_options:
|
68
|
+
- --inline-source
|
60
69
|
- --charset=UTF-8
|
61
70
|
require_paths:
|
62
71
|
- lib
|