pieces 0.3.0 → 0.3.1

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: fc6517c3ea0a591bb7a6deafc161937aa4eb5be4
4
- data.tar.gz: 04508f264f041cd126949f8c18e583713dc1e0e0
3
+ metadata.gz: 0e3737739ad55be3e3b237b47fc48e4adaa3d590
4
+ data.tar.gz: 28d783c2cb5b7bd3707c2d1ea87b8ef71d439f92
5
5
  SHA512:
6
- metadata.gz: da143a39a6e03b46ae92e8770c27838b34513438a8bcedeb60e838434beb8d2ef2723f1a973dd152b7a71ea720872d8b7c88ad39ef0bf75d1f81c2809910e874
7
- data.tar.gz: 5a2d32331d1093236b0c32be2a3993e0669f028c6bdb8a3be46f3051af9081d6b7ed3d74afa5fc8e4e372537d89c4f4ab8cf4292125e78d14186c7589e662ee1
6
+ metadata.gz: c8e843d3a7bd8d4a05054a03c78dc1e680bdb272fdd5f9243f9804fca80feba09ab079e6050233b16d5f6812d367c0fb58109b2221ea4e69c9d9b3e7443e6b6a
7
+ data.tar.gz: 98b150e43dab7a0b396232712eb97fdaa92dfff8bf9ecf93f17c77ce862161cd2167c5b318b26272c6b37714c8dfaef13337680c7215fbb1b7310983c87a942e
data/.gitignore CHANGED
@@ -1,10 +1,10 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
10
- /example/build/
9
+ build/
10
+ Gemfile.lock
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Pieces
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/pieces.svg)](http://badge.fury.io/rb/pieces)
3
4
  [![Build Status](https://travis-ci.org/drpheltright/pieces.svg)](https://travis-ci.org/drpheltright/pieces)
4
5
  [![Code Climate](https://codeclimate.com/github/drpheltright/pieces/badges/gpa.svg)](https://codeclimate.com/github/drpheltright/pieces)
5
6
  [![Test Coverage](https://codeclimate.com/github/drpheltright/pieces/badges/coverage.svg)](https://codeclimate.com/github/drpheltright/pieces/coverage)
@@ -76,10 +77,11 @@ With these three files in place and having installed pieces on your system
76
77
  (`gem install pieces`) you can run:
77
78
 
78
79
  ```
79
- pieces build
80
+ pieces server
80
81
  ```
81
82
 
82
- This will build HTML and CSS into `build/`.
83
+ Now visit [http://localhost:8080](http://localhost:8080) to see your site! If
84
+ you change your `config/routes.yml` or views they will be reflected on the site.
83
85
 
84
86
  ## Create new static site
85
87
 
@@ -99,7 +101,19 @@ Once you've built the pieces and routes for your site all you have to do is run:
99
101
  pieces build
100
102
  ```
101
103
 
102
- Make sure you run this from your pieces directory!
104
+ Your site will be built into `build/` directory. You can then use these HTML
105
+ files for your site.
106
+
107
+ Whilst developing you won't want to keep running `pieces build`. Pieces comes
108
+ with a server inbuilt that reloads everytime you make a change.
109
+
110
+ To run it:
111
+
112
+ ```
113
+ pieces server
114
+ ```
115
+
116
+ Now visit [http://localhost:8080](http://localhost:8080) in your browser.
103
117
 
104
118
  ## Configuration
105
119
 
data/lib/pieces.rb CHANGED
@@ -2,6 +2,7 @@ require 'pieces/compilers/route_compiler'
2
2
  require 'pieces/compilers/style_compiler'
3
3
  require 'pieces/builder'
4
4
  require 'pieces/generator'
5
+ require 'pieces/server'
5
6
  require 'pieces/tilt_extension'
6
7
  require 'pieces/version'
7
8
 
data/lib/pieces/cli.rb CHANGED
@@ -17,7 +17,15 @@ module Pieces
17
17
  puts 'done.'
18
18
  end
19
19
 
20
- map %w[--version -v] => :version
20
+ map %w(s) => :server
21
+
22
+ desc 'server DIR', 'serve application in DIR'
23
+ def server(path = Dir.pwd)
24
+ puts "Serving pieces from #{path}/build... "
25
+ Pieces::Server.start(path: path)
26
+ end
27
+
28
+ map %w(--version -v) => :version
21
29
 
22
30
  desc '--version', 'get pieces version'
23
31
  def version
@@ -0,0 +1,52 @@
1
+ require 'rack'
2
+ require 'listen'
3
+
4
+ module Pieces
5
+ class Server < Rack::Server
6
+ attr_reader :path
7
+
8
+ def initialize(options)
9
+ @path = options[:path]
10
+ super
11
+ end
12
+
13
+ def start
14
+ build_pieces
15
+ listener.start
16
+ super
17
+ end
18
+
19
+ private
20
+
21
+ def app
22
+ files = files_to_serve(path)
23
+ build_path = "#{path}/build"
24
+
25
+ Rack::Builder.new do
26
+ use Rack::Reloader
27
+
28
+ use Rack::Static, urls: files,
29
+ root: build_path,
30
+ index: 'index.html'
31
+
32
+ run Proc.new { |env| [404, {}, ['Not found']] }
33
+ end.to_app
34
+ end
35
+
36
+ def build_pieces
37
+ Pieces::Builder.build(path: path)
38
+ end
39
+
40
+ def listener
41
+ Listen.to("#{path}/config/", "#{path}/app/views/") do
42
+ print "Rebuilding #{path}... "
43
+ build_pieces
44
+ puts 'done.'
45
+ end
46
+ end
47
+
48
+ def files_to_serve(path)
49
+ Dir["#{path}/build/**/*"].map { |file| file.sub("#{path}/build", '') }
50
+ end
51
+ end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Pieces
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
data/pieces.gemspec CHANGED
@@ -16,8 +16,10 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = ['pieces']
17
17
  spec.require_paths = ['lib']
18
18
 
19
- spec.add_dependency 'tilt', '~> 2.0.1'
20
- spec.add_dependency 'thor', '~> 0.19.1'
19
+ spec.add_dependency 'tilt', '~> 2.0.1'
20
+ spec.add_dependency 'thor', '~> 0.19.1'
21
+ spec.add_dependency 'rack', '~> 1.6.1'
22
+ spec.add_dependency 'listen', '~> 3.0.3'
21
23
 
22
24
  spec.add_development_dependency 'bundler'
23
25
  spec.add_development_dependency 'codeclimate-test-reporter'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pieces
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Morton
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.19.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: listen
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.3
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -158,6 +186,7 @@ files:
158
186
  - lib/pieces/compilers/route_compiler.rb
159
187
  - lib/pieces/compilers/style_compiler.rb
160
188
  - lib/pieces/generator.rb
189
+ - lib/pieces/server.rb
161
190
  - lib/pieces/tilt_extension.rb
162
191
  - lib/pieces/version.rb
163
192
  - lib/tilt/css.rb