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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88131643b5d76012128a809c37310c7ee23d579b
4
- data.tar.gz: d23d07e0c757691e72cdb33857062d3b6369f396
3
+ metadata.gz: 04012bcf9d65a7b85dad2a539064f900dd6e8a4a
4
+ data.tar.gz: 74f65331b8bfba26ed4386e331e2977721746f47
5
5
  SHA512:
6
- metadata.gz: 9885405c03e0979ffe6c0761911845f3554ac5a723b66607e013a2b7f737374a173c28884c9e239e12d6fcb93b0df68454c5ef90b597c3c93f5489a85c8e72f0
7
- data.tar.gz: 58f9d55f78decf4355375ac1230929bb861405f873ab789b98ad0105aa439d5bde88177718e83d57313333e32b8d40ba8b8a8196983c75f4e6428dc0f058370d
6
+ metadata.gz: 18d446a39a75ffb6725b078c45c90599c48b10b443e0cd81ebf870bd99d08824b4a4566418c5e5d4a916a845334c2f19c3428a21b47428176505857935125278
7
+ data.tar.gz: 99f594515d3fa323bb9acfbb18c0ee34777ddfbcb02f1f093d863433d752f77311a3047d51a7bba065c6565f7dca3eccb6bd5042cdd34f37d470aed550c33b43
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ .rspec
3
4
  .bundle
4
5
  .config
5
6
  .yardoc
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "jruby"
4
+ notifications:
5
+ email:
6
+ recipients:
7
+ - kenoir@gmail.com
8
+ on_failure: change
9
+ on_success: never
@@ -0,0 +1,6 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/.+\.rb$})
4
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
5
+ watch('spec/spec_helper.rb') { "spec" }
6
+ end
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
@@ -1 +1,9 @@
1
- require "bundler/gem_tasks"
1
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
2
+
3
+ require 'rspec/core/rake_task'
4
+ require 'bundler/gem_tasks'
5
+ require 'alephant/preview'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
@@ -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
- DEFAULT_LOCATION = 'components'
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(Dir.pwd, DEFAULT_LOCATION, id)
52
+ File.join(BASE_LOCATION, id)
45
53
  end
46
54
 
47
55
  def model_location
@@ -5,7 +5,7 @@ module Alephant
5
5
  module Preview
6
6
  module Template
7
7
  def self.path
8
- "#{Dir.pwd}/components/lib"
8
+ ENV['PREVIEW_TEMPLATE_PATH'] || "#{Dir.pwd}/components/lib"
9
9
  end
10
10
 
11
11
  def self.update(template_location)
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Preview
3
- VERSION = "0.0.5.3"
3
+ VERSION = "0.0.5.4"
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ { "a" : "b" }
@@ -0,0 +1,7 @@
1
+ module MyApp
2
+ class Foo < ::Alephant::Views::Base
3
+ def content
4
+ "content"
5
+ end
6
+ end
7
+ end
@@ -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
@@ -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.3
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-24 00:00:00.000000000 Z
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