mack-notifier 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gems.rb +13 -0
- data/lib/gems/tmail-1.2.3.1/ext/Makefile +20 -0
- data/lib/gems/tmail-1.2.3.1/ext/tmailscanner/tmail/MANIFEST +4 -0
- data/lib/gems/tmail-1.2.3.1/ext/tmailscanner/tmail/depend +1 -0
- data/lib/gems/tmail-1.2.3.1/ext/tmailscanner/tmail/extconf.rb +33 -0
- data/lib/gems/tmail-1.2.3.1/ext/tmailscanner/tmail/tmailscanner.c +583 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail.rb +5 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/Makefile +18 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/address.rb +426 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/attachments.rb +46 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/base64.rb +46 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/compat.rb +41 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/config.rb +67 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/core_extensions.rb +63 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/encode.rb +581 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/header.rb +960 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/index.rb +9 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/interface.rb +1125 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/loader.rb +3 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/mail.rb +578 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/mailbox.rb +495 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/main.rb +6 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/mbox.rb +3 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/net.rb +248 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/obsolete.rb +132 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/parser.rb +1476 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/parser.y +381 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/port.rb +379 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/quoting.rb +118 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/require_arch.rb +58 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/scanner.rb +49 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/scanner_r.rb +261 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/stringio.rb +280 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/utils.rb +337 -0
- data/lib/gems/tmail-1.2.3.1/lib/tmail/version.rb +39 -0
- data/lib/gems/tmail-1.2.3.1/meta/MANIFEST +128 -0
- data/lib/gems/tmail-1.2.3.1/meta/VERSION +1 -0
- data/lib/gems/tmail-1.2.3.1/meta/project.yaml +30 -0
- data/lib/gems/tmail-1.2.3.1/meta/unixname +1 -0
- data/lib/gems/validatable-1.6.7/README +118 -0
- data/lib/gems/validatable-1.6.7/lib/child_validation.rb +15 -0
- data/lib/gems/validatable-1.6.7/lib/errors.rb +74 -0
- data/lib/gems/validatable-1.6.7/lib/included_validation.rb +9 -0
- data/lib/gems/validatable-1.6.7/lib/macros.rb +283 -0
- data/lib/gems/validatable-1.6.7/lib/object_extension.rb +21 -0
- data/lib/gems/validatable-1.6.7/lib/requireable.rb +26 -0
- data/lib/gems/validatable-1.6.7/lib/understandable.rb +31 -0
- data/lib/gems/validatable-1.6.7/lib/validatable.rb +19 -0
- data/lib/gems/validatable-1.6.7/lib/validatable_class_methods.rb +85 -0
- data/lib/gems/validatable-1.6.7/lib/validatable_instance_methods.rb +106 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validates_acceptance_of.rb +11 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validates_confirmation_of.rb +15 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validates_each.rb +14 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validates_format_of.rb +13 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validates_length_of.rb +25 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validates_numericality_of.rb +16 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validates_presence_of.rb +13 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validates_true_for.rb +13 -0
- data/lib/gems/validatable-1.6.7/lib/validations/validation_base.rb +88 -0
- data/lib/gems/validatable-1.6.7/rakefile.rb +50 -0
- data/lib/gems/validatable-1.6.7/test/all_tests.rb +1 -0
- data/lib/gems/validatable-1.6.7/test/functional/validatable_test.rb +437 -0
- data/lib/gems/validatable-1.6.7/test/functional/validates_acceptance_of_test.rb +16 -0
- data/lib/gems/validatable-1.6.7/test/functional/validates_confirmation_of_test.rb +56 -0
- data/lib/gems/validatable-1.6.7/test/functional/validates_each_test.rb +14 -0
- data/lib/gems/validatable-1.6.7/test/functional/validates_format_of_test.rb +34 -0
- data/lib/gems/validatable-1.6.7/test/functional/validates_length_of_test.rb +64 -0
- data/lib/gems/validatable-1.6.7/test/functional/validates_numericality_of_test.rb +57 -0
- data/lib/gems/validatable-1.6.7/test/functional/validates_presence_of_test.rb +16 -0
- data/lib/gems/validatable-1.6.7/test/functional/validates_true_for_test.rb +27 -0
- data/lib/gems/validatable-1.6.7/test/test_helper.rb +33 -0
- data/lib/gems/validatable-1.6.7/test/unit/errors_test.rb +64 -0
- data/lib/gems/validatable-1.6.7/test/unit/understandable_test.rb +19 -0
- data/lib/gems/validatable-1.6.7/test/unit/validatable_test.rb +38 -0
- data/lib/gems/validatable-1.6.7/test/unit/validates_acceptance_of_test.rb +21 -0
- data/lib/gems/validatable-1.6.7/test/unit/validates_confirmation_of_test.rb +64 -0
- data/lib/gems/validatable-1.6.7/test/unit/validates_format_of_test.rb +34 -0
- data/lib/gems/validatable-1.6.7/test/unit/validates_length_of_test.rb +75 -0
- data/lib/gems/validatable-1.6.7/test/unit/validates_numericality_of_test.rb +52 -0
- data/lib/gems/validatable-1.6.7/test/unit/validates_presence_of_test.rb +25 -0
- data/lib/gems/validatable-1.6.7/test/unit/validates_true_for_test.rb +29 -0
- data/lib/gems/validatable-1.6.7/test/unit/validation_base_test.rb +52 -0
- data/lib/gems/xmpp4r-0.4/CHANGELOG +83 -0
- data/lib/gems/xmpp4r-0.4/COPYING +340 -0
- data/lib/gems/xmpp4r-0.4/LICENSE +59 -0
- data/lib/gems/xmpp4r-0.4/README.rdoc +110 -0
- data/lib/gems/xmpp4r-0.4/README_ruby19.txt +43 -0
- data/lib/gems/xmpp4r-0.4/Rakefile +262 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/adventure/README +56 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/adventure/adventure.rb +23 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/adventure/adventuremuc.rb +136 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/adventure/cube.xml +15 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/adventure/tower.xml +69 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/adventure/world.rb +424 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/fileserve.conf +11 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/fileserve.rb +346 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/getonline.rb +56 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/gtkmucclient.rb +315 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/migrate.rb +88 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/minimuc.rb +266 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/pep-aggregator/index.xsl +235 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb +147 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/recvfile.rb +84 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/rosterdiscovery.rb +129 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/sendfile.conf +10 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/sendfile.rb +72 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr.rb +51 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_jabber.rb +43 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/shellmgr/shellmgr_test.rb +10 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/versionpoll.rb +90 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/xmpping.rb +146 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/advanced/xmppingrc.sample +14 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/change_password.rb +41 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/client.rb +70 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/component.rb +11 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/echo.rb +37 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/jabbersend.rb +41 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/mass_sender.rb +68 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/muc_owner_config.rb +12 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/mucinfo.rb +41 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/mucsimplebot.rb +82 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/register.rb +42 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/remove_registration.rb +18 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/roster.rb +44 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/rosterprint.rb +50 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/rosterrename.rb +34 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/rosterwatch.rb +171 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/send_vcard.rb +67 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/tune_client.rb +56 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/tune_server.rb +58 -0
- data/lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/versionbot.rb +75 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r.rb +116 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/base64.rb +32 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams.rb +15 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/filetransfer.rb +319 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/ibb/base.rb +257 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/ibb/initiator.rb +31 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/ibb/target.rb +47 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb +152 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb +86 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb +198 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb +65 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb +73 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb.orig +62 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/iq/bytestreams.rb +170 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/bytestreams/iq/si.rb +206 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/callbacks.rb +124 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/caps.rb +1 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/caps/c.rb +53 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/caps/helper/generator.rb +160 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/caps/helper/helper.rb +87 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/client.rb +317 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/command/helper/responder.rb +53 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/command/iq/command.rb +154 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/component.rb +103 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/connection.rb +219 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/dataforms.rb +5 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/dataforms/x/data.rb +297 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/debuglog.rb +42 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/delay.rb +5 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/delay/x/delay.rb +99 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/discovery.rb +7 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/discovery/helper/responder.rb +165 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/discovery/iq/discoinfo.rb +211 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/discovery/iq/discoitems.rb +147 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/errors.rb +281 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/feature_negotiation.rb +5 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/feature_negotiation/iq/feature.rb +28 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/framework/base.rb +55 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/framework/bot.rb +148 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/httpbinding.rb +5 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/httpbinding/client.rb +285 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/idgenerator.rb +37 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/iq.rb +221 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/jid.rb +167 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/message.rb +148 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc.rb +14 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/helper/mucbrowser.rb +92 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/helper/mucclient.rb +462 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/helper/simplemucclient.rb +332 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/iq/mucadmin.rb +23 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/iq/mucadminitem.rb +20 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/iq/mucowner.rb +15 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/item.rb +143 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/x/muc.rb +70 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/x/mucuserinvite.rb +60 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/muc/x/mucuseritem.rb +36 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/presence.rb +232 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub.rb +8 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/configuration.rb +86 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/event.rb +49 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/item.rb +35 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/items.rb +44 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/node_config.rb +48 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/publish.rb +24 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/subscription.rb +62 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/subscription_config.rb +67 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/children/unsubscribe.rb +48 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/helper/nodebrowser.rb +130 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/helper/nodehelper.rb +156 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/helper/servicehelper.rb +417 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/pubsub/iq/pubsub.rb +19 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/query.rb +15 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/rexmladdons.rb +151 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/roster.rb +7 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/roster/helper/roster.rb +519 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/roster/iq/roster.rb +215 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/roster/x/roster.rb +138 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/rpc.rb +2 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/rpc/helper/client.rb +123 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/rpc/helper/server.rb +74 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/rpc/helper/xmlrpcaddons.rb +67 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/rpc/iq/rpc.rb +23 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/sasl.rb +237 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/semaphore.rb +38 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/stream.rb +497 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/streamparser.rb +77 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/tune.rb +2 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/tune/helper/helper.rb +58 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/tune/tune.rb +113 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/vcard.rb +6 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/vcard/helper/vcard.rb +84 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/vcard/iq/vcard.rb +109 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/version.rb +7 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/version/helper/responder.rb +72 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/version/helper/simpleresponder.rb +44 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/version/iq/version.rb +105 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/x.rb +37 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/xhtml.rb +1 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/xhtml/html.rb +115 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/xmpp4r.rb +18 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/xmppelement.rb +168 -0
- data/lib/gems/xmpp4r-0.4/lib/xmpp4r/xmppstanza.rb +162 -0
- data/lib/gems/xmpp4r-0.4/setup.rb +1586 -0
- data/lib/gems/xmpp4r-0.4/test/bytestreams/tc_ibb.rb +186 -0
- data/lib/gems/xmpp4r-0.4/test/bytestreams/tc_socks5bytestreams.rb +113 -0
- data/lib/gems/xmpp4r-0.4/test/caps/tc_helper.rb +156 -0
- data/lib/gems/xmpp4r-0.4/test/dataforms/tc_data.rb +81 -0
- data/lib/gems/xmpp4r-0.4/test/delay/tc_xdelay.rb +51 -0
- data/lib/gems/xmpp4r-0.4/test/discovery/tc_responder.rb +91 -0
- data/lib/gems/xmpp4r-0.4/test/lib/assert_equal_xml.rb +14 -0
- data/lib/gems/xmpp4r-0.4/test/lib/clienttester.rb +120 -0
- data/lib/gems/xmpp4r-0.4/test/muc/tc_muc_mucclient.rb +830 -0
- data/lib/gems/xmpp4r-0.4/test/muc/tc_muc_simplemucclient.rb +114 -0
- data/lib/gems/xmpp4r-0.4/test/muc/tc_mucowner.rb +50 -0
- data/lib/gems/xmpp4r-0.4/test/pubsub/tc_helper.rb +662 -0
- data/lib/gems/xmpp4r-0.4/test/pubsub/tc_nodeconfig.rb +54 -0
- data/lib/gems/xmpp4r-0.4/test/pubsub/tc_subscriptionconfig.rb +41 -0
- data/lib/gems/xmpp4r-0.4/test/roster/tc_helper.rb +514 -0
- data/lib/gems/xmpp4r-0.4/test/roster/tc_iqqueryroster.rb +173 -0
- data/lib/gems/xmpp4r-0.4/test/roster/tc_xroster.rb +73 -0
- data/lib/gems/xmpp4r-0.4/test/rpc/tc_helper.rb +96 -0
- data/lib/gems/xmpp4r-0.4/test/tc_callbacks.rb +129 -0
- data/lib/gems/xmpp4r-0.4/test/tc_class_names.rb +146 -0
- data/lib/gems/xmpp4r-0.4/test/tc_client.rb +30 -0
- data/lib/gems/xmpp4r-0.4/test/tc_errors.rb +146 -0
- data/lib/gems/xmpp4r-0.4/test/tc_idgenerator.rb +30 -0
- data/lib/gems/xmpp4r-0.4/test/tc_iq.rb +113 -0
- data/lib/gems/xmpp4r-0.4/test/tc_iqquery.rb +31 -0
- data/lib/gems/xmpp4r-0.4/test/tc_jid.rb +204 -0
- data/lib/gems/xmpp4r-0.4/test/tc_message.rb +116 -0
- data/lib/gems/xmpp4r-0.4/test/tc_presence.rb +150 -0
- data/lib/gems/xmpp4r-0.4/test/tc_rexml.rb +139 -0
- data/lib/gems/xmpp4r-0.4/test/tc_stream.rb +229 -0
- data/lib/gems/xmpp4r-0.4/test/tc_streamComponent.rb +95 -0
- data/lib/gems/xmpp4r-0.4/test/tc_streamError.rb +131 -0
- data/lib/gems/xmpp4r-0.4/test/tc_streamSend.rb +59 -0
- data/lib/gems/xmpp4r-0.4/test/tc_streamparser.rb +112 -0
- data/lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb +135 -0
- data/lib/gems/xmpp4r-0.4/test/ts_xmpp4r.rb +53 -0
- data/lib/gems/xmpp4r-0.4/test/tune/tc_helper_recv.rb +84 -0
- data/lib/gems/xmpp4r-0.4/test/tune/tc_helper_send.rb +74 -0
- data/lib/gems/xmpp4r-0.4/test/tune/tc_tune.rb +79 -0
- data/lib/gems/xmpp4r-0.4/test/vcard/tc_helper.rb +49 -0
- data/lib/gems/xmpp4r-0.4/test/vcard/tc_iqvcard.rb +62 -0
- data/lib/gems/xmpp4r-0.4/test/version/tc_helper.rb +60 -0
- data/lib/gems/xmpp4r-0.4/test/version/tc_iqqueryversion.rb +97 -0
- data/lib/gems/xmpp4r-0.4/test/xhtml/tc_html.rb +41 -0
- data/lib/gems/xmpp4r-0.4/tools/gen_requires.bash +31 -0
- data/lib/gems/xmpp4r-0.4/tools/xmpp4r-gemspec-test.rb +11 -0
- data/lib/gems/xmpp4r-0.4/xmpp4r.gemspec +291 -0
- data/lib/gems/xmpp4r-simple-0.8.8/CHANGELOG +73 -0
- data/lib/gems/xmpp4r-simple-0.8.8/COPYING +281 -0
- data/lib/gems/xmpp4r-simple-0.8.8/README +59 -0
- data/lib/gems/xmpp4r-simple-0.8.8/lib/xmpp4r-simple.rb +492 -0
- data/lib/gems/xmpp4r-simple-0.8.8/test/test_xmpp4r_simple.rb +242 -0
- data/lib/mack-notifier.rb +1 -3
- metadata +398 -46
@@ -0,0 +1,21 @@
|
|
1
|
+
class Object #:nodoc:
|
2
|
+
module InstanceExecHelper #:nodoc:
|
3
|
+
end
|
4
|
+
include InstanceExecHelper
|
5
|
+
def instance_eval_with_params(*args, &block)
|
6
|
+
begin
|
7
|
+
old_critical, Thread.critical = Thread.critical, true
|
8
|
+
n = 0
|
9
|
+
n += 1 while respond_to?(mname="__instance_exec#{n}")
|
10
|
+
InstanceExecHelper.module_eval{ define_method(mname, &block) }
|
11
|
+
ensure
|
12
|
+
Thread.critical = old_critical
|
13
|
+
end
|
14
|
+
begin
|
15
|
+
ret = send(mname, *args)
|
16
|
+
ensure
|
17
|
+
InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
|
18
|
+
end
|
19
|
+
ret
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Validatable
|
2
|
+
module Requireable #:nodoc:
|
3
|
+
module ClassMethods #:nodoc:
|
4
|
+
def requires(*args)
|
5
|
+
required_options.concat args
|
6
|
+
end
|
7
|
+
|
8
|
+
def required_options
|
9
|
+
@required_options ||= []
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.included(klass)
|
14
|
+
klass.extend ClassMethods
|
15
|
+
end
|
16
|
+
|
17
|
+
def requires(options)
|
18
|
+
required_options = self.class.required_options.inject([]) do |errors, attribute|
|
19
|
+
errors << attribute.to_s unless options.has_key?(attribute)
|
20
|
+
errors
|
21
|
+
end
|
22
|
+
raise ArgumentError.new("#{self.class} requires options: #{required_options.join(', ')}") if required_options.any?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Validatable
|
2
|
+
module Understandable #:nodoc:
|
3
|
+
module ClassMethods #:nodoc:
|
4
|
+
def understands(*args)
|
5
|
+
understandings.concat args
|
6
|
+
end
|
7
|
+
|
8
|
+
def understandings
|
9
|
+
@understandings ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def all_understandings
|
13
|
+
return understandings + self.superclass.all_understandings if self.superclass.respond_to? :all_understandings
|
14
|
+
understandings
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.included(klass)
|
19
|
+
klass.extend ClassMethods
|
20
|
+
end
|
21
|
+
|
22
|
+
def must_understand(hash)
|
23
|
+
invalid_options = hash.inject([]) do |errors, (key, value)|
|
24
|
+
errors << key.to_s unless self.class.all_understandings.include?(key)
|
25
|
+
errors
|
26
|
+
end
|
27
|
+
raise ArgumentError.new("invalid options: #{invalid_options.join(', ')}") if invalid_options.any?
|
28
|
+
true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/object_extension')
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/errors')
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/validatable_class_methods')
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/macros')
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + '/validatable_instance_methods')
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + '/included_validation')
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/child_validation')
|
9
|
+
require File.expand_path(File.dirname(__FILE__) + '/understandable')
|
10
|
+
require File.expand_path(File.dirname(__FILE__) + '/requireable')
|
11
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validation_base')
|
12
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validates_format_of')
|
13
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validates_presence_of')
|
14
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validates_acceptance_of')
|
15
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validates_confirmation_of')
|
16
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validates_length_of')
|
17
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validates_true_for')
|
18
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validates_numericality_of')
|
19
|
+
require File.expand_path(File.dirname(__FILE__) + '/validations/validates_each')
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Validatable
|
2
|
+
module ClassMethods #:nodoc:
|
3
|
+
|
4
|
+
def validate_children(instance, group)
|
5
|
+
self.children_to_validate.each do |child_validation|
|
6
|
+
next unless child_validation.should_validate?(instance)
|
7
|
+
child = instance.send child_validation.attribute
|
8
|
+
if (child.respond_to?(:valid_for_group?))
|
9
|
+
child.valid_for_group?(group)
|
10
|
+
else
|
11
|
+
child.valid?
|
12
|
+
end
|
13
|
+
child.errors.each do |attribute, messages|
|
14
|
+
if messages.is_a?(String)
|
15
|
+
add_error(instance, child_validation.map[attribute.to_sym] || attribute, messages)
|
16
|
+
else
|
17
|
+
messages.each do |message|
|
18
|
+
add_error(instance, child_validation.map[attribute.to_sym] || attribute, message)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def all_before_validations
|
26
|
+
if self.superclass.respond_to? :all_before_validations
|
27
|
+
return before_validations + self.superclass.all_before_validations
|
28
|
+
end
|
29
|
+
before_validations
|
30
|
+
end
|
31
|
+
|
32
|
+
def before_validations
|
33
|
+
@before_validations ||= []
|
34
|
+
end
|
35
|
+
|
36
|
+
def all_validations
|
37
|
+
if self.respond_to?(:superclass) && self.superclass.respond_to?(:all_validations)
|
38
|
+
return validations + self.superclass.all_validations
|
39
|
+
end
|
40
|
+
validations
|
41
|
+
end
|
42
|
+
|
43
|
+
def validations
|
44
|
+
@validations ||= []
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_error(instance, attribute, msg)
|
48
|
+
instance.errors.add(attribute, msg)
|
49
|
+
end
|
50
|
+
|
51
|
+
def validation_keys_include?(key)
|
52
|
+
validations.map { |validation| validation.key }.include?(key)
|
53
|
+
end
|
54
|
+
|
55
|
+
def validations_to_include
|
56
|
+
@validations_to_include ||= []
|
57
|
+
end
|
58
|
+
|
59
|
+
protected
|
60
|
+
|
61
|
+
def add_validations(args, klass)
|
62
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
63
|
+
args.each do |attribute|
|
64
|
+
new_validation = klass.new self, attribute, options
|
65
|
+
self.validations << new_validation
|
66
|
+
self.create_valid_method_for_groups new_validation.groups
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_valid_method_for_groups(groups)
|
71
|
+
groups.each do |group|
|
72
|
+
self.class_eval do
|
73
|
+
define_method "valid_for_#{group}?".to_sym do
|
74
|
+
valid_for_group?(group)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def children_to_validate
|
81
|
+
@children_to_validate ||= []
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Validatable
|
2
|
+
def self.included(klass) #:nodoc:
|
3
|
+
klass.extend Validatable::ClassMethods
|
4
|
+
klass.extend Validatable::Macros
|
5
|
+
end
|
6
|
+
|
7
|
+
# call-seq: valid?
|
8
|
+
#
|
9
|
+
# Returns true if no errors were added otherwise false. Only executes validations that have no :groups option specified
|
10
|
+
def valid?
|
11
|
+
valid_for_group?(nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
# call-seq: errors
|
15
|
+
#
|
16
|
+
# Returns the Errors object that holds all information about attribute error messages.
|
17
|
+
def errors
|
18
|
+
@errors ||= Validatable::Errors.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid_for_group?(group) #:nodoc:
|
22
|
+
run_before_validations
|
23
|
+
errors.clear
|
24
|
+
self.class.validate_children(self, group)
|
25
|
+
self.validate(group)
|
26
|
+
errors.empty?
|
27
|
+
end
|
28
|
+
|
29
|
+
def times_validated(key) #:nodoc:
|
30
|
+
times_validated_hash[key] || 0
|
31
|
+
end
|
32
|
+
|
33
|
+
def increment_times_validated_for(validation) #:nodoc:
|
34
|
+
if validation.key != nil
|
35
|
+
if times_validated_hash[validation.key].nil?
|
36
|
+
times_validated_hash[validation.key] = 1
|
37
|
+
else
|
38
|
+
times_validated_hash[validation.key] += 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# call-seq: validate_only(key)
|
44
|
+
#
|
45
|
+
# Only executes a specified validation. The argument should follow a pattern based on the key of the validation.
|
46
|
+
# Examples:
|
47
|
+
# * validates_presence_of :name can be run with obj.validate_only("presence_of/name")
|
48
|
+
# * validates_presence_of :birthday, :key => "a key" can be run with obj.validate_only("presence_of/a key")
|
49
|
+
def validate_only(key)
|
50
|
+
validation_name, attribute_name = key.split("/")
|
51
|
+
validation_name = validation_name.split("_").collect{|word| word.capitalize}.join
|
52
|
+
validation_key = "#{self.class.name}/Validatable::Validates#{validation_name}/#{attribute_name}"
|
53
|
+
validation = self.class.all_validations.find { |validation| validation.key == validation_key }
|
54
|
+
raise ArgumentError.new("validation with key #{validation_key} could not be found") if validation.nil?
|
55
|
+
errors.clear
|
56
|
+
run_validation(validation)
|
57
|
+
end
|
58
|
+
|
59
|
+
protected
|
60
|
+
def times_validated_hash #:nodoc:
|
61
|
+
@times_validated_hash ||= {}
|
62
|
+
end
|
63
|
+
|
64
|
+
def validate(group) #:nodoc:
|
65
|
+
validation_levels.each do |level|
|
66
|
+
validations_for_level_and_group(level, group).each do |validation|
|
67
|
+
run_validation(validation) if validation.should_validate?(self)
|
68
|
+
end
|
69
|
+
return unless self.errors.empty?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def run_validation(validation) #:nodoc:
|
74
|
+
validation_result = validation.valid?(self)
|
75
|
+
add_error(validation.attribute, validation.message(self)) unless validation_result
|
76
|
+
increment_times_validated_for(validation)
|
77
|
+
validation.run_after_validate(validation_result, self, validation.attribute)
|
78
|
+
end
|
79
|
+
|
80
|
+
def run_before_validations #:nodoc:
|
81
|
+
self.class.all_before_validations.each do |block|
|
82
|
+
instance_eval &block
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_error(attribute, message) #:nodoc:
|
87
|
+
self.class.add_error(self, attribute, message)
|
88
|
+
end
|
89
|
+
|
90
|
+
def validations_for_level_and_group(level, group) #:nodoc:
|
91
|
+
validations_for_level = self.all_validations.select { |validation| validation.level == level }
|
92
|
+
return validations_for_level.select { |validation| validation.groups.empty? } if group.nil?
|
93
|
+
validations_for_level.select { |validation| validation.groups.include?(group) }
|
94
|
+
end
|
95
|
+
|
96
|
+
def all_validations #:nodoc:
|
97
|
+
res = self.class.validations_to_include.inject(self.class.all_validations) do |result, included_validation_class|
|
98
|
+
result += self.send(included_validation_class.attribute).all_validations
|
99
|
+
result
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def validation_levels #:nodoc:
|
104
|
+
self.class.all_validations.inject([1]) { |result, validation| result << validation.level }.uniq.sort
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Validatable
|
2
|
+
class ValidatesConfirmationOf < ValidationBase #:nodoc:
|
3
|
+
option :case_sensitive
|
4
|
+
default :case_sensitive => true
|
5
|
+
|
6
|
+
def valid?(instance)
|
7
|
+
return instance.send(self.attribute) == instance.send("#{self.attribute}_confirmation".to_sym) if case_sensitive
|
8
|
+
instance.send(self.attribute).to_s.casecmp(instance.send("#{self.attribute}_confirmation".to_sym).to_s) == 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def message(instance)
|
12
|
+
super || "doesn't match confirmation"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Validatable
|
2
|
+
class ValidatesEach < ValidationBase #:nodoc:
|
3
|
+
required_option :logic
|
4
|
+
|
5
|
+
def valid?(instance)
|
6
|
+
instance.instance_eval(&logic)
|
7
|
+
true # return true so no error is added. should look in the future at doing this different.
|
8
|
+
end
|
9
|
+
|
10
|
+
def message(instance)
|
11
|
+
super || "is invalid"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Validatable
|
2
|
+
class ValidatesFormatOf < ValidationBase #:nodoc:
|
3
|
+
required_option :with
|
4
|
+
|
5
|
+
def valid?(instance)
|
6
|
+
not (instance.send(self.attribute).to_s =~ self.with).nil?
|
7
|
+
end
|
8
|
+
|
9
|
+
def message(instance)
|
10
|
+
super || "is invalid"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Validatable
|
2
|
+
class ValidatesLengthOf < ValidationBase #:nodoc:
|
3
|
+
option :minimum, :maximum, :is, :within, :allow_nil
|
4
|
+
|
5
|
+
def message(instance)
|
6
|
+
super || "is invalid"
|
7
|
+
end
|
8
|
+
|
9
|
+
def valid?(instance)
|
10
|
+
valid = true
|
11
|
+
value = instance.send(self.attribute)
|
12
|
+
|
13
|
+
if value.nil?
|
14
|
+
return true if allow_nil
|
15
|
+
value = ""
|
16
|
+
end
|
17
|
+
|
18
|
+
valid &&= value.length <= maximum unless maximum.nil?
|
19
|
+
valid &&= value.length >= minimum unless minimum.nil?
|
20
|
+
valid &&= value.length == is unless is.nil?
|
21
|
+
valid &&= within.include?(value.length) unless within.nil?
|
22
|
+
valid
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Validatable
|
2
|
+
class ValidatesNumericalityOf < ValidationBase #:nodoc:
|
3
|
+
option :only_integer
|
4
|
+
|
5
|
+
def valid?(instance)
|
6
|
+
value = instance.send(self.attribute).to_s
|
7
|
+
regex = self.only_integer ? /\A[+-]?\d+\Z/ : /^\d*\.{0,1}\d+$/
|
8
|
+
not (value =~ regex).nil?
|
9
|
+
end
|
10
|
+
|
11
|
+
def message(instance)
|
12
|
+
super || "must be a number"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Validatable
|
2
|
+
class ValidatesPresenceOf < ValidationBase #:nodoc:
|
3
|
+
def valid?(instance)
|
4
|
+
return false if instance.send(self.attribute).nil?
|
5
|
+
instance.send(self.attribute).respond_to?(:strip) ? instance.send(self.attribute).strip.length != 0 : true
|
6
|
+
end
|
7
|
+
|
8
|
+
def message(instance)
|
9
|
+
super || "can't be empty"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Validatable
|
2
|
+
class ValidationBase #:nodoc:
|
3
|
+
class << self
|
4
|
+
def required_option(*args)
|
5
|
+
option(*args)
|
6
|
+
requires(*args)
|
7
|
+
end
|
8
|
+
|
9
|
+
def option(*args)
|
10
|
+
attr_accessor(*args)
|
11
|
+
understands(*args)
|
12
|
+
end
|
13
|
+
|
14
|
+
def default(hash)
|
15
|
+
defaults.merge! hash
|
16
|
+
end
|
17
|
+
|
18
|
+
def defaults
|
19
|
+
@defaults ||= {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def all_defaults
|
23
|
+
return defaults.merge(self.superclass.all_defaults) if self.superclass.respond_to? :all_defaults
|
24
|
+
defaults
|
25
|
+
end
|
26
|
+
|
27
|
+
def after_validate(&block)
|
28
|
+
after_validations << block
|
29
|
+
end
|
30
|
+
|
31
|
+
def after_validations
|
32
|
+
@after_validations ||= []
|
33
|
+
end
|
34
|
+
|
35
|
+
def all_after_validations
|
36
|
+
return after_validations + self.superclass.all_after_validations if self.superclass.respond_to? :all_after_validations
|
37
|
+
after_validations
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
include Understandable
|
42
|
+
include Requireable
|
43
|
+
|
44
|
+
option :message, :if, :times, :level, :groups, :key, :after_validate
|
45
|
+
default :level => 1, :groups => []
|
46
|
+
attr_accessor :attribute
|
47
|
+
|
48
|
+
def initialize(klass, attribute, options={})
|
49
|
+
must_understand options
|
50
|
+
requires options
|
51
|
+
self.class.all_understandings.each do |understanding|
|
52
|
+
options[understanding] = self.class.all_defaults[understanding] unless options.has_key? understanding
|
53
|
+
self.instance_variable_set("@#{understanding}", options[understanding])
|
54
|
+
end
|
55
|
+
self.attribute = attribute
|
56
|
+
self.groups = [self.groups] unless self.groups.is_a?(Array)
|
57
|
+
self.key = "#{klass.name}/#{self.class.name}/#{self.key || self.attribute}"
|
58
|
+
raise_error_if_key_is_dup(klass)
|
59
|
+
end
|
60
|
+
|
61
|
+
def raise_error_if_key_is_dup(klass)
|
62
|
+
message = "key #{self.key} must be unique, provide the :key option to specify a unique key"
|
63
|
+
raise ArgumentError.new(message) if klass.validation_keys_include? self.key
|
64
|
+
end
|
65
|
+
|
66
|
+
def should_validate?(instance)
|
67
|
+
result = validate_this_time?(instance)
|
68
|
+
result &&= instance.instance_eval(&self.if) unless self.if.nil?
|
69
|
+
result
|
70
|
+
end
|
71
|
+
|
72
|
+
def message(instance)
|
73
|
+
@message.respond_to?(:call) ? instance.instance_eval(&@message) : @message
|
74
|
+
end
|
75
|
+
|
76
|
+
def validate_this_time?(instance)
|
77
|
+
return true if @times.nil?
|
78
|
+
self.times > instance.times_validated(self.key)
|
79
|
+
end
|
80
|
+
|
81
|
+
def run_after_validate(result, instance, attribute)
|
82
|
+
self.class.all_after_validations.each do |block|
|
83
|
+
block.call result, instance, attribute
|
84
|
+
end
|
85
|
+
instance.instance_eval_with_params result, attribute, &self.after_validate unless self.after_validate.nil?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|