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,89 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'messed'
6
+ rescue LoadError
7
+ if ENV['MESSED_HOME']
8
+ require File.join(ENV['MESSED_HOME'], 'lib', 'messed')
9
+ else
10
+ raise("no messed!")
11
+ end
12
+ end
13
+
14
+ require 'thor'
15
+
16
+ class IncomingRunnerTask < Thor
17
+
18
+ method_options :detach => false
19
+ method_options :environment => "development"
20
+ desc "start [NAME]", "start an incoming instance"
21
+ def start(name = nil)
22
+ application = Messed::Booter.new(File.expand_path(File.join(File.dirname(__FILE__), '..')), options.environment)
23
+ incoming = if name.nil? and application.incoming_map.size == 1
24
+ application.incoming_map.values.first
25
+ elsif application.incoming_map.key?(name)
26
+ application.incoming_map[name]
27
+ else
28
+ raise(name ? "unable to find incoming with name #{name}" : "You have no incoming setup.")
29
+ end
30
+
31
+ Messed::Interface::Runner.new(incoming).start
32
+ end
33
+
34
+ end
35
+
36
+ IncomingRunnerTask.start
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'messed'
6
+ rescue LoadError
7
+ if ENV['MESSED_HOME']
8
+ require File.join(ENV['MESSED_HOME'], 'lib', 'messed')
9
+ else
10
+ raise("no messed!")
11
+ end
12
+ end
13
+
14
+ require 'thor'
15
+
16
+ $root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
17
+
18
+ Messed::Tasks::Runner.start
19
+
20
+ RunnerTask.start
21
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'messed'
6
+ rescue LoadError
7
+ if ENV['MESSED_HOME']
8
+ require File.join(ENV['MESSED_HOME'], 'lib', 'messed')
9
+ else
10
+ raise("no messed!")
11
+ end
12
+ end
13
+
14
+ require 'thor'
15
+
16
+ class IncomingRunnerTask < Thor
17
+
18
+ method_options :detach => false
19
+ method_options :environment => "development"
20
+ desc "start [NAME]", "start an incoming instance"
21
+ def start(name = nil)
22
+ application = Messed::Booter.new(File.expand_path(File.join(File.dirname(__FILE__), '..')), options.environment)
23
+ incoming = if name.nil? and application.incoming_map.size == 1
24
+ application.incoming_map.values.first
25
+ elsif application.incoming_map.key?(name)
26
+ application.incoming_map[name]
27
+ else
28
+ raise(name ? "unable to find incoming with name #{name}" : "You have no incoming setup.")
29
+ end
30
+
31
+ IncomingRunner.new(incoming)
32
+ end
33
+
34
+ end
35
+
36
+ IncomingRunnerTask.start
@@ -0,0 +1,11 @@
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.twitter_sender.adapter = :twitter_sender
10
+ interfaces.twitter_sender.options[:username] = 'josh'
11
+ interfaces.twitter_sender.options[:password] = 'josh'
@@ -0,0 +1,146 @@
1
+ Loading interface `twitter_sender'
2
+ Putting response say onto outgoing queue
3
+ Putting response reply onto outgoing queue
4
+ Putting response whisper onto outgoing queue
5
+ Loading interface `twitter_sender'
6
+ Putting response say onto outgoing queue
7
+ Putting response reply onto outgoing queue
8
+ Putting response whisper onto outgoing queue
9
+ Loading interface `twitter_sender'
10
+ Loading interface `twitter_sender'
11
+ Loading interface `twitter_sender'
12
+ Loading interface `twitter_sender'
13
+ Loading interface `twitter_sender'
14
+ Putting response say onto outgoing queue
15
+ Putting response reply onto outgoing queue
16
+ Putting response whisper onto outgoing queue
17
+ Loading interface `twitter_sender'
18
+ Putting response say onto outgoing queue
19
+ Putting response reply onto outgoing queue
20
+ Putting response whisper onto outgoing queue
21
+ Loading interface `twitter_sender'
22
+ Putting response say onto outgoing queue
23
+ Putting response reply onto outgoing queue
24
+ Putting response whisper onto outgoing queue
25
+ Loading interface `twitter_sender'
26
+ Putting response say onto outgoing queue
27
+ Putting response reply onto outgoing queue
28
+ Putting response whisper onto outgoing queue
29
+ Loading interface `twitter_sender'
30
+ Putting response say onto outgoing queue
31
+ Putting response reply onto outgoing queue
32
+ Putting response whisper onto outgoing queue
33
+ Loading interface `twitter_sender'
34
+ Loading interface `twitter_sender'
35
+ Loading interface `twitter_sender'
36
+ Putting response say onto outgoing queue
37
+ Putting response reply onto outgoing queue
38
+ Putting response whisper onto outgoing queue
39
+ Loading interface `twitter_sender'
40
+ Loading interface `twitter_sender'
41
+ Putting response say onto outgoing queue
42
+ Putting response reply onto outgoing queue
43
+ Putting response whisper onto outgoing queue
44
+ Loading interface `twitter_sender'
45
+ Putting response say onto outgoing queue
46
+ Putting response reply onto outgoing queue
47
+ Putting response whisper onto outgoing queue
48
+ Loading interface `twitter_sender'
49
+ Putting response say onto outgoing queue
50
+ Putting response reply onto outgoing queue
51
+ Putting response whisper onto outgoing queue
52
+ Loading interface `twitter_sender'
53
+ Putting response say onto outgoing queue
54
+ Putting response reply onto outgoing queue
55
+ Putting response whisper onto outgoing queue
56
+ Loading interface `twitter_sender'
57
+ Putting response say onto outgoing queue
58
+ Putting response reply onto outgoing queue
59
+ Putting response whisper onto outgoing queue
60
+ Loading interface `twitter_sender'
61
+ Putting response say onto outgoing queue
62
+ Putting response reply onto outgoing queue
63
+ Putting response whisper onto outgoing queue
64
+ Loading interface `twitter_sender'
65
+ Putting response say onto outgoing queue
66
+ Putting response reply onto outgoing queue
67
+ Putting response whisper onto outgoing queue
68
+ Loading interface `twitter_sender'
69
+ Putting response say onto outgoing queue
70
+ Putting response reply onto outgoing queue
71
+ Putting response whisper onto outgoing queue
72
+ Loading interface `twitter_sender'
73
+ Putting response say onto outgoing queue
74
+ Putting response reply onto outgoing queue
75
+ Putting response whisper onto outgoing queue
76
+ Loading interface `twitter_sender'
77
+ Putting response say onto outgoing queue
78
+ Putting response reply onto outgoing queue
79
+ Putting response whisper onto outgoing queue
80
+ Loading interface `twitter_sender'
81
+ Loading interface `twitter_sender'
82
+ Loading interface `twitter_sender'
83
+ Loading interface `twitter_sender'
84
+ Processing `say'
85
+ Putting response say onto outgoing queue
86
+ No response.
87
+ Processing `reply'
88
+ Putting response reply onto outgoing queue
89
+ No response.
90
+ Processing `whisper'
91
+ Putting response whisper onto outgoing queue
92
+ No response.
93
+ Loading interface `twitter_sender'
94
+ Processing `say'
95
+ Putting response say onto outgoing queue
96
+ No response.
97
+ Processing `reply'
98
+ Putting response reply onto outgoing queue
99
+ No response.
100
+ Processing `whisper'
101
+ Putting response whisper onto outgoing queue
102
+ No response.
103
+ Loading interface `twitter_sender'
104
+ Processing `say'
105
+ Putting response say onto outgoing queue
106
+ No response.
107
+ Processing `reply'
108
+ Putting response reply onto outgoing queue
109
+ No response.
110
+ Processing `whisper'
111
+ Putting response whisper onto outgoing queue
112
+ No response.
113
+ Loading interface `twitter_sender'
114
+ Processing `say'
115
+ Putting response say onto outgoing queue
116
+ No response.
117
+ Processing `reply'
118
+ Putting response reply onto outgoing queue
119
+ No response.
120
+ Processing `whisper'
121
+ Putting response whisper onto outgoing queue
122
+ No response.
123
+ Setting up interface: :twitter_sender
124
+ Status handler for Messed started on 0.0.0.0:19191
125
+ Processing `say'
126
+ Putting response say onto outgoing queue
127
+ No response.
128
+ Processing `reply'
129
+ Putting response reply onto outgoing queue
130
+ No response.
131
+ Processing `whisper'
132
+ Putting response whisper onto outgoing queue
133
+ No response.
134
+ Status handler for Messed::Interface started on 0.0.0.0:11190
135
+ Setting up interface: :twitter_sender
136
+ Status handler for Messed started on 0.0.0.0:19191
137
+ Processing `say'
138
+ Putting response say onto outgoing queue
139
+ No response.
140
+ Processing `reply'
141
+ Putting response reply onto outgoing queue
142
+ No response.
143
+ Processing `whisper'
144
+ Putting response whisper onto outgoing queue
145
+ No response.
146
+ Status handler for Messed::Interface started on 0.0.0.0:11190
File without changes
@@ -0,0 +1,20 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Mon, 09 Nov 2009 14:37:07 GMT
3
+ Server: hi
4
+ Status: 200 OK
5
+ X-Served-From: sjc1c195
6
+ Content-Type: application/json; charset=utf-8
7
+ X-Served-By: sjc1h009.twitter.com
8
+ X-Timeline-Cache-Hit: Hit
9
+ Cache-Control: max-age=15, must-revalidate, max-age=300
10
+ Expires: Mon, 09 Nov 2009 14:42:07 GMT
11
+ Content-Length: 7026
12
+ Vary: Accept-Encoding
13
+ X-Varnish: 2124311127
14
+ Age: 0
15
+ Via: 1.1 varnish
16
+ X-Cache-Svr: sjc1h009.twitter.com
17
+ X-Cache: MISS
18
+ Connection: close
19
+
20
+ {"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/295456431/smalllogog_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:41 +0000","from_user":"redpandajewelry","to_user_id":null,"text":"I love niobium colors http://flic.kr/p/7ept6w","id":5559802757,"from_user_id":41981,"geo":null,"iso_language_code":"it","source":"&lt;a href=&quot;http://flickr.com/services/twitter/&quot; rel=&quot;nofollow&quot;&gt;Flickr&lt;/a&gt;"},{"profile_image_url":"http://a1.twimg.com/profile_images/466063174/twitter_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:41 +0000","from_user":"MeganNBaker","to_user_id":null,"text":"apple cinnamon oatmeal from trader joes = love. they should really put one in rochester before i move home.","id":5559802708,"from_user_id":6115983,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/502272605/headshot_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:41 +0000","from_user":"louiealdip","to_user_id":7245782,"text":"@erikamodina love that book! :) she said okay! :)) I HAVE A BLACK CARDIGAN ALREADY! :)","id":5559802663,"from_user_id":9782054,"to_user":"erikamodina","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/424179347/002_2__0_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:40 +0000","from_user":"hava35","to_user_id":71282164,"text":"@7Jaguar Hi, good morning, how are you? love you...","id":5559802299,"from_user_id":60872971,"to_user":"7JAGUAR","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a1.twimg.com/profile_images/444858244/n1250311767_30074763_1017_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:40 +0000","from_user":"ampuniakudj","to_user_id":null,"text":"i love you girl","id":5559802278,"from_user_id":27890452,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/509666999/IMG_2091_normal.JPG","created_at":"Mon, 09 Nov 2009 14:36:40 +0000","from_user":"tiffanylovebug","to_user_id":8994366,"text":"@justinbieber ahh Justin come to Dallas, Texas! Please and thankyouuu i love you&lt;3 wish me luck with my physco english teacher:P","id":5559802258,"from_user_id":10779502,"to_user":"justinbieber","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://help.twitter.com/index.php?pg=kb.page&amp;id=75&quot; rel=&quot;nofollow&quot;&gt;txt&lt;/a&gt;"},{"profile_image_url":"http://a1.twimg.com/profile_images/220424034/0011__normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:39 +0000","from_user":"djCatscan","to_user_id":null,"text":"Damn i love my Culture Vulture.","id":5559802212,"from_user_id":17965922,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/506087969/IMG00033-20090904-0026_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:39 +0000","from_user":"Flee_Dee","to_user_id":null,"text":"RT @iAlyssafaye: #musicmondays lloyd feat lil. Wayne (YOU) I love it!(Throwbaq my shiit tho=] )","id":5559802197,"from_user_id":76032217,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://ubertwitter.com&quot; rel=&quot;nofollow&quot;&gt;UberTwitter&lt;/a&gt;"},{"profile_image_url":"http://a1.twimg.com/profile_images/512625550/Selena07_normal.png","created_at":"Mon, 09 Nov 2009 14:36:39 +0000","from_user":"Selena_Jonas95","to_user_id":70146460,"text":"@Jonas_BieberFan Ohhh... no I never hated Selena But I didnmt like her that much but Now I love her and so does all of my friends! hehe!!","id":5559802137,"from_user_id":52367015,"to_user":"Jonas_BieberFan","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a1.twimg.com/profile_images/514275970/Foto-0047_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:39 +0000","from_user":"najlalove","to_user_id":8994366,"text":"@justinbieber good moriningjustin cann u plzz follws myy soon plzz i love u \u2665","id":5559802115,"from_user_id":19645706,"to_user":"justinbieber","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a1.twimg.com/profile_images/407761428/Rachellebw8_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:39 +0000","from_user":"RachelleLuvsMo","to_user_id":11614634,"text":"@thelittleidiot --*you* my darling love. I Love *You* With All My Heart,Your Eternal Love Rachelle LaDelle' xxxxoooo @&gt;--&gt;-- I miss *you*.xo","id":5559802030,"from_user_id":54505816,"to_user":"thelittleidiot","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/459061357/CIMG3047_normal.JPG","created_at":"Mon, 09 Nov 2009 14:36:39 +0000","from_user":"saescamilla15","to_user_id":13614872,"text":"@Destuhneee haha that's why you love me :D","id":5559801998,"from_user_id":13615584,"to_user":"Destuhneee","geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://echofon.com/&quot; rel=&quot;nofollow&quot;&gt;Echofon&lt;/a&gt;"},{"profile_image_url":"http://a3.twimg.com/profile_images/207793583/l_3704e355ca6c4f8eb4fbbdff0b2d75ac_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:38 +0000","from_user":"joshjohnson80","to_user_id":null,"text":"THANK YOU to all my friends who made this weekend SPECIAL! Love you all SO MUCH!!!!","id":5559801857,"from_user_id":10477193,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://www.myspace.com/sync&quot; rel=&quot;nofollow&quot;&gt;MySpace&lt;/a&gt;"},{"profile_image_url":"http://a1.twimg.com/profile_images/511475780/7723_164782524847_620469847_3666553_759475_n_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:38 +0000","from_user":"MissZaraLouise","to_user_id":null,"text":"I swear ppl love to tlkbwt me my ears just dnt stop burning!! Wow!!","id":5559801736,"from_user_id":64982975,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"},{"profile_image_url":"http://a1.twimg.com/profile_images/451617040/chairandchin_bw_normal.jpg","created_at":"Mon, 09 Nov 2009 14:36:38 +0000","from_user":"jamesglave","to_user_id":null,"text":"I love sending dinner guests home with a giant bucket of compost.","id":5559801732,"from_user_id":90034,"geo":null,"iso_language_code":"en","source":"&lt;a href=&quot;http://twitter.com/&quot;&gt;web&lt;/a&gt;"}],"max_id":5559802757,"since_id":0,"refresh_url":"?since_id=5559802757&q=love","next_page":"?page=2&max_id=5559802757&q=love","results_per_page":15,"page":1,"completed_in":0.025489,"query":"love"}
File without changes
@@ -0,0 +1,36 @@
1
+ require 'spec/spec_helper'
2
+ require 'em-http/mock'
3
+ require 'rack'
4
+
5
+ describe "A Messed application", 'twitter searching' do
6
+
7
+ before(:all) do
8
+ EventMachine::HttpRequest.register_file("http://search.twitter.com:80/search.json?q=love", :get, File.join(File.dirname(__FILE__), 'http', 'twitter_search'))
9
+ EventMachine::HttpRequest.pass_through_requests = false
10
+ end
11
+
12
+ it "should take a twitter search and process them" do
13
+ Messed::Booter.new(File.join(File.dirname(__FILE__), 'applications', 'twitter_search')) do |booter|
14
+ booter.application.incoming.drain!
15
+ booter.application.outgoing.drain!
16
+
17
+ booter.application.match {
18
+ always do
19
+ say message
20
+ end
21
+ }
22
+
23
+ booter.interface_for(:search).start
24
+ EM.add_timer(1) do
25
+ booter.application.incoming.jobs_available.should == 15
26
+ booter.application.start
27
+ EM.add_timer(1) do
28
+ booter.application.outgoing.jobs_available.should == 15
29
+ EM.stop_event_loop
30
+ end
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec/spec_helper'
2
+ require 'em-http/mock'
3
+ require 'rack'
4
+
5
+ EventMachine::HttpRequest = EventMachine::MockHttpRequest
6
+
7
+ describe "A Messed application", 'twitter sending' do
8
+ before(:all) do
9
+ EventMachine::HttpRequest.register_file("http://twitter.com:80/direct_messages/new.json", :post, File.join(File.dirname(__FILE__), 'http', 'direct_message'))
10
+ EventMachine::HttpRequest.register_file("http://twitter.com:80/statuses/update.json", :post, File.join(File.dirname(__FILE__), 'http', 'update'))
11
+
12
+ EventMachine::HttpRequest.pass_through_requests = false
13
+ end
14
+
15
+ before(:each) do
16
+ EventMachine::HttpRequest.reset_counts!
17
+ end
18
+
19
+ it "should take messages off the outgoing queue and dispatch them to twitter" do
20
+ Messed::Booter.new(File.join(File.dirname(__FILE__), 'applications', 'twitter_sender')) do |booter|
21
+ booter.application.incoming.drain!
22
+ booter.application.outgoing.drain!
23
+ booter.application.incoming << Messed::Message::Twitter.new {|m| m.body = 'say' }
24
+ booter.application.incoming << Messed::Message::Twitter.new {|m| m.body = 'reply'; m.from = 'josh' }
25
+ booter.application.incoming << Messed::Message::Twitter.new {|m| m.body = 'whisper'; m.from = 'josh' }
26
+
27
+ booter.application.match {
28
+ with 'say' do
29
+ say message
30
+ end
31
+
32
+ with 'reply' do
33
+ reply message
34
+ end
35
+
36
+ with 'whisper' do
37
+ whisper message
38
+ end
39
+ }
40
+
41
+ booter.application.start
42
+ EM.add_timer(1) do
43
+ booter.interface_for(:twitter_sender).start
44
+ EM.add_timer(1) do
45
+ booter.application.outgoing.jobs_available.should == 0
46
+ EventMachine::HttpRequest.count("http://twitter.com:80/direct_messages/new.json", "POST").should == 1
47
+ EventMachine::HttpRequest.count("http://twitter.com:80/statuses/update.json", "POST").should == 2
48
+ EM.stop_event_loop
49
+ end
50
+ end
51
+
52
+
53
+ #booter.application.start(false)
54
+ #p booter.interface_for('twitter_sender')
55
+ #
56
+ #
57
+ #booter.application.outgoing.jobs_available.should == 0
58
+ #EventMachine::HttpRequest.count("http://twitter.com:80/direct_messages/new.json", "POST").should == 1
59
+ #EventMachine::HttpRequest.count("http://twitter.com:80/statuses/update.json", "POST").should == 2
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Messed::Booter do
4
+ it "should list all the possible interfaces" do
5
+ Messed::Booter.possible_interfaces(File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'booter'))).should =~ [:search, :twitter_sender]
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ with 'hey you' do
2
+ say 'hey hey'
3
+ end
@@ -0,0 +1,7 @@
1
+ with 'hey you' do
2
+ say 'hey hey'
3
+ end
4
+
5
+ otherwise do
6
+ say message
7
+ end
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'messed'
6
+ rescue LoadError
7
+ if ENV['MESSED_HOME']
8
+ require File.join(ENV['MESSED_HOME'], 'lib', 'messed')
9
+ else
10
+ raise("no messed!")
11
+ end
12
+ end
13
+
14
+ require 'thor'
15
+
16
+ class IncomingRunnerTask < Thor
17
+
18
+ method_options :detach => false
19
+ method_options :environment => "development"
20
+ desc "start [NAME]", "start an incoming instance"
21
+ def start(name = nil)
22
+ application = Messed::Booter.new(File.expand_path(File.join(File.dirname(__FILE__), '..')), options.environment)
23
+ incoming = if name.nil? and application.incoming_map.size == 1
24
+ application.incoming_map.values.first
25
+ elsif application.incoming_map.key?(name)
26
+ application.incoming_map[name]
27
+ else
28
+ raise(name ? "unable to find incoming with name #{name}" : "You have no incoming setup.")
29
+ end
30
+
31
+ Messed::Interface::Runner.new(incoming).start
32
+ end
33
+
34
+ end
35
+
36
+ IncomingRunnerTask.start
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'messed'
6
+ rescue LoadError
7
+ if ENV['MESSED_HOME']
8
+ require File.join(ENV['MESSED_HOME'], 'lib', 'messed')
9
+ else
10
+ raise("no messed!")
11
+ end
12
+ end
13
+
14
+ require 'thor'
15
+
16
+ $root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
17
+
18
+ Messed::Tasks::Runner.start
19
+
20
+ RunnerTask.start
21
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'messed'
6
+ rescue LoadError
7
+ if ENV['MESSED_HOME']
8
+ require File.join(ENV['MESSED_HOME'], 'lib', 'messed')
9
+ else
10
+ raise("no messed!")
11
+ end
12
+ end
13
+
14
+ require 'thor'
15
+
16
+ class IncomingRunnerTask < Thor
17
+
18
+ method_options :detach => false
19
+ method_options :environment => "development"
20
+ desc "start [NAME]", "start an incoming instance"
21
+ def start(name = nil)
22
+ application = Messed::Booter.new(File.expand_path(File.join(File.dirname(__FILE__), '..')), options.environment)
23
+ incoming = if name.nil? and application.incoming_map.size == 1
24
+ application.incoming_map.values.first
25
+ elsif application.incoming_map.key?(name)
26
+ application.incoming_map[name]
27
+ else
28
+ raise(name ? "unable to find incoming with name #{name}" : "You have no incoming setup.")
29
+ end
30
+
31
+ IncomingRunner.new(incoming)
32
+ end
33
+
34
+ end
35
+
36
+ IncomingRunnerTask.start
@@ -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] = 'josh'
15
+ interfaces.twitter_sender.options[:password] = 'josh'
@@ -0,0 +1,11 @@
1
+ Loading interface `twitter_sender'
2
+ Loading interface `search'
3
+ Loading interface `twitter_sender'
4
+ Loading interface `search'
5
+ Setting up interface: :twitter_sender
6
+ Setting up interface: :search
7
+ Setting up interface: :search
8
+ Setting up interface: :twitter_sender
9
+ Setting up interface: :twitter_sender
10
+ Setting up interface: :search
11
+ Starting...