artaius 0.2.0

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.
@@ -0,0 +1,94 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe Artaius::Plugins::Identify do
4
+
5
+ Identify = Artaius::Plugins::Identify
6
+
7
+ it 'must include required modules' do
8
+ Identify.must_include Cinch::Plugin
9
+ end
10
+
11
+ it "must use correct plugin's name" do
12
+ Identify.plugin_name.must_equal 'identify'
13
+ end
14
+
15
+ it 'must have correct required options' do
16
+ Identify.required_options.must_equal [:username, :password]
17
+ end
18
+
19
+ it "must interact with QuakeNet's bot: Q" do
20
+ Identify::Q.must_equal 'Q@CServe.quakenet.org'
21
+ end
22
+
23
+ describe 'methods' do
24
+ it 'must ask Q for CHALLENGEAUTH via #send_challenge' do
25
+ skip("Write me")
26
+ end
27
+
28
+ it 'must authenticate bot via #challengeauth' do
29
+ skip("Write me")
30
+ end
31
+ end
32
+
33
+ describe 'listeners' do
34
+ it 'must have one listener' do
35
+ Identify.listeners.size.must_equal 1
36
+ end
37
+
38
+ it 'must listen to :connect event' do
39
+ Identify.listeners[0].event.must_equal :connect
40
+ end
41
+
42
+ it 'must use identify method to handle :connect event' do
43
+ Identify.listeners[0].method.must_equal :send_challenge
44
+ end
45
+ end
46
+
47
+ describe 'matchers' do
48
+ let(:matcher) { Identify.matchers[0] }
49
+
50
+ it 'must have one matcher' do
51
+ Identify.matchers.size.must_equal 1
52
+ end
53
+
54
+ it 'must react on NOTICE event' do
55
+ matcher.react_on.must_equal :notice
56
+ end
57
+
58
+ it 'must not use prefix' do
59
+ matcher.use_prefix.must_equal false
60
+ end
61
+
62
+ it 'must not use suffix' do
63
+ matcher.use_suffix.must_equal false
64
+ end
65
+
66
+ it 'must use challengeauth method to handle pattern matches' do
67
+ matcher.method.must_equal :challengeauth
68
+ end
69
+
70
+ describe 'pattern' do
71
+ let(:pattern) { Identify.matchers[0].pattern }
72
+
73
+ it 'must use correct pattern' do
74
+ pattern.must_equal /^CHALLENGE (.+?) (.+)$/
75
+ end
76
+
77
+ it 'must match the challengeauth code from Q' do
78
+ pattern.must_match "CHALLENGE a6de7f3e6a8daba5570abc81f4f56474 HMAC-MD5 HMAC-SHA-1 HMAC-SHA-256 LEGACY-MD5"
79
+ pattern.must_match "CHALLENGE a6de7f3e6a8daba5570abc81f4f56474 HMAC-MD5"
80
+
81
+ pattern.wont_match "CHALLENGE a6de7f3e6a8daba5570abc81f4f56474"
82
+ pattern.wont_match "CHALLENGE"
83
+ pattern.wont_match ""
84
+ pattern.wont_match "THE_CHALLENGE a6de7f3e6a8daba5570abc81f4f56474 HMAC-MD5"
85
+ pattern.wont_match "THE CHALLENGE a6de7f3e6a8daba5570abc81f4f56474 HMAC-MD5"
86
+ pattern.wont_match " CHALLENGE a6de7f3e6a8daba5570abc81f4f56474 HMAC-MD5"
87
+ pattern.wont_match "CHALLENGE a6de7f3e6a8daba5570abc81f4f56474HMAC-MD5"
88
+ pattern.wont_match "CHALLENGE a6de7f3e6a8daba5570abc81f4f56474HMAC-MD5"
89
+ pattern.wont_match "CHALLENGE HMAC-MD5"
90
+ end
91
+ end
92
+
93
+ end
94
+ end
@@ -0,0 +1,199 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe Artaius::Plugins::Mixer do
4
+ Mixer = Artaius::Plugins::Mixer
5
+
6
+ it 'must include required modules' do
7
+ Identify.must_include Cinch::Plugin
8
+ end
9
+
10
+ it "it must use correct plugin's name" do
11
+ Mixer.plugin_name.must_equal 'mixer'
12
+ end
13
+
14
+ it 'must have correct default limit' do
15
+ Mixer::DEFAULT_LIMIT.must_equal 10
16
+ end
17
+
18
+ it 'must react on channel' do
19
+ Mixer.react_on.must_equal :channel
20
+ end
21
+
22
+ describe 'game' do
23
+ let(:game) { Mixer::Game.new([], 10, Time.parse('2012-05-08 11:47:16 +0300')) }
24
+
25
+ it 'must have correct number of minimum slots to start the game' do
26
+ Mixer::MIN_SLOTS.must_equal 2
27
+ end
28
+
29
+ it 'must have correct delay, when game cannot start for a long time' do
30
+ Mixer::PENDING_DELAY.must_equal 300
31
+ end
32
+
33
+ it 'must have players attribute' do
34
+ game.players.wont_be_nil
35
+ end
36
+
37
+ it 'must have limit attribute' do
38
+ game.limit.must_equal 10
39
+ end
40
+
41
+ it 'must have time attribute' do
42
+ game.time.must_be_instance_of Time
43
+ end
44
+
45
+ end
46
+
47
+ describe 'matchers' do
48
+ let(:start_game) { Mixer.matchers.find { |m| m.method == :start_game } }
49
+ let(:add_player) { Mixer.matchers.find { |m| m.method == :add_player } }
50
+ let(:cancel) { Mixer.matchers.find { |m| m.method == :cancel } }
51
+ let(:roster) { Mixer.matchers.find { |m| m.method == :roster } }
52
+ let(:force_start) { Mixer.matchers.find { |m| m.method == :force_start } }
53
+ let(:slot_disp) { Mixer.matchers.find { |m| m.method == :slot_dispatcher } }
54
+ let(:slots) { Mixer.matchers.find { |m| m.method == :slots } }
55
+
56
+ it 'it must have correct number of matchers' do
57
+ Mixer.matchers.size.must_equal 7
58
+ end
59
+
60
+ describe 'start_game matcher' do
61
+ it 'must exist' do
62
+ start_game.wont_be_nil
63
+ end
64
+
65
+ it 'must match the pattern' do
66
+ start_game.pattern.must_match 'game'
67
+ start_game.pattern.must_match 'game 10'
68
+ start_game.pattern.must_match 'game 2'
69
+ start_game.pattern.must_match 'game 32'
70
+
71
+ start_game.pattern.wont_match 'game 1'
72
+ start_game.pattern.wont_match 'game 0'
73
+ start_game.pattern.wont_match 'game '
74
+ start_game.pattern.wont_match 'game 6'
75
+ start_game.pattern.wont_match 'game 200'
76
+ start_game.pattern.wont_match 'game 01'
77
+ start_game.pattern.wont_match 'game 09'
78
+ start_game.pattern.wont_match 'game 010'
79
+ end
80
+
81
+ it 'does not have suffix' do
82
+ start_game.suffix.must_be_nil
83
+ end
84
+ end
85
+
86
+ describe 'add_player matcher' do
87
+ it 'must exist' do
88
+ add_player.wont_be_nil
89
+ end
90
+
91
+ it 'must match the pattern' do
92
+ add_player.pattern.must_match 'play'
93
+
94
+ add_player.pattern.wont_match 'play '
95
+ end
96
+
97
+ it 'does not have suffix' do
98
+ start_game.suffix.must_be_nil
99
+ end
100
+ end
101
+
102
+ describe 'cancel matcher' do
103
+ it 'must exist' do
104
+ cancel.wont_be_nil
105
+ end
106
+
107
+ it 'must match the pattern' do
108
+ cancel.pattern.must_match 'cancel'
109
+
110
+ cancel.pattern.wont_match 'cancel '
111
+ end
112
+
113
+ it 'does not have suffix' do
114
+ cancel.suffix.must_be_nil
115
+ end
116
+ end
117
+
118
+ describe 'roster matcher' do
119
+ it 'must exist' do
120
+ roster.wont_be_nil
121
+ end
122
+
123
+ it 'must match the pattern' do
124
+ roster.pattern.must_match 'roster'
125
+
126
+ roster.pattern.wont_match 'roster '
127
+ end
128
+
129
+ it 'does not have suffix' do
130
+ roster.suffix.must_be_nil
131
+ end
132
+ end
133
+
134
+ describe 'force start matcher' do
135
+ it 'must exist' do
136
+ force_start.wont_be_nil
137
+ end
138
+
139
+ it 'must match the pattern' do
140
+ force_start.pattern.must_match 'start'
141
+
142
+ force_start.pattern.wont_match 'start '
143
+ end
144
+
145
+ it 'does not have suffix' do
146
+ force_start.suffix.must_be_nil
147
+ end
148
+ end
149
+
150
+ describe 'slot dispatcher matcher' do
151
+ it 'must exist' do
152
+ slot_disp.wont_be_nil
153
+ end
154
+
155
+ it 'must match the pattern' do
156
+ slot_disp.pattern.must_match 'slot+'
157
+ slot_disp.pattern.must_match 'slot-'
158
+ slot_disp.pattern.must_match 'slot+ 2'
159
+ slot_disp.pattern.must_match 'slot- 2'
160
+ slot_disp.pattern.must_match 'slot+ 16'
161
+ slot_disp.pattern.must_match 'slot- 16'
162
+
163
+ slot_disp.pattern.wont_match 'slot'
164
+ slot_disp.pattern.wont_match 'slot- '
165
+ slot_disp.pattern.wont_match 'slot+ '
166
+ slot_disp.pattern.wont_match 'slot- '
167
+ slot_disp.pattern.wont_match 'slot+ 1'
168
+ slot_disp.pattern.wont_match 'slot- 1'
169
+ slot_disp.pattern.wont_match 'slot+ 100'
170
+ slot_disp.pattern.wont_match 'slot- 100'
171
+ slot_disp.pattern.wont_match 'slot+ 5'
172
+ slot_disp.pattern.wont_match 'slot- 5'
173
+ slot_disp.pattern.wont_match 'slot+ 5 '
174
+ slot_disp.pattern.wont_match 'slot- 5 '
175
+ slot_disp.pattern.wont_match 'slot-+'
176
+ slot_disp.pattern.wont_match 'slot+-'
177
+ slot_disp.pattern.wont_match 'slot++'
178
+ slot_disp.pattern.wont_match 'slot--'
179
+ end
180
+
181
+ it 'does not have suffix' do
182
+ slot_disp.suffix.must_be_nil
183
+ end
184
+ end
185
+
186
+ describe 'slots matcher' do
187
+ it 'must exist' do
188
+ slots.wont_be_nil
189
+ end
190
+
191
+ it 'must match the pattern' do
192
+ slots.pattern.must_match 'slots'
193
+
194
+ slots.pattern.wont_match 'slots '
195
+ end
196
+ end
197
+
198
+ end
199
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ require 'fivemat/minitest/autorun'
2
+
3
+ require_relative '../lib/artaius'
4
+
5
+ # Force R18n to use English locale for testing.
6
+ Artaius.const_set("I18n", R18n.from_env('config/locales', :en))
7
+ Dir['lib/artaius/plugins/*.rb'].each { |plugin| load plugin }
@@ -0,0 +1,15 @@
1
+ namespace :db do
2
+
3
+ desc 'Run migrations'
4
+ task :migrate => :environment do
5
+ to = ENV['TO'].to_i
6
+ from = ENV['FROM'].to_i
7
+ Artaius::Database.migrate(to, from)
8
+ end
9
+
10
+ desc 'Rollback database to the previous version'
11
+ task :rollback => :environment do
12
+ Artaius::Database.rollback
13
+ end
14
+
15
+ end
@@ -0,0 +1,3 @@
1
+ task :environment do
2
+ require_relative File.join(File.dirname(__FILE__), '..', 'lib', 'artaius')
3
+ end
@@ -0,0 +1,6 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.test_files = FileList['spec/**/*_spec.rb']
5
+ t.verbose = true
6
+ end
metadata ADDED
@@ -0,0 +1,213 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: artaius
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kyrylo Silin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cinch
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: kag
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.0.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: r18n-desktop
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.14
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.14
62
+ - !ruby/object:Gem::Dependency
63
+ name: sequel
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 3.34.1
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.34.1
78
+ - !ruby/object:Gem::Dependency
79
+ name: sqlite3
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.3.6
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.6
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: minitest
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.12.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 2.12.1
126
+ - !ruby/object:Gem::Dependency
127
+ name: fivemat
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: 1.0.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: 1.0.0
142
+ description: ! " Artaius is an IRC (Internet Relay Chat) bot for KAG (King Arthur's
143
+ Gold)\n game. It cannot everything for the time being.\n"
144
+ email: kyrylosilin@gmail.com
145
+ executables: []
146
+ extensions: []
147
+ extra_rdoc_files:
148
+ - README.md
149
+ - LICENSE
150
+ files:
151
+ - .gitignore
152
+ - Gemfile
153
+ - LICENSE
154
+ - README.md
155
+ - Rakefile
156
+ - artaius.gemspec
157
+ - bin/artaius
158
+ - config/locales/en.yml
159
+ - config/locales/ru.yml
160
+ - config/plugins/.gitignore
161
+ - db/.gitignore
162
+ - db/migrations/001_create_players.rb
163
+ - lib/artaius.rb
164
+ - lib/artaius/bot.rb
165
+ - lib/artaius/database.rb
166
+ - lib/artaius/models/player.rb
167
+ - lib/artaius/plugins/archivarius.rb
168
+ - lib/artaius/plugins/identify.rb
169
+ - lib/artaius/plugins/mixer.rb
170
+ - lib/artaius/version.rb
171
+ - spec/lib/artaius/bot_spec.rb
172
+ - spec/lib/artaius/plugins/archivarius_spec.rb
173
+ - spec/lib/artaius/plugins/identify_spec.rb
174
+ - spec/lib/artaius/plugins/mixer_spec.rb
175
+ - spec/lib/artaius/version_spec.rb
176
+ - spec/spec_helper.rb
177
+ - tasks/db.rake
178
+ - tasks/environment.rake
179
+ - tasks/test.rake
180
+ homepage: https://github.com/kyrylo/artaius
181
+ licenses:
182
+ - zlib
183
+ post_install_message:
184
+ rdoc_options:
185
+ - --charset=UTF-8
186
+ require_paths:
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ~>
192
+ - !ruby/object:Gem::Version
193
+ version: '1.9'
194
+ required_rubygems_version: !ruby/object:Gem::Requirement
195
+ none: false
196
+ requirements:
197
+ - - ! '>='
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 1.8.23
203
+ signing_key:
204
+ specification_version: 3
205
+ summary: IRC bot serving King Arthur's Gold players.
206
+ test_files:
207
+ - spec/lib/artaius/bot_spec.rb
208
+ - spec/lib/artaius/plugins/archivarius_spec.rb
209
+ - spec/lib/artaius/plugins/identify_spec.rb
210
+ - spec/lib/artaius/plugins/mixer_spec.rb
211
+ - spec/lib/artaius/version_spec.rb
212
+ - spec/spec_helper.rb
213
+ has_rdoc: