alephant 0.0.9.9.1-java → 0.1.1-java
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/alephant.gemspec +8 -2
- data/lib/alephant.rb +40 -56
- data/lib/alephant/models/jsonpath_lookup.rb +16 -0
- data/lib/alephant/models/parser.rb +20 -2
- data/lib/alephant/models/queue.rb +6 -5
- data/lib/alephant/models/render_mapper.rb +56 -0
- data/lib/alephant/models/writer.rb +44 -0
- data/lib/alephant/version.rb +1 -1
- data/lib/env.rb +0 -2
- data/spec/alephant_spec.rb +51 -197
- data/spec/fixtures/components/foo/models/bar.rb +7 -0
- data/spec/fixtures/components/foo/models/foo.rb +1 -1
- data/spec/parser_spec.rb +17 -9
- data/spec/render_mapper_spec.rb +63 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/writer_spec.rb +52 -0
- metadata +97 -34
- data/bin/alephant +0 -37
- data/lib/alephant/errors.rb +0 -6
- data/lib/alephant/errors/invalid_view_path.rb +0 -6
- data/lib/alephant/errors/view_model_not_found.rb +0 -6
- data/lib/alephant/errors/view_template_not_found.rb +0 -6
- data/lib/alephant/models/cache.rb +0 -28
- data/lib/alephant/models/logger.rb +0 -22
- data/lib/alephant/models/multi_renderer.rb +0 -84
- data/lib/alephant/models/renderer.rb +0 -34
- data/lib/alephant/models/sequence_table.rb +0 -99
- data/lib/alephant/models/sequencer.rb +0 -61
- data/lib/alephant/preview/server.rb +0 -75
- data/lib/alephant/preview/template.rb +0 -63
- data/lib/alephant/tasks.rb +0 -8
- data/lib/alephant/util/string.rb +0 -9
- data/lib/alephant/views.rb +0 -15
- data/lib/alephant/views/base.rb +0 -16
- data/lib/alephant/views/preview.rb +0 -44
- data/lib/tasks/preview.rake +0 -16
- data/spec/cache_spec.rb +0 -63
- data/spec/logger_spec.rb +0 -40
- data/spec/multi_renderer_spec.rb +0 -92
- data/spec/renderer_spec.rb +0 -62
- data/spec/sequencer_spec.rb +0 -107
data/spec/parser_spec.rb
CHANGED
@@ -1,19 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Alephant::Parser do
|
4
|
-
|
5
|
-
let (:instance) { Alephant::Parser }
|
6
|
-
subject { Alephant::Parser }
|
7
|
-
|
8
4
|
describe "parse(msg)" do
|
5
|
+
let(:msg) { Struct.new(:body).new("{ \"foo\":\"bar\" }") }
|
6
|
+
let(:msg_with_options) do
|
7
|
+
Struct.new(:body).new(<<-EOS)
|
8
|
+
{
|
9
|
+
"some" : {
|
10
|
+
"location" : "bar"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
EOS
|
14
|
+
end
|
9
15
|
it "returns parsed JSON with symbolized keys" do
|
10
|
-
|
16
|
+
subject.parse(msg)[:foo].should eq 'bar'
|
17
|
+
end
|
11
18
|
|
12
|
-
|
13
|
-
|
19
|
+
context "initialized with vary_jsonpath" do
|
20
|
+
subject { Alephant::Parser.new('$.some.location') }
|
14
21
|
|
15
|
-
|
16
|
-
|
22
|
+
it "adds the correct :options to the returned hash" do
|
23
|
+
expect(subject.parse(msg_with_options)[:options][:variant]).to eq "bar"
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alephant::RenderMapper do
|
4
|
+
let(:component_id) { :foo }
|
5
|
+
let(:data) {{ :foo => :bar }}
|
6
|
+
let(:path) { File.join(File.dirname(__FILE__), 'fixtures/components') }
|
7
|
+
|
8
|
+
subject { Alephant::RenderMapper }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
File.stub(:directory?).and_return(true)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "initialize(view_base_path)" do
|
15
|
+
context "view_base_path = invalid_path" do
|
16
|
+
it "should raise InvalidViewPath" do
|
17
|
+
File.stub(:directory?).and_return(false)
|
18
|
+
expect {
|
19
|
+
subject.new(component_id, './invalid_path')
|
20
|
+
}.to raise_error(
|
21
|
+
'Invalid path'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "view_base_path = '.'" do
|
27
|
+
it "sets base_path" do
|
28
|
+
expect(subject.new(component_id, '.').base_path).to eq("./#{component_id}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "view_base_path = nil" do
|
33
|
+
it "sets base_path" do
|
34
|
+
expect(subject.new(component_id).base_path).to eq(Alephant::RenderMapper::DEFAULT_LOCATION)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "create_renderer(template_file, data)" do
|
40
|
+
it "Returns a valid renderer" do
|
41
|
+
expect(
|
42
|
+
subject.new(component_id, path)
|
43
|
+
.create_renderer('foo', { :content => 'hello'})
|
44
|
+
).to be_a(Alephant::Renderer::Mustache)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "Returns expected rendered content from a render" do
|
48
|
+
expect(
|
49
|
+
subject.new(component_id, path)
|
50
|
+
.create_renderer('foo', { :content => 'hello'}).render
|
51
|
+
).to eq("hello\n")
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "generate(data)" do
|
57
|
+
it "calls create_renderer for each template found" do
|
58
|
+
expect(
|
59
|
+
subject.new(component_id, path).generate(data).size
|
60
|
+
).to eq(2)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/writer_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alephant::Writer do
|
4
|
+
before(:each) do
|
5
|
+
Alephant::RenderMapper.any_instance.stub(:initialize)
|
6
|
+
Alephant::Cache.any_instance.stub(:initialize)
|
7
|
+
end
|
8
|
+
subject do
|
9
|
+
Alephant::Writer.new({
|
10
|
+
:renderer_id => 'renderer_id',
|
11
|
+
:lookup_table_name => 'lookup_table_name'
|
12
|
+
})
|
13
|
+
end
|
14
|
+
describe "#write(data, version)" do
|
15
|
+
before(:each) do
|
16
|
+
Alephant::RenderMapper.any_instance
|
17
|
+
.stub(:generate)
|
18
|
+
.and_return({
|
19
|
+
'component_id' => Struct.new(:render).new('content')
|
20
|
+
})
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should write the correct lookup location" do
|
25
|
+
options = { :key => :value }
|
26
|
+
data = { :options => options }
|
27
|
+
|
28
|
+
Alephant::Cache.any_instance
|
29
|
+
.stub(:put)
|
30
|
+
Alephant::Lookup
|
31
|
+
.should_receive(:create)
|
32
|
+
.with('lookup_table_name', 'component_id')
|
33
|
+
.and_call_original
|
34
|
+
Alephant::Lookup::Lookup.any_instance
|
35
|
+
.stub(:initialize)
|
36
|
+
Alephant::Lookup::Lookup.any_instance
|
37
|
+
.should_receive(:write)
|
38
|
+
.with(options, 'renderer_id_component_id_0')
|
39
|
+
|
40
|
+
subject.write(data, 0)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should put the correct location, content to cache" do
|
44
|
+
Alephant::Lookup::Lookup.any_instance.stub(:initialize)
|
45
|
+
Alephant::Lookup::Lookup.any_instance.stub(:write)
|
46
|
+
Alephant::Cache.any_instance
|
47
|
+
.should_receive(:put).with('renderer_id_component_id_0', 'content')
|
48
|
+
|
49
|
+
subject.write({}, 0)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Robert Kenny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -206,10 +206,93 @@ dependencies:
|
|
206
206
|
version: '0'
|
207
207
|
prerelease: false
|
208
208
|
type: :runtime
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: alephant-sequencer
|
211
|
+
version_requirements: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - '>='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
requirement: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - '>='
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '0'
|
221
|
+
prerelease: false
|
222
|
+
type: :runtime
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: alephant-logger
|
225
|
+
version_requirements: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
requirement: !ruby/object:Gem::Requirement
|
231
|
+
requirements:
|
232
|
+
- - '>='
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '0'
|
235
|
+
prerelease: false
|
236
|
+
type: :runtime
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: alephant-cache
|
239
|
+
version_requirements: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - '>='
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
requirement: !ruby/object:Gem::Requirement
|
245
|
+
requirements:
|
246
|
+
- - '>='
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: '0'
|
249
|
+
prerelease: false
|
250
|
+
type: :runtime
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: alephant-renderer
|
253
|
+
version_requirements: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - '>='
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
requirement: !ruby/object:Gem::Requirement
|
259
|
+
requirements:
|
260
|
+
- - '>='
|
261
|
+
- !ruby/object:Gem::Version
|
262
|
+
version: '0'
|
263
|
+
prerelease: false
|
264
|
+
type: :runtime
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: alephant-lookup
|
267
|
+
version_requirements: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - '>='
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0'
|
272
|
+
requirement: !ruby/object:Gem::Requirement
|
273
|
+
requirements:
|
274
|
+
- - '>='
|
275
|
+
- !ruby/object:Gem::Version
|
276
|
+
version: '0'
|
277
|
+
prerelease: false
|
278
|
+
type: :runtime
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: alephant-preview
|
281
|
+
version_requirements: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - '>='
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
286
|
+
requirement: !ruby/object:Gem::Requirement
|
287
|
+
requirements:
|
288
|
+
- - '>='
|
289
|
+
- !ruby/object:Gem::Version
|
290
|
+
version: '0'
|
291
|
+
prerelease: false
|
292
|
+
type: :runtime
|
209
293
|
description: Static publishing to S3 based on SQS messages
|
210
294
|
email: kenoir@gmail.com
|
211
|
-
executables:
|
212
|
-
- alephant
|
295
|
+
executables: []
|
213
296
|
extensions: []
|
214
297
|
extra_rdoc_files: []
|
215
298
|
files:
|
@@ -222,42 +305,24 @@ files:
|
|
222
305
|
- README.md
|
223
306
|
- Rakefile
|
224
307
|
- alephant.gemspec
|
225
|
-
- bin/alephant
|
226
308
|
- lib/alephant.rb
|
227
|
-
- lib/alephant/
|
228
|
-
- lib/alephant/errors/invalid_view_path.rb
|
229
|
-
- lib/alephant/errors/view_model_not_found.rb
|
230
|
-
- lib/alephant/errors/view_template_not_found.rb
|
231
|
-
- lib/alephant/models/cache.rb
|
232
|
-
- lib/alephant/models/logger.rb
|
233
|
-
- lib/alephant/models/multi_renderer.rb
|
309
|
+
- lib/alephant/models/jsonpath_lookup.rb
|
234
310
|
- lib/alephant/models/parser.rb
|
235
311
|
- lib/alephant/models/queue.rb
|
236
|
-
- lib/alephant/models/
|
237
|
-
- lib/alephant/models/
|
238
|
-
- lib/alephant/models/sequencer.rb
|
239
|
-
- lib/alephant/preview/server.rb
|
240
|
-
- lib/alephant/preview/template.rb
|
241
|
-
- lib/alephant/tasks.rb
|
242
|
-
- lib/alephant/util/string.rb
|
312
|
+
- lib/alephant/models/render_mapper.rb
|
313
|
+
- lib/alephant/models/writer.rb
|
243
314
|
- lib/alephant/version.rb
|
244
|
-
- lib/alephant/views.rb
|
245
|
-
- lib/alephant/views/base.rb
|
246
|
-
- lib/alephant/views/preview.rb
|
247
315
|
- lib/env.rb
|
248
|
-
- lib/tasks/preview.rake
|
249
316
|
- spec/alephant_spec.rb
|
250
|
-
- spec/
|
317
|
+
- spec/fixtures/components/foo/models/bar.rb
|
251
318
|
- spec/fixtures/components/foo/models/foo.rb
|
252
319
|
- spec/fixtures/components/foo/templates/bar.mustache
|
253
320
|
- spec/fixtures/components/foo/templates/foo.mustache
|
254
|
-
- spec/logger_spec.rb
|
255
|
-
- spec/multi_renderer_spec.rb
|
256
321
|
- spec/parser_spec.rb
|
257
322
|
- spec/queue_spec.rb
|
258
|
-
- spec/
|
259
|
-
- spec/sequencer_spec.rb
|
323
|
+
- spec/render_mapper_spec.rb
|
260
324
|
- spec/spec_helper.rb
|
325
|
+
- spec/writer_spec.rb
|
261
326
|
homepage: https://github.com/BBC-News/alephant
|
262
327
|
licenses:
|
263
328
|
- GPLv3
|
@@ -281,17 +346,15 @@ rubyforge_project:
|
|
281
346
|
rubygems_version: 2.1.9
|
282
347
|
signing_key:
|
283
348
|
specification_version: 4
|
284
|
-
summary: Static
|
349
|
+
summary: Static publishing in the cloud
|
285
350
|
test_files:
|
286
351
|
- spec/alephant_spec.rb
|
287
|
-
- spec/
|
352
|
+
- spec/fixtures/components/foo/models/bar.rb
|
288
353
|
- spec/fixtures/components/foo/models/foo.rb
|
289
354
|
- spec/fixtures/components/foo/templates/bar.mustache
|
290
355
|
- spec/fixtures/components/foo/templates/foo.mustache
|
291
|
-
- spec/logger_spec.rb
|
292
|
-
- spec/multi_renderer_spec.rb
|
293
356
|
- spec/parser_spec.rb
|
294
357
|
- spec/queue_spec.rb
|
295
|
-
- spec/
|
296
|
-
- spec/sequencer_spec.rb
|
358
|
+
- spec/render_mapper_spec.rb
|
297
359
|
- spec/spec_helper.rb
|
360
|
+
- spec/writer_spec.rb
|
data/bin/alephant
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'pathname'
|
4
|
-
require 'trollop'
|
5
|
-
|
6
|
-
root = Pathname.new(__FILE__).dirname.parent
|
7
|
-
lib_path = (root + 'lib').realdirpath
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift(lib_path)
|
10
|
-
|
11
|
-
require 'alephant'
|
12
|
-
require 'alephant/tasks'
|
13
|
-
|
14
|
-
SUB_COMMANDS = %w(preview)
|
15
|
-
global_opts = Trollop::options do
|
16
|
-
banner <<-EOS
|
17
|
-
Static publishing to S3 based on SQS messages
|
18
|
-
Usage:
|
19
|
-
alephant preview # Runs preview server
|
20
|
-
alephant update # Attempts to update preview template
|
21
|
-
Dependent on the following environmen variables being set:
|
22
|
-
- STATIC_HOST_REGEX="static.(int|test|live).myhost.com"
|
23
|
-
- PREVIEW_TEMPLATE_URL"http://myapp.com/mustache_template"
|
24
|
-
EOS
|
25
|
-
stop_on SUB_COMMANDS
|
26
|
-
end
|
27
|
-
|
28
|
-
cmd = ARGV.shift # get the subcommand
|
29
|
-
case cmd
|
30
|
-
when "preview"
|
31
|
-
Rake::Task['alephant:preview:go'].invoke
|
32
|
-
when "update"
|
33
|
-
Rake::Task['alephant:preview:update'].invoke
|
34
|
-
else
|
35
|
-
Trollop::die "unknown subcommand #{cmd.inspect}"
|
36
|
-
end
|
37
|
-
|
data/lib/alephant/errors.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'aws-sdk'
|
2
|
-
|
3
|
-
module Alephant
|
4
|
-
class Cache
|
5
|
-
attr_reader :id, :bucket, :path
|
6
|
-
|
7
|
-
def initialize(id, path)
|
8
|
-
@logger = ::Alephant.logger
|
9
|
-
@id = id
|
10
|
-
@path = path
|
11
|
-
|
12
|
-
s3 = AWS::S3.new
|
13
|
-
@bucket = s3.buckets[id]
|
14
|
-
@logger.info("Cache.initialize: end with id #{id} and path #{path}")
|
15
|
-
end
|
16
|
-
|
17
|
-
def put(id, data)
|
18
|
-
@bucket.objects["#{@path}/#{id}"].write(data)
|
19
|
-
@logger.info("Cache.put: #{@path}/#{id}")
|
20
|
-
end
|
21
|
-
|
22
|
-
def get(id)
|
23
|
-
@logger.info("Cache.get: #{@path}/#{id}")
|
24
|
-
@bucket.objects["#{@path}/#{id}"].read
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|