scamp 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,6 +16,24 @@ Ruby >= 1.9.2 (At least for the named captures)
16
16
 
17
17
  ## Usage and Examples
18
18
 
19
+ ### The most simple example:
20
+
21
+ require 'scamp'
22
+
23
+ scamp = Scamp.new(:api_key => "YOUR API KEY", :subdomain => "yoursubdomain", :verbose => true)
24
+
25
+ scamp.behaviour do
26
+ # Simple matching based on regex or string:
27
+ match "ping" do
28
+ say "pong"
29
+ end
30
+ end
31
+
32
+ # Connect and join some rooms
33
+ scamp.connect!([293788, "Monitoring"])
34
+
35
+ ### A more in-depth run through
36
+
19
37
  Matchers are tested in order and all that satisfy the match and conditions will be run. Careful, Scamp listens to itself, you could easily create an infinite loop. Look in the examples dir for more.
20
38
 
21
39
  require 'scamp'
@@ -100,13 +118,11 @@ Matchers are tested in order and all that satisfy the match and conditions will
100
118
  # Connect and join some rooms
101
119
  scamp.connect!([293788, "Monitoring"])
102
120
 
103
- In the room/user conditions you can use the name, regex or ID of a user or room, in say you can ise a string or ID, eg:
121
+ In the room/user conditions and say/play commands you can use the name or ID of a user or room, eg:
104
122
 
105
- :conditions => {:room => /someregex/}
106
123
  :conditions => {:room => "some string"}
107
124
  :conditions => {:room => 123456}
108
125
 
109
- :conditions => {:user => /someregex/}
110
126
  :conditions => {:user => "some string"}
111
127
  :conditions => {:user => 123456}
112
128
 
@@ -19,7 +19,7 @@ class Scamp
19
19
  http = EventMachine::HttpRequest.new(url).post :head => {'Content-Type' => 'application/json', 'authorization' => [api_key, 'X']}, :body => Yajl::Encoder.encode({:message => {:body => payload, :type => type}})
20
20
  http.errback { logger.error "Couldn't connect to #{url} to post message \"#{payload}\" to room #{room_id}" }
21
21
  http.callback {
22
- if http.response_header.status == 200
22
+ if [200,201].include? http.response_header.status
23
23
  logger.debug "Posted message \"#{payload}\" to room #{room_id}"
24
24
  else
25
25
  logger.error "Couldn't post message \"#{payload}\" to room #{room_id} using url #{url}, http response from the API was #{http.response_header.status}"
data/lib/scamp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Scamp
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -598,7 +598,7 @@ describe Scamp do
598
598
  EM.run_block {
599
599
  stub_request(:post, @message_post_url).
600
600
  with(:headers => {'Authorization'=>[@valid_params[:api_key], 'X'], 'Content-Type' => 'application/json'}).
601
- to_return(:status => 200, :body => Yajl::Encoder.encode(:room => @valid_room_cache_data[123]), :headers => {})
601
+ to_return(:status => 201, :body => Yajl::Encoder.encode(:room => @valid_room_cache_data[123]), :headers => {})
602
602
  bot.send(:send_message, 123, "Hi", "Textmessage")
603
603
  }
604
604
  logger_output.should =~ /DEBUG.*Posted message "Hi" to room 123/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &2152463380 !ruby/object:Gem::Requirement
16
+ requirement: &70295424002980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0.beta.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152463380
24
+ version_requirements: *70295424002980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: yajl-ruby
27
- requirement: &2152461660 !ruby/object:Gem::Requirement
27
+ requirement: &70295424002200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152461660
35
+ version_requirements: *70295424002200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: em-http-request
38
- requirement: &2152459120 !ruby/object:Gem::Requirement
38
+ requirement: &70295424001540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0.beta.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2152459120
46
+ version_requirements: *70295424001540
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &2152457780 !ruby/object:Gem::Requirement
49
+ requirement: &70295424000840 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.6.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152457780
57
+ version_requirements: *70295424000840
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &2152454380 !ruby/object:Gem::Requirement
60
+ requirement: &70295424000160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.10.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2152454380
68
+ version_requirements: *70295424000160
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &2152453060 !ruby/object:Gem::Requirement
71
+ requirement: &70295423999460 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 1.7.6
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152453060
79
+ version_requirements: *70295423999460
80
80
  description: Eventmachine based Campfire bot framework
81
81
  email:
82
82
  - will@willj.net