comboy-autumn 3.1

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 (81) hide show
  1. data/README.textile +1192 -0
  2. data/autumn.gemspec +25 -0
  3. data/bin/autumn +27 -0
  4. data/lib/autumn.rb +2 -0
  5. data/lib/autumn/authentication.rb +290 -0
  6. data/lib/autumn/channel_leaf.rb +107 -0
  7. data/lib/autumn/coder.rb +166 -0
  8. data/lib/autumn/console_boot.rb +9 -0
  9. data/lib/autumn/ctcp.rb +250 -0
  10. data/lib/autumn/daemon.rb +207 -0
  11. data/lib/autumn/datamapper_hacks.rb +290 -0
  12. data/lib/autumn/foliater.rb +231 -0
  13. data/lib/autumn/formatting.rb +236 -0
  14. data/lib/autumn/generator.rb +231 -0
  15. data/lib/autumn/genesis.rb +191 -0
  16. data/lib/autumn/inheritable_attributes.rb +162 -0
  17. data/lib/autumn/leaf.rb +738 -0
  18. data/lib/autumn/log_facade.rb +49 -0
  19. data/lib/autumn/misc.rb +87 -0
  20. data/lib/autumn/script.rb +74 -0
  21. data/lib/autumn/speciator.rb +165 -0
  22. data/lib/autumn/stem.rb +919 -0
  23. data/lib/autumn/stem_facade.rb +176 -0
  24. data/resources/daemons/Anothernet.yml +3 -0
  25. data/resources/daemons/AustHex.yml +29 -0
  26. data/resources/daemons/Bahamut.yml +67 -0
  27. data/resources/daemons/Dancer.yml +3 -0
  28. data/resources/daemons/GameSurge.yml +3 -0
  29. data/resources/daemons/IRCnet.yml +3 -0
  30. data/resources/daemons/Ithildin.yml +7 -0
  31. data/resources/daemons/KineIRCd.yml +56 -0
  32. data/resources/daemons/PTlink.yml +6 -0
  33. data/resources/daemons/QuakeNet.yml +20 -0
  34. data/resources/daemons/RFC1459.yml +158 -0
  35. data/resources/daemons/RFC2811.yml +16 -0
  36. data/resources/daemons/RFC2812.yml +36 -0
  37. data/resources/daemons/RatBox.yml +25 -0
  38. data/resources/daemons/Ultimate.yml +24 -0
  39. data/resources/daemons/Undernet.yml +6 -0
  40. data/resources/daemons/Unreal.yml +110 -0
  41. data/resources/daemons/_Other.yml +7 -0
  42. data/resources/daemons/aircd.yml +33 -0
  43. data/resources/daemons/bdq-ircd.yml +3 -0
  44. data/resources/daemons/hybrid.yml +38 -0
  45. data/resources/daemons/ircu.yml +67 -0
  46. data/resources/daemons/tr-ircd.yml +8 -0
  47. data/skel/Rakefile +135 -0
  48. data/skel/config/global.yml +2 -0
  49. data/skel/config/seasons/testing/database.yml +7 -0
  50. data/skel/config/seasons/testing/leaves.yml +7 -0
  51. data/skel/config/seasons/testing/season.yml +2 -0
  52. data/skel/config/seasons/testing/stems.yml +9 -0
  53. data/skel/leaves/administrator/README +20 -0
  54. data/skel/leaves/administrator/controller.rb +67 -0
  55. data/skel/leaves/administrator/views/autumn.txt.erb +1 -0
  56. data/skel/leaves/administrator/views/reload.txt.erb +11 -0
  57. data/skel/leaves/insulter/README +17 -0
  58. data/skel/leaves/insulter/controller.rb +65 -0
  59. data/skel/leaves/insulter/views/about.txt.erb +1 -0
  60. data/skel/leaves/insulter/views/help.txt.erb +1 -0
  61. data/skel/leaves/insulter/views/insult.txt.erb +1 -0
  62. data/skel/leaves/scorekeeper/README +34 -0
  63. data/skel/leaves/scorekeeper/config.yml +2 -0
  64. data/skel/leaves/scorekeeper/controller.rb +104 -0
  65. data/skel/leaves/scorekeeper/helpers/general.rb +64 -0
  66. data/skel/leaves/scorekeeper/models/channel.rb +12 -0
  67. data/skel/leaves/scorekeeper/models/person.rb +14 -0
  68. data/skel/leaves/scorekeeper/models/pseudonym.rb +11 -0
  69. data/skel/leaves/scorekeeper/models/score.rb +14 -0
  70. data/skel/leaves/scorekeeper/tasks/stats.rake +17 -0
  71. data/skel/leaves/scorekeeper/views/about.txt.erb +1 -0
  72. data/skel/leaves/scorekeeper/views/change.txt.erb +5 -0
  73. data/skel/leaves/scorekeeper/views/history.txt.erb +11 -0
  74. data/skel/leaves/scorekeeper/views/points.txt.erb +5 -0
  75. data/skel/leaves/scorekeeper/views/usage.txt.erb +1 -0
  76. data/skel/script/console +34 -0
  77. data/skel/script/daemon +29 -0
  78. data/skel/script/destroy +48 -0
  79. data/skel/script/generate +48 -0
  80. data/skel/script/server +15 -0
  81. metadata +170 -0
@@ -0,0 +1,236 @@
1
+ # Defines the Autumn::Formatting class, which provides macros for different
2
+ # protocols for IRC message stylization.
3
+
4
+ module Autumn
5
+
6
+ # Adds text formatting to Autumn objects. Text formatting (color and styles)
7
+ # is not a part of the original IRC spec, so many clients have come up with
8
+ # many different ways of sending formatted text. The classes in this module
9
+ # encapsulate those various methods.
10
+ #
11
+ # To add formatting to a stem or leaf, simply include the appropriate module
12
+ # in your Leaf subclass, Stem instance, or other Autumn object. You can also
13
+ # use these constants directly from the module, without adding them into your
14
+ # class.
15
+ #
16
+ # Where possible, all modules in the Formatting module follow an implicit
17
+ # protocol, which includes methods like +color+, +bold+, +plain+, and
18
+ # +underline+.
19
+
20
+ module Formatting
21
+
22
+ # The mIRC format is the oldest IRC text formatting protocol, written for
23
+ # use with the mIRC client. Although mIRC formatting is by far the most
24
+ # common and most widely supported, it is also has the fewest features. mIRC
25
+ # also has some limitations that can occur when coloring text; please see
26
+ # the color method for more information.
27
+ #
28
+ # To stylize your text, insert the appropriate style code in your text where
29
+ # desired. For example (assuming you have <tt>include</tt>d the Mirc
30
+ # module):
31
+ #
32
+ # "I'm feeling #{BOLD}bold today, and #{ITALIC}how#{PLAIN}!"
33
+ #
34
+ # yields:
35
+ #
36
+ # I'm feeling <b>bold today, and <i>how</i></b>!
37
+ #
38
+ # To colorize text, you must call the color method, and insert an UNCOLOR
39
+ # token at the end of the colorized text:
40
+ #
41
+ # "The system is: #{color(:red)}down#{UNCOLOR}!"
42
+
43
+ module Mirc
44
+ # Insert this character to set all following text unformatted.
45
+ PLAIN = 15.chr
46
+ # Insert this character to set all following text bolded.
47
+ BOLD = 2.chr
48
+ # Insert this character to set all following text italicized.
49
+ ITALIC = 22.chr
50
+ # Insert this character to set all following text underlined.
51
+ UNDERLINE = 31.chr
52
+
53
+ # The mIRC color code sentinel.
54
+ COLOR_CODE = 3.chr
55
+ # Insert this character to stop colorizing text.
56
+ UNCOLOR = COLOR_CODE + " "
57
+ # Same as UNCOLOR, but suppresses the trailing space for situations where
58
+ # no conflict is assured.
59
+ UNCOLOR_NO_SPACE = COLOR_CODE
60
+ # Valid IRC colors, in the mIRC style, to be used with the color method.
61
+ COLORS = {
62
+ :white => '00',
63
+ :black => '01',
64
+ :dark_blue => '02',
65
+ :navy_blue => '02',
66
+ :dark_green => '03',
67
+ :red => '04',
68
+ :brown => '05',
69
+ :dark_red => '05',
70
+ :purple => '06',
71
+ :dark_yellow => '07',
72
+ :olive => '07',
73
+ :orange => '07',
74
+ :yellow => '08',
75
+ :green => '09',
76
+ :lime => '09',
77
+ :dark_cyan => '10',
78
+ :teal => '10',
79
+ :cyan => '11',
80
+ :blue => '12',
81
+ :royal_blue => '12',
82
+ :magenta => '13',
83
+ :pink => '13',
84
+ :fuchsia => '13',
85
+ :gray => '14',
86
+ :light_gray => '15',
87
+ :silver => '15'
88
+ }
89
+
90
+ # Colors the following text with a foreground and background color. Colors
91
+ # are a symbol in the COLORS hash. By default the background is left
92
+ # uncolored. This method returns a string that should be prepended to the
93
+ # text you want to colorize. Append an UNCOLOR token when you wish to end
94
+ # colorization.
95
+ #
96
+ # Because of limitations in the mIRC color-coding system, a space will be
97
+ # added after the color code (and before any colorized text). Without this
98
+ # space character, it is possible that your text will appear in the wrong
99
+ # color. (This is most likely to happen when colorizing numbers with
100
+ # commas in them, such as "1,160".) If you would like to suppress this
101
+ # space, because you either are sure that your text will be formatted
102
+ # correctly anyway, or you simply don't care, you can pass
103
+ # <tt>:suppress_space => true</tt> to this method.
104
+
105
+ def color(fgcolor, bgcolor=nil, options={})
106
+ fgcolor = :black unless COLORS.include? fgcolor
107
+ bgcolor = :white unless (bgcolor.nil? or COLORS.include? bgcolor)
108
+ "#{COLOR_CODE}#{COLORS[fgcolor]}#{bgcolor ? (',' + COLORS[bgcolor]) : ''}#{options[:suppress_space] ? '' : ' '}"
109
+ end
110
+
111
+ # Sets all following text unformatted.
112
+ def plain; PLAIN; end
113
+
114
+ # Sets all following text bold.
115
+ def bold; BOLD; end
116
+
117
+ # Sets all following text italic.
118
+ def italic; ITALIC; end
119
+
120
+ # Sets all following text underline.
121
+ def underline; UNDERLINE; end
122
+
123
+ # Removes coloring from all following text. Options:
124
+ #
125
+ # +suppress_space+:: By default, this method places a space after the
126
+ # uncolor token to prevent "color bleed." If you would
127
+ # like to suppress this behavior, set this to true.
128
+ def uncolor(options={})
129
+ options[:suppress_space] ? UNCOLOR_NO_SPACE : UNCOLOR
130
+ end
131
+ end
132
+
133
+ # The default formatter for leaves that do not specify otherwise.
134
+ DEFAULT = Mirc
135
+
136
+ # The ircle formatting system is an adaptation of the mIRC system, written
137
+ # for use by the ircle Macintosh client. Its primary purpose is to improve
138
+ # upon mIRC's lackluster color support. The ircle protocol is identical to
139
+ # the mIRC protocol for purposes of text styling (bold, italic, underline),
140
+ # so stylized text will appear the same on both clients.
141
+ #
142
+ # The only difference is in text colorization, for which ircle has a
143
+ # slightly better system, but one that is incompatible with mIRC-type
144
+ # clients.
145
+ #
146
+ # Styling text is done exactly as it is in the Mirc module; coloring text is
147
+ # done with the COLORS hash, as so:
148
+ #
149
+ # "The system is: #{COLORS[:red]}down#{PLAIN}!"
150
+ #
151
+ # Note that there is no support for background coloring.
152
+
153
+ module Ircle
154
+ # Insert this character to set all following text unformatted and
155
+ # uncolored.
156
+ PLAIN = 15.chr
157
+ # Insert this character to set all following text bolded.
158
+ BOLD = 2.chr
159
+ # Insert this character to set all following text italicized.
160
+ ITALIC = 22.chr
161
+ # Insert this character to set all following text underlined.
162
+ UNDERLINE = 31.chr
163
+ # The ircle color code sentinel.
164
+ COLOR_CODE = 3.chr
165
+ # Insert a character from this hash to set the color of all following
166
+ # text.
167
+ COLORS = {
168
+ :white => COLOR_CODE + '0',
169
+ :black => COLOR_CODE + '1',
170
+ :red => COLOR_CODE + '2',
171
+ :orange => COLOR_CODE + '3',
172
+ :yellow => COLOR_CODE + '4',
173
+ :light_green => COLOR_CODE + '5',
174
+ :green => COLOR_CODE + '6',
175
+ :blue_green => COLOR_CODE + '7',
176
+ :cyan => COLOR_CODE + '8',
177
+ :light_blue => COLOR_CODE + '9',
178
+ :blue => COLOR_CODE + ':',
179
+ :purple => COLOR_CODE + ';',
180
+ :magenta => COLOR_CODE + '<',
181
+ :purple_red => COLOR_CODE + '=',
182
+ :light_gray => COLOR_CODE + '>',
183
+ :dark_gray => COLOR_CODE + '?',
184
+ :dark_red => COLOR_CODE + '@',
185
+ :dark_orange => COLOR_CODE + 'A',
186
+ :dark_yellow => COLOR_CODE + 'B',
187
+ :dark_light_green => COLOR_CODE + 'C',
188
+ :dark_green => COLOR_CODE + 'D',
189
+ :dark_blue_green => COLOR_CODE + 'E',
190
+ :dark_cyan => COLOR_CODE + 'F',
191
+ :dark_light_blue => COLOR_CODE + 'G',
192
+ :dark_blue => COLOR_CODE + 'H',
193
+ :dark_purple => COLOR_CODE + 'I',
194
+ :dark_magenta => COLOR_CODE + 'J',
195
+ :dark_purple_red => COLOR_CODE + 'K',
196
+ # User-defined colors:
197
+ :server_message => COLOR_CODE + 'a',
198
+ :standard_message => COLOR_CODE + 'b',
199
+ :private_message => COLOR_CODE + 'c',
200
+ :notify => COLOR_CODE + 'd',
201
+ :dcc_ctcp => COLOR_CODE + 'e',
202
+ :window_bg => COLOR_CODE + 'f',
203
+ :own_message => COLOR_CODE + 'g',
204
+ :notice => COLOR_CODE + 'h',
205
+ :user_highlight => COLOR_CODE + 'i',
206
+ :userlist_chanop => COLOR_CODE + 'l',
207
+ :userlist_ircop => COLOR_CODE + 'm',
208
+ :userlist_voice => COLOR_CODE + 'n'
209
+ }
210
+ # For purposes of cross-compatibility, this constant has been added to
211
+ # match the Mirc module. Removes all formatting and coloring on all
212
+ # following text.
213
+ UNCOLOR = PLAIN
214
+
215
+ # For purposes of cross-compatibility, this method has been added to match
216
+ # the Mirc method with the same name. All inapplicable parameters and
217
+ # color names are ignored.
218
+
219
+ def color(fgcolor, bgcolor=nil, options={})
220
+ COLORS[fgcolor]
221
+ end
222
+
223
+ # Sets all following text unformatted.
224
+ def plain; PLAIN; end
225
+
226
+ # Sets all following text bold.
227
+ def bold; BOLD; end
228
+
229
+ # Sets all following text italic.
230
+ def italic; ITALIC; end
231
+
232
+ # Sets all following text underline.
233
+ def underline; UNDERLINE; end
234
+ end
235
+ end
236
+ end
@@ -0,0 +1,231 @@
1
+ # Defines the Autumn::Generator class, which generates and destroys files and
2
+ # directories of Autumn objects for script/generate.
3
+
4
+ require 'yaml'
5
+ require 'autumn/coder'
6
+
7
+ module Autumn
8
+
9
+ # Generates the files for Autumn templates such as leaves and seasons. The
10
+ # contents of these template files are populated by an LeafCoder instance.
11
+
12
+ class Generator # :nodoc:
13
+ # The names of the required files in a season's directory, and example
14
+ # for each file.
15
+ SEASON_FILES = {
16
+ "leaves.yml" => {
17
+ 'Scorekeeper' => {
18
+ 'class' => 'Scorekeeper'
19
+ },
20
+ 'Insulter' => {
21
+ 'class' => 'Insulter'
22
+ },
23
+ 'Administrator' => {
24
+ 'class' => 'Administrator',
25
+ 'authentication' => {
26
+ 'type' => 'op'
27
+ }
28
+ }
29
+ },
30
+ "stems.yml" => {
31
+ 'Example' => {
32
+ 'server' => 'irc.yourircserver.com',
33
+ 'nick' => 'MyIRCBot',
34
+ 'channel' => '#yourchannel',
35
+ 'rejoin' => true,
36
+ 'leaves' => [ 'Administrator', 'Scorekeeper', 'Insulter' ]
37
+ }
38
+ },
39
+ "season.yml" => {
40
+ 'logging' => 'debug'
41
+ },
42
+ 'database.yml' => {
43
+ 'Example' => {
44
+ 'adapter' => 'mysql',
45
+ 'host' => 'localhost',
46
+ 'username' => 'root',
47
+ 'password' => '',
48
+ 'database' => 'example_database'
49
+ }
50
+ }
51
+ }
52
+
53
+ # Creates a new instance.
54
+
55
+ def initialize
56
+ @coder = Autumn::TemplateCoder.new
57
+ end
58
+
59
+ # Generates the files for a new leaf with the given name. Options:
60
+ #
61
+ # +verbose+:: Print to standard output every action that is taken.
62
+ # +vcs+:: The version control system used by this project. The files and
63
+ # directories created by this method will be added to the project's
64
+ # VCS.
65
+
66
+ def leaf(name, options={})
67
+ lpath = "leaves/#{name.snakecase}"
68
+ if File.directory? lpath then
69
+ exists lpath, options
70
+ return
71
+ elsif File.exist? lpath then
72
+ raise "There is a file named #{lpath} in the way."
73
+ else
74
+ Dir.mkdir lpath
75
+ created lpath, options
76
+ end
77
+
78
+ cname = "leaves/#{name.snakecase}/controller.rb"
79
+ if File.exist? cname then
80
+ exists cname, options
81
+ else
82
+ @coder.leaf(name)
83
+ File.open(cname, 'w') { |file| file.puts @coder.output }
84
+ created cname, options
85
+ end
86
+
87
+ dpath = "leaves/#{name.snakecase}/data"
88
+ if File.directory? dpath then
89
+ exists dpath, options
90
+ else
91
+ Dir.mkdir dpath
92
+ created dpath, options
93
+ end
94
+
95
+ [ 'helpers', 'models', 'tasks', 'views' ].each do |dir|
96
+ path = "leaves/#{name.snakecase}/#{dir}"
97
+ if File.directory? path then
98
+ exists path, options
99
+ elsif File.exist? path then
100
+ raise "There is a file named #{path} in the way."
101
+ else
102
+ Dir.mkdir path
103
+ created path, options
104
+ end
105
+ end
106
+
107
+ vname = "leaves/#{name.snakecase}/views/about.txt.erb"
108
+ if File.exist? vname then
109
+ exists cname, options
110
+ else
111
+ File.open(vname, 'w') { |file| file.puts "Insert your about string here!" }
112
+ created vname, options
113
+ end
114
+
115
+ rname = "leaves/#{name.snakecase}/README"
116
+ if File.exist? rname then
117
+ exists rname, options
118
+ else
119
+ File.open(rname, 'w') { |file| file.puts "This is the read-me for your leaf." }
120
+ created rname, options
121
+ end
122
+ end
123
+
124
+ # Removes the files for a new leaf with the given name. Options:
125
+ #
126
+ # +verbose+:: Print to standard output every action that is taken.
127
+ # +vcs+:: The version control system used by this project. The files and
128
+ # directories removed by this method will be removed from the
129
+ # project's VCS.
130
+
131
+ def unleaf(name, options={})
132
+ lpath = "leaves/#{name.snakecase}"
133
+ if not File.directory? lpath then
134
+ raise "The directory #{lpath} doesn't exist."
135
+ end
136
+
137
+ if File.directory? "#{lpath}/data" and Dir.entries("#{lpath}/data").size > 2 then
138
+ print "\a" # ring the bell
139
+ puts "WARNING: Files exist in this leaf's data directory!"
140
+ puts "Type Ctrl-C in the next ten seconds if you don't want these files to be deleted..."
141
+ (0..9).each do |num|
142
+ print "#{10 - num}... "
143
+ $stdout.flush
144
+ sleep 1
145
+ end
146
+ print "\n"
147
+ end
148
+
149
+ FileUtils.remove_dir lpath
150
+ deleted lpath, options
151
+ end
152
+
153
+ # Generates the files and directories for a new season with the given name.
154
+ # Options:
155
+ #
156
+ # +verbose+:: Print to standard output every action that is taken.
157
+ # +vcs+:: The version control system used by this project. The files and
158
+ # directories created by this method will be added to the project's
159
+ # VCS.
160
+
161
+ def season(name, options={})
162
+ dname = "config/seasons/#{name.snakecase}"
163
+ if File.directory? dname then
164
+ raise "The directory #{dname} already exists."
165
+ elsif File.exist? dname then
166
+ raise "There is a file named #{dname} in the way."
167
+ else
168
+ Dir.mkdir dname
169
+ created dname, options
170
+ SEASON_FILES.each do |fname, content|
171
+ fpath = File.join(dname, fname)
172
+ if File.exist? fpath then
173
+ exists fpath, options
174
+ else
175
+ File.open(fpath, 'w') { |file| file.puts content.to_yaml }
176
+ created fpath, options
177
+ end
178
+ end
179
+ end
180
+ end
181
+
182
+ # Removes the files and directories for a season with the given name.
183
+ # Options:
184
+ #
185
+ # +verbose+:: Print to standard output every action that is taken.
186
+ # +vcs+:: The version control system used by this project. The files and
187
+ # directories removed by this method will be removed from the
188
+ # project's VCS.
189
+
190
+ def unseason(name, options={})
191
+ dname = "config/seasons/#{name.snakecase}"
192
+ if not File.directory? dname then
193
+ raise "The directory #{dname} doesn't exist."
194
+ end
195
+
196
+ FileUtils.remove_dir dname
197
+ deleted dname, options
198
+ end
199
+
200
+ private
201
+
202
+ def created(path, options)
203
+ puts "-- created #{path}" if options[:verbose]
204
+ system "cvs add #{path}" if options[:vcs] == :cvs
205
+ system "svn add #{path}" if options[:vcs] == :svn
206
+ system "git add #{path}" if options[:vcs] == :git
207
+ end
208
+
209
+ def exists(path, options)
210
+ puts "-- exists #{path}" if options[:verbose]
211
+ system "cvs add #{path}" if options[:vcs] == :cvs
212
+ system "svn add #{path}" if options[:vcs] == :svn
213
+ system "git add #{path}" if options[:vcs] == :git
214
+ end
215
+
216
+ def deleted(path, options)
217
+ puts "-- deleted #{path}" if options[:verbose]
218
+ system "cvs remove #{path}" if options[:vcs] == :cvs
219
+ system "svn del --force #{path}" if options[:vcs] == :svn
220
+ system "git rm -r #{path}" if options[:vcs] == :git
221
+ end
222
+
223
+ def notempty(path, options)
224
+ puts "-- notempty #{path}" if options[:verbose]
225
+ end
226
+
227
+ def notfound(path, options)
228
+ puts "-- notfound #{path}" if options[:verbose]
229
+ end
230
+ end
231
+ end