lumberg 1.0.6 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lumberg.rb +0 -1
- data/lib/lumberg/version.rb +1 -1
- data/lib/lumberg/whm/account.rb +24 -101
- data/lib/lumberg/whm/base.rb +3 -7
- data/lib/lumberg/whm/dns.rb +21 -73
- data/lib/lumberg/whm/reseller.rb +20 -113
- data/lib/lumberg/whm/server.rb +12 -63
- data/spec/whm/account_spec.rb +40 -198
- data/spec/whm/base_spec.rb +0 -4
- data/spec/whm/dns_spec.rb +5 -123
- data/spec/whm/reseller_spec.rb +11 -79
- data/spec/whm/server_spec.rb +8 -37
- metadata +4 -82
- data/lib/lumberg/whm/args.rb +0 -113
- data/spec/whm/args_spec.rb +0 -179
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lumberg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
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: 2012-
|
12
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -147,7 +147,6 @@ files:
|
|
147
147
|
- lib/lumberg/version.rb
|
148
148
|
- lib/lumberg/whm.rb
|
149
149
|
- lib/lumberg/whm/account.rb
|
150
|
-
- lib/lumberg/whm/args.rb
|
151
150
|
- lib/lumberg/whm/base.rb
|
152
151
|
- lib/lumberg/whm/dns.rb
|
153
152
|
- lib/lumberg/whm/reseller.rb
|
@@ -218,7 +217,6 @@ files:
|
|
218
217
|
- spec/vcr_cassettes/whm/server/systemloadavg.yml
|
219
218
|
- spec/vcr_cassettes/whm/server/version.yml
|
220
219
|
- spec/whm/account_spec.rb
|
221
|
-
- spec/whm/args_spec.rb
|
222
220
|
- spec/whm/base_spec.rb
|
223
221
|
- spec/whm/dns_spec.rb
|
224
222
|
- spec/whm/reseller_spec.rb
|
@@ -236,93 +234,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
236
234
|
- - ! '>='
|
237
235
|
- !ruby/object:Gem::Version
|
238
236
|
version: '0'
|
239
|
-
segments:
|
240
|
-
- 0
|
241
|
-
hash: 2770939314296025523
|
242
237
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
238
|
none: false
|
244
239
|
requirements:
|
245
240
|
- - ! '>='
|
246
241
|
- !ruby/object:Gem::Version
|
247
242
|
version: '0'
|
248
|
-
segments:
|
249
|
-
- 0
|
250
|
-
hash: 2770939314296025523
|
251
243
|
requirements: []
|
252
244
|
rubyforge_project: lumberg
|
253
245
|
rubygems_version: 1.8.23
|
254
246
|
signing_key:
|
255
247
|
specification_version: 3
|
256
248
|
summary: Ruby library for the WHM & cPanel API
|
257
|
-
test_files:
|
258
|
-
|
259
|
-
- spec/lumberg_spec.rb
|
260
|
-
- spec/spec_helper.rb
|
261
|
-
- spec/vcr_cassettes/whm/account/accountsummary.yml
|
262
|
-
- spec/vcr_cassettes/whm/account/changepackage.yml
|
263
|
-
- spec/vcr_cassettes/whm/account/createacct.yml
|
264
|
-
- spec/vcr_cassettes/whm/account/domainuserdata.yml
|
265
|
-
- spec/vcr_cassettes/whm/account/editquota.yml
|
266
|
-
- spec/vcr_cassettes/whm/account/limitbw.yml
|
267
|
-
- spec/vcr_cassettes/whm/account/listaccts.yml
|
268
|
-
- spec/vcr_cassettes/whm/account/listsuspended.yml
|
269
|
-
- spec/vcr_cassettes/whm/account/modifyacct.yml
|
270
|
-
- spec/vcr_cassettes/whm/account/myprivs.yml
|
271
|
-
- spec/vcr_cassettes/whm/account/passwd.yml
|
272
|
-
- spec/vcr_cassettes/whm/account/removeacct.yml
|
273
|
-
- spec/vcr_cassettes/whm/account/restoreaccount.yml
|
274
|
-
- spec/vcr_cassettes/whm/account/setsiteip.yml
|
275
|
-
- spec/vcr_cassettes/whm/account/suspend.yml
|
276
|
-
- spec/vcr_cassettes/whm/account/unsuspend.yml
|
277
|
-
- spec/vcr_cassettes/whm/dns/adddns.yml
|
278
|
-
- spec/vcr_cassettes/whm/dns/addzonerecord.yml
|
279
|
-
- spec/vcr_cassettes/whm/dns/dumpzone.yml
|
280
|
-
- spec/vcr_cassettes/whm/dns/editzonerecord.yml
|
281
|
-
- spec/vcr_cassettes/whm/dns/getzonerecord.yml
|
282
|
-
- spec/vcr_cassettes/whm/dns/killdns.yml
|
283
|
-
- spec/vcr_cassettes/whm/dns/listmxs.yml
|
284
|
-
- spec/vcr_cassettes/whm/dns/listzones.yml
|
285
|
-
- spec/vcr_cassettes/whm/dns/lookupnsip.yml
|
286
|
-
- spec/vcr_cassettes/whm/dns/removezonerecord.yml
|
287
|
-
- spec/vcr_cassettes/whm/dns/resetzone.yml
|
288
|
-
- spec/vcr_cassettes/whm/dns/resolvedomainname.yml
|
289
|
-
- spec/vcr_cassettes/whm/dns/savemxs.yml
|
290
|
-
- spec/vcr_cassettes/whm/reseller/acctcounts.yml
|
291
|
-
- spec/vcr_cassettes/whm/reseller/listacls.yml
|
292
|
-
- spec/vcr_cassettes/whm/reseller/listresellers.yml
|
293
|
-
- spec/vcr_cassettes/whm/reseller/resellerstats.yml
|
294
|
-
- spec/vcr_cassettes/whm/reseller/saveacllist.yml
|
295
|
-
- spec/vcr_cassettes/whm/reseller/setacls.yml
|
296
|
-
- spec/vcr_cassettes/whm/reseller/setresellerips.yml
|
297
|
-
- spec/vcr_cassettes/whm/reseller/setresellerlimits.yml
|
298
|
-
- spec/vcr_cassettes/whm/reseller/setresellermainip.yml
|
299
|
-
- spec/vcr_cassettes/whm/reseller/setresellernameservers.yml
|
300
|
-
- spec/vcr_cassettes/whm/reseller/setresellerpackagelimit.yml
|
301
|
-
- spec/vcr_cassettes/whm/reseller/setupreseller.yml
|
302
|
-
- spec/vcr_cassettes/whm/reseller/suspendreseller.yml
|
303
|
-
- spec/vcr_cassettes/whm/reseller/terminatereseller.yml
|
304
|
-
- spec/vcr_cassettes/whm/reseller/unsetupreseller.yml
|
305
|
-
- spec/vcr_cassettes/whm/reseller/unsuspendreseller.yml
|
306
|
-
- spec/vcr_cassettes/whm/server/addip.yml
|
307
|
-
- spec/vcr_cassettes/whm/server/applist.yml
|
308
|
-
- spec/vcr_cassettes/whm/server/delip.yml
|
309
|
-
- spec/vcr_cassettes/whm/server/gethostname.yml
|
310
|
-
- spec/vcr_cassettes/whm/server/getlanglist.yml
|
311
|
-
- spec/vcr_cassettes/whm/server/listips.yml
|
312
|
-
- spec/vcr_cassettes/whm/server/loadavg.yml
|
313
|
-
- spec/vcr_cassettes/whm/server/my_function.yml
|
314
|
-
- spec/vcr_cassettes/whm/server/nvget.yml
|
315
|
-
- spec/vcr_cassettes/whm/server/nvset.yml
|
316
|
-
- spec/vcr_cassettes/whm/server/reboot.yml
|
317
|
-
- spec/vcr_cassettes/whm/server/sethostname.yml
|
318
|
-
- spec/vcr_cassettes/whm/server/setresolvers.yml
|
319
|
-
- spec/vcr_cassettes/whm/server/showbw.yml
|
320
|
-
- spec/vcr_cassettes/whm/server/systemloadavg.yml
|
321
|
-
- spec/vcr_cassettes/whm/server/version.yml
|
322
|
-
- spec/whm/account_spec.rb
|
323
|
-
- spec/whm/args_spec.rb
|
324
|
-
- spec/whm/base_spec.rb
|
325
|
-
- spec/whm/dns_spec.rb
|
326
|
-
- spec/whm/reseller_spec.rb
|
327
|
-
- spec/whm/server_spec.rb
|
328
|
-
- spec/whm/whm_spec.rb
|
249
|
+
test_files: []
|
250
|
+
has_rdoc:
|
data/lib/lumberg/whm/args.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
module Lumberg
|
2
|
-
|
3
|
-
#
|
4
|
-
# ==== Optional
|
5
|
-
# * <tt>:whatever</tt> - PENDING
|
6
|
-
module Whm
|
7
|
-
class Args
|
8
|
-
attr_reader :required_params, :boolean_params, :optional_params, :one_of_params
|
9
|
-
attr_reader :options
|
10
|
-
# Check the included hash for the included parameters.
|
11
|
-
# Raises WhmArgumentError when it's mising the proper params
|
12
|
-
#
|
13
|
-
# ==== Example
|
14
|
-
#
|
15
|
-
# Args.new(options) do |c|
|
16
|
-
# c.requries :user, :pass
|
17
|
-
# c.booleans :name
|
18
|
-
# c.optionals :whatever
|
19
|
-
# end
|
20
|
-
def initialize(options)
|
21
|
-
@required_params ||= []
|
22
|
-
@boolean_params ||= []
|
23
|
-
@optional_params ||= []
|
24
|
-
@one_of_params ||= []
|
25
|
-
@options = options
|
26
|
-
|
27
|
-
yield self
|
28
|
-
|
29
|
-
requires!
|
30
|
-
booleans!
|
31
|
-
one_ofs!
|
32
|
-
valid_options!
|
33
|
-
end
|
34
|
-
|
35
|
-
# Specifies the required arguments
|
36
|
-
def requires(*values)
|
37
|
-
@optional_params.concat(values)
|
38
|
-
@required_params = values
|
39
|
-
end
|
40
|
-
|
41
|
-
# Specifies which arguments are boolean
|
42
|
-
def booleans(*values)
|
43
|
-
@optional_params.concat(values)
|
44
|
-
@boolean_params = values
|
45
|
-
end
|
46
|
-
|
47
|
-
# Specifies which arguments are optional
|
48
|
-
def optionals(*values)
|
49
|
-
@optional_params.concat(values)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Specifies which arguments take one of a set of arguments
|
53
|
-
def one_of(*values)
|
54
|
-
@optional_params.concat(values)
|
55
|
-
@one_of_params = values
|
56
|
-
end
|
57
|
-
|
58
|
-
protected
|
59
|
-
|
60
|
-
# Verifies that all required arguments are present
|
61
|
-
def requires!
|
62
|
-
@required_params.each do |param|
|
63
|
-
key = (param.is_a?(Array) ? param.first : param)
|
64
|
-
verify_required_param(key)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
# Checks to see if supplied params (which are booleans) contain
|
70
|
-
# either a 1 ("Yes") or 0 ("No") value.
|
71
|
-
def booleans!
|
72
|
-
@boolean_params.each do |param|
|
73
|
-
key = (param.is_a?(Array) ? param.first : param)
|
74
|
-
verify_boolean_param(key)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# Verifies that only valid arguments were set
|
79
|
-
def valid_options!
|
80
|
-
@options.keys.uniq.each do |key|
|
81
|
-
raise WhmArgumentError.new("Not a valid parameter: #{key}") unless @optional_params.include?(key)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Verifies that the one_of arguments were used correctly
|
86
|
-
def one_ofs!
|
87
|
-
if @one_of_params.size > 1
|
88
|
-
specified = @options.keys.select { |key| @one_of_params.include?(key) }.uniq
|
89
|
-
if specified.size > 1 || specified.size == 0
|
90
|
-
raise WhmArgumentError.new("The parameters may include only one of '#{@one_of_params.join(', ')}'")
|
91
|
-
end
|
92
|
-
else
|
93
|
-
raise WhmArgumentError.new("One of requires two or more items") unless @one_of_params.empty?
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
private
|
98
|
-
|
99
|
-
# Internal method for verifiying required arguments
|
100
|
-
def verify_required_param(param)
|
101
|
-
raise WhmArgumentError.new("Missing required parameter: #{param}") unless @options.has_key?(param)
|
102
|
-
raise WhmArgumentError.new("Required parameter cannot be blank: #{param}") if (@options[param].nil? || (@options[param].respond_to?(:empty?) && @options[param].empty?))
|
103
|
-
end
|
104
|
-
|
105
|
-
# Internal method for verifying boolean arguments
|
106
|
-
def verify_boolean_param(param)
|
107
|
-
if @options.include?(param) && ![true, false].include?(@options[param])
|
108
|
-
raise WhmArgumentError.new("Boolean parameter must be \"true\" or \"false\": #{param}")
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
data/spec/whm/args_spec.rb
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'lumberg/whm/args'
|
3
|
-
|
4
|
-
module Lumberg
|
5
|
-
describe Whm::Args do
|
6
|
-
context "required_parms" do
|
7
|
-
it "raises an error when missing" do
|
8
|
-
options = {:arg1 => true}
|
9
|
-
args = lambda {
|
10
|
-
Whm::Args.new(options) do |c|
|
11
|
-
c.requires :arg2
|
12
|
-
end
|
13
|
-
}
|
14
|
-
expect { args.call }.to raise_error(WhmArgumentError, /Missing required parameter: arg2/)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "does not raise an error with valid params" do
|
18
|
-
options = {:arg1 => true}
|
19
|
-
args = Whm::Args.new(options) { |c|
|
20
|
-
c.requires :arg1
|
21
|
-
}
|
22
|
-
|
23
|
-
args.required_params.should have(1).value
|
24
|
-
args.required_params.should include(:arg1)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "sets optional_params" do
|
28
|
-
options = {:arg1 => true, :arg2 => 2}
|
29
|
-
args = Whm::Args.new(options) { |c|
|
30
|
-
c.requires :arg1, :arg2
|
31
|
-
}
|
32
|
-
|
33
|
-
args.optional_params.should have(2).values
|
34
|
-
args.required_params.should have(2).values
|
35
|
-
|
36
|
-
args.optional_params.should include(*args.required_params)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "does not set boolean_params" do
|
40
|
-
options = {:arg1 => true, :arg2 => 2}
|
41
|
-
args = Whm::Args.new(options) { |c|
|
42
|
-
c.requires :arg1, :arg2
|
43
|
-
}
|
44
|
-
|
45
|
-
args.boolean_params.should be_empty
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "boolean_params" do
|
50
|
-
it "raises an error when the param is not boolean" do
|
51
|
-
options = {:arg1 => 'string'}
|
52
|
-
args = lambda {
|
53
|
-
Whm::Args.new(options) do |c|
|
54
|
-
c.booleans :arg1
|
55
|
-
end
|
56
|
-
}
|
57
|
-
expect { args.call }.to raise_error(WhmArgumentError, /Boolean parameter must be.*: arg1/)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "raises an error with boolean params" do
|
61
|
-
options = {:arg1 => true}
|
62
|
-
args = Whm::Args.new(options) { |c|
|
63
|
-
c.booleans :arg1
|
64
|
-
}
|
65
|
-
|
66
|
-
args.boolean_params.should have(1).value
|
67
|
-
args.boolean_params.should include(:arg1)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "sets optional_params" do
|
71
|
-
options = {:arg1 => true, :arg2 => false}
|
72
|
-
args = Whm::Args.new(options) { |c|
|
73
|
-
c.booleans :arg1, :arg2
|
74
|
-
}
|
75
|
-
|
76
|
-
args.optional_params.should have(2).values
|
77
|
-
args.boolean_params.should have(2).values
|
78
|
-
|
79
|
-
args.optional_params.should include(:arg1, :arg2)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "sets required_params" do
|
83
|
-
options = {:arg1 => true, :arg2 => false}
|
84
|
-
args = Whm::Args.new(options) { |c|
|
85
|
-
c.booleans :arg1, :arg2
|
86
|
-
}
|
87
|
-
|
88
|
-
args.required_params.should be_empty
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context "optional_params" do
|
93
|
-
it "raises an error with unknown params" do
|
94
|
-
options = {:arg1 => true}
|
95
|
-
args = lambda {
|
96
|
-
Whm::Args.new(options) do |c|
|
97
|
-
c.optionals :arg2
|
98
|
-
end
|
99
|
-
}
|
100
|
-
|
101
|
-
expect { args.call }.to raise_error(WhmArgumentError, /Not a valid parameter: arg1/)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "does not raise an error with known params" do
|
105
|
-
options = {:arg1 => true, :arg2 => 2}
|
106
|
-
args = Whm::Args.new(options) { |c|
|
107
|
-
c.optionals :arg1, :arg2
|
108
|
-
}
|
109
|
-
|
110
|
-
args.optional_params.should have(2).values
|
111
|
-
args.optional_params.should include(:arg1, :arg2)
|
112
|
-
end
|
113
|
-
|
114
|
-
it "does not set required_params" do
|
115
|
-
options = {:arg1 => true, :arg2 => 2}
|
116
|
-
args = Whm::Args.new(options) { |c|
|
117
|
-
c.optionals :arg1, :arg2
|
118
|
-
}
|
119
|
-
|
120
|
-
args.required_params.should be_empty
|
121
|
-
end
|
122
|
-
|
123
|
-
it "does not set boolean_params" do
|
124
|
-
options = {:arg1 => true, :arg2 => 2}
|
125
|
-
args = Whm::Args.new(options) { |c|
|
126
|
-
c.optionals :arg1, :arg2
|
127
|
-
}
|
128
|
-
|
129
|
-
args.boolean_params.should be_empty
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "one_of" do
|
134
|
-
it "allows one arg" do
|
135
|
-
options = {:arg1 => true}
|
136
|
-
args = lambda {
|
137
|
-
Whm::Args.new(options) do |c|
|
138
|
-
c.one_of :arg1
|
139
|
-
end
|
140
|
-
}
|
141
|
-
|
142
|
-
expect { args.call }.to raise_error(WhmArgumentError, /One of requires two or more items/)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "allows two or more args" do
|
146
|
-
options = {:arg1 => true}
|
147
|
-
|
148
|
-
args = Whm::Args.new(options) do |c|
|
149
|
-
c.one_of :arg1, :arg2
|
150
|
-
end
|
151
|
-
|
152
|
-
args.one_of_params.should have(2).values
|
153
|
-
args.one_of_params.should include(:arg1, :arg2)
|
154
|
-
end
|
155
|
-
|
156
|
-
it "does not allow 0 params" do
|
157
|
-
options = {}
|
158
|
-
args = lambda {
|
159
|
-
Whm::Args.new(options) do |c|
|
160
|
-
c.one_of :arg1, :arg2
|
161
|
-
end
|
162
|
-
}
|
163
|
-
|
164
|
-
expect { args.call }.to raise_error(WhmArgumentError, /The parameters may include only one of 'arg1, arg2'/)
|
165
|
-
end
|
166
|
-
|
167
|
-
it "does not allow both args" do
|
168
|
-
options = {:arg1 => true, :arg2 => 2}
|
169
|
-
args = lambda {
|
170
|
-
Whm::Args.new(options) do |c|
|
171
|
-
c.one_of :arg1, :arg2
|
172
|
-
end
|
173
|
-
}
|
174
|
-
|
175
|
-
expect { args.call }.to raise_error(WhmArgumentError, /The parameters may include only one of 'arg1, arg2'/)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|