messed 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/Gemfile +8 -0
  2. data/README.rdoc +22 -0
  3. data/Rakefile +76 -0
  4. data/VERSION +1 -0
  5. data/application_spec/Rakefile +12 -0
  6. data/application_spec/app/runner.rb +3 -0
  7. data/application_spec/bin/runner +18 -0
  8. data/application_spec/bin/status +36 -0
  9. data/application_spec/bin/web +29 -0
  10. data/application_spec/config/environment.rb +8 -0
  11. data/application_spec/config/environments/development.rb +0 -0
  12. data/application_spec/log/development.log +6 -0
  13. data/application_spec/spec/application_spec.rb +12 -0
  14. data/application_spec/spec/spec.opts +7 -0
  15. data/application_spec/spec/spec_helper.rb +42 -0
  16. data/bin/messed +9 -0
  17. data/lib/messed/booter.rb +114 -0
  18. data/lib/messed/configuration.rb +94 -0
  19. data/lib/messed/controller/helper.rb +8 -0
  20. data/lib/messed/controller/processing.rb +22 -0
  21. data/lib/messed/controller/respond.rb +48 -0
  22. data/lib/messed/controller.rb +17 -0
  23. data/lib/messed/em_runner.rb +50 -0
  24. data/lib/messed/interface/adapter/sms.rb +4 -0
  25. data/lib/messed/interface/adapter/twitter_consumer.rb +35 -0
  26. data/lib/messed/interface/adapter/twitter_search.rb +111 -0
  27. data/lib/messed/interface/adapter/twitter_sender.rb +44 -0
  28. data/lib/messed/interface/adapter/twitter_streaming.rb +50 -0
  29. data/lib/messed/interface/adapter.rb +68 -0
  30. data/lib/messed/interface/runner.rb +20 -0
  31. data/lib/messed/interface.rb +74 -0
  32. data/lib/messed/logger.rb +50 -0
  33. data/lib/messed/matcher.rb +50 -0
  34. data/lib/messed/message/twitter.rb +23 -0
  35. data/lib/messed/message.rb +35 -0
  36. data/lib/messed/queue/beanstalk.rb +56 -0
  37. data/lib/messed/queue.rb +17 -0
  38. data/lib/messed/session/memcache.rb +40 -0
  39. data/lib/messed/session.rb +7 -0
  40. data/lib/messed/tasks/console.rb +70 -0
  41. data/lib/messed/tasks/generation.rb +12 -0
  42. data/lib/messed/tasks/runner.rb +50 -0
  43. data/lib/messed/tasks/status.rb +37 -0
  44. data/lib/messed/tasks.rb +9 -0
  45. data/lib/messed/util/remote_status.rb +45 -0
  46. data/lib/messed.rb +235 -0
  47. data/patterns/messed/Pattern +24 -0
  48. data/patterns/messed/Rakefile +12 -0
  49. data/patterns/messed/app/runner.rb +5 -0
  50. data/patterns/messed/bin/console +3 -0
  51. data/patterns/messed/bin/runner +3 -0
  52. data/patterns/messed/bin/status +3 -0
  53. data/patterns/messed/bin/web +13 -0
  54. data/patterns/messed/config/environment.rb +15 -0
  55. data/patterns/messed/config/environments/development.rb +2 -0
  56. data/patterns/messed/config/environments/production.rb +0 -0
  57. data/patterns/messed/config/environments/test.rb +0 -0
  58. data/patterns/messed/spec/application_spec.rb +12 -0
  59. data/patterns/messed/spec/spec.opts +7 -0
  60. data/patterns/messed/spec/spec_helper.rb +44 -0
  61. data/spec/adapter/applications/twitter_search/app/application.rb +3 -0
  62. data/spec/adapter/applications/twitter_search/app/runner.rb +7 -0
  63. data/spec/adapter/applications/twitter_search/bin/incoming +89 -0
  64. data/spec/adapter/applications/twitter_search/bin/runner +21 -0
  65. data/spec/adapter/applications/twitter_search/bin/status +36 -0
  66. data/spec/adapter/applications/twitter_search/config/environment.rb +11 -0
  67. data/spec/adapter/applications/twitter_search/config/environments/development.rb +0 -0
  68. data/spec/adapter/applications/twitter_search/log/development.log +1006 -0
  69. data/spec/adapter/applications/twitter_sender/app/application.rb +0 -0
  70. data/spec/adapter/applications/twitter_sender/app/runner.rb +0 -0
  71. data/spec/adapter/applications/twitter_sender/bin/incoming +89 -0
  72. data/spec/adapter/applications/twitter_sender/bin/runner +21 -0
  73. data/spec/adapter/applications/twitter_sender/bin/status +36 -0
  74. data/spec/adapter/applications/twitter_sender/config/environment.rb +11 -0
  75. data/spec/adapter/applications/twitter_sender/config/environments/development.rb +0 -0
  76. data/spec/adapter/applications/twitter_sender/log/development.log +146 -0
  77. data/spec/adapter/http/direct_message +0 -0
  78. data/spec/adapter/http/twitter_search +20 -0
  79. data/spec/adapter/http/update +0 -0
  80. data/spec/adapter/twitter_search_spec.rb +36 -0
  81. data/spec/adapter/twitter_sender_spec.rb +64 -0
  82. data/spec/booter_spec.rb +7 -0
  83. data/spec/fixtures/booter/app/application.rb +3 -0
  84. data/spec/fixtures/booter/app/runner.rb +7 -0
  85. data/spec/fixtures/booter/bin/incoming +89 -0
  86. data/spec/fixtures/booter/bin/runner +21 -0
  87. data/spec/fixtures/booter/bin/status +36 -0
  88. data/spec/fixtures/booter/config/environment.rb +15 -0
  89. data/spec/fixtures/booter/config/environments/development.rb +0 -0
  90. data/spec/fixtures/booter/log/development.log +11 -0
  91. data/spec/message_spec.rb +52 -0
  92. data/spec/session_spec.rb +34 -0
  93. data/spec/spec.opts +7 -0
  94. data/spec/spec_helper.rb +8 -0
  95. data/test/app/runner.rb +5 -0
  96. data/test/config/environment.rb +15 -0
  97. data/test/config/environments/development.rb +2 -0
  98. data/test/config/environments/production.rb +0 -0
  99. data/test/config/environments/test.rb +0 -0
  100. data/test/spec/application_spec.rb +12 -0
  101. data/test/spec/spec_helper.rb +44 -0
  102. metadata +291 -0
@@ -0,0 +1,52 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe "A Messed application", 'messaging' do
4
+ before(:each) do
5
+ @app = Messed.new(:twitter)
6
+ @app.logger = LOGGER
7
+ @app.incoming = Messed::Queue::Beanstalk.new('incoming')
8
+ @app.outgoing = Messed::Queue::Beanstalk.new('outgoing')
9
+ @app.incoming.drain!
10
+ @app.outgoing.drain!
11
+ end
12
+
13
+ it "should pass a message in and back out" do
14
+ @app.match {
15
+ always do
16
+ say message
17
+ end
18
+ }
19
+
20
+ message = @app.message_class.new('my message')
21
+ @app.incoming << message
22
+ @app.start(false)
23
+ @app.outgoing.take{|m| m.body.should == message.body}
24
+ end
25
+
26
+ it "should pass a message in and back out as the reply field" do
27
+ @app.match {
28
+ always do
29
+ reply "thats a nice message!"
30
+ end
31
+ }
32
+
33
+ message = @app.message_class.new('my message')
34
+ @app.incoming << message
35
+ @app.start(false)
36
+ @app.outgoing.take{|m| m.body.should == 'thats a nice message!'; m.in_reply_to.body.should == message.body}
37
+ end
38
+
39
+ it "should pass a message in and back out as a private reply" do
40
+ @app.match {
41
+ always do
42
+ whisper "thats a nice message!"
43
+ end
44
+ }
45
+
46
+ message = @app.message_class.new('my message')
47
+ @app.incoming << message
48
+ @app.start(false)
49
+ @app.outgoing.take{|m| m.body.should == 'thats a nice message!'; m.in_reply_to.body.should == message.body; m.should be_private}
50
+ end
51
+
52
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe "A Messed application", 'sessions' do
4
+ before(:each) do
5
+ @app = Messed.new(:twitter)
6
+ @app.logger = LOGGER
7
+ @app.incoming = Messed::Queue::Beanstalk.new('incoming')
8
+ @app.outgoing = Messed::Queue::Beanstalk.new('outgoing')
9
+ @app.incoming.drain!
10
+ @app.outgoing.drain!
11
+ end
12
+
13
+ it "should pass a message in and back out" do
14
+ @app.match {
15
+ always do
16
+ session[:sent_count] ||= 0
17
+ session[:sent_count] += 1
18
+ say "i got #{session[:sent_count]} messages"
19
+ session.clear if session[:sent_count] >= 2
20
+ end
21
+ }
22
+
23
+ message = @app.message_class.new('my message')
24
+ message.from = 'josh'
25
+ message.from_user_id = 1234
26
+ @app.incoming << message
27
+ @app.start(false)
28
+ @app.outgoing.take{|m| m.body.should == "i got 1 messages"}
29
+ @app.incoming << message
30
+ @app.start(false)
31
+ @app.outgoing.take{|m| m.body.should == "i got 2 messages"}
32
+ end
33
+
34
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,7 @@
1
+ --colour
2
+ --format
3
+ specdoc
4
+ --loadby
5
+ mtime
6
+ --reverse
7
+ --backtrace
@@ -0,0 +1,8 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
+
3
+ require 'logger'
4
+
5
+ LOGGER = Logger.new('test.log')
6
+
7
+ require 'messed'
8
+
@@ -0,0 +1,5 @@
1
+ # define your mappings here
2
+
3
+ #with 'hey you' do
4
+ # say 'hey hey'
5
+ #end
@@ -0,0 +1,15 @@
1
+ queues.incoming.host = '127.0.0.1'
2
+ queues.incoming.port = 11300
3
+ queues.incoming.tube = 'incoming-tube'
4
+
5
+ queues.outgoing.host = '127.0.0.1'
6
+ queues.outgoing.port = 11300
7
+ queues.outgoing.tube = 'outgoing-tube'
8
+
9
+ # interfaces.search.adapter = :twitter_search
10
+ # interfaces.search.options[:fetch] = {:query => {'q' => 'love'}, :host => 'search.twitter.com', :path => 'search.json'}
11
+ # interfaces.search.options[:interval] = 30
12
+
13
+ # interfaces.twitter_sender.adapter = :twitter_sender
14
+ # interfaces.twitter_sender.options[:username] = 'username'
15
+ # interfaces.twitter_sender.options[:password] = 'password'
@@ -0,0 +1,2 @@
1
+ self.logger = ::Logger.new(STDOUT)
2
+ self.log_level = :debug
File without changes
File without changes
@@ -0,0 +1,12 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe "test" do
4
+
5
+ include MessedSpecHelper
6
+
7
+ it "should have a test" do
8
+ process('this is my message')
9
+ outgoing_messages.size.should == 1
10
+ outgoing_messages.first.body.should == "well, that was fun"
11
+ end
12
+ end
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ begin
3
+ require 'messed'
4
+ rescue LoadError
5
+ if ENV['MESSED_HOME']
6
+ require File.join(ENV['MESSED_HOME'], 'lib', 'messed')
7
+ else
8
+ raise("no messed!")
9
+ end
10
+ end
11
+
12
+ class MessedSpecHolder
13
+
14
+ attr_accessor :booter, :outgoing_messages
15
+
16
+ def initialize
17
+ @booter = Messed::Booter.new(File.join(File.dirname(__FILE__), '..'))
18
+ end
19
+
20
+ def application
21
+ @booter.application
22
+ end
23
+
24
+ def process(message)
25
+ @outgoing_messages = application.process(application.message_class.new(message))
26
+ end
27
+
28
+ end
29
+
30
+
31
+
32
+ module MessedSpecHelper
33
+
34
+ Holder = MessedSpecHolder.new
35
+
36
+ def process(message)
37
+ Holder.process(message)
38
+ end
39
+
40
+ def outgoing_messages
41
+ Holder.outgoing_messages
42
+ end
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,291 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: messed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joshua Hull
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-22 00:00:00 -05:00
13
+ default_executable: messed
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: eventmachine
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: em-http-request
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.6
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: em-beanstalk
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.0.6
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: hashify
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.2
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hwia
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.0.2
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: twitter-stream
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 0.1.3
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: activesupport
77
+ type: :runtime
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ - !ruby/object:Gem::Dependency
86
+ name: dressmaker
87
+ type: :runtime
88
+ version_requirement:
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: 0.0.3
94
+ version:
95
+ - !ruby/object:Gem::Dependency
96
+ name: beanstalk-client
97
+ type: :runtime
98
+ version_requirement:
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: "0"
104
+ version:
105
+ - !ruby/object:Gem::Dependency
106
+ name: rspec
107
+ type: :runtime
108
+ version_requirement:
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
115
+ - !ruby/object:Gem::Dependency
116
+ name: json
117
+ type: :runtime
118
+ version_requirement:
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ version:
125
+ - !ruby/object:Gem::Dependency
126
+ name: thor
127
+ type: :runtime
128
+ version_requirement:
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ version:
135
+ description: A framework for short message paradigms
136
+ email: joshbuddy@gmail.com
137
+ executables:
138
+ - messed
139
+ extensions: []
140
+
141
+ extra_rdoc_files:
142
+ - README.rdoc
143
+ files:
144
+ - Gemfile
145
+ - README.rdoc
146
+ - Rakefile
147
+ - VERSION
148
+ - application_spec/Rakefile
149
+ - application_spec/app/runner.rb
150
+ - application_spec/bin/runner
151
+ - application_spec/bin/status
152
+ - application_spec/bin/web
153
+ - application_spec/config/environment.rb
154
+ - application_spec/config/environments/development.rb
155
+ - application_spec/log/development.log
156
+ - application_spec/spec/application_spec.rb
157
+ - application_spec/spec/spec.opts
158
+ - application_spec/spec/spec_helper.rb
159
+ - bin/messed
160
+ - lib/messed.rb
161
+ - lib/messed/booter.rb
162
+ - lib/messed/configuration.rb
163
+ - lib/messed/controller.rb
164
+ - lib/messed/controller/helper.rb
165
+ - lib/messed/controller/processing.rb
166
+ - lib/messed/controller/respond.rb
167
+ - lib/messed/em_runner.rb
168
+ - lib/messed/interface.rb
169
+ - lib/messed/interface/adapter.rb
170
+ - lib/messed/interface/adapter/sms.rb
171
+ - lib/messed/interface/adapter/twitter_consumer.rb
172
+ - lib/messed/interface/adapter/twitter_search.rb
173
+ - lib/messed/interface/adapter/twitter_sender.rb
174
+ - lib/messed/interface/adapter/twitter_streaming.rb
175
+ - lib/messed/interface/runner.rb
176
+ - lib/messed/logger.rb
177
+ - lib/messed/matcher.rb
178
+ - lib/messed/message.rb
179
+ - lib/messed/message/twitter.rb
180
+ - lib/messed/queue.rb
181
+ - lib/messed/queue/beanstalk.rb
182
+ - lib/messed/session.rb
183
+ - lib/messed/session/memcache.rb
184
+ - lib/messed/tasks.rb
185
+ - lib/messed/tasks/console.rb
186
+ - lib/messed/tasks/generation.rb
187
+ - lib/messed/tasks/runner.rb
188
+ - lib/messed/tasks/status.rb
189
+ - lib/messed/util/remote_status.rb
190
+ - patterns/messed/Pattern
191
+ - patterns/messed/Rakefile
192
+ - patterns/messed/app/runner.rb
193
+ - patterns/messed/bin/console
194
+ - patterns/messed/bin/runner
195
+ - patterns/messed/bin/status
196
+ - patterns/messed/bin/web
197
+ - patterns/messed/config/environment.rb
198
+ - patterns/messed/config/environments/development.rb
199
+ - patterns/messed/config/environments/production.rb
200
+ - patterns/messed/config/environments/test.rb
201
+ - patterns/messed/spec/application_spec.rb
202
+ - patterns/messed/spec/spec.opts
203
+ - patterns/messed/spec/spec_helper.rb
204
+ - spec/adapter/applications/twitter_search/app/application.rb
205
+ - spec/adapter/applications/twitter_search/app/runner.rb
206
+ - spec/adapter/applications/twitter_search/bin/incoming
207
+ - spec/adapter/applications/twitter_search/bin/runner
208
+ - spec/adapter/applications/twitter_search/bin/status
209
+ - spec/adapter/applications/twitter_search/config/environment.rb
210
+ - spec/adapter/applications/twitter_search/config/environments/development.rb
211
+ - spec/adapter/applications/twitter_search/log/development.log
212
+ - spec/adapter/applications/twitter_sender/app/application.rb
213
+ - spec/adapter/applications/twitter_sender/app/runner.rb
214
+ - spec/adapter/applications/twitter_sender/bin/incoming
215
+ - spec/adapter/applications/twitter_sender/bin/runner
216
+ - spec/adapter/applications/twitter_sender/bin/status
217
+ - spec/adapter/applications/twitter_sender/config/environment.rb
218
+ - spec/adapter/applications/twitter_sender/config/environments/development.rb
219
+ - spec/adapter/applications/twitter_sender/log/development.log
220
+ - spec/adapter/http/direct_message
221
+ - spec/adapter/http/twitter_search
222
+ - spec/adapter/http/update
223
+ - spec/adapter/twitter_search_spec.rb
224
+ - spec/adapter/twitter_sender_spec.rb
225
+ - spec/booter_spec.rb
226
+ - spec/fixtures/booter/app/application.rb
227
+ - spec/fixtures/booter/app/runner.rb
228
+ - spec/fixtures/booter/bin/incoming
229
+ - spec/fixtures/booter/bin/runner
230
+ - spec/fixtures/booter/bin/status
231
+ - spec/fixtures/booter/config/environment.rb
232
+ - spec/fixtures/booter/config/environments/development.rb
233
+ - spec/fixtures/booter/log/development.log
234
+ - spec/message_spec.rb
235
+ - spec/session_spec.rb
236
+ - spec/spec.opts
237
+ - spec/spec_helper.rb
238
+ has_rdoc: true
239
+ homepage: http://github.com/joshbuddy/messed
240
+ licenses: []
241
+
242
+ post_install_message:
243
+ rdoc_options:
244
+ - --charset=UTF-8
245
+ require_paths:
246
+ - lib
247
+ required_ruby_version: !ruby/object:Gem::Requirement
248
+ requirements:
249
+ - - ">="
250
+ - !ruby/object:Gem::Version
251
+ version: "0"
252
+ version:
253
+ required_rubygems_version: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: "0"
258
+ version:
259
+ requirements: []
260
+
261
+ rubyforge_project:
262
+ rubygems_version: 1.3.5
263
+ signing_key:
264
+ specification_version: 3
265
+ summary: A framework for short message paradigms
266
+ test_files:
267
+ - spec/adapter/applications/twitter_search/app/application.rb
268
+ - spec/adapter/applications/twitter_search/app/runner.rb
269
+ - spec/adapter/applications/twitter_search/config/environment.rb
270
+ - spec/adapter/applications/twitter_search/config/environments/development.rb
271
+ - spec/adapter/applications/twitter_sender/app/application.rb
272
+ - spec/adapter/applications/twitter_sender/app/runner.rb
273
+ - spec/adapter/applications/twitter_sender/config/environment.rb
274
+ - spec/adapter/applications/twitter_sender/config/environments/development.rb
275
+ - spec/adapter/twitter_search_spec.rb
276
+ - spec/adapter/twitter_sender_spec.rb
277
+ - spec/booter_spec.rb
278
+ - spec/fixtures/booter/app/application.rb
279
+ - spec/fixtures/booter/app/runner.rb
280
+ - spec/fixtures/booter/config/environment.rb
281
+ - spec/fixtures/booter/config/environments/development.rb
282
+ - spec/message_spec.rb
283
+ - spec/session_spec.rb
284
+ - spec/spec_helper.rb
285
+ - test/app/runner.rb
286
+ - test/config/environment.rb
287
+ - test/config/environments/development.rb
288
+ - test/config/environments/production.rb
289
+ - test/config/environments/test.rb
290
+ - test/spec/application_spec.rb
291
+ - test/spec/spec_helper.rb