autumn 3.1.8

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 (111) hide show
  1. data/AUTHORS +11 -0
  2. data/CHANGELOG +567 -0
  3. data/MANIFEST +110 -0
  4. data/README +1114 -0
  5. data/README.textile +1153 -0
  6. data/Rakefile +75 -0
  7. data/autumn.gemspec +44 -0
  8. data/bin/autumn +11 -0
  9. data/lib/autumn.rb +8 -0
  10. data/lib/autumn/authentication.rb +238 -0
  11. data/lib/autumn/channel_leaf.rb +107 -0
  12. data/lib/autumn/coder.rb +166 -0
  13. data/lib/autumn/console_boot.rb +10 -0
  14. data/lib/autumn/ctcp.rb +250 -0
  15. data/lib/autumn/daemon.rb +207 -0
  16. data/lib/autumn/datamapper_hacks.rb +290 -0
  17. data/lib/autumn/foliater.rb +231 -0
  18. data/lib/autumn/formatting.rb +236 -0
  19. data/lib/autumn/generator.rb +231 -0
  20. data/lib/autumn/genesis.rb +190 -0
  21. data/lib/autumn/inheritable_attributes.rb +162 -0
  22. data/lib/autumn/leaf.rb +738 -0
  23. data/lib/autumn/log_facade.rb +49 -0
  24. data/lib/autumn/misc.rb +87 -0
  25. data/lib/autumn/resources/daemons/Anothernet.yml +3 -0
  26. data/lib/autumn/resources/daemons/AustHex.yml +29 -0
  27. data/lib/autumn/resources/daemons/Bahamut.yml +67 -0
  28. data/lib/autumn/resources/daemons/Dancer.yml +3 -0
  29. data/lib/autumn/resources/daemons/GameSurge.yml +3 -0
  30. data/lib/autumn/resources/daemons/IRCnet.yml +3 -0
  31. data/lib/autumn/resources/daemons/Ithildin.yml +7 -0
  32. data/lib/autumn/resources/daemons/KineIRCd.yml +56 -0
  33. data/lib/autumn/resources/daemons/PTlink.yml +6 -0
  34. data/lib/autumn/resources/daemons/QuakeNet.yml +20 -0
  35. data/lib/autumn/resources/daemons/RFC1459.yml +158 -0
  36. data/lib/autumn/resources/daemons/RFC2811.yml +16 -0
  37. data/lib/autumn/resources/daemons/RFC2812.yml +36 -0
  38. data/lib/autumn/resources/daemons/RatBox.yml +25 -0
  39. data/lib/autumn/resources/daemons/Ultimate.yml +24 -0
  40. data/lib/autumn/resources/daemons/Undernet.yml +6 -0
  41. data/lib/autumn/resources/daemons/Unreal.yml +110 -0
  42. data/lib/autumn/resources/daemons/_Other.yml +7 -0
  43. data/lib/autumn/resources/daemons/aircd.yml +33 -0
  44. data/lib/autumn/resources/daemons/bdq-ircd.yml +3 -0
  45. data/lib/autumn/resources/daemons/hybrid.yml +38 -0
  46. data/lib/autumn/resources/daemons/ircu.yml +67 -0
  47. data/lib/autumn/resources/daemons/tr-ircd.yml +8 -0
  48. data/lib/autumn/script.rb +74 -0
  49. data/lib/autumn/speciator.rb +165 -0
  50. data/lib/autumn/stem.rb +919 -0
  51. data/lib/autumn/stem_facade.rb +176 -0
  52. data/lib/autumn/tool/bin.rb +301 -0
  53. data/lib/autumn/tool/create.rb +48 -0
  54. data/lib/autumn/tool/project_creator.rb +110 -0
  55. data/lib/autumn/version.rb +3 -0
  56. data/lib/skel/Rakefile +163 -0
  57. data/lib/skel/config/global.yml +2 -0
  58. data/lib/skel/config/seasons/testing/database.yml +4 -0
  59. data/lib/skel/config/seasons/testing/leaves.yml +9 -0
  60. data/lib/skel/config/seasons/testing/season.yml +2 -0
  61. data/lib/skel/config/seasons/testing/stems.yml +10 -0
  62. data/lib/skel/leaves/administrator/README +20 -0
  63. data/lib/skel/leaves/administrator/controller.rb +67 -0
  64. data/lib/skel/leaves/administrator/views/autumn.txt.erb +1 -0
  65. data/lib/skel/leaves/administrator/views/reload.txt.erb +11 -0
  66. data/lib/skel/leaves/insulter/README +17 -0
  67. data/lib/skel/leaves/insulter/controller.rb +65 -0
  68. data/lib/skel/leaves/insulter/views/about.txt.erb +1 -0
  69. data/lib/skel/leaves/insulter/views/help.txt.erb +1 -0
  70. data/lib/skel/leaves/insulter/views/insult.txt.erb +1 -0
  71. data/lib/skel/leaves/scorekeeper/README +34 -0
  72. data/lib/skel/leaves/scorekeeper/config.yml +2 -0
  73. data/lib/skel/leaves/scorekeeper/controller.rb +104 -0
  74. data/lib/skel/leaves/scorekeeper/helpers/general.rb +64 -0
  75. data/lib/skel/leaves/scorekeeper/models/channel.rb +12 -0
  76. data/lib/skel/leaves/scorekeeper/models/person.rb +14 -0
  77. data/lib/skel/leaves/scorekeeper/models/pseudonym.rb +11 -0
  78. data/lib/skel/leaves/scorekeeper/models/score.rb +14 -0
  79. data/lib/skel/leaves/scorekeeper/tasks/stats.rake +17 -0
  80. data/lib/skel/leaves/scorekeeper/views/about.txt.erb +1 -0
  81. data/lib/skel/leaves/scorekeeper/views/change.txt.erb +5 -0
  82. data/lib/skel/leaves/scorekeeper/views/history.txt.erb +11 -0
  83. data/lib/skel/leaves/scorekeeper/views/points.txt.erb +5 -0
  84. data/lib/skel/leaves/scorekeeper/views/usage.txt.erb +1 -0
  85. data/lib/skel/log/README +1 -0
  86. data/lib/skel/script/console +28 -0
  87. data/lib/skel/script/destroy +48 -0
  88. data/lib/skel/script/generate +48 -0
  89. data/lib/skel/shared/README +1 -0
  90. data/lib/skel/tmp/README +1 -0
  91. data/spec/authentication_spec.rb +328 -0
  92. data/spec/channel_leaf_spec.rb +142 -0
  93. data/spec/coder_spec.rb +146 -0
  94. data/spec/ctcp_spec.rb +222 -0
  95. data/spec/daemon_spec.rb +202 -0
  96. data/spec/datamapper_hacks_spec.rb +164 -0
  97. data/tasks/authors.rake +30 -0
  98. data/tasks/changelog.rake +18 -0
  99. data/tasks/copyright.rake +21 -0
  100. data/tasks/doc.rake +7 -0
  101. data/tasks/gem.rake +23 -0
  102. data/tasks/gem_installer.rake +76 -0
  103. data/tasks/install_dependencies.rake +6 -0
  104. data/tasks/manifest.rake +4 -0
  105. data/tasks/rcov.rake +23 -0
  106. data/tasks/release.rake +52 -0
  107. data/tasks/reversion.rake +8 -0
  108. data/tasks/setup.rake +24 -0
  109. data/tasks/spec.rake +7 -0
  110. data/tasks/yard.rake +4 -0
  111. metadata +188 -0
@@ -0,0 +1,48 @@
1
+ # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require 'autumn/tool/project_creator'
5
+
6
+ module Autumn
7
+ module Tool
8
+
9
+ # Create is a simple class used to create new projects based on the proto
10
+ # directory.
11
+ #
12
+ # It is primarly used for this command:
13
+ #
14
+ # ramaze --create project
15
+ #
16
+ # where project is the directory you want the content put into.
17
+
18
+ class Create
19
+
20
+ # Default options passed to Create::create
21
+ # :proto is the directory to duplicate
22
+ # :amend no files may be overwritten but missing files will be added
23
+ # :force will overwrite existing files
24
+ # :layout copy one subdirectory in +proto+
25
+
26
+ DEFAULT = {
27
+ :proto => File.join(ROOT, 'skel'),
28
+ :amend => false,
29
+ :force => false,
30
+ :layout => '/',
31
+ }
32
+
33
+ # Using ProjectCreator to copy all files and directories from lib/proto
34
+ # to another location.
35
+ # +options+ are described in the DEFAULT constant and should be:
36
+ # :force => (true|false|nil)
37
+ # :amend => (true|false|nil)
38
+ # :layout => (String|nil)
39
+ # :proto => String
40
+
41
+ def self.create(project, options = {})
42
+ options = DEFAULT.merge(options)
43
+ creator = ProjectCreator.new(project, options)
44
+ creator.create
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,110 @@
1
+ # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require 'fileutils'
5
+ require 'find'
6
+
7
+ class ProjectCreator
8
+ PROTO = []
9
+ PROTO << '~/.autumn_skel/' if ENV["HOME"] # Guard against Windows
10
+ attr_accessor :name, :options
11
+
12
+ def initialize(name, options = {})
13
+ @name, @options = name, options
14
+ end
15
+
16
+ def target
17
+ File.expand_path(name)
18
+ end
19
+
20
+ def proto
21
+ PROTO.map!{|pr| File.expand_path(pr) }
22
+ proto = options[:proto] ||= PROTO.find{|f| File.directory?(f) }
23
+ layout = options[:layout] ||= '/'
24
+ File.expand_path(File.join(proto, layout))
25
+ end
26
+
27
+ def create_root?
28
+ return true unless File.directory?(target)
29
+ return true if amend? or force?
30
+ fatal "%p is a directory, choose different project name or use --amend/--force" % target
31
+ end
32
+
33
+ def got_proto?
34
+ return true if File.directory?(proto)
35
+ fatal "Cannot create, %p doesn't exist, use --proto or create the proto directory" % proto
36
+ end
37
+
38
+ def create
39
+ got_proto?
40
+
41
+ puts "Found proto at: %p, proceeding...\n\n" % proto
42
+ mkdir(relate('/')) if create_root?
43
+ proceed
44
+ end
45
+
46
+ def proceed
47
+ files, directories = partition{|path| File.file?(path) }
48
+ proceed_directories(directories)
49
+ proceed_files(files)
50
+ end
51
+
52
+ def proceed_files(files)
53
+ files.each{|file| copy(file, relate(file)) }
54
+ end
55
+
56
+ def proceed_directories(dirs)
57
+ dirs.each{|dir| mkdir(relate(dir)) }
58
+ end
59
+
60
+ def mkdir(dir)
61
+ exists = File.directory?(dir)
62
+ return if exists and amend?
63
+ return if exists and not force?
64
+ puts "mkdir(%p)" % dir
65
+ FileUtils.mkdir_p(dir)
66
+ end
67
+
68
+ def copy(from, to)
69
+ return unless copy_check(to)
70
+ puts "copy(%p, %p)" % [from, to]
71
+ FileUtils.cp(from, to)
72
+ post_process(to)
73
+ end
74
+
75
+ def copy_check(to)
76
+ exists = File.file?(to)
77
+ return if exists and amend?
78
+ return if exists and not force?
79
+ return true
80
+ end
81
+
82
+ # Think about a useful way to process the generated files it should be
83
+ # possible to substitute some things like the project name in the
84
+ # configuration
85
+
86
+ def post_process(file)
87
+ source = File.read(file)
88
+ File.open(file, 'w+') do |io|
89
+ io.puts source.gsub('$${project}', @name)
90
+ end
91
+ end
92
+
93
+ def relate(path)
94
+ File.join(target, path.to_s.sub(proto, ''))
95
+ end
96
+
97
+ def amend?; options[:amend] end
98
+ def force?; options[:force] end
99
+
100
+ def fatal(message)
101
+ warn message
102
+ exit 1
103
+ end
104
+
105
+ def each
106
+ Dir["#{proto}/**/*"].each{|path| yield(path) }
107
+ end
108
+
109
+ include Enumerable
110
+ end
@@ -0,0 +1,3 @@
1
+ module Autumn
2
+ VERSION = "3.1.8"
3
+ end
@@ -0,0 +1,163 @@
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+
5
+ def include_autumn
6
+ begin
7
+ require "autumn"
8
+ require "autumn/genesis"
9
+ rescue LoadError
10
+ require "rubygems"
11
+ require "autumn"
12
+ require "autumn/genesis"
13
+ end
14
+ end
15
+
16
+ task :default do
17
+ puts 'Type "rake --tasks" to see a list of tasks you can perform.'
18
+ end
19
+
20
+ # Load the Autumn environment.
21
+ task :environment do
22
+ include_autumn
23
+ AL_ROOT = File.dirname(__FILE__)
24
+ @genesis = Autumn::Genesis.new
25
+ @genesis.load_global_settings
26
+ @genesis.load_season_settings
27
+ end
28
+
29
+ task :boot do
30
+ include_autumn
31
+ AL_ROOT = File.dirname(__FILE__)
32
+ @genesis = Autumn::Genesis.new
33
+ @genesis.boot! false
34
+ end
35
+
36
+ namespace :app do
37
+ desc "Launch the Autumn daemon"
38
+ task :start do
39
+ system 'autumn start -D'
40
+ end
41
+
42
+ desc "Stop the Autumn daemon"
43
+ task :stop do
44
+ system 'autumn stop'
45
+ end
46
+
47
+ desc "Restart the Autumn daemon"
48
+ task :restart do
49
+ system 'autumn restart -D'
50
+ end
51
+
52
+ desc "Start Autumn but not as a daemon (stay on top)"
53
+ task :run do
54
+ system 'autumn start'
55
+ end
56
+
57
+ desc "Force the daemon to a stopped state (clears PID files)"
58
+ task :zap do
59
+ system 'autumn stop'
60
+ end
61
+ end
62
+
63
+ namespace :log do
64
+ desc "Remove all log files"
65
+ task :clear do
66
+ system 'rm -vf tmp/*.log tmp/*.output log/*.log*'
67
+ end
68
+
69
+ desc "Print all error messages in the log files"
70
+ task :errors => :environment do
71
+ season_log = "log/#{@genesis.config.global :season}.log"
72
+ system_log = 'tmp/autumn.log'
73
+ if File.exists? season_log then
74
+ puts "==== ERROR-LEVEL LOG MESSAGES ===="
75
+ File.open(season_log, 'r') do |log|
76
+ puts log.grep(/^[EF],/)
77
+ end
78
+ end
79
+ if File.exists? system_log then
80
+ puts "==== UNCAUGHT EXCEPTIONS ===="
81
+ File.open(system_log, 'r') do |log|
82
+ puts log.grep(/^[EF],/)
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ def local_db?(db)
89
+ db.host.nil? or db.host == 'localhost'
90
+ end
91
+
92
+ namespace :db do
93
+ desc "Recreate database tables according to the model objects"
94
+ task :migrate => :boot do
95
+ dname = ENV['DB']
96
+ raise "Usage: DB=[Database config name] rake db:migrate" unless dname
97
+ raise "Unknown database config #{dname}" unless database = repository(dname.to_sym)
98
+ puts "Migrating the #{dname} database..."
99
+ # Find models that have definitions for the selected database and migrate them
100
+ repository(dname.to_sym) do
101
+ repository(dname.to_sym).models.each { |mod| mod.auto_migrate! dname.to_sym }
102
+ end
103
+ end
104
+ desc "Nondestructively update database tables according to the model objects"
105
+ task :upgrade => :boot do
106
+ dname = ENV['DB']
107
+ raise "Usage: DB=[Database config name] rake db:upgrade" unless dname
108
+ raise "Unknown database config #{dname}" unless database = repository(dname.to_sym)
109
+ puts "Upgrading the #{dname} database..."
110
+ # Find models that have definitions for the selected database and upgrade them
111
+ repository(dname.to_sym) do
112
+ repository(dname.to_sym).models.each { |mod| mod.auto_upgrade! dname.to_sym }
113
+ end
114
+ end
115
+ end
116
+
117
+ namespace :doc do
118
+ desc "Generate documentation for all leaves"
119
+ task :leaves => :environment do
120
+ FileUtils.remove_dir 'doc/leaves' if File.directory? 'doc/leaves'
121
+ Dir.glob("leaves/*").each do |leaf_dir|
122
+ Dir.chdir leaf_dir do
123
+ system "rdoc --main README --title '#{File.basename(leaf_dir).camelcase} Documentation' -o ../../doc/leaves/#{File.basename leaf_dir} --line-numbers --inline-source controller.rb helpers models README"
124
+ end
125
+ end
126
+ end
127
+
128
+ desc "Remove all documentation"
129
+ task :clear => :environment do
130
+ FileUtils.remove_dir 'doc/api' if File.directory? 'doc/api'
131
+ FileUtils.remove_dir 'doc/leaves' if File.directory? 'doc/leaves'
132
+ end
133
+ end
134
+
135
+ desc "Verify leaf and API specs"
136
+ Spec::Rake::SpecTask.new do |t|
137
+ t.spec_files = FileList['spec/**/*.rb', 'leaves/*/spec/**/*.rb']
138
+ t.spec_opts = [ '-cfs' ]
139
+ end
140
+
141
+ namespace :spec do
142
+ desc "Verify API specs"
143
+ Spec::Rake::SpecTask.new('autumn') do |t|
144
+ t.spec_files = FileList['spec/**/*.rb']
145
+ t.spec_opts = [ '-cfs' ]
146
+ end
147
+
148
+ desc "Verify leaf specs"
149
+ Spec::Rake::SpecTask.new('leaves') do |t|
150
+ t.spec_files = FileList['leaves/*/spec/**/*.rb']
151
+ t.spec_opts = [ '-cfs' ]
152
+ end
153
+ end
154
+
155
+ # Load any custom Rake tasks in the bot's tasks directory.
156
+ Dir["leaves/*"].each do |leaf|
157
+ leaf_name = File.basename(leaf, ".rb").downcase
158
+ namespace leaf_name.to_sym do # Tasks are placed in a namespace named after the leaf
159
+ FileList["leaves/#{leaf_name}/tasks/**/*.rake"].sort.each do |task|
160
+ load task
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ season: testing
@@ -0,0 +1,4 @@
1
+ ---
2
+ Example:
3
+ adapter: sqlite3
4
+ database: $project.db
@@ -0,0 +1,9 @@
1
+ ---
2
+ Administrator:
3
+ authentication:
4
+ type: op
5
+ class: Administrator
6
+ Scorekeeper:
7
+ class: Scorekeeper
8
+ Insulter:
9
+ class: Insulter
@@ -0,0 +1,2 @@
1
+ ---
2
+ logging: debug
@@ -0,0 +1,10 @@
1
+ ---
2
+ Example:
3
+ nick: $${project}
4
+ leaves:
5
+ - Administrator
6
+ - Scorekeeper
7
+ - Insulter
8
+ rejoin: true
9
+ channel: "#autumn"
10
+ server: irc.freenode.net
@@ -0,0 +1,20 @@
1
+ = Administrator: An Autumn Leaf
2
+
3
+ <b>Version 1.0 (Jul 8, 2008)</b>
4
+
5
+ Author:: Tim Morgan (mailto:riscfuture@gmail.com)
6
+ Copyright:: Copyright (c)2008 Tim Morgan
7
+ License:: Distributed under the same terms as Ruby.
8
+
9
+ This leaf allows the owner of the IRC bot to perform administrative commands on
10
+ the bot, such as quitting or reloading it. In order to protect such commands
11
+ from abuse, this bot uses the Authenticator module. The Authenticator method
12
+ that is used is specified by the +authentication+ option. For more information,
13
+ see the *Authentication* section of the README.
14
+
15
+ == Usage
16
+
17
+ !autumn:: Displays information about the version of Autumn that is running this
18
+ leaf (unprotected command).
19
+ !quit:: Terminates the stem on which the message was received.
20
+ !reload:: Reloads all source files of all leaves, and all their view files.
@@ -0,0 +1,67 @@
1
+ # Controller for the Administrator leaf.
2
+
3
+ class Controller < Autumn::Leaf
4
+
5
+ # Typing this command reloads all source code for all leaves and support
6
+ # files, allowing you to make "on-the-fly" changes without restarting the
7
+ # process. It does this by reloading the source files defining the classes.
8
+ #
9
+ # If you supply the configuration name of a leaf, only that leaf is reloaded.
10
+ #
11
+ # This command does not reload the YAML configuration files, only the source
12
+ # code.
13
+
14
+ def reload_command(stem, sender, reply_to, msg)
15
+ var :leaves => Hash.new
16
+ if msg then
17
+ if Foliater.instance.leaves.include?(msg) then
18
+ begin
19
+ Foliater.instance.hot_reload Foliater.instance.leaves[msg]
20
+ rescue
21
+ logger.error "Error when reloading #{msg}:"
22
+ logger.error $!
23
+ var(:leaves)[msg] = $!.to_s
24
+ else
25
+ var(:leaves)[msg] = false
26
+ end
27
+ logger.info "#{msg}: Reloaded"
28
+ else
29
+ var :not_found => msg
30
+ end
31
+ else
32
+ Foliater.instance.leaves.each do |name, leaf|
33
+ begin
34
+ Foliater.instance.hot_reload leaf
35
+ rescue
36
+ logger.error "Error when reloading #{name}:"
37
+ logger.error $!
38
+ var(:leaves)[name] = $!.to_s
39
+ else
40
+ var(:leaves)[name] = false
41
+ end
42
+ logger.info "#{name}: Reloaded"
43
+ end
44
+ end
45
+ end
46
+ ann :reload_command, :protected => true
47
+
48
+ # Typing this command will cause the Stem to exit.
49
+
50
+ def quit_command(stem, sender, reply_to, msg)
51
+ stem.quit
52
+ end
53
+ ann :quit_command, :protected => true
54
+
55
+ # Typing this command will display information about the version of Autumn
56
+ # that is running this leaf.
57
+
58
+ def autumn_command(stem, sender, reply_to, msg)
59
+ var :version => AUTUMN_VERSION
60
+ end
61
+
62
+ # Suppress the !commands command; don't want to publicize the administrative
63
+ # features.
64
+
65
+ def commands_command(stem, sender, reply_to, msg)
66
+ end
67
+ end