alephant 0.0.8.1-java → 0.0.8.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8fc9f2543721fab6acfabaeb658894ea9a273e6
4
- data.tar.gz: e170e8102cc7454923f60c197d5ffc8414a297ab
3
+ metadata.gz: 0ba15f2488f4d6fb9e5b4e731e1e73456c12e3e8
4
+ data.tar.gz: 62e9795e08fee239b5a11101bb878a07e708bd4b
5
5
  SHA512:
6
- metadata.gz: 8a2e82a0f57b675498827a2112d0f16ec357b0952953ab9ea4359e3f26f53523e5f350464f6e0dc466185aa035c5509e2807b9b0d91a88fa60e3350650f49014
7
- data.tar.gz: d420d6cf5997341e0fe07cc9f6ca5612d839805a33f569ac5c7de62f6b5b607ebd8a3ccfdb7cc70a152ce0320cc2c4022c8c1a256beca8b598690a28536ecbf6
6
+ metadata.gz: d9e9ba3aefb6dd5bec0c014528a1dcf926b27673d807c2fdf9acaf76911acfeab5da95bf09569465ca073d09f73ffd9078cfd39c90c8879b60e286134f79a55f
7
+ data.tar.gz: 52d9907ef2300a75947230e42c47e67c2039665963ed3fe1d41a39b73b2523bf5eca915d21b9b4fe4c984c24c2b45af12bcc1441951fc94d550e447bcc16180f
data/lib/alephant.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  $: << File.dirname(__FILE__)
2
2
 
3
3
  require 'aws-sdk'
4
- require 'json'
5
4
 
6
5
  require_relative 'env'
7
6
 
@@ -10,6 +9,7 @@ require 'alephant/models/queue'
10
9
  require 'alephant/models/cache'
11
10
  require 'alephant/models/renderer'
12
11
  require 'alephant/models/sequencer'
12
+ require 'alephant/models/parser'
13
13
 
14
14
  require 'alephant/errors'
15
15
  require 'alephant/views'
@@ -45,16 +45,13 @@ module Alephant
45
45
  @queue = Queue.new(@sqs_queue_id)
46
46
  @cache = Cache.new(@s3_bucket_id, @s3_object_path)
47
47
  @renderer = Renderer.new(@view_id, @view_path)
48
+ @parser = Parser.new
48
49
  end
49
50
 
50
51
  def set_logger(logger)
51
52
  ::Alephant.logger = logger
52
53
  end
53
54
 
54
- def parse(msg)
55
- JSON.parse(msg, :symbolize_names => true)
56
- end
57
-
58
55
  def write(data)
59
56
  @cache.put(
60
57
  @s3_object_id,
@@ -63,7 +60,7 @@ module Alephant
63
60
  end
64
61
 
65
62
  def receive(msg)
66
- data = parse(msg.body)
63
+ data = @parser.parse msg.body
67
64
 
68
65
  @logger.info("Alephant.receive: with id #{msg.id} and body digest: #{msg.md5}")
69
66
 
@@ -0,0 +1,9 @@
1
+ require 'json'
2
+
3
+ module Alephant
4
+ class Parser
5
+ def parse data
6
+ JSON.parse(data, :symbolize_names => true)
7
+ end
8
+ end
9
+ end
@@ -1,4 +1,5 @@
1
1
  require 'sinatra/base'
2
+ require 'alephant/models/parser'
2
3
  require 'alephant/models/renderer'
3
4
  require 'alephant/views/preview'
4
5
  require 'faraday'
@@ -42,7 +43,15 @@ module Alephant
42
43
  end
43
44
 
44
45
  def fixture_data
45
- JSON.parse(File.open(fixture_location).read)
46
+ parser.parse raw_fixture_data
47
+ end
48
+
49
+ def raw_fixture_data
50
+ File.open(fixture_location).read
51
+ end
52
+
53
+ def parser
54
+ @parser ||= Parser.new
46
55
  end
47
56
 
48
57
  def base_path
@@ -1,3 +1,3 @@
1
1
  module Alephant
2
- VERSION = "0.0.8.1"
2
+ VERSION = "0.0.8.2"
3
3
  end
@@ -180,30 +180,6 @@ describe Alephant::Alephant do
180
180
  end
181
181
  end
182
182
 
183
- describe "parse(msg)" do
184
- before(:each) do
185
- sequencer = double()
186
- queue = double()
187
- cache = double()
188
- renderer = double()
189
-
190
- Alephant::Sequencer.any_instance.stub(:initialize).and_return(sequencer)
191
- Alephant::Queue.any_instance.stub(:initialize).and_return(queue)
192
- Alephant::Cache.any_instance.stub(:initialize).and_return(cache)
193
- Alephant::Renderer.any_instance.stub(:initialize).and_return(renderer)
194
- end
195
-
196
- it "should return keys as symbols" do
197
- data = "{ \"foo\":\"bar\" }"
198
-
199
- instance = subject.new.parse data
200
- key = instance.keys[0]
201
-
202
- key.should be_a Symbol
203
- instance[key].should eq 'bar'
204
- end
205
- end
206
-
207
183
  describe "write(data)" do
208
184
  before(:each) do
209
185
  sequencer = double()
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Alephant::Parser do
4
+
5
+ let (:instance) { Alephant::Parser }
6
+ subject { Alephant::Parser }
7
+
8
+ describe "parse(msg)" do
9
+ it "returns parsed JSON with symbolized keys" do
10
+ data = "{ \"foo\":\"bar\" }"
11
+
12
+ instance = subject.new.parse data
13
+ key = instance.keys[0]
14
+
15
+ key.should be_a Symbol
16
+ instance[key].should eq 'bar'
17
+ end
18
+ end
19
+ end
20
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8.1
4
+ version: 0.0.8.2
5
5
  platform: java
6
6
  authors:
7
7
  - Robert Kenny
@@ -216,6 +216,7 @@ files:
216
216
  - lib/alephant/errors/view_template_not_found.rb
217
217
  - lib/alephant/models/cache.rb
218
218
  - lib/alephant/models/logger.rb
219
+ - lib/alephant/models/parser.rb
219
220
  - lib/alephant/models/queue.rb
220
221
  - lib/alephant/models/renderer.rb
221
222
  - lib/alephant/models/sequencer.rb
@@ -234,6 +235,7 @@ files:
234
235
  - spec/fixtures/views/models/example.rb
235
236
  - spec/fixtures/views/templates/example.mustache
236
237
  - spec/logger_spec.rb
238
+ - spec/parser_spec.rb
237
239
  - spec/queue_spec.rb
238
240
  - spec/renderer_spec.rb
239
241
  - spec/sequencer_spec.rb
@@ -268,6 +270,7 @@ test_files:
268
270
  - spec/fixtures/views/models/example.rb
269
271
  - spec/fixtures/views/templates/example.mustache
270
272
  - spec/logger_spec.rb
273
+ - spec/parser_spec.rb
271
274
  - spec/queue_spec.rb
272
275
  - spec/renderer_spec.rb
273
276
  - spec/sequencer_spec.rb