Auto 4.0.0.alpha.1-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. data/.yardopts +7 -0
  2. data/Gemfile +19 -0
  3. data/LICENSE.md +31 -0
  4. data/README.md +109 -0
  5. data/Rakefile +41 -0
  6. data/bin/auto +110 -0
  7. data/bin/auto-conf +45 -0
  8. data/conf/example.json +100 -0
  9. data/conf/example.yml +125 -0
  10. data/docs/Contributing.md +77 -0
  11. data/docs/Events.md +103 -0
  12. data/docs/Todo.md +21 -0
  13. data/docs/Upgrade.md +16 -0
  14. data/ext/dsl_base.c +49 -0
  15. data/ext/libauto/auto.h +20 -0
  16. data/ext/libauto/extconf.rb +16 -0
  17. data/ext/libauto/libauto.c +29 -0
  18. data/ext/libauto/libauto.h +28 -0
  19. data/ext/libauto/logger.c +177 -0
  20. data/ext/libauto/logger.h +44 -0
  21. data/lib/auto.rb +43 -0
  22. data/lib/auto/api.rb +7 -0
  23. data/lib/auto/api/events.rb +166 -0
  24. data/lib/auto/api/object.rb +29 -0
  25. data/lib/auto/api/plugin.rb +155 -0
  26. data/lib/auto/api/timers.rb +93 -0
  27. data/lib/auto/bot.rb +338 -0
  28. data/lib/auto/config.rb +181 -0
  29. data/lib/auto/configure.rb +410 -0
  30. data/lib/auto/configure/shell.rb +154 -0
  31. data/lib/auto/dsl/base.rb +74 -0
  32. data/lib/auto/dsl/irc.rb +13 -0
  33. data/lib/auto/irc.rb +8 -0
  34. data/lib/auto/irc/common.rb +63 -0
  35. data/lib/auto/irc/library.rb +89 -0
  36. data/lib/auto/irc/object/channel.rb +21 -0
  37. data/lib/auto/irc/object/entity.rb +90 -0
  38. data/lib/auto/irc/object/message.rb +99 -0
  39. data/lib/auto/irc/object/user.rb +139 -0
  40. data/lib/auto/irc/protocol.rb +164 -0
  41. data/lib/auto/irc/protocol/numerics.rb +60 -0
  42. data/lib/auto/irc/sasl/diffie_hellman.rb +36 -0
  43. data/lib/auto/irc/sasl/mech.rb +15 -0
  44. data/lib/auto/irc/sasl/mech/dh_blowfish.rb +83 -0
  45. data/lib/auto/irc/sasl/mech/plain.rb +39 -0
  46. data/lib/auto/irc/server.rb +301 -0
  47. data/lib/auto/irc/state/channel_manager.rb +6 -0
  48. data/lib/auto/irc/state/support.rb +142 -0
  49. data/lib/auto/irc/state/user_manager.rb +6 -0
  50. data/lib/auto/irc/std/commands.rb +99 -0
  51. data/lib/auto/irc/std/numerics.rb +216 -0
  52. data/lib/auto/rubyext/integer.rb +25 -0
  53. data/lib/auto/rubyext/string.rb +10 -0
  54. data/lib/auto/version.rb +18 -0
  55. data/lib/libauto.so +0 -0
  56. data/spec/api_events_spec.rb +68 -0
  57. data/spec/config_json_spec.rb +116 -0
  58. data/spec/config_other_spec.rb +29 -0
  59. data/spec/config_yaml_spec.rb +136 -0
  60. data/spec/helper.rb +19 -0
  61. data/spec/irc_object_entity_spec.rb +51 -0
  62. data/spec/logger_spec.rb +30 -0
  63. data/spec/plugin_base_spec.rb +35 -0
  64. data/spec/timers_spec.rb +42 -0
  65. metadata +238 -0
@@ -0,0 +1,125 @@
1
+ ---
2
+
3
+ # Auto 4 example YAML configuration file
4
+
5
+ # Core libraries to load.
6
+ #
7
+ # irc: IRC protocol framework.
8
+ libraries:
9
+ - irc
10
+
11
+ # List of IRC servers to which to connect.
12
+ irc:
13
+ # Server name, followed by properties.
14
+ freenode:
15
+
16
+ # Server address.
17
+ address: irc.freenode.net
18
+
19
+ # Server port.
20
+ port: 7000
21
+
22
+ # Whether to use SSL: true or false.
23
+ useSSL: true
24
+
25
+ # Nicknames. Auto will use the first one, and if it fails, it will try
26
+ # each one until success is achieved.
27
+ nickname:
28
+ - moobot
29
+ - altnick
30
+
31
+ # Username or ident.
32
+ username: Auto
33
+
34
+ # Real name or GECOS.
35
+ realName: Auto
36
+
37
+ # SASL options. Remove this if you don't want to use SASL or the server
38
+ # does not support it.
39
+ SASL:
40
+ # Timeout in seconds. 15s is reasonable.
41
+ timeout: 15
42
+ # Account as which to identify.
43
+ username: moobot
44
+ # Password for the account.
45
+ password: moopass
46
+
47
+ # List of channels to join automatically.
48
+ autojoin:
49
+ - name: '#autoproject' # The channel name. Don't forget the quotes because channels have octothorpes.
50
+ key: ~ # Key, if necessary.
51
+
52
+ # Another server. Add as many as you wish.
53
+ Rizon:
54
+
55
+ address: irc.rizon.net
56
+ port: 6667
57
+ useSSL: false
58
+ nickname:
59
+ - moobot
60
+ - altnick
61
+ username: Auto
62
+ realName: Auto
63
+
64
+ # Identify the traditional way; that is, by privately messaging a service.
65
+ nickIdentify:
66
+ # The name of the service--usually NickServ.
67
+ service: NickServ
68
+ # The command to use--usually identify.
69
+ command: identify
70
+ # The password to use. If the server uses Atheme, we suggest putting the accountname followed by
71
+ # the password here, so that identification never fails.
72
+ password: moopass
73
+
74
+ # Database configuration
75
+ #
76
+ # In addition to the 'sequel' Ruby gem, you will need some additional gem(s) depending
77
+ # upon the database management system of your choice:
78
+ #
79
+ # SQLite users: sqlite3
80
+ # MySQL users: mysqlplus
81
+ # Postgres users: pg
82
+ #
83
+ # If your DBMS is not supported and you would like it to be, we'll consider a feature
84
+ # request which you may submit either to the mailing group (http://j.mp/autotalk), or
85
+ # to the issue hub (https://github.com/Auto/Auto/issues). Alas, we regret to inform
86
+ # our users that the official database model hasn't support for NoSQL systems, so such
87
+ # NoSQL database management systems as MongoDB, Redis, CouchDB, Cassandra, etc. cannot
88
+ # be officially supported at this time, although that's not to say a plugin is
89
+ # incapable of extending Auto to support them.
90
+ database:
91
+
92
+ # The type of database.
93
+ #
94
+ # sqlite (recommended): A very simple SQL database system which outputs to a file.
95
+ # [needs] name
96
+ #
97
+ # mysql: A popular SQL system based on a network server/client model.
98
+ # [needs] name, hostname, username, password
99
+ #
100
+ # postgres: An advanced SQL system popularly employed as an alternative to MySQL.
101
+ # [needs] name, hostname, username, password
102
+ type: sqlite
103
+
104
+ # Database name.
105
+ #
106
+ # SQLite users should provide a path to a file (e.g., you may use 'auto.db'
107
+ # to write to /path/to/auto/installation/auto.db, or perhaps '/home/your_home_dir/autobot.db')
108
+ #
109
+ # MySQL and Postgres users should provide the name of the database; e.g. 'autobot'
110
+ name: auto.db
111
+
112
+ # Hostname to which to connect.
113
+ #
114
+ # This is needed only for MySQL and Postgres.
115
+ hostname: localhost
116
+
117
+ # Username as which to authenticate.
118
+ #
119
+ # This is needed only for MySQL and Postgres.
120
+ username: auto
121
+
122
+ # Password associated with this username.
123
+ #
124
+ # This is needed only for MySQL and Postgres.
125
+ password: insecurepassword123
@@ -0,0 +1,77 @@
1
+ # @title Standards of Contributing
2
+ # @author noxgirl
3
+
4
+ Standards of Contributing
5
+ =========================
6
+
7
+ So that Auto 4 may maintain consistency, usability, and functionality,
8
+ we ask that all contributions to Auto 4 conform with a few standards and
9
+ conventions.
10
+
11
+ While this is solely a requirement for contributions to Auto 4, we would
12
+ suggest following it whenever extending or modifying Auto, whether your
13
+ intention is to ship your code upstream, release it independently, or
14
+ merely keep for your own personal use.
15
+
16
+ Moreover, to further the philosophy of free software, while we do not
17
+ demand it, we do ask that you publish code you write for Auto.
18
+
19
+ **Documentation**
20
+
21
+ Auto maintains thorough documentation. Please document your code employing rdoc
22
+ and YARD standards.
23
+
24
+ When using the `@author` tag, please provide your GitHub
25
+ username at minimum.
26
+
27
+ **Coding**
28
+
29
+ For indentation, ensure that you use spaces in lieu of tabs. For Ruby code and
30
+ YAML, use two spaces. For C code, use four spaces.
31
+
32
+ Vim users, observe the modelines each source file contains:
33
+
34
+ # vim: set ts=4 sts=2 sw=2 et:
35
+
36
+ and
37
+
38
+ /* vim: set ts=4 sts=4 sw=4 et cindent: */
39
+
40
+ Ruby coders, largely keep your code in compliance with [this style guide](https://github.com/bbatsov/ruby-style-guide).
41
+
42
+ C coders, we prefer Allman (not K&R) style.
43
+
44
+ **Language**
45
+
46
+ In documentation, commit messages, and other such things, we require compliance
47
+ with these three rules:
48
+
49
+ 1. No obscene language.
50
+ 2. It must be legible.
51
+ 3. It must be grammatically correct at least to a reasonable degree.
52
+
53
+ **Membership**
54
+
55
+ While we recognize and credit all individuals who contribute, no matter how
56
+ small their contribution, we are also willing to grant commit access and
57
+ official membership to regular contributors.
58
+
59
+ Please contact Autumn Perrault (also known as noxgirl) if you wish to become
60
+ a member of the Auto Project:
61
+
62
+ + By e-mail: autumn@destellae.net
63
+ + By IRC: "autumn" on irc.freenode.net (usually in #auto)
64
+
65
+ **Releasing**
66
+
67
+ To release a new version, follow this process:
68
+
69
+ 1. Ensure successful compilation and testing with `rake`.
70
+ 2. Update `lib/auto/version.rb`.
71
+ 3. Update `README.md` -- the version number and documentation link.
72
+ 4. Commit `lib/auto/version.rb` and `README.md` with a message of "Version bump to x."
73
+ 5. Cross-compile for Microsoft Windows with `rake cross compile`.
74
+ 6. Package the typical gem with `rake gem`.
75
+ 7. Package the Windows distribution with `rake cross native gem`.
76
+ 8. Tag the git branch with `git tag -a x -m "vX release"`.
77
+
@@ -0,0 +1,103 @@
1
+ # @title Specification of Events
2
+
3
+ Specification of Events
4
+ =======================
5
+
6
+ **Events** are managed by Auto's event systems, each of which is an instance
7
+ of {Auto::API::Events}.
8
+
9
+ `$m.events` manages the **Auto** events, which is to say the central events,
10
+ while libraries have their own individual events systems.
11
+
12
+ {Auto::DSL::Base} provides `#on`, `#emit`, `#undo_on`, etc., which all provide
13
+ easy distinction between the individual event systems. `:auto`, for example,
14
+ indicates the central system, whereas `:irc` indicates the IRC event system.
15
+
16
+ :auto
17
+ -----
18
+
19
+ ### :start
20
+
21
+ This event occurs when Auto is starting, and each library is expected to await
22
+ this event and upon its occurrence, initiate any of their processes.
23
+
24
+ ### :die `|reason|`
25
+
26
+ **reason** (_String_): The reason for termination.
27
+
28
+ This occurs when Auto is terminating.
29
+
30
+ ### :net_receive `|socket_object|`
31
+
32
+ **socket_object** (_Object_): The object with which the socket (`.socket`) is
33
+ associated.
34
+
35
+ This occurs when the socket associated with `socket_object` has data waiting to
36
+ be read (as determined by `select()`).
37
+
38
+ ### :rehash
39
+
40
+ This event occurs when the configuration file is successfully reprocessed and
41
+ reloaded.
42
+
43
+ :irc
44
+ ----
45
+
46
+ ### :preconnect |irc|
47
+
48
+ **irc** (_Auto::IRC::Server_): The IRC connection.
49
+
50
+ This event occurs when we are about to register (i.e., send `USER`, `CAP LS`)
51
+ on the server and initiate connection.
52
+
53
+ ### :receive |irc, data|
54
+
55
+ **irc** (_Auto::IRC::Server_): The IRC connection.
56
+ **data** (_String_): The line of data.
57
+
58
+ This event occurs when data has been removed from the receive queue and is ready
59
+ for processing, with newlines and carriage returns stripped.
60
+
61
+ ### :connected |irc|
62
+
63
+ **irc** (_Auto::IRC::Server_): The IRC connection.
64
+
65
+ This event occurs after ISUPPORT has been received and processed, and the
66
+ connection is fully established.
67
+
68
+ Typically, at this point, any traditional service identification and autojoining
69
+ occurs.
70
+
71
+ ### :disconnect |irc, reason|
72
+
73
+ **irc** (_Auto::IRC::Server_): The IRC connection.
74
+ **reason** (_String_): The reason for which we are disconnecting.
75
+
76
+ This event occurs when we're about to disconnect from the given server.
77
+
78
+ ### :send_join |irc, channel, key|
79
+
80
+ **irc** (_Auto::IRC::Server_): The IRC connection.
81
+ **channel** (_String_): The channel which we are attempting to join.
82
+ **key** (_String_ or _nil_): The key, if provided.
83
+
84
+ This event occurs when we try to join a channel.
85
+
86
+ ### :send_nick |irc, nickname|
87
+
88
+ **irc** (_Auto::IRC::Server_): The IRC connection.
89
+ **nickname** (_String_): The nickname we are trying to use.
90
+
91
+ This occurs when we try to change our nickname with /NICK.
92
+
93
+ ### :self_who |irc|
94
+
95
+ **irc** (_Auto::IRC::Server_): The IRC connection.
96
+
97
+ This occurs when we send a /WHO on ourselves.
98
+
99
+ ### irc:onWhoReply `[all strs](irc*, nick, username, host, realname, awaystatus, server)`
100
+
101
+ This event occurs when the bot receives **RPL_WHOREPLY** (numeric 352) in response to a /WHO. Note that
102
+ `awaystatus =~ /H/` will be true if the user is not away, while `awaystatus =~ /G/` will be true if the
103
+ user is away (`H` meaning _here_, `G` meaning _gone_).
@@ -0,0 +1,21 @@
1
+ # @title Developers' To-Do List
2
+
3
+ Developers' To-Do List
4
+ ======================
5
+
6
+ 4.0.0
7
+ -----
8
+
9
+ + [ ] Write Auto::DSL::IRC.
10
+ + [ ] Add DSL #extend functions to Auto::API::Plugin#configure.
11
+ + [ ] Document exceptions for #configure also.
12
+ + [ ] Add Auto::IRC::Object::Entity#who.
13
+ + [ ] Move IRC::Object::Channel to Auto::IRC::Object::Channel, and make it a proper
14
+ subclass of Auto::IRC::Object::Entity.
15
+ + [ ] Finish Auto::Configure::Shell.
16
+
17
+ **Plugins**
18
+
19
+ * [ ] IRC relay.
20
+ * [ ] Last.fm.
21
+ * [ ] Twitter.
@@ -0,0 +1,16 @@
1
+ # @title Upgrade Auto 3 to 4
2
+
3
+ Upgrade Auto 3 to 4
4
+ ===================
5
+
6
+ Summary
7
+ -----------
8
+ Auto 3 was a comprehensive release of Auto, and is currently available from
9
+ [Arinity](https://github.com/arinity/Auto). As all things should hopefully improve
10
+ however, this fourth major revision was begun.
11
+
12
+ Nonetheless, we recognize that it is essential that we provide a means by which
13
+ Auto users may upgrade their old configuration files and databases to function
14
+ with Auto 4.
15
+
16
+ We intend to address this matter when Auto 4 is nearer stability.
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright (c) 2013, Autumn Perrault, et al.
3
+ * All rights reserved.
4
+ * This free software is distributed under the FreeBSD license (LICENSE.md).
5
+ *
6
+ */
7
+ #include "ruby.h"
8
+
9
+ VALUE mAuto;
10
+ VALUE mDSL;
11
+ VALUE mBase;
12
+
13
+ static VALUE clock_do(int argc, VALUE *argv, VALUE self)
14
+ {
15
+ return rb_funcall2(rb_funcall(rb_funcall(rb_gv_get("$m"), rb_intern("clock"), 0), rb_intern("spawn"), 0), argc, argv);
16
+ }
17
+
18
+ static VALUE clock_stop(int argc, VALUE *argv, VALUE self)
19
+ {
20
+ return rb_funcall2(rb_funcall(rb_funcall(rb_gv_get("$m"), rb_intern("clock"), 0), rb_intern("del"), 0), argc, argc);
21
+ }
22
+
23
+ static VALUE undo_on(VALUE self, VALUE sys, VALUE hook)
24
+ {
25
+ if(sys == rb_intern("auto"))
26
+ {
27
+ return rb_funcall(rb_funcall(rb_gv_get("$m"), rb_intern("events"), 0) rb_intern("del"), 1, hook);
28
+ }
29
+ else
30
+ {
31
+ if(rb_funcall(rb_gv_get("$m"), rb_intern("respond_to?"), 1, sys) == Qtrue)
32
+ {
33
+ return rb_funcall(rb_funcall(rb_funcall(rb_gv_get("$m"), sys, 0), rb_intern("events"), 0), rb_intern("del"), 1, hook);
34
+ }
35
+ else
36
+ {
37
+ return Qnil;
38
+ }
39
+ }
40
+ }
41
+
42
+ void Init_dsl_base()
43
+ {
44
+ mAuto = rb_define_module("Auto");
45
+ mDSL = rb_define_module_under(mAuto, "DSL");
46
+ mBase = rb_define_module_under(mDSL, "Base");
47
+ }
48
+
49
+ /* vim: set ts=4 sts=4 sw=4 et cindent: */
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (c) 2013, Autumn Perrault, et al.
3
+ * All rights reserved.
4
+ * This free software is distributed under the FreeBSD license (LICENSE.md).
5
+ *
6
+ */
7
+
8
+ #ifndef AUTO_H
9
+ #define AUTO_H
10
+
11
+ /* include the Ruby header */
12
+ #include "ruby.h"
13
+
14
+ /* include libauto headers */
15
+ #include "libauto.h"
16
+ #include "logger.h"
17
+
18
+ #endif // AUTO_H
19
+
20
+ /* vim: set ts=4 sts=4 sw=4 et cindent: */
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
3
+ # This free software is distributed under the FreeBSD license (LICENSE.md).
4
+
5
+ require 'mkmf'
6
+
7
+ extension = 'libauto'
8
+
9
+ dir_config extension
10
+
11
+ $CFLAGS << " -I./include/ "
12
+ $CFLAGS << " -Wno-unused-function "
13
+
14
+ create_makefile extension
15
+
16
+ # vim: set ts=4 sts=2 sw=2 et:
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright (c) 2013, Autumn Perrault, et al.
3
+ * All rights reserved.
4
+ * This free software is distributed under the FreeBSD license (LICENSE.md).
5
+ *
6
+ */
7
+
8
+ #include "auto.h"
9
+
10
+ /* initialize exceptions */
11
+ void initialize_exceptions()
12
+ {
13
+ eLogError = rb_define_class("LogError", rb_eStandardError);
14
+ ePluginError = rb_define_class("PluginError", rb_eStandardError);
15
+ eConfigError = rb_define_class("ConfigError", rb_eStandardError);
16
+ eDatabaseError = rb_define_class("DatabaseError", rb_eStandardError);
17
+ }
18
+
19
+ /* initialize Auto module */
20
+ void Init_libauto()
21
+ {
22
+ mAuto = rb_define_module("Auto");
23
+ /* initialize exceptions */
24
+ initialize_exceptions();
25
+ /* initialize Auto::Logger */
26
+ init_auto_logger();
27
+ }
28
+
29
+ /* vim: set ts=4 sts=4 sw=4 et cindent: */