alephant-preview 0.0.5.3 → 0.0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/Guardfile +6 -0
- data/README.md +4 -0
- data/Rakefile +9 -1
- data/alephant-preview.gemspec +2 -0
- data/lib/alephant/preview/server.rb +10 -2
- data/lib/alephant/preview/template.rb +1 -1
- data/lib/alephant/preview/version.rb +1 -1
- data/spec/fixtures/components/foo/fixtures/foo.json +1 -0
- data/spec/fixtures/components/foo/models/foo.rb +7 -0
- data/spec/fixtures/components/foo/templates/.DS_Store +0 -0
- data/spec/fixtures/components/foo/templates/foo.mustache +1 -0
- data/spec/fixtures/lib/templates/preview.mustache +1 -0
- data/spec/preview_spec.rb +40 -0
- data/spec/spec_helper.rb +12 -0
- metadata +47 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04012bcf9d65a7b85dad2a539064f900dd6e8a4a
|
4
|
+
data.tar.gz: 74f65331b8bfba26ed4386e331e2977721746f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18d446a39a75ffb6725b078c45c90599c48b10b443e0cd81ebf870bd99d08824b4a4566418c5e5d4a916a845334c2f19c3428a21b47428176505857935125278
|
7
|
+
data.tar.gz: 99f594515d3fa323bb9acfbb18c0ee34777ddfbcb02f1f093d863433d752f77311a3047d51a7bba065c6565f7dca3eccb6bd5042cdd34f37d470aed550c33b43
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Provides an in-page preview of components during development
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/BBC-News/alephant-preview.png?branch=master)](https://travis-ci.org/BBC-News/alephant-preview)
|
6
|
+
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/alephant-preview.png)](http://badge.fury.io/rb/alephant-preview)
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
data/Rakefile
CHANGED
data/alephant-preview.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_development_dependency "rspec"
|
21
21
|
spec.add_development_dependency "rspec-nc"
|
22
|
+
spec.add_development_dependency "rack-test"
|
22
23
|
spec.add_development_dependency "guard"
|
23
24
|
spec.add_development_dependency "guard-rspec"
|
24
25
|
spec.add_development_dependency "pry"
|
@@ -28,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
28
29
|
spec.add_development_dependency "rake"
|
29
30
|
|
30
31
|
spec.add_runtime_dependency 'sinatra'
|
32
|
+
spec.add_runtime_dependency 'sinatra-reloader'
|
31
33
|
spec.add_runtime_dependency 'faraday'
|
32
34
|
spec.add_runtime_dependency 'trollop'
|
33
35
|
spec.add_runtime_dependency 'rake'
|
@@ -6,6 +6,7 @@ require 'alephant/support/parser'
|
|
6
6
|
require 'alephant/preview/template/base'
|
7
7
|
|
8
8
|
require 'sinatra/base'
|
9
|
+
require "sinatra/reloader"
|
9
10
|
require 'faraday'
|
10
11
|
require 'json'
|
11
12
|
require 'uri'
|
@@ -13,7 +14,10 @@ require 'uri'
|
|
13
14
|
module Alephant
|
14
15
|
module Preview
|
15
16
|
class Server < Sinatra::Base
|
16
|
-
|
17
|
+
register Sinatra::Reloader
|
18
|
+
also_reload 'components/*/models/*.rb'
|
19
|
+
|
20
|
+
BASE_LOCATION = "#{(ENV['BASE_LOCATION'] || Dir.pwd)}/components"
|
17
21
|
|
18
22
|
get '/preview/:id/:template/:region/?:fixture?' do
|
19
23
|
render_preview
|
@@ -23,6 +27,10 @@ module Alephant
|
|
23
27
|
render_component
|
24
28
|
end
|
25
29
|
|
30
|
+
get '/status' do
|
31
|
+
'ok'
|
32
|
+
end
|
33
|
+
|
26
34
|
def render_preview
|
27
35
|
Template::Base.new(
|
28
36
|
{ region => render_component },
|
@@ -41,7 +49,7 @@ module Alephant
|
|
41
49
|
end
|
42
50
|
|
43
51
|
def base_path
|
44
|
-
File.join(
|
52
|
+
File.join(BASE_LOCATION, id)
|
45
53
|
end
|
46
54
|
|
47
55
|
def model_location
|
@@ -0,0 +1 @@
|
|
1
|
+
{ "a" : "b" }
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
{{content}}
|
@@ -0,0 +1 @@
|
|
1
|
+
top{{{page_region}}}bottom
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alephant::Preview::Server do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
Alephant::Preview::Server
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '/preview/:id/:template/:region/?:fixture?' do
|
11
|
+
context 'valid component' do
|
12
|
+
it "should return the rendered component inside the page region specified" do
|
13
|
+
get '/preview/foo/foo/page_region/foo'
|
14
|
+
|
15
|
+
expect(last_response).to be_ok
|
16
|
+
expect(last_response.body).to eq("topcontent\nbottom\n")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '/component/:id/:template/?:fixture?' do
|
22
|
+
context 'valid component' do
|
23
|
+
it "should return the rendered component" do
|
24
|
+
get '/component/foo/foo/foo'
|
25
|
+
|
26
|
+
expect(last_response).to be_ok
|
27
|
+
expect(last_response.body).to eq("content\n")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '/status' do
|
33
|
+
it "responds with ok" do
|
34
|
+
get '/status'
|
35
|
+
|
36
|
+
expect(last_response).to be_ok
|
37
|
+
expect(last_response.body).to eq('ok')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$: << File.join(File.dirname(__FILE__),"..", "lib")
|
2
|
+
|
3
|
+
FIXTURE_PATH = File.join(File.dirname(__FILE__),'fixtures')
|
4
|
+
|
5
|
+
ENV['BASE_LOCATION'] = FIXTURE_PATH
|
6
|
+
ENV['PREVIEW_TEMPLATE_PATH'] = File.join(FIXTURE_PATH, 'lib')
|
7
|
+
ENV['RACK_ENV'] = 'test'
|
8
|
+
|
9
|
+
require 'pry'
|
10
|
+
require 'rack/test'
|
11
|
+
require 'alephant/preview'
|
12
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.5.
|
4
|
+
version: 0.0.5.4
|
5
5
|
platform: ruby
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
version: '0'
|
39
39
|
prerelease: false
|
40
40
|
type: :development
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack-test
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
prerelease: false
|
54
|
+
type: :development
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: guard
|
43
57
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -150,6 +164,20 @@ dependencies:
|
|
150
164
|
version: '0'
|
151
165
|
prerelease: false
|
152
166
|
type: :runtime
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sinatra-reloader
|
169
|
+
version_requirements: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirement: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - '>='
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
prerelease: false
|
180
|
+
type: :runtime
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: faraday
|
155
183
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -244,7 +272,9 @@ extra_rdoc_files: []
|
|
244
272
|
files:
|
245
273
|
- .gitignore
|
246
274
|
- .ruby-version
|
275
|
+
- .travis.yml
|
247
276
|
- Gemfile
|
277
|
+
- Guardfile
|
248
278
|
- LICENSE.txt
|
249
279
|
- README.md
|
250
280
|
- Rakefile
|
@@ -258,6 +288,13 @@ files:
|
|
258
288
|
- lib/alephant/preview/template/base.rb
|
259
289
|
- lib/alephant/preview/template/updater.rb
|
260
290
|
- lib/alephant/preview/version.rb
|
291
|
+
- spec/fixtures/components/foo/fixtures/foo.json
|
292
|
+
- spec/fixtures/components/foo/models/foo.rb
|
293
|
+
- spec/fixtures/components/foo/templates/.DS_Store
|
294
|
+
- spec/fixtures/components/foo/templates/foo.mustache
|
295
|
+
- spec/fixtures/lib/templates/preview.mustache
|
296
|
+
- spec/preview_spec.rb
|
297
|
+
- spec/spec_helper.rb
|
261
298
|
homepage: ''
|
262
299
|
licenses:
|
263
300
|
- MIT
|
@@ -282,4 +319,11 @@ rubygems_version: 2.1.9
|
|
282
319
|
signing_key:
|
283
320
|
specification_version: 4
|
284
321
|
summary: Preview component templates
|
285
|
-
test_files:
|
322
|
+
test_files:
|
323
|
+
- spec/fixtures/components/foo/fixtures/foo.json
|
324
|
+
- spec/fixtures/components/foo/models/foo.rb
|
325
|
+
- spec/fixtures/components/foo/templates/.DS_Store
|
326
|
+
- spec/fixtures/components/foo/templates/foo.mustache
|
327
|
+
- spec/fixtures/lib/templates/preview.mustache
|
328
|
+
- spec/preview_spec.rb
|
329
|
+
- spec/spec_helper.rb
|