dreamy 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,32 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamyDnsTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @xml = <<EOF
8
+ <data>
9
+ <account_id>8675309</account_id>
10
+ <comment></comment>
11
+ <editable>0</editable>
12
+ <record>anessalee.net</record>
13
+ <type>A</type>
14
+ <value>202.22.191.4</value>
15
+ <zone>anessalee.net</zone>
16
+ </data>
17
+ EOF
18
+ end
19
+
20
+ should "create a new DNS entry from xml" do
21
+ d = Dreamy::Dns.new_from_xml(Hpricot.XML(@xml))
22
+ assert_equal 8675309, d.account_id
23
+ assert_equal "", d.comment
24
+ assert_equal 0, d.editable
25
+ assert_equal "anessalee.net", d.record
26
+ assert_equal "A", d.type
27
+ assert_equal "202.22.191.4", d.value
28
+ assert_equal "anessalee.net", d.zone
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,74 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamyDomainTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @domain_xml = <<EOF
8
+ <data>
9
+ <account_id>8675309</account_id>
10
+ <domain>anessalee.net</domain>
11
+ <fastcgi>0</fastcgi>
12
+ <home>juniormint.Dreamy.com</home>
13
+ <hosting_type>full</hosting_type>
14
+ <outside_url></outside_url>
15
+ <passenger>0</passenger>
16
+ <path>anessalee.net</path>
17
+ <php>pcgi5</php>
18
+ <php_fcgid>0</php_fcgid>
19
+ <security>0</security>
20
+ <type>http</type>
21
+ <unique_ip></unique_ip>
22
+ <user>sant0sk1</user>
23
+ <www_or_not>both_work</www_or_not>
24
+ <xcache>0</xcache>
25
+ </data>
26
+ EOF
27
+
28
+ @mysql_xml = <<EOF
29
+ <data>
30
+ <account_id>8675309</account_id>
31
+ <domain>mysql.anessalee.net</domain>
32
+ <home>zechiel.swordfish.Dreamy.com</home>
33
+ <type>mysqldns</type>
34
+ <unique_ip></unique_ip>
35
+ </data>
36
+ EOF
37
+
38
+ @d = Dreamy::Domain.new_from_xml(Hpricot.XML(@domain_xml))
39
+ @m = Dreamy::Domain.new_from_xml(Hpricot.XML(@mysql_xml))
40
+ end
41
+
42
+ should "assign valid http domain from xml" do
43
+ assert_equal 8675309, @d.account_id
44
+ assert_equal "anessalee.net", @d.domain
45
+ assert_equal 0, @d.fastcgi
46
+ assert_equal "juniormint.Dreamy.com", @d.home
47
+ assert_equal "full", @d.hosting_type
48
+ assert_equal "", @d.outside_url
49
+ assert_equal 0, @d.passenger
50
+ assert_equal "anessalee.net", @d.path
51
+ assert_equal "pcgi5", @d.php
52
+ assert_equal 0, @d.php_fcgid
53
+ assert_equal 0, @d.security
54
+ assert_equal "http", @d.type
55
+ assert_equal "", @d.unique_ip
56
+ assert_equal "sant0sk1", @d.user
57
+ assert_equal "both_work", @d.www_or_not
58
+ assert_equal 0, @d.xcache
59
+ end
60
+
61
+ should "assign valid mysql domain from xml" do
62
+ assert_equal 8675309, @m.account_id
63
+ assert_equal "mysql.anessalee.net", @m.domain
64
+ assert_equal "zechiel.swordfish.Dreamy.com", @m.home
65
+ assert_equal "mysqldns", @m.type
66
+ assert_equal "", @m.unique_ip
67
+ end
68
+
69
+ should "return shortened server name if requested" do
70
+ assert_equal "juniormint", @d.short_home
71
+ end
72
+ end
73
+
74
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamyMysqlDbTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @xml = <<EOF
8
+ <data>
9
+ <account_id>8675309</account_id>
10
+ <db>betterdb2435</db>
11
+ <description>This one's better</description>
12
+ <home>haass.tuna.dreamhost.com</home>
13
+ <disk_usage_mb>0.0078125</disk_usage_mb>
14
+ </data>
15
+ EOF
16
+ end
17
+
18
+ should "create a new user from xml" do
19
+ db = Dreamy::MysqlDb.new_from_xml(Hpricot.XML(@xml))
20
+ assert_equal 8675309, db.account_id
21
+ assert_equal "betterdb2435", db.name
22
+ assert_equal "This one's better", db.description
23
+ assert_equal "haass.tuna.dreamhost.com", db.home
24
+ assert_equal 0.0078125, db.disk_usage_mb
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamyMysqlHostTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @xml = <<EOF
8
+ <data>
9
+ <account_id>8675309</account_id>
10
+ <domain>mysql.site.dreamhosters.com</domain>
11
+ <home>haass.tuna.dreamhost.com</home>
12
+ </data>
13
+ EOF
14
+ end
15
+
16
+ should "create a new user from xml" do
17
+ host = Dreamy::MysqlHost.new_from_xml(Hpricot.XML(@xml))
18
+ assert_equal 8675309, host.account_id
19
+ assert_equal "mysql.site.dreamhosters.com", host.domain
20
+ assert_equal "haass.tuna.dreamhost.com", host.home
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamyMysqlUserTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @xml = <<EOF
8
+ <data>
9
+ <account_id>8675309</account_id>
10
+ <db>betterdb2435</db>
11
+ <home>haass.tuna.dreamhost.com</home>
12
+ <username>user_fu</username>
13
+ <host>haass.tuna.dreamhost.com</host>
14
+ <select_priv>Y</select_priv>
15
+ <insert_priv>Y</insert_priv>
16
+ <update_priv>N</update_priv>
17
+ <delete_priv>Y</delete_priv>
18
+ <create_priv>N</create_priv>
19
+ <drop_priv>Y</drop_priv>
20
+ <index_priv>Y</index_priv>
21
+ <alter_priv>N</alter_priv>
22
+ </data>
23
+ EOF
24
+ end
25
+
26
+ should "create a new user from xml" do
27
+ u = Dreamy::MysqlUser.new_from_xml(Hpricot.XML(@xml))
28
+ assert_equal 8675309, u.account_id
29
+ assert_equal "betterdb2435", u.db
30
+ assert_equal "haass.tuna.dreamhost.com", u.home
31
+ assert_equal "user_fu", u.username
32
+ assert_equal "haass.tuna.dreamhost.com", u.host
33
+ assert_equal "Y", u.select
34
+ assert_equal "Y", u.insert
35
+ assert_equal "N", u.update
36
+ assert_equal "Y", u.delete
37
+ assert_equal "N", u.create
38
+ assert_equal "Y", u.drop
39
+ assert_equal "Y", u.index
40
+ assert_equal "N", u.alter
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,147 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamyPrivateServerTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @xml = <<EOF
8
+ <data>
9
+ <account_id>8675309</account_id>
10
+ <ps>ps10034</ps>
11
+ <type>web</type>
12
+ <memory_mb>200</memory_mb>
13
+ <start_date>2008-07-23</start_date>
14
+ </data>
15
+ EOF
16
+ end
17
+
18
+ should "create a new PS from xml" do
19
+ ps = Dreamy::PrivateServer.new_from_xml(Hpricot.XML(@xml))
20
+ assert_equal 8675309, ps.account_id
21
+ assert_equal "ps10034", ps.name
22
+ assert_equal "web", ps.type
23
+ assert_equal 200, ps.memory
24
+ assert_equal "2008-07-23", ps.start_date
25
+ end
26
+ end
27
+
28
+ context "Settings" do
29
+ setup do
30
+ @xml = <<EOF
31
+ <data>
32
+ <setting>apache2_enabled</setting>
33
+ <value>1</value>
34
+ </data>
35
+ <data>
36
+ <setting>comment</setting>
37
+ <value></value>
38
+ </data>
39
+ <data>
40
+ <setting>courier_enabled</setting>
41
+ <value>0</value>
42
+ </data>
43
+ <data>
44
+ <setting>jabber_transports_enabled</setting>
45
+ <value>1</value>
46
+ </data>
47
+ <data>
48
+ <setting>lighttpd_enabled</setting>
49
+ <value>0</value>
50
+ </data>
51
+ <data>
52
+ <setting>machine</setting>
53
+ <value>ps12345</value>
54
+ </data>
55
+ <data>
56
+ <setting>modphp_4_selected</setting>
57
+ <value>1</value>
58
+ </data>
59
+ <data>
60
+ <setting>php_cache_xcache</setting>
61
+ <value>0</value>
62
+ </data>
63
+ <data>
64
+ <setting>proftpd_enabled</setting>
65
+ <value>1</value>
66
+ </data>
67
+ <result>success</result>
68
+ EOF
69
+ end
70
+
71
+ should "create settings hash from xml" do
72
+ settings = Dreamy::PrivateServer.settings_from_xml(Hpricot.XML(@xml))
73
+ assert_equal "1", settings["apache2_enabled"]
74
+ assert_equal "", settings["comment"]
75
+ assert_equal "0", settings["courier_enabled"]
76
+ assert_equal "1", settings["jabber_transports_enabled"]
77
+ assert_equal "0", settings["lighttpd_enabled"]
78
+ assert_equal "ps12345", settings["machine"]
79
+ assert_equal "1", settings["modphp_4_selected"]
80
+ assert_equal "0", settings["php_cache_xcache"]
81
+ assert_equal "1", settings["proftpd_enabled"]
82
+ end
83
+ end
84
+
85
+ context "Sizes" do
86
+ setup do
87
+ @xml = <<EOF
88
+ <data>
89
+ <memory_mb>2300</memory_mb>
90
+ <monthly_cost>0.00</monthly_cost>
91
+ <period_cost>0.0000</period_cost>
92
+ <period_seconds>715</period_seconds>
93
+ <stamp>2009-04-29 16:28:28</stamp>
94
+ </data>
95
+ EOF
96
+ end
97
+
98
+ should "create size hash from xml" do
99
+ size = Dreamy::PrivateServer.size_from_xml(Hpricot.XML(@xml))
100
+ assert_equal 2300, size["memory_mb"]
101
+ assert_equal 0.00, size["monthly_cost"]
102
+ assert_equal 0.0000, size["period_cost"]
103
+ assert_equal 715, size["period_seconds"]
104
+ assert_equal "2009-04-29 16:28:28", size["stamp"]
105
+ end
106
+ end
107
+
108
+ context "Usage" do
109
+ setup do
110
+ @xml = <<EOF
111
+ <data>
112
+ <load>0.02</load>
113
+ <memory_mb>146</memory_mb>
114
+ <stamp>2009-05-02 17:26:44</stamp>
115
+ </data>
116
+ EOF
117
+ end
118
+
119
+ should "create usage hash from xml" do
120
+ usage = Dreamy::PrivateServer.usage_from_xml(Hpricot.XML(@xml))
121
+ assert_equal 0.02, usage["load"]
122
+ assert_equal 146, usage["memory_mb"]
123
+ assert_equal "2009-05-02 17:26:44", usage["stamp"]
124
+ end
125
+ end
126
+
127
+ context "Pending servers" do
128
+ setup do
129
+ @xml = <<EOF
130
+ <data>
131
+ <account_id>8675309</account_id>
132
+ <ip>10.5.3.2</ip>
133
+ <type>web</type>
134
+ <stamp>2009-03-12 06:43:48</stamp>
135
+ </data>
136
+ EOF
137
+ end
138
+
139
+ should "create pending server hash from xml" do
140
+ pending = Dreamy::PrivateServer.pending_from_xml(Hpricot.XML(@xml))
141
+ assert_equal "8675309", pending["account_id"]
142
+ assert_equal "10.5.3.2", pending["ip"]
143
+ assert_equal "2009-03-12 06:43:48", pending["stamp"]
144
+ end
145
+ end
146
+
147
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamySubscriberTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @xml = <<EOF
8
+ <data>
9
+ <email>joe@schmoe.com</email>
10
+ <confirmed>1</confirmed>
11
+ <subscribe_date>2007-12-13 16:55:15</subscribe_date>
12
+ <name>Josh</name>
13
+ <num_bounces>0</num_bounces>
14
+ </data>
15
+ EOF
16
+ end
17
+
18
+ should "create a new user from xml" do
19
+ s = Dreamy::Subscriber.new_from_xml(Hpricot.XML(@xml))
20
+ assert_equal "joe@schmoe.com", s.email
21
+ assert_equal 1, s.confirmed
22
+ assert_equal "2007-12-13 16:55:15", s.subscribe_date
23
+ assert_equal "Josh", s.name
24
+ assert_equal 0, s.num_bounces
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,10 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'shoulda'
4
+
5
+ dir = File.dirname(__FILE__)
6
+
7
+ $:.unshift(File.join(dir, '/../lib/'))
8
+ require dir + '/../lib/dreamy'
9
+
10
+ CREDS = YAML::load(File.open("#{dir}/credentials.yml"))
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + "/test_helper.rb"
2
+
3
+ class DreamyUserTest < Test::Unit::TestCase
4
+
5
+ context "Creation" do
6
+ setup do
7
+ @xml = <<EOF
8
+ <data>
9
+ <account_id>8675309</account_id>
10
+ <disk_used_mb>123.04</disk_used_mb>
11
+ <gecos>Joe Schmoe</gecos>
12
+ <home>spork.Dreamy.com</home>
13
+ <password>YahRight!</password>
14
+ <quota_mb>50</quota_mb>
15
+ <shell>/bin/bash</shell>
16
+ <type>mail</type>
17
+ <username>joe@schmoe.com</username>
18
+ </data>
19
+ EOF
20
+ end
21
+
22
+ should "create a new user from xml" do
23
+ u = Dreamy::User.new_from_xml(Hpricot.XML(@xml))
24
+ assert_equal 8675309, u.account_id
25
+ assert_equal 123.04, u.disk_used_mb
26
+ assert_equal "Joe Schmoe", u.gecos
27
+ assert_equal "spork.Dreamy.com", u.home
28
+ assert_equal "YahRight!", u.password
29
+ assert_equal 50, u.quota_mb
30
+ assert_equal "/bin/bash", u.shell
31
+ assert_equal "mail", u.type
32
+ assert_equal "joe@schmoe.com", u.username
33
+ end
34
+ end
35
+
36
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dreamy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
+ platform: ruby
6
+ authors:
7
+ - Jerod Santo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-20 00:00:00 -05:00
13
+ default_executable: dh
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: visionmedia-terminal-table
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.5
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hpricot
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0.7"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: uuid
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.0.1
44
+ version:
45
+ description:
46
+ email: jerod.santo@gmail.com
47
+ executables:
48
+ - dh
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - README.md
53
+ files:
54
+ - README.md
55
+ - Rakefile
56
+ - VERSION.yml
57
+ - bin/dh
58
+ - lib/dreamy.rb
59
+ - lib/dreamy/announce_list.rb
60
+ - lib/dreamy/base.rb
61
+ - lib/dreamy/command.rb
62
+ - lib/dreamy/commands/announce.rb
63
+ - lib/dreamy/commands/base.rb
64
+ - lib/dreamy/commands/dns.rb
65
+ - lib/dreamy/commands/domains.rb
66
+ - lib/dreamy/commands/help.rb
67
+ - lib/dreamy/commands/mysql.rb
68
+ - lib/dreamy/commands/ps.rb
69
+ - lib/dreamy/commands/users.rb
70
+ - lib/dreamy/core_extensions.rb
71
+ - lib/dreamy/dns.rb
72
+ - lib/dreamy/domain.rb
73
+ - lib/dreamy/easy_class_maker.rb
74
+ - lib/dreamy/mysql/db.rb
75
+ - lib/dreamy/mysql/host.rb
76
+ - lib/dreamy/mysql/user.rb
77
+ - lib/dreamy/private_server.rb
78
+ - lib/dreamy/subscriber.rb
79
+ - lib/dreamy/user.rb
80
+ - test/announce_test.rb
81
+ - test/base_test.rb
82
+ - test/dns_test.rb
83
+ - test/domain_test.rb
84
+ - test/mysql_db_test.rb
85
+ - test/mysql_host_test.rb
86
+ - test/mysql_user_test.rb
87
+ - test/private_server_test.rb
88
+ - test/subscriber_test.rb
89
+ - test/test_helper.rb
90
+ - test/user_test.rb
91
+ has_rdoc: true
92
+ homepage: http://github.com/sant0sk1/dreamy
93
+ licenses: []
94
+
95
+ post_install_message:
96
+ rdoc_options:
97
+ - --charset=UTF-8
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
105
+ version:
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: "0"
111
+ version:
112
+ requirements: []
113
+
114
+ rubyforge_project:
115
+ rubygems_version: 1.3.5
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: A Ruby library and command line tool for accessing DreamHost's API
119
+ test_files:
120
+ - test/announce_test.rb
121
+ - test/base_test.rb
122
+ - test/dns_test.rb
123
+ - test/domain_test.rb
124
+ - test/mysql_db_test.rb
125
+ - test/mysql_host_test.rb
126
+ - test/mysql_user_test.rb
127
+ - test/private_server_test.rb
128
+ - test/subscriber_test.rb
129
+ - test/test_helper.rb
130
+ - test/user_test.rb