solutious-rudy 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/CHANGES.txt +8 -9
  2. data/README.rdoc +48 -7
  3. data/Rakefile +102 -7
  4. data/Rudyfile +28 -0
  5. data/bin/ird +162 -0
  6. data/bin/rudy +287 -93
  7. data/lib/annoy.rb +227 -0
  8. data/lib/aws_sdb/service.rb +1 -1
  9. data/lib/console.rb +20 -4
  10. data/lib/escape.rb +305 -0
  11. data/lib/rudy.rb +265 -125
  12. data/lib/rudy/aws.rb +61 -26
  13. data/lib/rudy/aws/ec2.rb +20 -296
  14. data/lib/rudy/aws/ec2/address.rb +121 -0
  15. data/lib/rudy/aws/ec2/group.rb +241 -0
  16. data/lib/rudy/aws/ec2/image.rb +46 -0
  17. data/lib/rudy/aws/ec2/instance.rb +407 -0
  18. data/lib/rudy/aws/ec2/keypair.rb +92 -0
  19. data/lib/rudy/aws/ec2/snapshot.rb +87 -0
  20. data/lib/rudy/aws/ec2/volume.rb +234 -0
  21. data/lib/rudy/aws/simpledb.rb +33 -15
  22. data/lib/rudy/cli.rb +142 -0
  23. data/lib/rudy/cli/addresses.rb +85 -0
  24. data/lib/rudy/cli/backups.rb +175 -0
  25. data/lib/rudy/{command → cli}/config.rb +18 -13
  26. data/lib/rudy/cli/deploy.rb +12 -0
  27. data/lib/rudy/cli/disks.rb +125 -0
  28. data/lib/rudy/cli/domains.rb +17 -0
  29. data/lib/rudy/cli/groups.rb +77 -0
  30. data/lib/rudy/{command → cli}/images.rb +18 -6
  31. data/lib/rudy/cli/instances.rb +142 -0
  32. data/lib/rudy/cli/keypairs.rb +47 -0
  33. data/lib/rudy/cli/manager.rb +51 -0
  34. data/lib/rudy/{command → cli}/release.rb +10 -10
  35. data/lib/rudy/cli/routines.rb +80 -0
  36. data/lib/rudy/cli/volumes.rb +121 -0
  37. data/lib/rudy/command/addresses.rb +62 -39
  38. data/lib/rudy/command/backups.rb +60 -170
  39. data/lib/rudy/command/disks-old.rb +322 -0
  40. data/lib/rudy/command/disks.rb +5 -209
  41. data/lib/rudy/command/domains.rb +34 -0
  42. data/lib/rudy/command/groups.rb +105 -48
  43. data/lib/rudy/command/instances.rb +263 -70
  44. data/lib/rudy/command/keypairs.rb +149 -0
  45. data/lib/rudy/command/manager.rb +65 -0
  46. data/lib/rudy/command/volumes.rb +110 -49
  47. data/lib/rudy/config.rb +90 -70
  48. data/lib/rudy/config/objects.rb +67 -0
  49. data/lib/rudy/huxtable.rb +253 -0
  50. data/lib/rudy/metadata/backup.rb +23 -48
  51. data/lib/rudy/metadata/disk.rb +79 -68
  52. data/lib/rudy/metadata/machine.rb +34 -0
  53. data/lib/rudy/routines.rb +54 -0
  54. data/lib/rudy/routines/disk_handler.rb +190 -0
  55. data/lib/rudy/routines/release.rb +15 -0
  56. data/lib/rudy/routines/script_runner.rb +65 -0
  57. data/lib/rudy/routines/shutdown.rb +42 -0
  58. data/lib/rudy/routines/startup.rb +48 -0
  59. data/lib/rudy/utils.rb +57 -2
  60. data/lib/storable.rb +11 -5
  61. data/lib/sysinfo.rb +274 -0
  62. data/rudy.gemspec +84 -20
  63. data/support/randomize-root-password +45 -0
  64. data/support/rudy-ec2-startup +5 -5
  65. data/support/update-ec2-ami-tools +20 -0
  66. data/test/05_config/00_setup_test.rb +24 -0
  67. data/test/05_config/30_machines_test.rb +69 -0
  68. data/test/20_sdb/00_setup_test.rb +31 -0
  69. data/test/20_sdb/10_domains_test.rb +113 -0
  70. data/test/25_ec2/00_setup_test.rb +34 -0
  71. data/test/25_ec2/10_keypairs_test.rb +33 -0
  72. data/test/25_ec2/20_groups_test.rb +139 -0
  73. data/test/25_ec2/30_addresses_test.rb +35 -0
  74. data/test/25_ec2/40_volumes_test.rb +46 -0
  75. data/test/25_ec2/50_snapshots_test.rb +69 -0
  76. data/test/26_ec2_instances/00_setup_test.rb +33 -0
  77. data/test/26_ec2_instances/10_instances_test.rb +81 -0
  78. data/test/26_ec2_instances/50_images_test.rb +13 -0
  79. data/test/30_sdb_metadata/00_setup_test.rb +28 -0
  80. data/test/30_sdb_metadata/10_disks_test.rb +99 -0
  81. data/test/30_sdb_metadata/20_backups_test.rb +102 -0
  82. data/test/50_commands/00_setup_test.rb +11 -0
  83. data/test/50_commands/10_keypairs_test.rb +79 -0
  84. data/test/50_commands/20_groups_test.rb +77 -0
  85. data/test/50_commands/40_volumes_test.rb +55 -0
  86. data/test/50_commands/50_instances_test.rb +110 -0
  87. data/test/coverage.txt +51 -0
  88. data/test/helper.rb +35 -0
  89. data/tryouts/disks.rb +55 -0
  90. data/tryouts/nested_methods.rb +36 -0
  91. data/tryouts/session_tryout.rb +48 -0
  92. metadata +94 -25
  93. data/bin/rudy-ec2 +0 -108
  94. data/lib/rudy/command/base.rb +0 -839
  95. data/lib/rudy/command/deploy.rb +0 -12
  96. data/lib/rudy/command/environment.rb +0 -74
  97. data/lib/rudy/command/machines.rb +0 -170
  98. data/lib/rudy/command/metadata.rb +0 -41
  99. data/lib/rudy/metadata.rb +0 -26
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'helper')
2
+
3
+ module Rudy::Test
4
+ class Case_50_Commands < Test::Unit::TestCase
5
+ include Rudy::AWS
6
+
7
+ @@logger = StringIO.new
8
+
9
+
10
+ end
11
+ end
@@ -0,0 +1,79 @@
1
+
2
+ module Rudy::Test
3
+ class Case_50_Commands
4
+
5
+
6
+ context "#{name}_10 KeyPairs" do
7
+ setup do
8
+ @rkey = Rudy::KeyPairs.new(:logger => @@logger)
9
+ # So we can test with and without user specified keypairs
10
+ # (stage should have keypairs configured in ./.rudy/config or Rudyfile)
11
+ @rkey.global.environment = :test
12
+ stop_test !@rkey.is_a?(Rudy::KeyPairs), "We need Rudy::KeyPairs (#{@rkey})"
13
+ end
14
+
15
+ teardown do
16
+ #if @@logger && @@logger.is_a?(StringIO)
17
+ # @@logger.rewind
18
+ # puts @@logger.read
19
+ #end
20
+ end
21
+
22
+ should "(10) create a keypair" do
23
+ stop_test @rkey.any?, "Delete existing keypairs"
24
+ kp = @rkey.create
25
+ assert kp.is_a?(Rudy::AWS::EC2::KeyPair)
26
+ assert @rkey.exists?(kp.name), "KeyPair not registered with Amazon"
27
+ assert File.exists?(@rkey.path), "No private key: #{@rkey.path}"
28
+ assert File.exists?(@rkey.public_path), "No public key: #{@rkey.public_path}"
29
+ end
30
+
31
+ should "(11) create a keypair with an arbitrary name" do
32
+ n = "test-%s" % Rudy::Utils.strand
33
+ kp = @rkey.create(n)
34
+ assert kp.is_a?(Rudy::AWS::EC2::KeyPair)
35
+ assert @rkey.exists?(kp.name), "KeyPair not registered with Amazon"
36
+ assert File.exists?(@rkey.path(n)), "No private key: #{@rkey.path(n)}"
37
+ assert File.exists?(@rkey.public_path(n)), "No public key: #{@rkey.public_path(n)}"
38
+ end
39
+
40
+ should "(12) not create keypair if one exists" do
41
+ assert @rkey.exists?, "No #{@rkey.name} KeyPair"
42
+ begin; kp = @rkey.create; rescue; end # Quiet, you!
43
+ assert kp.nil?, "Keypair was still created"
44
+ end
45
+
46
+ should "(13) not create keypair if a root keypair is defined in config" do
47
+ assert_equal (@rkey.global.environment = :keypairtest), :keypairtest # stage needs keypairs configured
48
+ assert @rkey.has_root_keypair?, "No root keypair path defined in config"
49
+ begin; kp = @rkey.create; rescue => ex; end
50
+ assert kp.nil?, "Keypair was still created"
51
+ end
52
+
53
+ should "(20) list keypairs" do
54
+ # We assume we've created more than one keypair before this point
55
+ assert @rkey.any?, "No keypairs"
56
+ assert (kp_list = @rkey.list).is_a?(Array), "List not an Array"
57
+ assert kp_list.size > 1, "List not greater than 1 (#{kp_list.size})"
58
+ assert (kp_hash = @rkey.list_as_hash).is_a?(Hash), "List not a Hash"
59
+ end
60
+
61
+ should "(30) find existing keypair for current machine group" do
62
+ assert !(test_kp = @rkey.user_keypairpath(:root)).nil?, "Test keypair is nil"
63
+ @rkey.global.environment = :keypairtest # user_keypairpath will now look at the stage
64
+ assert !(stage_kp = @rkey.user_keypairpath(:root)).nil?, "keypairtest keypair is nil"
65
+ assert test_kp != stage_kp, "Test and Stage keypairs are the same (#{test_kp}, #{stage_kp})"
66
+ end
67
+
68
+ should "(99) destroy keypairs" do
69
+ assert @rkey.any?, "No keypairs registered"
70
+ @rkey.list.each { |kp| assert @rkey.destroy(kp.name), "Not destroyed #{kp.name}" }
71
+ assert !File.exists?(@rkey.path), "Still exists: #{@rkey.path}"
72
+ assert !File.exists?(@rkey.public_path), "Still exists: #{@rkey.public_path}"
73
+ end
74
+
75
+
76
+ end
77
+
78
+ end
79
+ end
@@ -0,0 +1,77 @@
1
+
2
+ module Rudy::Test
3
+ class Case_50_Commands
4
+
5
+
6
+ context "#{name}_20 Groups" do
7
+ setup do
8
+ @rgroup = Rudy::Groups.new(:logger => @@logger)
9
+ stop_test !@rgroup.is_a?(Rudy::Groups), "We need Rudy::Groups (#{@rgroup})"
10
+ end
11
+
12
+ teardown do
13
+ #if @@logger && @@logger.is_a?(StringIO)
14
+ # @@logger.rewind
15
+ # puts @@logger.read
16
+ #end
17
+ end
18
+
19
+ should "(10) create a group" do
20
+ stop_test @rgroup.any?, "Delete existing Groups"
21
+ group = @rgroup.create
22
+ assert group.is_a?(Rudy::AWS::EC2::Group)
23
+ assert @rgroup.exists?(group.name), "Group not registered with Amazon"
24
+ assert_equal group.name, @rgroup.name
25
+ # We don't check the rules because we do that in the lower
26
+ # level tests for Rudy::AWS::EC2::Groups.
27
+ end
28
+
29
+ should "(11) create a group with an arbitrary name" do
30
+ n = "test-%s" % Rudy::Utils.strand
31
+ group = @rgroup.create(n)
32
+
33
+ assert group.is_a?(Rudy::AWS::EC2::Group)
34
+ assert @rgroup.exists?(group.name), "Group #{group.name} not registered with Amazon"
35
+ assert_equal group.name, n
36
+ end
37
+
38
+
39
+ should "(20) list groups" do
40
+ assert @rgroup.any?, "No groups"
41
+ assert @rgroup.exists?, "No #{@rgroup.name} group"
42
+
43
+ kp_list = @rgroup.list
44
+ assert kp_list.is_a?(Array), "List not an Array"
45
+
46
+ kp_hash = @rgroup.list_as_hash
47
+ assert kp_hash.is_a?(Hash), "List not a Hash"
48
+ end
49
+
50
+ should "(30) not create group if one exists" do
51
+ assert @rgroup.exists?, "No #{@rgroup.name} Group"
52
+ begin
53
+ group = @rgroup.create
54
+ rescue # Quiet, you!
55
+ end
56
+ assert group.nil?, "Group was still created"
57
+ end
58
+
59
+ xshould "(40) modify group rules" do
60
+
61
+ end
62
+
63
+ should "(99) destroy groups" do
64
+ assert @rgroup.exists?, "Group #{@rgroup.name} doesn't exist"
65
+ @rgroup.list.each do |group|
66
+ next if group.name == 'default'
67
+ assert @rgroup.destroy(group.name), "Did not destroy #{group.name}"
68
+ end
69
+ assert !@rgroup.exists?, "Group #{@rgroup.name} still exists"
70
+ end
71
+
72
+
73
+ end
74
+
75
+
76
+ end
77
+ end
@@ -0,0 +1,55 @@
1
+
2
+
3
+ module Rudy::Test
4
+ class Case_50_Commands
5
+
6
+ context "#{name}_40 Volumes" do
7
+
8
+ setup do
9
+ @rvol = Rudy::Volumes.new(:logger => @@logger)
10
+ stop_test !@rvol.is_a?(Rudy::Volumes), "We need Rudy::Volumes (#{@rvol})"
11
+ end
12
+
13
+ should "(10) create a volume" do
14
+ volume_size = 2
15
+ #stop_test @rvol.any?(:available), "Destroy existing volumes"
16
+ volume = @rvol.create(volume_size)
17
+ assert volume.is_a?(Rudy::AWS::EC2::Volume), "Not a Volume"
18
+ # Should use the global zone by default
19
+ assert_equal @rvol.global.zone.to_s, volume.zone, "Zone incorrect: #{volume.zone}"
20
+ assert_equal volume_size.to_i, volume.size.to_i, "Size incorrect: #{volume.size}"
21
+ # Rudy::Volume should wait until the volume is available before returning
22
+ assert volume.available?, "Volume not available (#{volume.status})"
23
+ end
24
+
25
+ should "(11) list a volume as available" do
26
+
27
+ end
28
+
29
+ should "(20) list volumes" do
30
+ volume_list = @rvol.list
31
+ assert volume_list.is_a?(Array), "Not an Array"
32
+ assert volume_list.size > 0, "No Volumes in Array"
33
+
34
+ volume_hash = @rvol.list_as_hash
35
+ assert volume_hash.is_a?(Hash), "Not a Hash"
36
+ assert volume_hash.keys.size > 0, "No Volumes in Hash"
37
+
38
+ assert_equal volume_list.size.to_i, volume_hash.keys.size.to_i, "Hash and Array not equal size"
39
+ end
40
+
41
+ should "(90) destroy volumes" do
42
+ assert @rvol.any?, "No volumes"
43
+ volume_list = @rvol.list
44
+ volume_list.each do |vol|
45
+ next unless vol.available?
46
+ ret = @rvol.destroy(vol.awsid)
47
+ assert ret, "Not destroyed (#{ret} for #{vol.awsid})"
48
+ assert @rvol.deleting?(vol.awsid), "Volume not in deleting state (#{vol.awsid}: #{vol.state})"
49
+ end
50
+ end
51
+ end
52
+
53
+ end
54
+ end
55
+
@@ -0,0 +1,110 @@
1
+
2
+ module Rudy::Test
3
+ class Case_50_Commands
4
+
5
+ context "#{name}_50 Instances" do
6
+
7
+ setup do
8
+
9
+ @rmach = Rudy::Instances.new(:logger => @@logger)
10
+ stop_test !@rmach.is_a?(Rudy::Instances), "We needRudy::Instancess (#{@rmach})"
11
+
12
+ @rgroup = Rudy::Groups.new(:logger => @@logger)
13
+ stop_test !@rgroup.is_a?(Rudy::Groups), "We need Rudy::Instances (#{@rgroup})"
14
+
15
+ @rkey = Rudy::KeyPairs.new(:logger => @@logger)
16
+ stop_test !@rkey.is_a?(Rudy::KeyPairs), "We need Rudy::KeyPairs (#{@rkey})"
17
+
18
+ @rvol = Rudy::Volumes.new(:logger => @@logger)
19
+ stop_test !@rvol.is_a?(Rudy::Volumes), "We need Rudy::Volumes (#{@rvol})"
20
+
21
+ @rkey.global.environment = :test
22
+ @rgroup.global.environment = :test
23
+ @rmach.global.environment = :test
24
+ end
25
+
26
+ should "(01) have a test keypair" do
27
+ kp = @rkey.create
28
+ assert kp.is_a?(Rudy::AWS::EC2::KeyPair), "No keypair for #{@rkey.current_machine_group}"
29
+ assert File.exists?(@rkey.path), "No private key"
30
+ end
31
+
32
+ should "(05) have a security group" do
33
+ stop_test @rgroup.exists?(@rmach.current_machine_group), "Destroy existing groups first"
34
+ @rgroup.any?
35
+
36
+ assert @rmach.current_machine_group.is_a?(String), "No current machine group defined"
37
+
38
+ group = @rgroup.create
39
+
40
+ assert group.is_a?(Rudy::AWS::EC2::Group), "Not a Group"
41
+ assert @rgroup.exists?(@rmach.current_machine_group), "No matching security group"
42
+ end
43
+
44
+
45
+ should "(10) create an instance" do
46
+ stop_test @rmach.running?, "Shutdown the instances running in #{@rmach.current_machine_group}"
47
+ instances = @rmach.create
48
+ assert instances.is_a?(Array), "instances is not an Array"
49
+ assert instances.first.is_a?(Rudy::AWS::EC2::Instance), "instance is not a Rudy::AWS::EC2::Instance (#{instances.first.class})"
50
+ assert_equal 1, instances.size, "#{instances.size} instances were started"
51
+ end
52
+
53
+
54
+ should "(20) list instances in machine group" do
55
+ assert @rmach.running?, "No machines running"
56
+ instances = @rmach.list(:running)
57
+ assert instances.is_a?(Array), "instances is not an Array"
58
+ assert instances.first.is_a?(Rudy::AWS::EC2::Instance), "instance is not a Rudy::AWS::EC2::Instance"
59
+ end
60
+
61
+ should "(30) check console output" do
62
+ assert @rmach.console.is_a?(String), "No console output"
63
+ end
64
+
65
+ should "(45) attach volume to instance and then detach it" do
66
+ volume = @rvol.create(1)
67
+ #volume = @rvol.get('vol-9934d4f0')
68
+ instances = @rmach.list(:running)
69
+ assert !instances.empty?, "No instances running"
70
+ instance = instances.first
71
+ assert !volume.attached?, "Volume is attached"
72
+ assert instance.running?, "Instance not running"
73
+ assert volume.available?, "Volume not available"
74
+ assert @rvol.attach(volume, instance), "Volume #{volume.awsid} not attached to #{instance.awsid}"
75
+ assert @rvol.detach(volume), "Volume not detached (#{volume.awsid})"
76
+ assert @rvol.destroy(volume), "Volume not destroyed (#{volume.awsid})"
77
+ end
78
+
79
+ should "(90) destroy instances" do
80
+ assert @rmach.running?, "No instances running"
81
+ assert @rmach.destroy, "Instances not destroyed"
82
+ end
83
+
84
+ should "(95) destroy security group" do
85
+ # We can't delete the machine group until all instances are terminated
86
+ Rudy.waiter(2, 60, @@logger) { !@@ec2.instances.any?(:running) }
87
+ @rgroup.list do |group|
88
+ next if group.name == 'default' # The default group is invisible
89
+ assert @rgroup.destroy(group.name), "Did not destroy #{group.name}"
90
+ end
91
+ end
92
+
93
+
94
+ should "(96) destroy test keypair" do
95
+ # We can't delete the keypair until all instances are terminated
96
+ Rudy.waiter(2, 60, @@logger) { !@@ec2.instances.any?(:running) }
97
+ assert @rkey.destroy, "Keypair (#{@rkey.name}) not destroyed"
98
+ end
99
+
100
+ end
101
+
102
+
103
+ end
104
+ end
105
+
106
+
107
+ # assert_equal 'John Doe', @user.full_name
108
+ # assert_same_elements([:a, :b, :c], [:c, :a, :b])
109
+ # assert_contains(['a', '1'], /\d/)
110
+ # assert_contains(['a', '1'], 'a')
data/test/coverage.txt ADDED
@@ -0,0 +1,51 @@
1
+ Finished in 134.699353 seconds.
2
+
3
+ 81 tests, 200 assertions, 0 failures, 0 errors
4
+ +----------------------------------------------------+-------+-------+--------+
5
+ | File | Lines | LOC | COV |
6
+ +----------------------------------------------------+-------+-------+--------+
7
+ |lib/annoy.rb | 227 | 131 | 42.0% |
8
+ |lib/aws_sdb.rb | 3 | 2 | 100.0% |
9
+ |lib/aws_sdb/error.rb | 42 | 33 | 66.7% |
10
+ |lib/aws_sdb/service.rb | 215 | 192 | 96.4% |
11
+ |lib/console.rb | 401 | 263 | 35.7% |
12
+ |lib/rudy.rb | 275 | 186 | 57.5% |
13
+ |lib/rudy/addresses.rb | 22 | 14 | 57.1% |
14
+ |lib/rudy/aws.rb | 72 | 47 | 91.5% |
15
+ |lib/rudy/aws/ec2.rb | 28 | 23 | 100.0% |
16
+ |lib/rudy/aws/ec2/address.rb | 111 | 80 | 87.5% |
17
+ |lib/rudy/aws/ec2/group.rb | 237 | 150 | 86.7% |
18
+ |lib/rudy/aws/ec2/image.rb | 46 | 33 | 21.2% |
19
+ |lib/rudy/aws/ec2/instance.rb | 283 | 180 | 71.1% |
20
+ |lib/rudy/aws/ec2/keypair.rb | 90 | 71 | 93.0% |
21
+ |lib/rudy/aws/ec2/snapshot.rb | 87 | 63 | 87.3% |
22
+ |lib/rudy/aws/ec2/volume.rb | 184 | 127 | 60.6% |
23
+ |lib/rudy/aws/s3.rb | 3 | 2 | 100.0% |
24
+ |lib/rudy/aws/simpledb.rb | 71 | 54 | 100.0% |
25
+ |lib/rudy/backups.rb | 10 | 5 | 100.0% |
26
+ |lib/rudy/config.rb | 113 | 72 | 91.7% |
27
+ |lib/rudy/disks.rb | 9 | 5 | 100.0% |
28
+ |lib/rudy/groups.rb | 113 | 80 | 82.5% |
29
+ |lib/rudy/huxtable.rb | 212 | 152 | 54.6% |
30
+ |lib/rudy/keypairs.rb | 100 | 78 | 100.0% |
31
+ |lib/rudy/machines.rb | 193 | 142 | 9.2% |
32
+ |lib/rudy/manager.rb | 62 | 43 | 16.3% |
33
+ |lib/rudy/metadata/backup.rb | 135 | 100 | 73.0% |
34
+ |lib/rudy/metadata/disk.rb | 149 | 117 | 47.0% |
35
+ |lib/rudy/metadata/machine.rb | 34 | 23 | 82.6% |
36
+ |lib/rudy/routines.rb | 54 | 26 | 23.1% |
37
+ |lib/rudy/routines/disk_handler.rb | 190 | 133 | 5.3% |
38
+ |lib/rudy/routines/release.rb | 15 | 8 | 100.0% |
39
+ |lib/rudy/routines/script_runner.rb | 65 | 47 | 10.6% |
40
+ |lib/rudy/routines/shutdown.rb | 42 | 30 | 13.3% |
41
+ |lib/rudy/routines/startup.rb | 48 | 33 | 12.1% |
42
+ |lib/rudy/scm/svn.rb | 68 | 50 | 26.0% |
43
+ |lib/rudy/utils.rb | 118 | 75 | 54.7% |
44
+ |lib/rudy/volumes.rb | 108 | 84 | 11.9% |
45
+ |lib/storable.rb | 284 | 185 | 43.8% |
46
+ |lib/sysinfo.rb | 255 | 154 | 35.7% |
47
+ |lib/utils/crypto-key.rb | 93 | 36 | 55.6% |
48
+ +----------------------------------------------------+-------+-------+--------+
49
+ |Total | 4867 | 3329 | 55.6% |
50
+ +----------------------------------------------------+-------+-------+--------+
51
+ 55.6% 41 file(s) 4867 Lines 3329 LOC
data/test/helper.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'rubygems' if defined? Gem
2
+
3
+ libdir = File.join(File.dirname(__FILE__), '..', 'lib')
4
+ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
5
+
6
+ require 'test/unit'
7
+ require 'shoulda'
8
+
9
+ require 'rudy'
10
+
11
+
12
+ puts Rudy.banner("THIS IS RUBY #{RUBY_VERSION}")
13
+
14
+ # +should_stop+ should the test be stopped?
15
+ # +str+ The message to print when +should_stop+ is true
16
+ def stop_test(should_stop, str)
17
+ return unless should_stop
18
+ str ||= "Test stopped for unknown reason"
19
+ abort str.color(:red).bright
20
+ end
21
+ def xstop_test(*args, &ignore)
22
+ #puts %Q(Skipping stop_test: %s "%s") % [args.last.color(:blue), args.first.color(:blue).bright]
23
+ end
24
+
25
+ def skip(msg)
26
+ puts "%s (%s)" % ["SKIP".color(:blue).bright, msg]
27
+ :skip # this doesn't do anything, but I would like it to!
28
+ end
29
+
30
+ def xshould(*args, &ignore)
31
+ puts %Q(Skipping test: %s "%s") % [@name.color(:blue), args.first.color(:blue).bright]
32
+ end
33
+ def xcontext(*args, &ignore)
34
+ puts %q(Skipping context: "%s") % (@name || args.first).color(:blue).bright
35
+ end
data/tryouts/disks.rb ADDED
@@ -0,0 +1,55 @@
1
+ #--
2
+ # TODO: Handle nested hashes and arrays.
3
+ # TODO: to_xml, see: http://codeforpeople.com/lib/ruby/xx/xx-2.0.0/README
4
+ # TODO: Rename to Stuffany
5
+ #++
6
+
7
+ require 'yaml'
8
+ require 'fileutils'
9
+
10
+ module MetaData
11
+ extend self
12
+ @@paul = "front"
13
+
14
+ def paul
15
+ @@paul
16
+ end
17
+ end
18
+
19
+ class Disk < Storable
20
+ include MetaData
21
+ extend MetaData
22
+ field :poop
23
+ field :help
24
+
25
+
26
+ end
27
+
28
+ class Disks
29
+ def find *args
30
+ end
31
+
32
+ def exists? *args
33
+ end
34
+
35
+ end
36
+
37
+ d = Disk.new
38
+ d.poop = "100a"
39
+ d.help = true
40
+
41
+ puts d.paul
42
+ puts Disk.paul
43
+ puts Disk.superclass::VERSION
44
+
45
+ Disks.find disk_name
46
+ Disks.find :env => 'prod', :role => 'app'
47
+ Disks.exists? disk_name
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+