dsander-reve 0.0.116
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +155 -0
- data/LICENSE +22 -0
- data/Rakefile +79 -0
- data/init.rb +1 -0
- data/lib/reve/classes.rb +1341 -0
- data/lib/reve/exceptions.rb +353 -0
- data/lib/reve/extensions.rb +108 -0
- data/lib/reve.rb +1001 -0
- data/reve.rb +1 -0
- data/test/test_reve.rb +1191 -0
- data/test/xml/alliances.xml +171 -0
- data/test/xml/assets.xml +32 -0
- data/test/xml/badxml.xml +6 -0
- data/test/xml/certificate_tree.xml +231 -0
- data/test/xml/char_facwarstats.xml +18 -0
- data/test/xml/char_medals.xml +12 -0
- data/test/xml/character_sheet.xml +288 -0
- data/test/xml/characterid.xml +11 -0
- data/test/xml/charactername.xml +11 -0
- data/test/xml/characters.xml +13 -0
- data/test/xml/conqurable_stations.xml +12 -0
- data/test/xml/corp_facwarstats.xml +17 -0
- data/test/xml/corp_medals.xml +23 -0
- data/test/xml/corp_member_medals.xml +20 -0
- data/test/xml/corp_membersecurity.xml +49 -0
- data/test/xml/corporate_assets_list.xml +16 -0
- data/test/xml/corporate_market_orders.xml +10 -0
- data/test/xml/corporate_wallet_balance.xml +16 -0
- data/test/xml/corporate_wallet_journal.xml +11 -0
- data/test/xml/corporate_wallet_transactions.xml +10 -0
- data/test/xml/corporation_sheet.xml +52 -0
- data/test/xml/errors/error_100.xml +5 -0
- data/test/xml/errors/error_101.xml +5 -0
- data/test/xml/errors/error_102.xml +5 -0
- data/test/xml/errors/error_103.xml +5 -0
- data/test/xml/errors/error_104.xml +5 -0
- data/test/xml/errors/error_105.xml +5 -0
- data/test/xml/errors/error_106.xml +5 -0
- data/test/xml/errors/error_107.xml +5 -0
- data/test/xml/errors/error_108.xml +5 -0
- data/test/xml/errors/error_109.xml +5 -0
- data/test/xml/errors/error_110.xml +5 -0
- data/test/xml/errors/error_111.xml +5 -0
- data/test/xml/errors/error_112.xml +5 -0
- data/test/xml/errors/error_113.xml +5 -0
- data/test/xml/errors/error_114.xml +5 -0
- data/test/xml/errors/error_115.xml +5 -0
- data/test/xml/errors/error_116.xml +5 -0
- data/test/xml/errors/error_117.xml +5 -0
- data/test/xml/errors/error_118.xml +5 -0
- data/test/xml/errors/error_119.xml +5 -0
- data/test/xml/errors/error_120.xml +5 -0
- data/test/xml/errors/error_121.xml +5 -0
- data/test/xml/errors/error_122.xml +5 -0
- data/test/xml/errors/error_123.xml +5 -0
- data/test/xml/errors/error_124.xml +5 -0
- data/test/xml/errors/error_125.xml +5 -0
- data/test/xml/errors/error_200.xml +5 -0
- data/test/xml/errors/error_201.xml +5 -0
- data/test/xml/errors/error_202.xml +5 -0
- data/test/xml/errors/error_203.xml +5 -0
- data/test/xml/errors/error_204.xml +5 -0
- data/test/xml/errors/error_205.xml +5 -0
- data/test/xml/errors/error_206.xml +5 -0
- data/test/xml/errors/error_207.xml +5 -0
- data/test/xml/errors/error_208.xml +5 -0
- data/test/xml/errors/error_209.xml +5 -0
- data/test/xml/errors/error_210.xml +5 -0
- data/test/xml/errors/error_211.xml +5 -0
- data/test/xml/errors/error_212.xml +5 -0
- data/test/xml/errors/error_213.xml +5 -0
- data/test/xml/errors/error_214.xml +5 -0
- data/test/xml/errors/error_500.xml +5 -0
- data/test/xml/errors/error_501.xml +5 -0
- data/test/xml/errors/error_502.xml +5 -0
- data/test/xml/errors/error_503.xml +5 -0
- data/test/xml/errors/error_504.xml +5 -0
- data/test/xml/errors/error_505.xml +5 -0
- data/test/xml/errors/error_506.xml +5 -0
- data/test/xml/errors/error_507.xml +5 -0
- data/test/xml/errors/error_508.xml +5 -0
- data/test/xml/errors/error_509.xml +5 -0
- data/test/xml/errors/error_510.xml +5 -0
- data/test/xml/errors/error_511.xml +5 -0
- data/test/xml/errors/error_512.xml +5 -0
- data/test/xml/errors/error_513.xml +5 -0
- data/test/xml/errors/error_514.xml +5 -0
- data/test/xml/errors/error_515.xml +5 -0
- data/test/xml/errors/error_516.xml +5 -0
- data/test/xml/errors/error_517.xml +5 -0
- data/test/xml/errors/error_518.xml +5 -0
- data/test/xml/errors/error_519.xml +5 -0
- data/test/xml/errors/error_520.xml +5 -0
- data/test/xml/errors/error_521.xml +5 -0
- data/test/xml/errors/error_522.xml +5 -0
- data/test/xml/errors/error_523.xml +5 -0
- data/test/xml/errors/error_524.xml +5 -0
- data/test/xml/errors/error_525.xml +5 -0
- data/test/xml/errors/error_900.xml +5 -0
- data/test/xml/errors/error_901.xml +5 -0
- data/test/xml/errors/error_902.xml +5 -0
- data/test/xml/errors/error_903.xml +5 -0
- data/test/xml/errors/error_999.xml +5 -0
- data/test/xml/errors.xml +70 -0
- data/test/xml/eve_facwarstats.xml +35 -0
- data/test/xml/eve_facwartopstats.xml +178 -0
- data/test/xml/industryjobs.xml +11 -0
- data/test/xml/kills.xml +569 -0
- data/test/xml/map_facwarsystems.xml +13 -0
- data/test/xml/mapjumps.xml +15 -0
- data/test/xml/mapkills.xml +16 -0
- data/test/xml/market_transactions.xml +79 -0
- data/test/xml/marketorders.xml +43 -0
- data/test/xml/member_tracking.xml +22 -0
- data/test/xml/nonmember_corpsheet.xml +30 -0
- data/test/xml/reftypes.xml +14 -0
- data/test/xml/server_status.xml +9 -0
- data/test/xml/skill_in_training-amarr-titan.xml +15 -0
- data/test/xml/skill_in_training-none.xml +7 -0
- data/test/xml/skill_queue.xml +18 -0
- data/test/xml/skilltree.xml +41 -0
- data/test/xml/sovereignty.xml +29 -0
- data/test/xml/starbase_fuel.xml +23 -0
- data/test/xml/starbases.xml +12 -0
- data/test/xml/wallet_balance.xml +17 -0
- data/test/xml/wallet_journal.xml +48 -0
- data/tester.rb +17 -0
- metadata +187 -0
@@ -0,0 +1,353 @@
|
|
1
|
+
#--
|
2
|
+
# Code copyright Lisa Seelye, 2007-2008. www.crudvision.com
|
3
|
+
# Reve is not licensed for commercial use. For other uses there are no
|
4
|
+
# restrictions.
|
5
|
+
#
|
6
|
+
# The author is not adverse to tokens of appreciation in the form of Eve ISK,
|
7
|
+
# ships, and feedback. Please use
|
8
|
+
# http://www.crudvision.com/reve-ruby-eve-online-api-library/ to provide
|
9
|
+
# feedback or send ISK to Raquel Smith in Eve. :-)
|
10
|
+
#++
|
11
|
+
module Reve
|
12
|
+
# Exceptions live here.
|
13
|
+
module Exceptions
|
14
|
+
# Raise the flag!
|
15
|
+
def self.raise_it(code,msg = "No Error Message From CCP Server (But one DID occur!)")
|
16
|
+
msg = "(#{code.to_s}) #{msg}"
|
17
|
+
case code
|
18
|
+
when 100
|
19
|
+
raise WalletNotPreviouslyLoaded.new(msg)
|
20
|
+
when 101, 103
|
21
|
+
raise WalletExhausted.new(msg)
|
22
|
+
when 102
|
23
|
+
raise WalletPreviouslyLoaded.new(msg)
|
24
|
+
when 104
|
25
|
+
raise KeyNotFound.new(msg)
|
26
|
+
when 105
|
27
|
+
raise InvalidCharacterID.new(msg)
|
28
|
+
when 106
|
29
|
+
raise MustProvideUserIDParameterForAuthentication.new(msg)
|
30
|
+
when 107
|
31
|
+
raise InvalidBeforeRefID.new(msg)
|
32
|
+
when 108
|
33
|
+
raise InvalidAccountKey.new(msg)
|
34
|
+
when 109
|
35
|
+
raise AccountKeyOutOfRange.new(msg)
|
36
|
+
when 110
|
37
|
+
raise InvalidBeforeTransID.new(msg)
|
38
|
+
when 111
|
39
|
+
raise InvalidInteger.new(msg)
|
40
|
+
when 112
|
41
|
+
raise VersionMismatchException.new(msg)
|
42
|
+
when 113
|
43
|
+
raise VersionEscalationException.new(msg)
|
44
|
+
when 114
|
45
|
+
raise InvalidItemIDProvided.new(msg)
|
46
|
+
when 115
|
47
|
+
raise AssetsAlreadyFetched.new(msg)
|
48
|
+
when 116
|
49
|
+
raise IndustryJobsAlreadyFetched.new(msg)
|
50
|
+
when 117
|
51
|
+
raise MarketOrdersAlreadyFetched.new(msg)
|
52
|
+
when 118
|
53
|
+
raise ExpectedBeforeKillID.new(msg)
|
54
|
+
when 119
|
55
|
+
raise KillsExhausted.new(msg)
|
56
|
+
when 120
|
57
|
+
raise UnexpectedBeforeKillID.new(msg)
|
58
|
+
when 121
|
59
|
+
raise BadBeforeKillID.new(msg)
|
60
|
+
when 200
|
61
|
+
raise SecurityLevelNotHighEnough.new(msg + ' (Should you be using the full API Key?)')
|
62
|
+
when 201
|
63
|
+
raise CharacterDoesNotBelongToAccount.new(msg)
|
64
|
+
when 202
|
65
|
+
raise CachedAPIKeyAuthenticationFailure.new(msg)
|
66
|
+
when 203..205
|
67
|
+
raise AuthenticationFailure.new(msg)
|
68
|
+
when 206
|
69
|
+
raise MustHaveAccountantRole.new(msg)
|
70
|
+
when 207
|
71
|
+
raise NotAvailableForNPCCorps.new(msg)
|
72
|
+
when 208
|
73
|
+
raise MustHaveAccountantOrTraderRole.new(msg)
|
74
|
+
when 209
|
75
|
+
raise MustBeDirectorOrCEO.new(msg)
|
76
|
+
when 210,212
|
77
|
+
raise AuthenticationFailure.new(msg)
|
78
|
+
when 211
|
79
|
+
raise LoginDeniedByAccountStatus.new(msg)
|
80
|
+
when 213
|
81
|
+
raise CharacterNeedsFactoryManagerRole.new(msg)
|
82
|
+
when 214
|
83
|
+
raise CorporationNotInAlliance.new(msg)
|
84
|
+
when 500
|
85
|
+
raise GetNameInvalid.new(msg)
|
86
|
+
when 501
|
87
|
+
raise GetIDInvalid.new(msg)
|
88
|
+
when 502
|
89
|
+
raise CachedUntilException.new(msg)
|
90
|
+
when 503
|
91
|
+
raise InvalidInput.new(msg)
|
92
|
+
when 504
|
93
|
+
raise InvalidRace.new(msg)
|
94
|
+
when 505
|
95
|
+
raise InvalidGender.new(msg)
|
96
|
+
when 506
|
97
|
+
raise InvalidBloodline.new(msg)
|
98
|
+
when 507
|
99
|
+
raise InvalidAttribute.new(msg)
|
100
|
+
when 508
|
101
|
+
raise InvalidRefType.new(msg)
|
102
|
+
when 509
|
103
|
+
raise NullDataComponent.new(msg)
|
104
|
+
when 510
|
105
|
+
raise NoCorporationException.new(msg)
|
106
|
+
when 511
|
107
|
+
raise InvalidAccountKey.new(msg)
|
108
|
+
when 512
|
109
|
+
raise InvalidCharID.new(msg)
|
110
|
+
when 513
|
111
|
+
raise CorporateRoleFetchException.new(msg)
|
112
|
+
when 514
|
113
|
+
raise InvalidCorpID.new(msg)
|
114
|
+
when 515
|
115
|
+
raise InvalidUserIDOrAPIKey.new(msg)
|
116
|
+
when 516
|
117
|
+
raise UserInformationFetchException.new(msg)
|
118
|
+
when 517
|
119
|
+
raise CSVHeaderRowMismatch.new(msg)
|
120
|
+
when 518
|
121
|
+
raise TranquilityTimeException.new(msg)
|
122
|
+
when 519
|
123
|
+
raise StarbaseDetailFetchFailure.new(msg)
|
124
|
+
when 520
|
125
|
+
raise EveDatabaseConnectionFailure.new(msg)
|
126
|
+
when 521
|
127
|
+
raise InvalidUsernameOrPassword.new(msg)
|
128
|
+
when 522
|
129
|
+
raise CharacterRetrevialFailure.new(msg)
|
130
|
+
when 523
|
131
|
+
raise CorporationRetrevialFailure.new(msg)
|
132
|
+
when 524
|
133
|
+
raise FactionMemberInformationFailure.new(msg)
|
134
|
+
when 525
|
135
|
+
raise MedalInformationFetchFailure.new(msg)
|
136
|
+
when 900
|
137
|
+
raise BetaAccessDenied.new(msg)
|
138
|
+
when 901
|
139
|
+
raise WebsiteOffline.new(msg)
|
140
|
+
when 902
|
141
|
+
raise EveDatabaseOffline.new(msg)
|
142
|
+
when 903
|
143
|
+
raise ObeyCacheTimers.new(msg)
|
144
|
+
when 999
|
145
|
+
raise UserForcedException.new(msg)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# All API-specific exceptions derrive from this. Useful for rescuing one
|
150
|
+
# parent exception to handle all API exceptions.
|
151
|
+
class ReveError < StandardError
|
152
|
+
end
|
153
|
+
|
154
|
+
# 100
|
155
|
+
class WalletNotPreviouslyLoaded < ReveError #:nodoc:
|
156
|
+
end
|
157
|
+
# 101, 103
|
158
|
+
class WalletExhausted < ReveError #:nodoc:
|
159
|
+
end
|
160
|
+
# 102
|
161
|
+
class WalletPreviouslyLoaded < ReveError #:nodoc:
|
162
|
+
end
|
163
|
+
# 104
|
164
|
+
class KeyNotFound < ReveError #:nodoc:
|
165
|
+
end
|
166
|
+
# 105
|
167
|
+
class InvalidCharacterID < ReveError #:nodoc:
|
168
|
+
end
|
169
|
+
# 106
|
170
|
+
class MustProvideUserIDParameterForAuthentication < ReveError #:nodoc:
|
171
|
+
end
|
172
|
+
# 107
|
173
|
+
class InvalidBeforeRefID < ReveError #:nodoc:
|
174
|
+
end
|
175
|
+
# 108
|
176
|
+
class InvalidAccountKey < ReveError #:nodoc:
|
177
|
+
end
|
178
|
+
# 109
|
179
|
+
class AccountKeyOutOfRange < ReveError #:nodoc:
|
180
|
+
end
|
181
|
+
# 110
|
182
|
+
class InvalidBeforeTransID < ReveError #:nodoc:
|
183
|
+
end
|
184
|
+
# 111
|
185
|
+
class InvalidInteger < ReveError #:nodoc:
|
186
|
+
end
|
187
|
+
# 112
|
188
|
+
class VersionMismatchException < ReveError #:nodoc:
|
189
|
+
end
|
190
|
+
# 113
|
191
|
+
class VersionEscalationException < ReveError #:nodoc:
|
192
|
+
end
|
193
|
+
# 114
|
194
|
+
class InvalidItemIDProvided < ReveError #:nodoc:
|
195
|
+
end
|
196
|
+
# 115
|
197
|
+
class AssetsAlreadyFetched < ReveError #:nodoc:
|
198
|
+
end
|
199
|
+
# 116
|
200
|
+
class IndustryJobsAlreadyFetched < ReveError #:nodoc:
|
201
|
+
end
|
202
|
+
# 117
|
203
|
+
class MarketOrdersAlreadyFetched < ReveError #:nodoc:
|
204
|
+
end
|
205
|
+
# 118
|
206
|
+
class ExpectedBeforeKillID < ReveError #:nodoc:
|
207
|
+
end
|
208
|
+
# 119
|
209
|
+
class KillsExhausted < ReveError #:nodoc:
|
210
|
+
end
|
211
|
+
# 120
|
212
|
+
class UnexpectedBeforeKillID < ReveError #:nodoc:
|
213
|
+
end
|
214
|
+
# 121
|
215
|
+
class BadBeforeKillID < ReveError #:nodoc:
|
216
|
+
end
|
217
|
+
# 200
|
218
|
+
class SecurityLevelNotHighEnough < ReveError #:nodoc:
|
219
|
+
end
|
220
|
+
# 201
|
221
|
+
class CharacterDoesNotBelongToAccount < ReveError #:nodoc:
|
222
|
+
end
|
223
|
+
# 202
|
224
|
+
class CachedAPIKeyAuthenticationFailure < ReveError #:nodoc:
|
225
|
+
end
|
226
|
+
# 203, 204, 205, 210, 212
|
227
|
+
class AuthenticationFailure < ReveError #:nodoc:
|
228
|
+
end
|
229
|
+
# 206
|
230
|
+
class MustHaveAccountantRole < ReveError #:nodoc:
|
231
|
+
end
|
232
|
+
# 207
|
233
|
+
class NotAvailableForNPCCorps < ReveError #:nodoc:
|
234
|
+
end
|
235
|
+
# 208
|
236
|
+
class MustHaveAccountantOrTraderRole < ReveError #:nodoc:
|
237
|
+
end
|
238
|
+
# 209
|
239
|
+
class MustBeDirectorOrCEO < ReveError #:nodoc:
|
240
|
+
end
|
241
|
+
# 211
|
242
|
+
class LoginDeniedByAccountStatus < ReveError #:nodoc:
|
243
|
+
end
|
244
|
+
# 213
|
245
|
+
class CharacterNeedsFactoryManagerRole < ReveError #:nodoc:
|
246
|
+
end
|
247
|
+
# 214
|
248
|
+
class CorporationNotInAlliance < ReveError #:nodoc:
|
249
|
+
end
|
250
|
+
|
251
|
+
# 500
|
252
|
+
class GetNameInvalid < ReveError #:nodoc:
|
253
|
+
end
|
254
|
+
# 501
|
255
|
+
class GetIDInvalid < ReveError #:nodoc:
|
256
|
+
end
|
257
|
+
# 502
|
258
|
+
class CachedUntilException < ReveError #:nodoc:
|
259
|
+
end
|
260
|
+
# 503
|
261
|
+
class InvalidInput < ReveError #:nodoc:
|
262
|
+
end
|
263
|
+
# 504
|
264
|
+
class InvalidRace < ReveError #:nodoc:
|
265
|
+
end
|
266
|
+
# 505
|
267
|
+
class InvalidGender < ReveError #:nodoc:
|
268
|
+
end
|
269
|
+
# 506
|
270
|
+
class InvalidBloodline < ReveError #:nodoc:
|
271
|
+
end
|
272
|
+
# 507
|
273
|
+
class InvalidAttribute < ReveError #:nodoc:
|
274
|
+
end
|
275
|
+
# 508
|
276
|
+
class InvalidRefType < ReveError #:nodoc:
|
277
|
+
end
|
278
|
+
# 509
|
279
|
+
class NullDataComponent < ReveError #:nodoc:
|
280
|
+
end
|
281
|
+
# 510
|
282
|
+
class NoCorporationException < ReveError #:nodoc:
|
283
|
+
end
|
284
|
+
# 511
|
285
|
+
class InvalidAccountKey < ReveError #:nodoc:
|
286
|
+
end
|
287
|
+
# 512
|
288
|
+
class InvalidCharID < ReveError #:nodoc:
|
289
|
+
end
|
290
|
+
# 513
|
291
|
+
class CorporateRoleFetchException < ReveError #:nodoc:
|
292
|
+
end
|
293
|
+
# 514
|
294
|
+
class InvalidCorpID < ReveError #:nodoc:
|
295
|
+
end
|
296
|
+
# 515
|
297
|
+
class InvalidUserIDOrAPIKey < ReveError #:nodoc:
|
298
|
+
end
|
299
|
+
# 516
|
300
|
+
class UserInformationFetchException < ReveError #:nodoc:
|
301
|
+
end
|
302
|
+
# 517
|
303
|
+
class CSVHeaderRowMismatch < ReveError #:nodoc:
|
304
|
+
end
|
305
|
+
# 518
|
306
|
+
class TranquilityTimeException < ReveError #:nodoc:
|
307
|
+
end
|
308
|
+
# 519
|
309
|
+
class StarbaseDetailFetchFailure < ReveError #:nodoc:
|
310
|
+
end
|
311
|
+
# 520
|
312
|
+
class EveDatabaseConnectionFailure < ReveError #:nodoc:
|
313
|
+
end
|
314
|
+
# 521
|
315
|
+
class InvalidUsernameOrPassword < ReveError #:nodoc:
|
316
|
+
end
|
317
|
+
# 522
|
318
|
+
class CharacterRetrevialFailure < ReveError #:nodoc:
|
319
|
+
end
|
320
|
+
# 523
|
321
|
+
class CorporationRetrevialFailure < ReveError #:nodoc:
|
322
|
+
end
|
323
|
+
# 524
|
324
|
+
class FactionMemberInformationFailure < ReveError #:nodoc:
|
325
|
+
end
|
326
|
+
# 525
|
327
|
+
class MedalInformationFetchFailure < ReveError #:nodoc:
|
328
|
+
end
|
329
|
+
|
330
|
+
# 900
|
331
|
+
class BetaAccessDenied < ReveError #:nodoc:
|
332
|
+
end
|
333
|
+
class WebsiteOffline < ReveError #:nodoc:
|
334
|
+
end
|
335
|
+
# 902
|
336
|
+
class EveDatabaseOffline < ReveError #:nodoc:
|
337
|
+
end
|
338
|
+
# 903 - Obey the %*(&!*@ timers!!!
|
339
|
+
class ObeyCacheTimers < ReveError #:nodoc:
|
340
|
+
end
|
341
|
+
|
342
|
+
# 999
|
343
|
+
class UserForcedException < ReveError #:nodoc:
|
344
|
+
end
|
345
|
+
|
346
|
+
# this is an Exception to do with the connection to the Eve server failing
|
347
|
+
class ReveNetworkStatusException < StandardError
|
348
|
+
end
|
349
|
+
# used when something is encountered in XML that we didn't expect
|
350
|
+
class ReveUnexpectedEntityEncountered < StandardError
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'parsedate'
|
2
|
+
|
3
|
+
module Reve #:nodoc:
|
4
|
+
# All of these are shamelessly nicked from Ruby on Rails.
|
5
|
+
# The String Extensions have a bit more fault tolerance.
|
6
|
+
module Extensions
|
7
|
+
|
8
|
+
module NilClass
|
9
|
+
def to_date
|
10
|
+
self
|
11
|
+
end
|
12
|
+
def to_time
|
13
|
+
self
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Hash
|
18
|
+
def stringify_keys
|
19
|
+
inject({}) do |h, (key,value)|
|
20
|
+
h[key.to_s] = value
|
21
|
+
h
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def stringify_keys!
|
25
|
+
keys.each do |key|
|
26
|
+
unless key.class.to_s == "String" # See ActiveSupport for why this is needed!
|
27
|
+
self[key.to_s] = self[key]
|
28
|
+
delete(key)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
self
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Rails's cattr_ things. activesupport/lib/active_support/core_ext/class
|
36
|
+
# Really quite handy.
|
37
|
+
module Class #:nodoc:
|
38
|
+
def cattr_reader(*syms) #:nodoc:
|
39
|
+
syms.flatten.each do |sym|
|
40
|
+
next if sym.is_a?(Hash)
|
41
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
42
|
+
unless defined? @@#{sym}
|
43
|
+
@@#{sym} = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.#{sym}
|
47
|
+
@@#{sym}
|
48
|
+
end
|
49
|
+
|
50
|
+
def #{sym}
|
51
|
+
@@#{sym}
|
52
|
+
end
|
53
|
+
EOS
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def cattr_writer(*syms) #:nodoc:
|
58
|
+
options = syms.last.is_a?(Hash) ? syms.pop : {}
|
59
|
+
syms.flatten.each do |sym|
|
60
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
61
|
+
unless defined? @@#{sym}
|
62
|
+
@@#{sym} = nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.#{sym}=(obj)
|
66
|
+
@@#{sym} = obj
|
67
|
+
end
|
68
|
+
#{"
|
69
|
+
def #{sym}=(obj)
|
70
|
+
@@#{sym} = obj
|
71
|
+
end
|
72
|
+
" unless options[:instance_writer] == false }
|
73
|
+
EOS
|
74
|
+
end
|
75
|
+
end
|
76
|
+
def cattr_accessor(*syms) #:nodoc:
|
77
|
+
cattr_reader(*syms)
|
78
|
+
cattr_writer(*syms)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
module String
|
83
|
+
def to_time(form = :utc)
|
84
|
+
begin
|
85
|
+
::Time.send(form, *ParseDate.parsedate(self))
|
86
|
+
rescue Exception
|
87
|
+
self
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class String #:nodoc:
|
95
|
+
include Reve::Extensions::String
|
96
|
+
end
|
97
|
+
|
98
|
+
class Class #:nodoc:
|
99
|
+
include Reve::Extensions::Class
|
100
|
+
end
|
101
|
+
|
102
|
+
class Hash #:nodoc:
|
103
|
+
include Reve::Extensions::Hash
|
104
|
+
end
|
105
|
+
|
106
|
+
class NilClass #:nodoc:
|
107
|
+
include Reve::Extensions::NilClass
|
108
|
+
end
|