intellisense-ruby 0.7.5 → 0.7.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.
- data/Gemfile.lock +1 -1
- data/intellisense-ruby-0.7.5.gem +0 -0
- data/intellisense-ruby-0.7.6.gem +0 -0
- data/lib/intellisense-ruby/client.rb +4 -1
- data/lib/intellisense-ruby/consumer.rb +11 -2
- data/lib/intellisense-ruby/sqs_publisher.rb +9 -7
- data/lib/intellisense-ruby/version.rb +1 -1
- data/spec/consumer_spec.rb +49 -0
- data/spec/sqs_publisher_spec.rb +8 -2
- metadata +4 -9
- data/intellisense-ruby-0.6.6.gem +0 -0
- data/intellisense-ruby-0.6.7.gem +0 -0
- data/intellisense-ruby-0.6.8.gem +0 -0
- data/intellisense-ruby-0.7.0.gem +0 -0
- data/intellisense-ruby-0.7.2.gem +0 -0
- data/intellisense-ruby-0.7.3.gem +0 -0
- data/intellisense-ruby-0.7.4.gem +0 -0
data/Gemfile.lock
CHANGED
Binary file
|
Binary file
|
@@ -25,7 +25,8 @@ module IntellisenseRuby
|
|
25
25
|
check_api_key
|
26
26
|
|
27
27
|
@consumer = IntellisenseRuby::Consumer.new(@queue, @secret, options)
|
28
|
-
|
28
|
+
# TODO - make the use of the thread configurable
|
29
|
+
#@thread = Thread.new { @consumer.run }
|
29
30
|
|
30
31
|
@logger = options[:logger]
|
31
32
|
log('intellisense-ruby: SENSOR initialized!')
|
@@ -231,6 +232,8 @@ module IntellisenseRuby
|
|
231
232
|
queue_full = @queue.length >= @max_queue_size
|
232
233
|
@queue << action.to_json unless queue_full
|
233
234
|
|
235
|
+
@consumer.flush # flush right away
|
236
|
+
|
234
237
|
!queue_full
|
235
238
|
end
|
236
239
|
|
@@ -7,6 +7,8 @@ module IntellisenseRuby
|
|
7
7
|
|
8
8
|
class Consumer
|
9
9
|
|
10
|
+
attr_accessor :transport
|
11
|
+
|
10
12
|
# public: Creates a new consumer
|
11
13
|
#
|
12
14
|
# The consumer continuously takes messages off the queue
|
@@ -31,7 +33,7 @@ module IntellisenseRuby
|
|
31
33
|
@mutex = Mutex.new
|
32
34
|
|
33
35
|
@logger = options[:logger]
|
34
|
-
log(
|
36
|
+
log("intellisense-ruby: SENSOR initialized! with transport #{@transport}")
|
35
37
|
|
36
38
|
end
|
37
39
|
|
@@ -71,7 +73,14 @@ module IntellisenseRuby
|
|
71
73
|
when 'sqs'
|
72
74
|
log("intellisense-ruby: SENSOR using SQS transport to send #{@current_batch.to_s}")
|
73
75
|
sqs = IntellisenseRuby::SQS_Publisher.new @options
|
74
|
-
|
76
|
+
@current_batch.each {
|
77
|
+
|msg_data|
|
78
|
+
sent = sqs.send_message(msg_data)
|
79
|
+
if !sent #put the message back on the queue
|
80
|
+
@queue << msg_data
|
81
|
+
end
|
82
|
+
}
|
83
|
+
# sqs.send_message(@current_batch)
|
75
84
|
@mutex.synchronize {
|
76
85
|
@current_batch = []
|
77
86
|
}
|
@@ -36,13 +36,15 @@ module IntellisenseRuby
|
|
36
36
|
return false
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
begin
|
40
|
+
val = message.to_s
|
41
|
+
msg = @sqs_queue.send_message(val)
|
42
|
+
log_info("intellisense-ruby: SQS_Publisher - Sent message: #{msg.id}")
|
43
|
+
return true
|
44
|
+
rescue => ex
|
45
|
+
log_error("intellisense-ruby: SQS_Publisher - FAILED to send messages due to: #{ex.class.name}")
|
46
|
+
return false
|
47
|
+
end
|
46
48
|
end
|
47
49
|
|
48
50
|
private
|
data/spec/consumer_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'intellisense-ruby'
|
2
2
|
require 'thread'
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'mocha/setup'
|
4
5
|
|
5
6
|
describe Intellisense::Consumer do
|
6
7
|
|
@@ -85,4 +86,52 @@ describe Intellisense::Consumer do
|
|
85
86
|
consumer.is_requesting?.should == true
|
86
87
|
end
|
87
88
|
end
|
89
|
+
|
90
|
+
describe '#flush' do
|
91
|
+
|
92
|
+
it 'should initialize transport as http or sqs correctly' do
|
93
|
+
|
94
|
+
queue = Queue.new
|
95
|
+
options = Hash.new
|
96
|
+
|
97
|
+
options[:transport] = 'sqs'
|
98
|
+
consumer = Intellisense::Consumer.new(queue, 'testsecret', options)
|
99
|
+
expect(consumer.transport).to eq('sqs')
|
100
|
+
|
101
|
+
options[:transport] = 'http'
|
102
|
+
consumer = Intellisense::Consumer.new(queue, 'testsecret', options)
|
103
|
+
expect(consumer.transport).to eq('http')
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should iterate through the batch one at a time when sending to SQS' do
|
108
|
+
|
109
|
+
queue = Queue.new
|
110
|
+
msg1 = {:make => "bmw", :year => "2014"}
|
111
|
+
msg2 = {:make => "audi", :year => "2013"}
|
112
|
+
queue << msg1.to_json
|
113
|
+
queue << msg2.to_json
|
114
|
+
|
115
|
+
options = Hash.new
|
116
|
+
options[:warehouse_access_key_id] = 'AKIAJPYU646KQOWWZ4SA'
|
117
|
+
options[:warehouse_secret_access_key] = 'oxoHfy9nKZCrDbvWFj5Z25ADQOykD/8uTxj18N6g'
|
118
|
+
options[:warehouse_queue_url] = 'https://sqs.us-east-1.amazonaws.com/691677686063/yoda-events-dev'
|
119
|
+
|
120
|
+
options[:transport] = 'sqs'
|
121
|
+
consumer = Intellisense::Consumer.new(queue, 'testsecret', options)
|
122
|
+
|
123
|
+
# Stub send_message on all instances of SQS_Publisher
|
124
|
+
IntellisenseRuby::SQS_Publisher.any_instance.expects(:send_message).with(msg1.to_json)
|
125
|
+
IntellisenseRuby::SQS_Publisher.any_instance.expects(:send_message).with(msg2.to_json)
|
126
|
+
IntellisenseRuby::SQS_Publisher.any_instance.expects(:send_message).at_least(2)
|
127
|
+
IntellisenseRuby::SQS_Publisher.any_instance.expects(:send_message).at_most(2)
|
128
|
+
|
129
|
+
sentMessage = AWS::SQS::Queue::SentMessage.new
|
130
|
+
sentMessage.stubs(:id).returns('fake-id-12323123')
|
131
|
+
AWS::SQS::Queue.any_instance.stubs(:send_message).returns(sentMessage)
|
132
|
+
|
133
|
+
consumer.flush # should trigger expectations set above
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
88
137
|
end
|
data/spec/sqs_publisher_spec.rb
CHANGED
@@ -30,10 +30,16 @@ describe IntellisenseRuby::SQS_Publisher do
|
|
30
30
|
describe '#send_message' do
|
31
31
|
|
32
32
|
it 'should send with valid credentials' do
|
33
|
+
options = Hash.new
|
34
|
+
options[:warehouse_access_key_id] = 'AKIAJPYU646KQOWWZ4SA'
|
35
|
+
options[:warehouse_secret_access_key] = 'oxoHfy9nKZCrDbvWFj5Z25ADQOykD/8uTxj18N6g'
|
36
|
+
options[:warehouse_queue_url] = 'https://sqs.us-east-1.amazonaws.com/691677686063/yoda-events-dev'
|
33
37
|
# AWS::SQS::Queue.any_instance.stubs(:send_message).returns('STUBBED send_message')
|
34
38
|
# sqs_publisher.stubs(:send_message).returns('STUBBED send_message')
|
35
|
-
|
36
|
-
#
|
39
|
+
|
40
|
+
# NOTE - uncomment only when trying to test - since this actually sends message
|
41
|
+
#sqs_publisher = IntellisenseRuby::SQS_Publisher.new options
|
42
|
+
#expect(sqs_publisher.send_message(value: 'test')).to eq(true)
|
37
43
|
end
|
38
44
|
|
39
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intellisense-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -150,25 +150,20 @@ files:
|
|
150
150
|
- lib/intellisense-ruby/consumer.rb
|
151
151
|
- lib/intellisense-ruby/client.rb
|
152
152
|
- lib/intellisense-ruby/defaults.rb
|
153
|
-
- intellisense-ruby-0.7.4.gem
|
154
|
-
- intellisense-ruby-0.7.3.gem
|
155
153
|
- intellisense-ruby.sublime-project
|
156
|
-
- intellisense-ruby-0.6.6.gem
|
157
|
-
- intellisense-ruby-0.6.8.gem
|
158
|
-
- intellisense-ruby-0.7.2.gem
|
159
154
|
- intellisense-ruby.sublime-workspace
|
155
|
+
- intellisense-ruby-0.7.5.gem
|
160
156
|
- README.md
|
161
157
|
- Gemfile
|
158
|
+
- intellisense-ruby-0.7.6.gem
|
162
159
|
- Gemfile.lock
|
163
160
|
- intellisense-ruby.gemspec
|
164
161
|
- Rakefile
|
165
|
-
- intellisense-ruby-0.7.0.gem
|
166
162
|
- spec/consumer_spec.rb
|
167
163
|
- spec/module_spec.rb
|
168
164
|
- spec/spec_helper.rb
|
169
165
|
- spec/sqs_publisher_spec.rb
|
170
166
|
- spec/client_spec.rb
|
171
|
-
- intellisense-ruby-0.6.7.gem
|
172
167
|
homepage: https://github.com/pnayak/intellisense-ruby.git
|
173
168
|
licenses: []
|
174
169
|
post_install_message:
|
data/intellisense-ruby-0.6.6.gem
DELETED
Binary file
|
data/intellisense-ruby-0.6.7.gem
DELETED
Binary file
|
data/intellisense-ruby-0.6.8.gem
DELETED
Binary file
|
data/intellisense-ruby-0.7.0.gem
DELETED
Binary file
|
data/intellisense-ruby-0.7.2.gem
DELETED
Binary file
|
data/intellisense-ruby-0.7.3.gem
DELETED
Binary file
|
data/intellisense-ruby-0.7.4.gem
DELETED
Binary file
|