usmu 0.3.4-java → 0.4.0-java
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/CHANGELOG.md +8 -0
 - data/lib/usmu.rb +12 -0
 - data/lib/usmu/plugin/core.rb +17 -0
 - data/lib/usmu/ui/console.rb +1 -0
 - data/lib/usmu/ui/rack_server.rb +41 -0
 - data/lib/usmu/version.rb +1 -1
 - data/spec/spec_helper.rb +2 -0
 - data/usmu.gemspec +1 -0
 - metadata +17 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 736e52d9dd2dbf1b4887ebfcf2b18e87c0cd3fc5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 95c4b21ba16f9a240449c9e17a0aeb28985390cf
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ecf996f522a04839ff079909e0b92240ffe7519ab242995164247712cc667f50c97f6c416266743452f700971258c7621bc24513a64f8660094d726563ff8553
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a71ee92f2fb6c51be007df21de215819430a7a2987ccad1388460d394273e8e7808a5c6f89f883df480fa2e55338c8805665734f0d2c9f8982d6405648e97201
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Usmu Change Log
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## 0.4.0
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Matthew Scharley <matt.scharley@gmail.com>
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            * Bump to 0.4.0.dev for further dev (32596fe063dfb0452098b0bcac7d97f57ee772a5)
         
     | 
| 
      
 8 
     | 
    
         
            +
            * Ensure that loggers have the right functions available (df1c685c9ee7f3e4070351700d0ec28d999bc345)
         
     | 
| 
      
 9 
     | 
    
         
            +
            * [#25] Include a Rack app for viewing site dynamically (964486386bfa6325f191a44be0eb301ce5d200be)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       3 
11 
     | 
    
         
             
            ## 0.3.4
         
     | 
| 
       4 
12 
     | 
    
         | 
| 
       5 
13 
     | 
    
         
             
            Matthew Scharley <matt.scharley@gmail.com>
         
     | 
    
        data/lib/usmu.rb
    CHANGED
    
    | 
         @@ -70,6 +70,18 @@ module Usmu 
     | 
|
| 
       70 
70 
     | 
    
         
             
              def self.plugins
         
     | 
| 
       71 
71 
     | 
    
         
             
                @plugins ||= Usmu::Plugin.new
         
     | 
| 
       72 
72 
     | 
    
         
             
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              def self.load_lazy_tilt_modules
         
     | 
| 
      
 75 
     | 
    
         
            +
                # There be magic here. Not nice, but gets the job done. Tilt's data structure here is a little unusual.
         
     | 
| 
      
 76 
     | 
    
         
            +
                Tilt.default_mapping.lazy_map.map {|pair| pair[1]}.map {|i| i.map {|j| j[1]}}.flatten.uniq.each do |f|
         
     | 
| 
      
 77 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 78 
     | 
    
         
            +
                    require f
         
     | 
| 
      
 79 
     | 
    
         
            +
                    @log.debug("Loaded #{f}")
         
     | 
| 
      
 80 
     | 
    
         
            +
                  rescue LoadError => e
         
     | 
| 
      
 81 
     | 
    
         
            +
                    @log.debug("Failed to load #{f}: #{e.inspect}")
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
                end
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
       73 
85 
     | 
    
         
             
            end
         
     | 
| 
       74 
86 
     | 
    
         | 
| 
       75 
87 
     | 
    
         
             
            %W{
         
     | 
    
        data/lib/usmu/plugin/core.rb
    CHANGED
    
    | 
         @@ -28,6 +28,12 @@ module Usmu 
     | 
|
| 
       28 
28 
     | 
    
         
             
                      command.description = 'Initialise a new website in the given path, or the current directory if none given.'
         
     | 
| 
       29 
29 
     | 
    
         
             
                      command.action &method(:command_init)
         
     | 
| 
       30 
30 
     | 
    
         
             
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    c.command(:serve) do |command|
         
     | 
| 
      
 33 
     | 
    
         
            +
                      command.syntax = 'usmu server'
         
     | 
| 
      
 34 
     | 
    
         
            +
                      command.description = 'Serve files processed files directly. This won\'t update files on disk, but you will be able to view your website as rendered.'
         
     | 
| 
      
 35 
     | 
    
         
            +
                      command.action &method(:command_serve)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    end
         
     | 
| 
       31 
37 
     | 
    
         
             
                  end
         
     | 
| 
       32 
38 
     | 
    
         | 
| 
       33 
39 
     | 
    
         
             
                  # Command to generate a website.
         
     | 
| 
         @@ -59,6 +65,17 @@ module Usmu 
     | 
|
| 
       59 
65 
     | 
    
         
             
                    Dir["#{from}/**/{*,.??*}"].each {|f| init_copy_file(from, path, f) }
         
     | 
| 
       60 
66 
     | 
    
         
             
                  end
         
     | 
| 
       61 
67 
     | 
    
         | 
| 
      
 68 
     | 
    
         
            +
                  def command_serve(args, options)
         
     | 
| 
      
 69 
     | 
    
         
            +
                    configuration = @ui.configuration
         
     | 
| 
      
 70 
     | 
    
         
            +
                    @log.info('Starting webserver...')
         
     | 
| 
      
 71 
     | 
    
         
            +
                    require 'rack'
         
     | 
| 
      
 72 
     | 
    
         
            +
                    require 'usmu/ui/rack_server'
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    Rack::Handler::WEBrick.run Ui::RackServer.new(configuration),
         
     | 
| 
      
 75 
     | 
    
         
            +
                                               host: configuration['serve', 'host', default: '0.0.0.0'],
         
     | 
| 
      
 76 
     | 
    
         
            +
                                               port: configuration['serve', 'port', default: 8080]
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
       62 
79 
     | 
    
         
             
                  private
         
     | 
| 
       63 
80 
     | 
    
         | 
| 
       64 
81 
     | 
    
         
             
                  # Helper to copy a file.
         
     | 
    
        data/lib/usmu/ui/console.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            module Usmu
         
     | 
| 
      
 3 
     | 
    
         
            +
              module Ui
         
     | 
| 
      
 4 
     | 
    
         
            +
                class RackServer
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def initialize(configuration)
         
     | 
| 
      
 6 
     | 
    
         
            +
                    @log = Logging.logger[self]
         
     | 
| 
      
 7 
     | 
    
         
            +
                    @generator = SiteGenerator.new(configuration)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @configuration = configuration
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @index = configuration['serve', 'index', default: 'index.html']
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def call(env)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    path = env['PATH_INFO'][1...env['PATH_INFO'].length]
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @log.info "Received a request for: #{path}"
         
     | 
| 
      
 15 
     | 
    
         
            +
                    path = File.join(path, @index) if File.directory? File.join(@configuration.source_path, path)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    path = path[1...path.length] if path[0] == '/'
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @log.info "Serving: #{path}"
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    valid = @generator.renderables.select {|r| r.output_filename == path }
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    if valid.length > 0
         
     | 
| 
      
 22 
     | 
    
         
            +
                      page = valid[0]
         
     | 
| 
      
 23 
     | 
    
         
            +
                      type = case page.output_filename[page.output_filename.rindex('.')...page.output_filename.length]
         
     | 
| 
      
 24 
     | 
    
         
            +
                               when '.html', '.php'
         
     | 
| 
      
 25 
     | 
    
         
            +
                                 'text/html'
         
     | 
| 
      
 26 
     | 
    
         
            +
                               when '.css'
         
     | 
| 
      
 27 
     | 
    
         
            +
                                 'text/css'
         
     | 
| 
      
 28 
     | 
    
         
            +
                               when '.js'
         
     | 
| 
      
 29 
     | 
    
         
            +
                                 'text/javascript'
         
     | 
| 
      
 30 
     | 
    
         
            +
                               else
         
     | 
| 
      
 31 
     | 
    
         
            +
                                 'text/plain'
         
     | 
| 
      
 32 
     | 
    
         
            +
                             end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                      ['200', {'Content-Type' => type}, [page.render]]
         
     | 
| 
      
 35 
     | 
    
         
            +
                    else
         
     | 
| 
      
 36 
     | 
    
         
            +
                      ['404', {'Content-Type' => 'text/html'}, ['<!DOCTYPE html><h1>File not found.</h1>']]
         
     | 
| 
      
 37 
     | 
    
         
            +
                    end
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/usmu/version.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -8,6 +8,8 @@ require 'logging' 
     | 
|
| 
       8 
8 
     | 
    
         
             
            require 'rspec/logging_helper'
         
     | 
| 
       9 
9 
     | 
    
         
             
            require 'timeout'
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
            Logging.init :debug, :info, :success, :warn, :error, :fatal
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       11 
13 
     | 
    
         
             
            # This file was generated by the `rspec --init` command. Conventionally, all
         
     | 
| 
       12 
14 
     | 
    
         
             
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         
     | 
| 
       13 
15 
     | 
    
         
             
            # The generated `.rspec` file contains `--require spec_helper` which will cause this
         
     | 
    
        data/usmu.gemspec
    CHANGED
    
    | 
         @@ -25,6 +25,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
              spec.add_dependency 'slim', '~> 3.0'
         
     | 
| 
       27 
27 
     | 
    
         
             
              spec.add_dependency 'tilt', '~> 2.0'
         
     | 
| 
      
 28 
     | 
    
         
            +
              spec.add_dependency 'rack', '~> 1.6'
         
     | 
| 
       28 
29 
     | 
    
         
             
              spec.add_dependency 'deep_merge', '~> 1.0'
         
     | 
| 
       29 
30 
     | 
    
         
             
              spec.add_dependency 'commander', '~> 4.2'
         
     | 
| 
       30 
31 
     | 
    
         
             
              spec.add_dependency 'logging', '~> 1.8'
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: usmu
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: java
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Matthew Scharley
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-01- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-01-18 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: slim
         
     | 
| 
         @@ -38,6 +38,20 @@ dependencies: 
     | 
|
| 
       38 
38 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
40 
     | 
    
         
             
                    version: '2.0'
         
     | 
| 
      
 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'
         
     | 
| 
      
 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'
         
     | 
| 
       41 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
56 
     | 
    
         
             
              name: deep_merge
         
     | 
| 
       43 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -259,6 +273,7 @@ files: 
     | 
|
| 
       259 
273 
     | 
    
         
             
            - lib/usmu/template/static_file.rb
         
     | 
| 
       260 
274 
     | 
    
         
             
            - lib/usmu/ui.rb
         
     | 
| 
       261 
275 
     | 
    
         
             
            - lib/usmu/ui/console.rb
         
     | 
| 
      
 276 
     | 
    
         
            +
            - lib/usmu/ui/rack_server.rb
         
     | 
| 
       262 
277 
     | 
    
         
             
            - lib/usmu/version.rb
         
     | 
| 
       263 
278 
     | 
    
         
             
            - share/init-site/.gitignore
         
     | 
| 
       264 
279 
     | 
    
         
             
            - share/init-site/Gemfile
         
     |