pieces 0.3.0 → 0.3.1
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 +2 -2
- data/README.md +17 -3
- data/lib/pieces.rb +1 -0
- data/lib/pieces/cli.rb +9 -1
- data/lib/pieces/server.rb +52 -0
- data/lib/pieces/version.rb +1 -1
- data/pieces.gemspec +4 -2
- metadata +30 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0e3737739ad55be3e3b237b47fc48e4adaa3d590
         | 
| 4 | 
            +
              data.tar.gz: 28d783c2cb5b7bd3707c2d1ea87b8ef71d439f92
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c8e843d3a7bd8d4a05054a03c78dc1e680bdb272fdd5f9243f9804fca80feba09ab079e6050233b16d5f6812d367c0fb58109b2221ea4e69c9d9b3e7443e6b6a
         | 
| 7 | 
            +
              data.tar.gz: 98b150e43dab7a0b396232712eb97fdaa92dfff8bf9ecf93f17c77ce862161cd2167c5b318b26272c6b37714c8dfaef13337680c7215fbb1b7310983c87a942e
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            # Pieces
         | 
| 2 2 |  | 
| 3 | 
            +
            [](http://badge.fury.io/rb/pieces)
         | 
| 3 4 | 
             
            [](https://travis-ci.org/drpheltright/pieces)
         | 
| 4 5 | 
             
            [](https://codeclimate.com/github/drpheltright/pieces)
         | 
| 5 6 | 
             
            [](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  | 
| 80 | 
            +
            pieces server
         | 
| 80 81 | 
             
            ```
         | 
| 81 82 |  | 
| 82 | 
            -
             | 
| 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 | 
            -
             | 
| 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
    
    
    
        data/lib/pieces/cli.rb
    CHANGED
    
    | @@ -17,7 +17,15 @@ module Pieces | |
| 17 17 | 
             
                  puts 'done.'
         | 
| 18 18 | 
             
                end
         | 
| 19 19 |  | 
| 20 | 
            -
                map %w | 
| 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
         | 
    
        data/lib/pieces/version.rb
    CHANGED
    
    
    
        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', | 
| 20 | 
            -
              spec.add_dependency 'thor', | 
| 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. | 
| 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
         |