sbfaulkner-astrovan 0.5.8 → 0.5.9

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.rdoc CHANGED
@@ -28,6 +28,9 @@ This is my attempt.
28
28
 
29
29
  == CHANGES
30
30
 
31
+ === 0.5.9
32
+ - add render method
33
+
31
34
  === 0.5.8
32
35
  - add put and upload file transfer methods
33
36
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 5
4
- :patch: 8
4
+ :patch: 9
@@ -2,6 +2,18 @@ require 'net/scp'
2
2
 
3
3
  module Astrovan
4
4
  module Transfer
5
+ # Create a file on the remote servers, rendering the provided data as specified.
6
+ #
7
+ # Options:
8
+ # * +yaml+ - render the provided data as yaml
9
+ # * +to+ - the path to the new file
10
+ def render(options = {})
11
+ if data = options.delete(:yaml)
12
+ data = data.to_yaml
13
+ end
14
+ put data, options
15
+ end
16
+
5
17
  # Write to a file on the remote servers.
6
18
  #
7
19
  # Options:
@@ -3,31 +3,57 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  class TransferTest < Test::Unit::TestCase
4
4
  def setup
5
5
  @path = "/tmp/astrovan.#{Time.now.to_i}"
6
+ @from = nil
7
+ @to = nil
6
8
  super
7
9
  end
8
10
 
9
11
  def teardown
10
- system "rm -rf #{@path}.from #{@path}.to"
12
+ system "rm -rf #{@path}"
13
+ system "rm -rf #{@from}" if @from
14
+ system "rm -rf #{@to}" if @to
11
15
  super
12
16
  end
13
17
 
14
18
  def test_should_put_data_into_file
15
19
  data = Time.now.utc.to_s
16
- to = "#{@path}.to"
17
- using 'astrovan.local', :password => ENV['PASSWORD'], :data => data, :to => to do
20
+ @to = "#{@path}.to"
21
+ using 'astrovan.local', :password => ENV['PASSWORD'], :data => data, :to => @to do
18
22
  put data, :to => to
19
23
  end
20
- assert_equal data, File.open(to) { |f| f.gets.chomp }
24
+ assert_equal data, File.open(@to) { |f| f.gets.chomp }
21
25
  end
22
26
 
23
27
  def test_should_upload_file
24
28
  data = Time.now.utc.to_s
25
- from = "#{@path}.from"
26
- to = "#{@path}.to"
27
- File.open(from, "w") { |f| f.puts data }
28
- using 'astrovan.local', :password => ENV['PASSWORD'], :from => from, :to => to do
29
+ @from = "#{@path}.from"
30
+ @to = "#{@path}.to"
31
+ File.open(@from, "w") { |f| f.puts data }
32
+ using 'astrovan.local', :password => ENV['PASSWORD'], :from => @from, :to => @to do
29
33
  upload from, :to => to
30
34
  end
31
- assert_equal data, File.open(to) { |f| f.gets.chomp }
35
+ assert_equal data, File.open(@to) { |f| f.gets.chomp }
36
+ end
37
+
38
+ def test_should_render_yaml
39
+ common = {
40
+ 'adapter' => 'mysql',
41
+ 'username' => 'root',
42
+ 'password' => 'p@$$w0rd',
43
+ 'host' => '/var/run/mysqld/mysqld.sock',
44
+ 'socket' => '/tmp/mysql.sock'
45
+ }
46
+
47
+ data = {
48
+ 'development' => { 'database' => 'development_db' }.merge(common),
49
+ 'test' => { 'database' => 'test_db' }.merge(common),
50
+ 'production' => { 'database' => 'production_db' }.merge(common)
51
+ }
52
+ @to = "#{@path}.yml"
53
+
54
+ using 'astrovan.local', :password => ENV['PASSWORD'], :data => data, :to => @to do
55
+ render :yaml => data, :to => to
56
+ end
57
+ assert_equal data, File.open(@to) { |f| YAML.load(f) }
32
58
  end
33
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbfaulkner-astrovan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - S. Brent Faulkner