prow 0.1.0 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/lib/prow/app_builder/create.rb +51 -0
- data/lib/prow/app_builder/style_compiler.rb +15 -0
- data/lib/prow/app_builder/templates/config/pages.json +11 -0
- data/lib/prow/app_builder/templates/config.ru +2 -0
- data/lib/prow/app_builder/templates/templates/layouts/default.mustache +20 -0
- data/lib/prow/app_builder/templates/templates/pages/index.mustache +20 -0
- data/lib/prow/page.rb +23 -0
- data/lib/prow/page_compiler.rb +5 -9
- data/lib/prow/page_configs.rb +7 -1
- data/lib/prow/pages_compiler.rb +7 -13
- data/lib/prow/paths.rb +27 -0
- data/lib/prow/silence_warnings.rb +13 -0
- data/lib/prow/tasks.rb +3 -0
- data/lib/prow/version.rb +1 -1
- data/lib/prow/watcher.rb +44 -0
- data/lib/prow.rb +12 -1
- data/lib/tasks/prow.rake +31 -0
- data/prow.gemspec +2 -0
- data/spec/app_builder/create_spec.rb +56 -0
- data/spec/page_compiler_spec.rb +8 -5
- data/spec/pages_compiler_spec.rb +5 -7
- data/spec/paths_spec.rb +57 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/support/{public/.keep → fixtures/app/.gitkeep} +0 -0
- data/spec/support/{pages.json → fixtures/config/pages.json} +0 -0
- data/spec/support/fixtures/public/.keep +0 -0
- data/spec/support/fixtures/public/stylesheets/.gitkeep +0 -0
- data/spec/support/fixtures/sass/.gitkeep +0 -0
- data/spec/support/{templates → fixtures/templates}/layouts/default.mustache +0 -0
- data/spec/support/{templates → fixtures/templates}/layouts/foo.mustache +0 -0
- data/spec/support/{templates → fixtures/templates}/pages/bar.mustache +0 -0
- data/spec/support/{templates → fixtures/templates}/pages/foo.mustache +0 -0
- data/spec/support/{templates → fixtures/templates}/pages/index.mustache +0 -0
- data/spec/support/fixtures/templates/partials/header.mustache +1 -0
- data/spec/support/fixtures/templates/partials/temp.mustache +0 -0
- data/spec/support/{templates → fixtures/templates}/partials/things/it.mustache +0 -0
- data/spec/template_spec.rb +4 -2
- data/spec/templates_spec.rb +2 -2
- data/spec/watcher_spec.rb +59 -0
- metadata +75 -24
- data/lib/prow/default_paths.rb +0 -19
- data/spec/support/templates/index.mustache +0 -3
- data/spec/support/templates/partials/header.mustache +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d16c875b771c7a9017e14996b1d3d4ba6853cf91
|
4
|
+
data.tar.gz: a1e2b425d7352a81865e1ff27ab9d9cd21e5a0fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe1e5cfce4d03f45e6675d79064f1a2e89625ac65d475e0eed79103ac13dba7a775a82d94ae3e639c35ec7104c0ea98f72e8b410e3200dbcb6665f7d94cdadc0
|
7
|
+
data.tar.gz: fb894f5de8cc2571798f77fab54111ba636eaa4f165a5ce5e1a19b846341edd4c8f4b2fa5e491d3870549de771f60e954f5081b7349d778315797ac26d5b790e
|
data/.gitignore
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Prow
|
2
|
+
module AppBuilder
|
3
|
+
class Create < Struct.new(:path)
|
4
|
+
def perform
|
5
|
+
copy('config.ru')
|
6
|
+
mkdir('public')
|
7
|
+
mkdir('templates')
|
8
|
+
mkdir('config')
|
9
|
+
mkdir('templates/layouts')
|
10
|
+
mkdir('templates/pages')
|
11
|
+
mkdir('templates/partials')
|
12
|
+
copy('config/pages.json')
|
13
|
+
copy_partials
|
14
|
+
mkdir('sass')
|
15
|
+
create_and_move_stylesheets
|
16
|
+
copy_pages_and_layouts
|
17
|
+
end
|
18
|
+
|
19
|
+
def copy_pages_and_layouts
|
20
|
+
copy('templates/layouts/default.mustache')
|
21
|
+
copy('templates/pages/index.mustache')
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_partials
|
25
|
+
ShipdStyle::CopyDirectory.new(app_path + "/templates/partials", "templates").perform
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_and_move_stylesheets
|
29
|
+
copier = ShipdStyle::CopyStylesheets.new(app_path)
|
30
|
+
copier.perform
|
31
|
+
copier.remove_namespace
|
32
|
+
end
|
33
|
+
|
34
|
+
def mkdir(dir)
|
35
|
+
FileUtils.mkdir(app_path + "/" + dir) unless File.exist?(dir)
|
36
|
+
end
|
37
|
+
|
38
|
+
def copy(file_path)
|
39
|
+
FileUtils.cp(templates_path + "/" + file_path, app_path + "/" + file_path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def templates_path
|
43
|
+
File.dirname(__FILE__) + "/templates"
|
44
|
+
end
|
45
|
+
|
46
|
+
def app_path
|
47
|
+
path || `pwd`.chomp
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Prow
|
2
|
+
module AppBuilder
|
3
|
+
class StyleCompiler
|
4
|
+
attr_reader :paths
|
5
|
+
|
6
|
+
def initialize(paths = nil)
|
7
|
+
@paths = paths || Paths.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def perform
|
11
|
+
`compass compile --sass-dir=#{paths.sass} --css-dir=#{paths.stylesheets}`
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!DOCTYPE HTML>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Prow >> {{title}}</title>
|
6
|
+
<link href="/favicon.ico" rel="shortcut icon" type="image/ico">
|
7
|
+
<meta name="viewport" content="initial-scale=1">
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="/stylesheets/all.css">
|
10
|
+
<link href='http://fonts.googleapis.com/css?family=Port+Lligat+Slab' rel='stylesheet' type='text/css'>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<div id="page" class="row">
|
14
|
+
{{> header}}
|
15
|
+
{{> body}}
|
16
|
+
</div>
|
17
|
+
</body>
|
18
|
+
</html>
|
19
|
+
|
20
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class='inner'>
|
2
|
+
<h1>Hello from Prow</h1>
|
3
|
+
|
4
|
+
<p>
|
5
|
+
Whether you are building a one-page app or a static website,
|
6
|
+
Prow is your go-to tool for local development.
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<h4>Getting Started</h4>
|
10
|
+
<p>
|
11
|
+
Congratulations! You have already successfully created a Prow app, and run it!
|
12
|
+
Now it's time to start adding your own content.
|
13
|
+
</p>
|
14
|
+
<ul class='list-style'>
|
15
|
+
<li>Replace this page with one of your own</li>
|
16
|
+
<li>Add new pages</li>
|
17
|
+
<li>Change the CSS by modifying files in the sass directory</li>
|
18
|
+
</ul>
|
19
|
+
</div>
|
20
|
+
|
data/lib/prow/page.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Prow
|
2
|
+
class Page < Struct.new(:config_array)
|
3
|
+
def file_name
|
4
|
+
config_array.first
|
5
|
+
end
|
6
|
+
|
7
|
+
def config
|
8
|
+
config_array.last
|
9
|
+
end
|
10
|
+
|
11
|
+
def layout
|
12
|
+
config['layout'] || 'default'
|
13
|
+
end
|
14
|
+
|
15
|
+
def data
|
16
|
+
config['data'] || {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def name
|
20
|
+
file_name.split('.').first
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/prow/page_compiler.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Prow
|
2
|
-
class PageCompiler < Struct.new(:
|
2
|
+
class PageCompiler < Struct.new(:page, :templates, :compile_dir)
|
3
3
|
def compile
|
4
4
|
File.open(path, 'w+') do |f|
|
5
5
|
f.write(render)
|
@@ -10,24 +10,20 @@ module Prow
|
|
10
10
|
return @renderer if defined?(@renderer)
|
11
11
|
@renderer = Renderer.new
|
12
12
|
@renderer.templates = templates
|
13
|
-
@renderer.page_name = name
|
13
|
+
@renderer.page_name = page.name
|
14
14
|
@renderer
|
15
15
|
end
|
16
16
|
|
17
17
|
def render
|
18
|
-
renderer.render(layout.content, data)
|
18
|
+
renderer.render(layout.content, page.data)
|
19
19
|
end
|
20
20
|
|
21
21
|
def layout
|
22
|
-
templates.layout(
|
23
|
-
end
|
24
|
-
|
25
|
-
def data
|
26
|
-
config['data'] || {}
|
22
|
+
templates.layout(page.layout)
|
27
23
|
end
|
28
24
|
|
29
25
|
def path
|
30
|
-
compile_dir + "/" +
|
26
|
+
compile_dir + "/" + page.file_name
|
31
27
|
end
|
32
28
|
end
|
33
29
|
end
|
data/lib/prow/page_configs.rb
CHANGED
@@ -6,8 +6,14 @@ module Prow
|
|
6
6
|
JSON.parse(File.read(path))
|
7
7
|
end
|
8
8
|
|
9
|
+
def pages_array
|
10
|
+
load['pages'] || []
|
11
|
+
end
|
12
|
+
|
9
13
|
def collection
|
10
|
-
@collection ||=
|
14
|
+
@collection ||= pages_array.map do |config|
|
15
|
+
Page.new(config)
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
def_delegators :collection, :each, :size
|
data/lib/prow/pages_compiler.rb
CHANGED
@@ -1,29 +1,23 @@
|
|
1
1
|
module Prow
|
2
2
|
class PagesCompiler
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :paths
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@templates_path = templates_path || default_paths.templates_path
|
8
|
-
@compile_path = compile_path || default_paths.compile_path
|
5
|
+
def initialize(paths=nil)
|
6
|
+
@paths = paths || Paths.new
|
9
7
|
end
|
10
8
|
|
11
9
|
def compile
|
12
|
-
page_configs.each do |
|
13
|
-
PageCompiler.new(
|
10
|
+
page_configs.each do |page|
|
11
|
+
PageCompiler.new(page, templates, paths.compile).compile
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
17
15
|
def page_configs
|
18
|
-
@page_configs ||= PageConfigs.new(
|
16
|
+
@page_configs ||= PageConfigs.new(paths.pages_config)
|
19
17
|
end
|
20
18
|
|
21
19
|
def templates
|
22
|
-
@templates ||= Templates.new(
|
23
|
-
end
|
24
|
-
|
25
|
-
def default_paths
|
26
|
-
@default_paths ||= DefaultPaths.new
|
20
|
+
@templates ||= Templates.new(paths.templates)
|
27
21
|
end
|
28
22
|
end
|
29
23
|
end
|
data/lib/prow/paths.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Prow
|
2
|
+
class Paths < Struct.new(:source_path, :compile_path)
|
3
|
+
def source
|
4
|
+
source_path || `pwd`.chomp
|
5
|
+
end
|
6
|
+
|
7
|
+
def compile
|
8
|
+
compile_path || source + "/public"
|
9
|
+
end
|
10
|
+
|
11
|
+
[:templates, :sass, :config].each do |path|
|
12
|
+
define_method(path) { composite_path(source, path) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def pages_config
|
16
|
+
config + "/pages.json"
|
17
|
+
end
|
18
|
+
|
19
|
+
def stylesheets
|
20
|
+
composite_path(compile, "/stylesheets")
|
21
|
+
end
|
22
|
+
|
23
|
+
def composite_path(start_path, end_path)
|
24
|
+
"#{start_path}/#{end_path}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/prow/tasks.rb
ADDED
data/lib/prow/version.rb
CHANGED
data/lib/prow/watcher.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Prow
|
2
|
+
class Watcher
|
3
|
+
attr_reader :paths
|
4
|
+
|
5
|
+
def initialize(paths=nil)
|
6
|
+
@paths = paths || Paths.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def start
|
10
|
+
watch_all
|
11
|
+
end
|
12
|
+
|
13
|
+
def stop
|
14
|
+
template_listener.stop
|
15
|
+
end
|
16
|
+
|
17
|
+
def watch_all
|
18
|
+
silence_warnings do
|
19
|
+
template_listener.start
|
20
|
+
sass_listener.start
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def template_listener
|
25
|
+
@template_listener ||= Listen.to(paths.templates) do
|
26
|
+
compile_pages
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def sass_listener
|
31
|
+
@sass_listener ||= Listen.to(paths.sass) do
|
32
|
+
compile_stylesheets
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def compile_pages
|
37
|
+
Prow::PagesCompiler.new(paths).compile
|
38
|
+
end
|
39
|
+
|
40
|
+
def compile_stylesheets
|
41
|
+
Prow::AppBuilder::StyleCompiler.new(paths).perform
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/prow.rb
CHANGED
@@ -1,13 +1,24 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'forwardable'
|
3
|
+
require 'fileutils'
|
3
4
|
|
5
|
+
require 'shipd_style'
|
4
6
|
require 'mustache'
|
7
|
+
require 'listen'
|
8
|
+
|
9
|
+
require "prow/silence_warnings"
|
5
10
|
|
6
11
|
require "prow/version"
|
7
|
-
require "prow/
|
12
|
+
require "prow/paths"
|
13
|
+
require "prow/page"
|
8
14
|
require "prow/page_configs"
|
9
15
|
require "prow/template"
|
10
16
|
require "prow/templates"
|
11
17
|
require "prow/renderer"
|
12
18
|
require "prow/page_compiler"
|
13
19
|
require "prow/pages_compiler"
|
20
|
+
|
21
|
+
require "prow/app_builder/create"
|
22
|
+
require "prow/app_builder/style_compiler"
|
23
|
+
|
24
|
+
require "prow/watcher"
|
data/lib/tasks/prow.rake
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
namespace :prow do
|
2
|
+
desc "Copies over all the files needed for a Prow Application"
|
3
|
+
task :create do
|
4
|
+
Prow::AppBuilder::Create.new.perform
|
5
|
+
Prow::PagesCompiler.new.compile
|
6
|
+
Prow::AppBuilder::StyleCompiler.new.perform
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :compile do
|
10
|
+
desc "Complile all the mustache to ruby using the pages.json file"
|
11
|
+
task :html do
|
12
|
+
Prow::PagesCompiler.new.compile
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Uses compass to compile all the styles sheets in the sass directory"
|
16
|
+
task :css do
|
17
|
+
Prow::AppBuilder::StyleCompiler.new.perform
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Compile html and css"
|
22
|
+
task :compile do
|
23
|
+
Prow::PagesCompiler.new.compile
|
24
|
+
Prow::AppBuilder::StyleCompiler.new.perform
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Runs the app"
|
28
|
+
task :run do
|
29
|
+
`rackup`
|
30
|
+
end
|
31
|
+
end
|
data/prow.gemspec
CHANGED
@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency "shipd_style"
|
32
32
|
spec.add_dependency "mustache"
|
33
|
+
spec.add_dependency "vienna"
|
34
|
+
spec.add_dependency "listen"
|
33
35
|
|
34
36
|
spec.add_development_dependency "bundler", "~> 1.6"
|
35
37
|
spec.add_development_dependency "rspec"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Prow::AppBuilder::Create do
|
4
|
+
let(:creator) { Prow::AppBuilder::Create.new(app_path) }
|
5
|
+
let(:app_path) { File.dirname(__FILE__) + "/../support/fixtures/app" }
|
6
|
+
let(:app_templates_path) { File.dirname(__FILE__) + "/../../lib/prow/app_builder/templates" }
|
7
|
+
|
8
|
+
before { `rm -rf #{app_path}/*` }
|
9
|
+
|
10
|
+
it "should copy the config.ru file" do
|
11
|
+
creator.perform
|
12
|
+
expect(File.exist?(app_path + "/config.ru")).to be(true)
|
13
|
+
expect(File.read(app_path + "/config.ru")).to eq(File.read(app_templates_path + "/config.ru"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should make the public directory" do
|
17
|
+
creator.perform
|
18
|
+
expect(File.exist?(app_path + "/public")).to be(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should make the templates directory with each of its expected subdirectories" do
|
22
|
+
creator.perform
|
23
|
+
expect(File.exist?(app_path + "/templates")).to be(true)
|
24
|
+
expect(File.exist?(app_path + "/templates/layouts")).to be(true)
|
25
|
+
expect(File.exist?(app_path + "/templates/pages")).to be(true)
|
26
|
+
expect(File.exist?(app_path + "/templates/partials")).to be(true)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should copy the pages.json file" do
|
30
|
+
creator.perform
|
31
|
+
expect(File.exist?(app_path + "/config/pages.json")).to be(true)
|
32
|
+
expect(File.read(app_path + "/config/pages.json")).to eq(File.read(app_templates_path + "/config/pages.json"))
|
33
|
+
end
|
34
|
+
|
35
|
+
it "adds a sample layout and home page" do
|
36
|
+
creator.perform
|
37
|
+
expect(File.exist?(app_path + "/templates/layouts/default.mustache")).to be(true)
|
38
|
+
expect(File.exist?(app_path + "/templates/pages/index.mustache")).to be(true)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "copies over shipd style sass sheets" do
|
42
|
+
creator.perform
|
43
|
+
expect(File.exist?(app_path + "/sass/mobile")).to be(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "renames the base style sheets to not include shipd" do
|
47
|
+
creator.perform
|
48
|
+
expect(File.exist?(app_path + "/sass/shipd-mobile.scss")).not_to be(true)
|
49
|
+
expect(File.exist?(app_path + "/sass/mobile.scss")).to be(true)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "copies over partial templates from shipd_style" do
|
53
|
+
creator.perform
|
54
|
+
expect(File.exist?(app_path + "/templates/partials/carousel.mustache")).to be(true)
|
55
|
+
end
|
56
|
+
end
|
data/spec/page_compiler_spec.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Prow::PageCompiler do
|
4
|
-
let(:compiler) { Prow::PageCompiler.new(
|
5
|
-
let(:
|
4
|
+
let(:compiler) { Prow::PageCompiler.new(page, templates, compile_dir) }
|
5
|
+
let(:page) { Prow::Page.new([name, config]) }
|
6
|
+
let(:paths) { Prow::Paths.new(File.dirname(__FILE__) + "/support/fixtures") }
|
7
|
+
|
8
|
+
let(:full_configs) { JSON.parse(File.read(paths.pages_config))['pages'] }
|
6
9
|
let(:config) { full_configs[name]}
|
7
10
|
let(:name) { 'index.html' }
|
8
|
-
let(:templates) { Prow::Templates.new(
|
9
|
-
let(:compile_dir) {
|
10
|
-
let(:file_path) {
|
11
|
+
let(:templates) { Prow::Templates.new(paths.templates) }
|
12
|
+
let(:compile_dir) { paths.compile }
|
13
|
+
let(:file_path) { paths.compile + "/index.html" }
|
11
14
|
|
12
15
|
before { File.delete(file_path) if File.exist?(file_path) }
|
13
16
|
|
data/spec/pages_compiler_spec.rb
CHANGED
@@ -1,21 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Prow::PagesCompiler do
|
4
|
-
let(:pages) { Prow::PagesCompiler.new(
|
5
|
-
let(:
|
6
|
-
let(:templates_path) { File.dirname(__FILE__) + "/support/templates" }
|
7
|
-
let(:public_path) { File.dirname(__FILE__) + "/support/public" }
|
4
|
+
let(:pages) { Prow::PagesCompiler.new(paths) }
|
5
|
+
let(:paths) { Prow::Paths.new(File.dirname(__FILE__) + "/support/fixtures") }
|
8
6
|
|
9
7
|
describe '#compile' do
|
10
8
|
before { pages.compile }
|
11
9
|
|
12
10
|
it "compiles entries in pages.json" do
|
13
|
-
expect(File.exist?(
|
14
|
-
expect(File.exist?(
|
11
|
+
expect(File.exist?(paths.compile + "/index.html")).to be(true)
|
12
|
+
expect(File.exist?(paths.compile + "/foo.html")).to be(true)
|
15
13
|
end
|
16
14
|
|
17
15
|
it "does not compile pages that are not included in pages.json" do
|
18
|
-
expect(File.exist?(
|
16
|
+
expect(File.exist?(paths.compile + "/bar.html")).to be(false)
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
data/spec/paths_spec.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Prow::Paths do
|
4
|
+
let(:paths) { Prow::Paths.new }
|
5
|
+
let(:source_path) { `pwd`.chomp }
|
6
|
+
|
7
|
+
context 'when initialized with no paths' do
|
8
|
+
it "uses pwd for the source directory" do
|
9
|
+
expect(paths.source).to eq(`pwd`.chomp)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "uses public in pwd in the compile directory" do
|
13
|
+
expect(paths.compile).to eq(paths.source + "/public")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when initialized with a source path' do
|
18
|
+
let(:source_path) { File.dirname(__FILE__) + "/support" }
|
19
|
+
let(:paths) { Prow::Paths.new(source_path) }
|
20
|
+
|
21
|
+
it "uses that for the source_directory" do
|
22
|
+
expect(paths.source).to eq(source_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "uses the source path to construct a compile path" do
|
26
|
+
expect(paths.compile).to eq(source_path + "/public")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when both paths are initialized' do
|
31
|
+
let(:compile_path) { File.dirname(__FILE__) + "/support/public" }
|
32
|
+
let(:paths) { Prow::Paths.new(source_path, compile_path) }
|
33
|
+
|
34
|
+
it "uses what it is given" do
|
35
|
+
expect(paths.source).to eq(source_path)
|
36
|
+
expect(paths.compile).to eq(compile_path)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'composite paths' do
|
41
|
+
it "constructs a templates path from the source directory" do
|
42
|
+
expect(paths.templates).to eq(source_path + "/templates")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "contructs a sass path from the source directory" do
|
46
|
+
expect(paths.sass). to eq(source_path + "/sass")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "constructs a configuration directory from the source" do
|
50
|
+
expect(paths.config). to eq(source_path + "/config")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "constructs a pages_config from the config path" do
|
54
|
+
expect(paths.pages_config).to eq(source_path + "/config/pages.json")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require_relative "../lib/prow"
|
2
|
-
|
3
|
-
#require 'nokogiri'
|
2
|
+
$VERBOSE = nil # to silence warnings from Celluloid
|
4
3
|
|
5
4
|
RSpec.configure do |config|
|
5
|
+
#config.full_backtrace = true
|
6
|
+
|
6
7
|
config.expect_with :rspec do |expectations|
|
7
8
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
8
9
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello Header World
|
File without changes
|
File without changes
|
data/spec/template_spec.rb
CHANGED
@@ -3,14 +3,16 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe Prow::Template do
|
4
4
|
let(:template) { Prow::Template.new(path, templates_path) }
|
5
5
|
let(:path) { templates_path + "/layouts/default.mustache" }
|
6
|
-
let(:templates_path) { File.dirname(__FILE__) + "/support/templates" }
|
6
|
+
let(:templates_path) { File.dirname(__FILE__) + "/support/fixtures/templates" }
|
7
7
|
|
8
8
|
it "derives the type from the first directory name" do
|
9
9
|
expect(template.type).to eq("layouts")
|
10
10
|
end
|
11
11
|
|
12
12
|
it "returns lazy the template content" do
|
13
|
-
|
13
|
+
silence_warnings do
|
14
|
+
expect(template.instance_variable_get('@content')).to eq(nil)
|
15
|
+
end
|
14
16
|
expect(template.content).to eq(File.read(path))
|
15
17
|
expect(template.instance_variable_get('@content')).not_to eq(nil)
|
16
18
|
end
|
data/spec/templates_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Prow::Templates do
|
4
4
|
let(:templates) { Prow::Templates.new(templates_path) }
|
5
|
-
let(:templates_path) { File.dirname(__FILE__) + "/support/templates" }
|
5
|
+
let(:templates_path) { File.dirname(__FILE__) + "/support/fixtures/templates" }
|
6
6
|
|
7
7
|
describe '#layout' do
|
8
8
|
it "returns layouts via name" do
|
@@ -29,7 +29,7 @@ RSpec.describe Prow::Templates do
|
|
29
29
|
|
30
30
|
describe '#partials' do
|
31
31
|
it "returns all of the partials" do
|
32
|
-
expect(templates.partials.size).to
|
32
|
+
expect(templates.partials.size).to be > 2
|
33
33
|
expect(templates.partials.map(&:name)).to include("things/it", "header")
|
34
34
|
end
|
35
35
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Prow::Watcher do
|
4
|
+
let(:runner) { Prow::Watcher.new(paths) }
|
5
|
+
let(:paths) { Prow::Paths.new(File.dirname(__FILE__) + "/support/fixtures" )}
|
6
|
+
|
7
|
+
before do
|
8
|
+
# create some initial content
|
9
|
+
Prow::PagesCompiler.new(paths).compile
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
runner.stop
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#start' do
|
17
|
+
context 'when templates change' do
|
18
|
+
after do
|
19
|
+
File.open(header_template_path, 'w') do |f|
|
20
|
+
f.write(original_header_content)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:header_template_path) { paths.templates + "/partials/header.mustache" }
|
25
|
+
let(:new_header_content) { "Yo, header!" }
|
26
|
+
let(:original_header_content) { "Hello Header World\n" }
|
27
|
+
|
28
|
+
it "regenerates pages" do
|
29
|
+
runner.start
|
30
|
+
File.open(header_template_path, 'w') do |f|
|
31
|
+
f.write(new_header_content)
|
32
|
+
end
|
33
|
+
sleep 1
|
34
|
+
expect(File.read(paths.compile + "/index.html")).to include(new_header_content)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when the pages.json changes' do
|
39
|
+
it "regenerates pages"
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when sass files change' do
|
43
|
+
let(:scss_path) { paths.sass + "/foo.scss" }
|
44
|
+
let(:stylesheet_path) { paths.compile + "/stylesheets/foo.css" }
|
45
|
+
|
46
|
+
before do
|
47
|
+
File.delete(scss_path) if File.exist?(scss_path)
|
48
|
+
File.delete(stylesheet_path) if File.exist?(stylesheet_path)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "watches sass files and regenerates stylesheets" do
|
52
|
+
runner.start
|
53
|
+
File.open(scss_path, 'w') {|f| f.write("body {background: red;}") }
|
54
|
+
sleep 1
|
55
|
+
expect(File.exist?(stylesheet_path)).to be(true)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kane Baccigalupi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shipd_style
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: vienna
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: listen
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bundler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,30 +129,47 @@ files:
|
|
101
129
|
- README.md
|
102
130
|
- Rakefile
|
103
131
|
- lib/prow.rb
|
104
|
-
- lib/prow/
|
132
|
+
- lib/prow/app_builder/create.rb
|
133
|
+
- lib/prow/app_builder/style_compiler.rb
|
134
|
+
- lib/prow/app_builder/templates/config.ru
|
135
|
+
- lib/prow/app_builder/templates/config/pages.json
|
136
|
+
- lib/prow/app_builder/templates/templates/layouts/default.mustache
|
137
|
+
- lib/prow/app_builder/templates/templates/pages/index.mustache
|
138
|
+
- lib/prow/page.rb
|
105
139
|
- lib/prow/page_compiler.rb
|
106
140
|
- lib/prow/page_configs.rb
|
107
141
|
- lib/prow/pages_compiler.rb
|
142
|
+
- lib/prow/paths.rb
|
108
143
|
- lib/prow/renderer.rb
|
144
|
+
- lib/prow/silence_warnings.rb
|
145
|
+
- lib/prow/tasks.rb
|
109
146
|
- lib/prow/template.rb
|
110
147
|
- lib/prow/templates.rb
|
111
148
|
- lib/prow/version.rb
|
149
|
+
- lib/prow/watcher.rb
|
150
|
+
- lib/tasks/prow.rake
|
112
151
|
- prow.gemspec
|
152
|
+
- spec/app_builder/create_spec.rb
|
113
153
|
- spec/page_compiler_spec.rb
|
114
154
|
- spec/pages_compiler_spec.rb
|
155
|
+
- spec/paths_spec.rb
|
115
156
|
- spec/spec_helper.rb
|
116
|
-
- spec/support/
|
117
|
-
- spec/support/
|
118
|
-
- spec/support/
|
119
|
-
- spec/support/
|
120
|
-
- spec/support/
|
121
|
-
- spec/support/templates/
|
122
|
-
- spec/support/templates/
|
123
|
-
- spec/support/templates/pages/
|
124
|
-
- spec/support/templates/
|
125
|
-
- spec/support/templates/
|
157
|
+
- spec/support/fixtures/app/.gitkeep
|
158
|
+
- spec/support/fixtures/config/pages.json
|
159
|
+
- spec/support/fixtures/public/.keep
|
160
|
+
- spec/support/fixtures/public/stylesheets/.gitkeep
|
161
|
+
- spec/support/fixtures/sass/.gitkeep
|
162
|
+
- spec/support/fixtures/templates/layouts/default.mustache
|
163
|
+
- spec/support/fixtures/templates/layouts/foo.mustache
|
164
|
+
- spec/support/fixtures/templates/pages/bar.mustache
|
165
|
+
- spec/support/fixtures/templates/pages/foo.mustache
|
166
|
+
- spec/support/fixtures/templates/pages/index.mustache
|
167
|
+
- spec/support/fixtures/templates/partials/header.mustache
|
168
|
+
- spec/support/fixtures/templates/partials/temp.mustache
|
169
|
+
- spec/support/fixtures/templates/partials/things/it.mustache
|
126
170
|
- spec/template_spec.rb
|
127
171
|
- spec/templates_spec.rb
|
172
|
+
- spec/watcher_spec.rb
|
128
173
|
homepage: https://github.com/shipd/prow
|
129
174
|
licenses:
|
130
175
|
- MIT
|
@@ -145,23 +190,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
190
|
version: '0'
|
146
191
|
requirements: []
|
147
192
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.4.3
|
149
194
|
signing_key:
|
150
195
|
specification_version: 4
|
151
196
|
summary: Prow is a front end development framework, that can also server static websites
|
152
197
|
test_files:
|
198
|
+
- spec/app_builder/create_spec.rb
|
153
199
|
- spec/page_compiler_spec.rb
|
154
200
|
- spec/pages_compiler_spec.rb
|
201
|
+
- spec/paths_spec.rb
|
155
202
|
- spec/spec_helper.rb
|
156
|
-
- spec/support/
|
157
|
-
- spec/support/
|
158
|
-
- spec/support/
|
159
|
-
- spec/support/
|
160
|
-
- spec/support/
|
161
|
-
- spec/support/templates/
|
162
|
-
- spec/support/templates/
|
163
|
-
- spec/support/templates/pages/
|
164
|
-
- spec/support/templates/
|
165
|
-
- spec/support/templates/
|
203
|
+
- spec/support/fixtures/app/.gitkeep
|
204
|
+
- spec/support/fixtures/config/pages.json
|
205
|
+
- spec/support/fixtures/public/.keep
|
206
|
+
- spec/support/fixtures/public/stylesheets/.gitkeep
|
207
|
+
- spec/support/fixtures/sass/.gitkeep
|
208
|
+
- spec/support/fixtures/templates/layouts/default.mustache
|
209
|
+
- spec/support/fixtures/templates/layouts/foo.mustache
|
210
|
+
- spec/support/fixtures/templates/pages/bar.mustache
|
211
|
+
- spec/support/fixtures/templates/pages/foo.mustache
|
212
|
+
- spec/support/fixtures/templates/pages/index.mustache
|
213
|
+
- spec/support/fixtures/templates/partials/header.mustache
|
214
|
+
- spec/support/fixtures/templates/partials/temp.mustache
|
215
|
+
- spec/support/fixtures/templates/partials/things/it.mustache
|
166
216
|
- spec/template_spec.rb
|
167
217
|
- spec/templates_spec.rb
|
218
|
+
- spec/watcher_spec.rb
|
data/lib/prow/default_paths.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Prow
|
2
|
-
class DefaultPaths
|
3
|
-
def base_path
|
4
|
-
File.dirname(__FILE__) + "/.."
|
5
|
-
end
|
6
|
-
|
7
|
-
def config_path
|
8
|
-
"#{base_path}/pages.json"
|
9
|
-
end
|
10
|
-
|
11
|
-
def templates_path
|
12
|
-
"#{base_path}/templates"
|
13
|
-
end
|
14
|
-
|
15
|
-
def compiled_path
|
16
|
-
"#{base_path}/public"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<div id='header'>Hello Header World</div>
|