chef 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chef might be problematic. Click here for more details.
- data/LICENSE +201 -0
- data/README.rdoc +135 -0
- data/bin/chef-client +26 -0
- data/bin/chef-solo +26 -0
- data/lib/chef.rb +49 -0
- data/lib/chef/application.rb +98 -0
- data/lib/chef/application/agent.rb +18 -0
- data/lib/chef/application/client.rb +209 -0
- data/lib/chef/application/indexer.rb +141 -0
- data/lib/chef/application/server.rb +18 -0
- data/lib/chef/application/solo.rb +214 -0
- data/lib/chef/client.rb +396 -0
- data/lib/chef/compile.rb +138 -0
- data/lib/chef/config.rb +141 -0
- data/lib/chef/cookbook.rb +144 -0
- data/lib/chef/cookbook/metadata.rb +407 -0
- data/lib/chef/cookbook/metadata/version.rb +87 -0
- data/lib/chef/cookbook_loader.rb +168 -0
- data/lib/chef/couchdb.rb +172 -0
- data/lib/chef/daemon.rb +170 -0
- data/lib/chef/exceptions.rb +36 -0
- data/lib/chef/file_cache.rb +205 -0
- data/lib/chef/log.rb +39 -0
- data/lib/chef/mixin/check_helper.rb +31 -0
- data/lib/chef/mixin/checksum.rb +37 -0
- data/lib/chef/mixin/command.rb +351 -0
- data/lib/chef/mixin/create_path.rb +56 -0
- data/lib/chef/mixin/deep_merge.rb +36 -0
- data/lib/chef/mixin/find_preferred_file.rb +99 -0
- data/lib/chef/mixin/from_file.rb +36 -0
- data/lib/chef/mixin/generate_url.rb +48 -0
- data/lib/chef/mixin/language.rb +79 -0
- data/lib/chef/mixin/params_validate.rb +197 -0
- data/lib/chef/mixin/template.rb +84 -0
- data/lib/chef/node.rb +406 -0
- data/lib/chef/node/attribute.rb +412 -0
- data/lib/chef/openid_registration.rb +181 -0
- data/lib/chef/platform.rb +253 -0
- data/lib/chef/provider.rb +40 -0
- data/lib/chef/provider/cron.rb +137 -0
- data/lib/chef/provider/directory.rb +72 -0
- data/lib/chef/provider/execute.rb +58 -0
- data/lib/chef/provider/file.rb +191 -0
- data/lib/chef/provider/group.rb +120 -0
- data/lib/chef/provider/group/groupadd.rb +92 -0
- data/lib/chef/provider/group/pw.rb +88 -0
- data/lib/chef/provider/http_request.rb +102 -0
- data/lib/chef/provider/ifconfig.rb +131 -0
- data/lib/chef/provider/link.rb +157 -0
- data/lib/chef/provider/mount.rb +121 -0
- data/lib/chef/provider/mount/mount.rb +208 -0
- data/lib/chef/provider/package.rb +160 -0
- data/lib/chef/provider/package/apt.rb +110 -0
- data/lib/chef/provider/package/dpkg.rb +113 -0
- data/lib/chef/provider/package/freebsd.rb +153 -0
- data/lib/chef/provider/package/macports.rb +105 -0
- data/lib/chef/provider/package/portage.rb +124 -0
- data/lib/chef/provider/package/rpm.rb +99 -0
- data/lib/chef/provider/package/rubygems.rb +130 -0
- data/lib/chef/provider/package/yum-dump.py +104 -0
- data/lib/chef/provider/package/yum.rb +175 -0
- data/lib/chef/provider/remote_directory.rb +126 -0
- data/lib/chef/provider/remote_file.rb +134 -0
- data/lib/chef/provider/route.rb +118 -0
- data/lib/chef/provider/ruby_block.rb +15 -0
- data/lib/chef/provider/script.rb +42 -0
- data/lib/chef/provider/service.rb +129 -0
- data/lib/chef/provider/service/debian.rb +64 -0
- data/lib/chef/provider/service/freebsd.rb +157 -0
- data/lib/chef/provider/service/gentoo.rb +54 -0
- data/lib/chef/provider/service/init.rb +126 -0
- data/lib/chef/provider/service/redhat.rb +62 -0
- data/lib/chef/provider/template.rb +141 -0
- data/lib/chef/provider/user.rb +170 -0
- data/lib/chef/provider/user/pw.rb +113 -0
- data/lib/chef/provider/user/useradd.rb +107 -0
- data/lib/chef/queue.rb +145 -0
- data/lib/chef/recipe.rb +210 -0
- data/lib/chef/resource.rb +256 -0
- data/lib/chef/resource/apt_package.rb +34 -0
- data/lib/chef/resource/bash.rb +33 -0
- data/lib/chef/resource/cron.rb +143 -0
- data/lib/chef/resource/csh.rb +33 -0
- data/lib/chef/resource/directory.rb +76 -0
- data/lib/chef/resource/dpkg_package.rb +34 -0
- data/lib/chef/resource/execute.rb +127 -0
- data/lib/chef/resource/file.rb +84 -0
- data/lib/chef/resource/gem_package.rb +41 -0
- data/lib/chef/resource/group.rb +68 -0
- data/lib/chef/resource/http_request.rb +52 -0
- data/lib/chef/resource/ifconfig.rb +134 -0
- data/lib/chef/resource/link.rb +78 -0
- data/lib/chef/resource/macports_package.rb +29 -0
- data/lib/chef/resource/mount.rb +135 -0
- data/lib/chef/resource/package.rb +80 -0
- data/lib/chef/resource/perl.rb +33 -0
- data/lib/chef/resource/portage_package.rb +33 -0
- data/lib/chef/resource/python.rb +33 -0
- data/lib/chef/resource/remote_directory.rb +91 -0
- data/lib/chef/resource/remote_file.rb +60 -0
- data/lib/chef/resource/route.rb +135 -0
- data/lib/chef/resource/ruby.rb +33 -0
- data/lib/chef/resource/ruby_block.rb +20 -0
- data/lib/chef/resource/script.rb +51 -0
- data/lib/chef/resource/service.rb +134 -0
- data/lib/chef/resource/template.rb +60 -0
- data/lib/chef/resource/user.rb +98 -0
- data/lib/chef/resource_collection.rb +176 -0
- data/lib/chef/resource_definition.rb +67 -0
- data/lib/chef/rest.rb +238 -0
- data/lib/chef/role.rb +231 -0
- data/lib/chef/run_list.rb +156 -0
- data/lib/chef/runner.rb +123 -0
- data/lib/chef/search.rb +88 -0
- data/lib/chef/search/result.rb +64 -0
- data/lib/chef/search_index.rb +77 -0
- data/lib/chef/tasks/chef_repo.rake +345 -0
- data/lib/chef/util/file_edit.rb +125 -0
- data/lib/chef/util/fileedit.rb +121 -0
- metadata +262 -0
@@ -0,0 +1,256 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/mixin/params_validate'
|
20
|
+
require 'chef/mixin/check_helper'
|
21
|
+
require 'chef/mixin/language'
|
22
|
+
require 'chef/resource_collection'
|
23
|
+
require 'chef/node'
|
24
|
+
|
25
|
+
class Chef
|
26
|
+
class Resource
|
27
|
+
|
28
|
+
include Chef::Mixin::CheckHelper
|
29
|
+
include Chef::Mixin::ParamsValidate
|
30
|
+
include Chef::Mixin::Language
|
31
|
+
|
32
|
+
attr_accessor :actions, :params, :provider, :updated, :allowed_actions, :collection, :cookbook_name, :recipe_name
|
33
|
+
attr_reader :resource_name, :source_line, :node
|
34
|
+
|
35
|
+
def initialize(name, collection=nil, node=nil)
|
36
|
+
@name = name
|
37
|
+
if collection
|
38
|
+
@collection = collection
|
39
|
+
else
|
40
|
+
@collection = Chef::ResourceCollection.new()
|
41
|
+
end
|
42
|
+
@node = node ? node : Chef::Node.new
|
43
|
+
@noop = nil
|
44
|
+
@before = nil
|
45
|
+
@actions = Hash.new
|
46
|
+
@params = Hash.new
|
47
|
+
@provider = nil
|
48
|
+
@allowed_actions = [ :nothing ]
|
49
|
+
@action = :nothing
|
50
|
+
@updated = false
|
51
|
+
@supports = {}
|
52
|
+
@ignore_failure = false
|
53
|
+
@not_if = nil
|
54
|
+
@only_if = nil
|
55
|
+
sline = caller(4).shift
|
56
|
+
if sline
|
57
|
+
@source_line = sline.gsub!(/^(.+):(.+):.+$/, '\1 line \2')
|
58
|
+
@source_line = ::File.expand_path(@source_line) if @source_line
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def load_prior_resource
|
63
|
+
begin
|
64
|
+
prior_resource = @collection.lookup(self.to_s)
|
65
|
+
Chef::Log.debug("Setting #{self.to_s} to the state of the prior #{self.to_s}")
|
66
|
+
prior_resource.instance_variables.each do |iv|
|
67
|
+
unless iv == "@source_line" || iv == "@action"
|
68
|
+
self.instance_variable_set(iv, prior_resource.instance_variable_get(iv))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
true
|
72
|
+
rescue ArgumentError => e
|
73
|
+
true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def supports(args={})
|
78
|
+
if args.any?
|
79
|
+
@supports = args
|
80
|
+
else
|
81
|
+
@supports
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def provider(arg=nil)
|
86
|
+
set_or_return(
|
87
|
+
:provider,
|
88
|
+
arg,
|
89
|
+
:kind_of => [ Class ]
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
def action(arg=nil)
|
94
|
+
if arg
|
95
|
+
action_list = arg.kind_of?(Array) ? arg : [ arg ]
|
96
|
+
action_list = action_list.collect { |a| a.to_sym }
|
97
|
+
action_list.each do |action|
|
98
|
+
validate(
|
99
|
+
{
|
100
|
+
:action => action,
|
101
|
+
},
|
102
|
+
{
|
103
|
+
:action => { :kind_of => Symbol, :equal_to => @allowed_actions },
|
104
|
+
}
|
105
|
+
)
|
106
|
+
end
|
107
|
+
@action = action_list
|
108
|
+
else
|
109
|
+
@action
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def name(name=nil)
|
114
|
+
set_if_args(@name, name) do
|
115
|
+
raise ArgumentError, "name must be a string!" unless name.kind_of?(String)
|
116
|
+
@name = name
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def noop(tf=nil)
|
121
|
+
set_if_args(@noop, tf) do
|
122
|
+
raise ArgumentError, "noop must be true or false!" unless tf == true || tf == false
|
123
|
+
@noop = tf
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def ignore_failure(arg=nil)
|
128
|
+
set_or_return(
|
129
|
+
:ignore_failure,
|
130
|
+
arg,
|
131
|
+
:kind_of => [ TrueClass, FalseClass ]
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
def epic_fail(arg=nil)
|
136
|
+
ignore_failure(arg)
|
137
|
+
end
|
138
|
+
|
139
|
+
def notifies(*args)
|
140
|
+
raise ArgumentError, "Wrong number of arguments (should be 1, 2, or 3)" unless ( args.size > 0 && args.size < 4)
|
141
|
+
if args.size > 1
|
142
|
+
notifies_helper(*args)
|
143
|
+
else
|
144
|
+
resources_array = *args
|
145
|
+
resources_array.each do |resource|
|
146
|
+
resource.each do |key, value|
|
147
|
+
notifies_helper(value[0], key, value[1])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def resources(*args)
|
154
|
+
@collection.resources(*args)
|
155
|
+
end
|
156
|
+
|
157
|
+
def subscribes(action, resources, timing=:delayed)
|
158
|
+
timing = check_timing(timing)
|
159
|
+
rarray = resources.kind_of?(Array) ? resources : [ resources ]
|
160
|
+
rarray.each do |resource|
|
161
|
+
action_sym = action.to_sym
|
162
|
+
if resource.actions.has_key?(action_sym)
|
163
|
+
resource.actions[action_sym][timing] << self
|
164
|
+
else
|
165
|
+
resource.actions[action_sym] = Hash.new
|
166
|
+
resource.actions[action_sym][:delayed] = Array.new
|
167
|
+
resource.actions[action_sym][:immediate] = Array.new
|
168
|
+
resource.actions[action_sym][timing] << self
|
169
|
+
end
|
170
|
+
end
|
171
|
+
true
|
172
|
+
end
|
173
|
+
|
174
|
+
def is(*args)
|
175
|
+
return *args
|
176
|
+
end
|
177
|
+
|
178
|
+
def to_s
|
179
|
+
"#{@resource_name}[#{@name}]"
|
180
|
+
end
|
181
|
+
|
182
|
+
# Serialize this object as a hash
|
183
|
+
def to_json(*a)
|
184
|
+
instance_vars = Hash.new
|
185
|
+
self.instance_variables.each do |iv|
|
186
|
+
instance_vars[iv] = self.instance_variable_get(iv) unless iv == "@collection"
|
187
|
+
end
|
188
|
+
results = {
|
189
|
+
'json_class' => self.class.name,
|
190
|
+
'instance_vars' => instance_vars
|
191
|
+
}
|
192
|
+
results.to_json(*a)
|
193
|
+
end
|
194
|
+
|
195
|
+
def self.json_create(o)
|
196
|
+
resource = self.new(o["instance_vars"]["@name"])
|
197
|
+
o["instance_vars"].each do |k,v|
|
198
|
+
resource.instance_variable_set(k.to_sym, v)
|
199
|
+
end
|
200
|
+
resource
|
201
|
+
end
|
202
|
+
|
203
|
+
def only_if(arg=nil, &blk)
|
204
|
+
if Kernel.block_given?
|
205
|
+
@only_if = blk
|
206
|
+
else
|
207
|
+
@only_if = arg if arg
|
208
|
+
end
|
209
|
+
@only_if
|
210
|
+
end
|
211
|
+
|
212
|
+
def not_if(arg=nil, &blk)
|
213
|
+
if Kernel.block_given?
|
214
|
+
@not_if = blk
|
215
|
+
else
|
216
|
+
@not_if = arg if arg
|
217
|
+
end
|
218
|
+
@not_if
|
219
|
+
end
|
220
|
+
|
221
|
+
def run_action(action)
|
222
|
+
provider = Chef::Platform.provider_for_node(@node, self)
|
223
|
+
provider.load_current_resource
|
224
|
+
provider.send("action_#{action}")
|
225
|
+
end
|
226
|
+
|
227
|
+
private
|
228
|
+
|
229
|
+
def check_timing(timing)
|
230
|
+
unless timing == :delayed || timing == :immediate || timing == :immediately
|
231
|
+
raise ArgumentError, "Timing must be :delayed or :immediate(ly), you said #{timing}"
|
232
|
+
end
|
233
|
+
if timing == :immediately
|
234
|
+
timing = :immediate
|
235
|
+
end
|
236
|
+
timing
|
237
|
+
end
|
238
|
+
|
239
|
+
def notifies_helper(action, resources, timing=:delayed)
|
240
|
+
timing = check_timing(timing)
|
241
|
+
rarray = resources.kind_of?(Array) ? resources : [ resources ]
|
242
|
+
rarray.each do |resource|
|
243
|
+
action_sym = action.to_sym
|
244
|
+
if @actions.has_key?(action_sym)
|
245
|
+
@actions[action_sym][timing] << resource
|
246
|
+
else
|
247
|
+
@actions[action_sym] = Hash.new
|
248
|
+
@actions[action_sym][:delayed] = Array.new
|
249
|
+
@actions[action_sym][:immediate] = Array.new
|
250
|
+
@actions[action_sym][timing] << resource
|
251
|
+
end
|
252
|
+
end
|
253
|
+
true
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/resource/package'
|
20
|
+
require 'chef/provider/package/apt'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Resource
|
24
|
+
class AptPackage < Chef::Resource::Package
|
25
|
+
|
26
|
+
def initialize(name, collection=nil, node=nil)
|
27
|
+
super(name, collection, node)
|
28
|
+
@resource_name = :apt_package
|
29
|
+
@provider = Chef::Provider::Package::Apt
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/resource/script'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Resource
|
23
|
+
class Bash < Chef::Resource::Script
|
24
|
+
|
25
|
+
def initialize(name, collection=nil, node=nil)
|
26
|
+
super(name, collection, node)
|
27
|
+
@resource_name = :bash
|
28
|
+
@interpreter = "bash"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/resource'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Resource
|
23
|
+
class Cron < Chef::Resource
|
24
|
+
|
25
|
+
def initialize(name, collection=nil, node=nil)
|
26
|
+
super(name, collection, node)
|
27
|
+
@resource_name = :cron
|
28
|
+
@action = :create
|
29
|
+
@allowed_actions.push(:create, :delete)
|
30
|
+
@minute = "*"
|
31
|
+
@hour = "*"
|
32
|
+
@day = "*"
|
33
|
+
@month = "*"
|
34
|
+
@weekday = "*"
|
35
|
+
@command = nil
|
36
|
+
@user = "root"
|
37
|
+
end
|
38
|
+
|
39
|
+
def minute(arg=nil)
|
40
|
+
if arg.is_a?(Integer)
|
41
|
+
converted_arg = arg.to_s
|
42
|
+
else
|
43
|
+
converted_arg = arg
|
44
|
+
end
|
45
|
+
begin
|
46
|
+
if Integer(arg) > 59 then raise RangeError end
|
47
|
+
rescue ArgumentError
|
48
|
+
end
|
49
|
+
set_or_return(
|
50
|
+
:minute,
|
51
|
+
converted_arg,
|
52
|
+
:kind_of => String
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def hour(arg=nil)
|
57
|
+
if arg.is_a?(Integer)
|
58
|
+
converted_arg = arg.to_s
|
59
|
+
else
|
60
|
+
converted_arg = arg
|
61
|
+
end
|
62
|
+
begin
|
63
|
+
if Integer(arg) > 23 then raise RangeError end
|
64
|
+
rescue ArgumentError
|
65
|
+
end
|
66
|
+
set_or_return(
|
67
|
+
:hour,
|
68
|
+
converted_arg,
|
69
|
+
:kind_of => String
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
def day(arg=nil)
|
74
|
+
if arg.is_a?(Integer)
|
75
|
+
converted_arg = arg.to_s
|
76
|
+
else
|
77
|
+
converted_arg = arg
|
78
|
+
end
|
79
|
+
begin
|
80
|
+
if Integer(arg) > 31 then raise RangeError end
|
81
|
+
rescue ArgumentError
|
82
|
+
end
|
83
|
+
set_or_return(
|
84
|
+
:day,
|
85
|
+
converted_arg,
|
86
|
+
:kind_of => String
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def month(arg=nil)
|
91
|
+
if arg.is_a?(Integer)
|
92
|
+
converted_arg = arg.to_s
|
93
|
+
else
|
94
|
+
converted_arg = arg
|
95
|
+
end
|
96
|
+
begin
|
97
|
+
if Integer(arg) > 12 then raise RangeError end
|
98
|
+
rescue ArgumentError
|
99
|
+
end
|
100
|
+
set_or_return(
|
101
|
+
:month,
|
102
|
+
converted_arg,
|
103
|
+
:kind_of => String
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
def weekday(arg=nil)
|
108
|
+
if arg.is_a?(Integer)
|
109
|
+
converted_arg = arg.to_s
|
110
|
+
else
|
111
|
+
converted_arg = arg
|
112
|
+
end
|
113
|
+
begin
|
114
|
+
if Integer(arg) > 7 then raise RangeError end
|
115
|
+
rescue ArgumentError
|
116
|
+
end
|
117
|
+
set_or_return(
|
118
|
+
:weekday,
|
119
|
+
converted_arg,
|
120
|
+
:kind_of => String
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def command(arg=nil)
|
125
|
+
set_or_return(
|
126
|
+
:command,
|
127
|
+
arg,
|
128
|
+
:kind_of => String
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
def user(arg=nil)
|
133
|
+
set_or_return(
|
134
|
+
:user,
|
135
|
+
arg,
|
136
|
+
:kind_of => String
|
137
|
+
)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
|