japr 0.3.2 → 0.4.0
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 +7 -0
- data/README.md +8 -8
- data/lib/japr.rb +2 -1
- data/lib/japr/converter.rb +7 -0
- data/lib/japr/extensions/liquid/liquid_block_extensions.rb +27 -22
- data/lib/japr/pipeline.rb +78 -75
- data/lib/japr/template.rb +8 -0
- data/lib/japr/templates/css_tag_template.rb +4 -1
- data/lib/japr/templates/javascript_tag_template.rb +4 -1
- data/lib/japr/templates/template_helper.rb +14 -0
- data/lib/japr/version.rb +1 -1
- metadata +44 -52
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 87d28ef23acc5a0f92c4cd7d583b6d2fce8c8704
         | 
| 4 | 
            +
              data.tar.gz: 5b09118929232fd3f5c18409c702781f67a39d46
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 95e903e0e43c4491dcde84b0a463c668e6ec4085523f9064e7e76eabafef913e8c312c5188a1dbb72396595e33f440adb92f85d4aa40a16e5e1b9e265f9ee89b
         | 
| 7 | 
            +
              data.tar.gz: 81e8bbbc83d1f671906f3c4861c4a16645fac86f54347a51277db7af63ec070606ba35d193d918a4a509472af63e8b0e5fce0be63c2b40a65357b9cdbfc2abe9
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            # JAPR (Jekyll Asset Pipeline Reborn)
         | 
| 2 2 |  | 
| 3 3 | 
             
            [](http://badge.fury.io/rb/japr)
         | 
| 4 | 
            -
            [](https://travis-ci.org/janosrusiczki/japr)
         | 
| 5 | 
            +
            [](https://coveralls.io/r/janosrusiczki/japr?branch=master)
         | 
| 6 | 
            +
            [](https://gemnasium.com/janosrusiczki/japr)
         | 
| 7 | 
            +
            [](https://codeclimate.com/github/janosrusiczki/japr)
         | 
| 8 8 |  | 
| 9 9 | 
             
            JAPR is a powerful asset pipeline that automatically collects, converts and compresses / minifies your site's JavaScript and CSS assets when you compile your [Jekyll](http://jekyllrb.com/) site.
         | 
| 10 10 |  | 
| @@ -349,21 +349,21 @@ Setting        | Default  | Description | |
| 349 349 |  | 
| 350 350 | 
             
            5. Instead of running the `jekyll` command to compile your site, you should use Octopress' rake commands (e.g. `rake generate`) as outlined [here](http://octopress.org/docs/blogging/).
         | 
| 351 351 |  | 
| 352 | 
            -
            If you have any difficulties using JAPR with Octopress, please [open an issue](http://github.com/ | 
| 352 | 
            +
            If you have any difficulties using JAPR with Octopress, please [open an issue](http://github.com/janosrusiczki/japr/issues).
         | 
| 353 353 |  | 
| 354 354 | 
             
            ## Contribute
         | 
| 355 355 |  | 
| 356 | 
            -
            You can contribute to the JAPR by submitting a pull request [via GitHub](https://github.com/ | 
| 356 | 
            +
            You can contribute to the JAPR by submitting a pull request [via GitHub](https://github.com/janosrusiczki/japr). There are a few areas that need improvement:
         | 
| 357 357 |  | 
| 358 358 | 
             
            - __Tests, tests, tests.__ **This project is now almost fully tested.**
         | 
| 359 359 | 
             
            - __Handle remote assets.__ Right now, JAPR does not provide any way to include remote assets in bundles unless you save them locally before generating your site. Moshen's [Jekyll Asset Bundler](https://github.com/moshen/jekyll-asset_bundler) allows you to include remote assets, which is pretty interesting. That said, it is generally better to keep remote assets separate so that they load asynchronously.
         | 
| 360 360 | 
             
            - __Successive preprocessing.__ Currently you can only preprocess a file once. It would be better if you could run an asset through multiple preprocessors before it gets compressed and bundled. **As of v0.1.0, JAPR now supports successive preprocessing.**
         | 
| 361 361 |  | 
| 362 | 
            -
            If you have any ideas or you would like to see anything else improved please use the [issues section](https://github.com/ | 
| 362 | 
            +
            If you have any ideas or you would like to see anything else improved please use the [issues section](https://github.com/janosrusiczki/japr/issues).
         | 
| 363 363 |  | 
| 364 364 | 
             
            ## Community
         | 
| 365 365 |  | 
| 366 | 
            -
            - Here is a list of [sites that use JAPR](http://github.com/ | 
| 366 | 
            +
            - Here is a list of [sites that use JAPR](http://github.com/janosrusiczki/japr/wiki/Sites-that-use-JAPR). Feel free to add your site to the list if you want.
         | 
| 367 367 |  | 
| 368 368 | 
             
            ## Credits
         | 
| 369 369 |  | 
    
        data/lib/japr.rb
    CHANGED
    
    | @@ -28,6 +28,7 @@ require 'japr/asset' | |
| 28 28 | 
             
            require 'japr/converter'
         | 
| 29 29 | 
             
            require 'japr/compressor'
         | 
| 30 30 | 
             
            require 'japr/template'
         | 
| 31 | 
            +
            require 'japr/templates/template_helper'
         | 
| 31 32 | 
             
            require 'japr/templates/javascript_tag_template'
         | 
| 32 33 | 
             
            require 'japr/templates/css_tag_template'
         | 
| 33 34 | 
             
            require 'japr/pipeline'
         | 
| @@ -50,5 +51,5 @@ module JAPR | |
| 50 51 | 
             
                'bundle'        => true,
         | 
| 51 52 | 
             
                'compress'      => true,
         | 
| 52 53 | 
             
                'gzip'          => false
         | 
| 53 | 
            -
              }
         | 
| 54 | 
            +
              }.freeze
         | 
| 54 55 | 
             
            end
         | 
    
        data/lib/japr/converter.rb
    CHANGED
    
    | @@ -18,6 +18,13 @@ module JAPR | |
| 18 18 | 
             
                  ''
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| 21 | 
            +
                # Finds a converter class based on a filename
         | 
| 22 | 
            +
                def self.klass(filename)
         | 
| 23 | 
            +
                  JAPR::Converter.subclasses.select do |c|
         | 
| 24 | 
            +
                    c.filetype == File.extname(filename).downcase
         | 
| 25 | 
            +
                  end.last
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 21 28 | 
             
                # Logic to convert assets
         | 
| 22 29 | 
             
                #
         | 
| 23 30 | 
             
                # Available instance variables:
         | 
| @@ -12,30 +12,35 @@ module JAPR | |
| 12 12 |  | 
| 13 13 | 
             
                def render(context)
         | 
| 14 14 | 
             
                  site = context.registers[:site]
         | 
| 15 | 
            -
                  config = site.config | 
| 15 | 
            +
                  config = site.config.fetch('asset_pipeline', {})
         | 
| 16 16 |  | 
| 17 17 | 
             
                  # Run Jekyll Asset Pipeline
         | 
| 18 | 
            -
                  pipeline, cached =  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
                   | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
                     | 
| 18 | 
            +
                  pipeline, cached = run_pipeline(site, config)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  return nil unless pipeline.is_a?(Pipeline)
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  # Prevent Jekyll from cleaning up saved assets if new pipeline
         | 
| 23 | 
            +
                  preserve_assets(site, config, pipeline) unless cached
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  # Return HTML tag pointing to asset
         | 
| 26 | 
            +
                  pipeline.html
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                private
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                def run_pipeline(site, config)
         | 
| 32 | 
            +
                  Pipeline.run(nodelist.first, @markup.strip, site.source, site.dest,
         | 
| 33 | 
            +
                               self.class.tag_name, self.class.output_type, config)
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                def preserve_assets(site, config, pipeline)
         | 
| 37 | 
            +
                  pipeline.assets.each do |asset|
         | 
| 38 | 
            +
                    config = JAPR::DEFAULTS.merge(config)
         | 
| 39 | 
            +
                    staging_path = File.expand_path(File.join(site.source,
         | 
| 40 | 
            +
                                                              config['staging_path']))
         | 
| 41 | 
            +
                    site.static_files << Jekyll::StaticFile.new(site, staging_path,
         | 
| 42 | 
            +
                                                                asset.output_path,
         | 
| 43 | 
            +
                                                                asset.filename)
         | 
| 39 44 | 
             
                  end
         | 
| 40 45 | 
             
                end
         | 
| 41 46 | 
             
              end
         | 
    
        data/lib/japr/pipeline.rb
    CHANGED
    
    | @@ -1,11 +1,12 @@ | |
| 1 1 | 
             
            module JAPR
         | 
| 2 | 
            +
              # rubocop:disable ClassLength
         | 
| 2 3 | 
             
              class Pipeline
         | 
| 3 4 | 
             
                class << self
         | 
| 4 5 | 
             
                  # Generate hash based on manifest
         | 
| 5 6 | 
             
                  def hash(source, manifest, options = {})
         | 
| 6 7 | 
             
                    options = DEFAULTS.merge(options)
         | 
| 7 8 | 
             
                    begin
         | 
| 8 | 
            -
                      Digest::MD5.hexdigest(YAML. | 
| 9 | 
            +
                      Digest::MD5.hexdigest(YAML.safe_load(manifest).map! do |path|
         | 
| 9 10 | 
             
                        "#{path}#{File.mtime(File.join(source, path)).to_i}"
         | 
| 10 11 | 
             
                      end.join.concat(options.to_s))
         | 
| 11 12 | 
             
                    rescue Exception => e
         | 
| @@ -20,32 +21,18 @@ module JAPR | |
| 20 21 | 
             
                    hash = hash(source, manifest, config)
         | 
| 21 22 |  | 
| 22 23 | 
             
                    # Check if pipeline has been cached
         | 
| 23 | 
            -
                    if cache.key?(hash)
         | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 27 | 
            -
                       | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
                        end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                        # Add processed pipeline to cache
         | 
| 38 | 
            -
                        cache[hash] = pipeline
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                        # Return newly processed pipeline and cached status
         | 
| 41 | 
            -
                        return pipeline, false
         | 
| 42 | 
            -
                      rescue Exception => e
         | 
| 43 | 
            -
                        # Add exception to cache
         | 
| 44 | 
            -
                        cache[hash] = e
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                        # Re-raise the exception
         | 
| 47 | 
            -
                        raise e
         | 
| 48 | 
            -
                      end
         | 
| 24 | 
            +
                    return cache[hash], true if cache.key?(hash)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    begin
         | 
| 27 | 
            +
                      puts "Processing '#{tag}' manifest '#{prefix}'"
         | 
| 28 | 
            +
                      pipeline = new(manifest, prefix, source, destination, type, config)
         | 
| 29 | 
            +
                      process_pipeline(hash, pipeline)
         | 
| 30 | 
            +
                    rescue Exception => e
         | 
| 31 | 
            +
                      # Add exception to cache
         | 
| 32 | 
            +
                      cache[hash] = e
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                      # Re-raise the exception
         | 
| 35 | 
            +
                      raise e
         | 
| 49 36 | 
             
                    end
         | 
| 50 37 | 
             
                  end
         | 
| 51 38 |  | 
| @@ -64,17 +51,31 @@ module JAPR | |
| 64 51 | 
             
                    config = DEFAULTS.merge(config)
         | 
| 65 52 | 
             
                    staging_path = File.join(source, config['staging_path'])
         | 
| 66 53 | 
             
                    FileUtils.rm_rf(staging_path)
         | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
                      raise e
         | 
| 54 | 
            +
                  rescue Exception => e
         | 
| 55 | 
            +
                    puts "Failed to remove staged assets: #{e.message}"
         | 
| 56 | 
            +
                    # Re-raise the exception
         | 
| 57 | 
            +
                    raise e
         | 
| 72 58 | 
             
                  end
         | 
| 73 59 |  | 
| 74 60 | 
             
                  # Add prefix to output
         | 
| 75 61 | 
             
                  def puts(message)
         | 
| 76 62 | 
             
                    $stdout.puts("Asset Pipeline: #{message}")
         | 
| 77 63 | 
             
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  private
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  def process_pipeline(hash, pipeline)
         | 
| 68 | 
            +
                    pipeline.assets.each do |asset|
         | 
| 69 | 
            +
                      puts "Saved '#{asset.filename}' to " \
         | 
| 70 | 
            +
                        "'#{pipeline.destination}/#{asset.output_path}'"
         | 
| 71 | 
            +
                    end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                    # Add processed pipeline to cache
         | 
| 74 | 
            +
                    cache[hash] = pipeline
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                    # Return newly processed pipeline and cached status
         | 
| 77 | 
            +
                    [pipeline, false]
         | 
| 78 | 
            +
                  end
         | 
| 78 79 | 
             
                end
         | 
| 79 80 |  | 
| 80 81 | 
             
                # Initialize new pipeline
         | 
| @@ -89,7 +90,7 @@ module JAPR | |
| 89 90 | 
             
                  process
         | 
| 90 91 | 
             
                end
         | 
| 91 92 |  | 
| 92 | 
            -
                attr_reader :assets, :html
         | 
| 93 | 
            +
                attr_reader :assets, :html, :destination
         | 
| 93 94 |  | 
| 94 95 | 
             
                private
         | 
| 95 96 |  | 
| @@ -106,17 +107,17 @@ module JAPR | |
| 106 107 |  | 
| 107 108 | 
             
                # Collect assets based on manifest
         | 
| 108 109 | 
             
                def collect
         | 
| 109 | 
            -
                  @assets = YAML. | 
| 110 | 
            +
                  @assets = YAML.safe_load(@manifest).map! do |path|
         | 
| 110 111 | 
             
                    full_path = File.join(@source, path)
         | 
| 111 112 | 
             
                    File.open(File.join(@source, path)) do |file|
         | 
| 112 113 | 
             
                      JAPR::Asset.new(file.read, File.basename(path),
         | 
| 113 114 | 
             
                                      File.dirname(full_path))
         | 
| 114 115 | 
             
                    end
         | 
| 115 116 | 
             
                  end
         | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 117 | 
            +
                rescue Exception => e
         | 
| 118 | 
            +
                  puts 'Asset Pipeline: Failed to load assets from provided ' \
         | 
| 119 | 
            +
                       "manifest: #{e.message}"
         | 
| 120 | 
            +
                  raise e
         | 
| 120 121 | 
             
                end
         | 
| 121 122 |  | 
| 122 123 | 
             
                # Convert assets based on the file extension if converter is defined
         | 
| @@ -126,36 +127,37 @@ module JAPR | |
| 126 127 | 
             
                    finished = false
         | 
| 127 128 | 
             
                    while finished == false
         | 
| 128 129 | 
             
                      # Find a converter to use
         | 
| 129 | 
            -
                      klass = JAPR::Converter. | 
| 130 | 
            -
                        c.filetype == File.extname(asset.filename).downcase
         | 
| 131 | 
            -
                      end.last
         | 
| 130 | 
            +
                      klass = JAPR::Converter.klass(asset.filename)
         | 
| 132 131 |  | 
| 133 132 | 
             
                      # Convert asset if converter is found
         | 
| 134 133 | 
             
                      if klass.nil?
         | 
| 135 134 | 
             
                        finished = true
         | 
| 136 135 | 
             
                      else
         | 
| 137 | 
            -
                         | 
| 138 | 
            -
                          # Convert asset content
         | 
| 139 | 
            -
                          converter = klass.new(asset)
         | 
| 140 | 
            -
             | 
| 141 | 
            -
                          # Replace asset content and filename
         | 
| 142 | 
            -
                          asset.content = converter.converted
         | 
| 143 | 
            -
                          asset.filename = File.basename(asset.filename, '.*')
         | 
| 144 | 
            -
             | 
| 145 | 
            -
                          # Add back the output extension if no extension left
         | 
| 146 | 
            -
                          if File.extname(asset.filename) == ''
         | 
| 147 | 
            -
                            asset.filename = "#{asset.filename}#{@type}"
         | 
| 148 | 
            -
                          end
         | 
| 149 | 
            -
                        rescue Exception => e
         | 
| 150 | 
            -
                          puts "Asset Pipeline: Failed to convert '#{asset.filename}' " \
         | 
| 151 | 
            -
                               "with '#{klass}': #{e.message}"
         | 
| 152 | 
            -
                          raise e
         | 
| 153 | 
            -
                        end
         | 
| 136 | 
            +
                        convert_asset(klass, asset)
         | 
| 154 137 | 
             
                      end
         | 
| 155 138 | 
             
                    end
         | 
| 156 139 | 
             
                  end
         | 
| 157 140 | 
             
                end
         | 
| 158 141 |  | 
| 142 | 
            +
                # Convert an asset with a given converter class
         | 
| 143 | 
            +
                def convert_asset(klass, asset)
         | 
| 144 | 
            +
                  # Convert asset content
         | 
| 145 | 
            +
                  converter = klass.new(asset)
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                  # Replace asset content and filename
         | 
| 148 | 
            +
                  asset.content = converter.converted
         | 
| 149 | 
            +
                  asset.filename = File.basename(asset.filename, '.*')
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                  # Add back the output extension if no extension left
         | 
| 152 | 
            +
                  if File.extname(asset.filename) == ''
         | 
| 153 | 
            +
                    asset.filename = "#{asset.filename}#{@type}"
         | 
| 154 | 
            +
                  end
         | 
| 155 | 
            +
                rescue Exception => e
         | 
| 156 | 
            +
                  puts "Asset Pipeline: Failed to convert '#{asset.filename}' " \
         | 
| 157 | 
            +
                       "with '#{klass}': #{e.message}"
         | 
| 158 | 
            +
                  raise e
         | 
| 159 | 
            +
                end
         | 
| 160 | 
            +
             | 
| 159 161 | 
             
                # Bundle multiple assets into a single asset
         | 
| 160 162 | 
             
                def bundle
         | 
| 161 163 | 
             
                  content = @assets.map(&:content).join("\n")
         | 
| @@ -172,7 +174,7 @@ module JAPR | |
| 172 174 | 
             
                      c.filetype == @type
         | 
| 173 175 | 
             
                    end.last
         | 
| 174 176 |  | 
| 175 | 
            -
                     | 
| 177 | 
            +
                    break unless klass
         | 
| 176 178 |  | 
| 177 179 | 
             
                    begin
         | 
| 178 180 | 
             
                      asset.content = klass.new(asset.content).compressed
         | 
| @@ -202,34 +204,35 @@ module JAPR | |
| 202 204 |  | 
| 203 205 | 
             
                  @assets.each do |asset|
         | 
| 204 206 | 
             
                    directory = File.join(@source, staging_path, output_path)
         | 
| 205 | 
            -
                     | 
| 206 | 
            -
             | 
| 207 | 
            -
                    begin
         | 
| 208 | 
            -
                      # Save file to disk
         | 
| 209 | 
            -
                      File.open(File.join(directory, asset.filename), 'w') do |file|
         | 
| 210 | 
            -
                        file.write(asset.content)
         | 
| 211 | 
            -
                      end
         | 
| 212 | 
            -
                    rescue Exception => e
         | 
| 213 | 
            -
                      puts "Asset Pipeline: Failed to save '#{asset.filename}' to " \
         | 
| 214 | 
            -
                           "disk: #{e.message}"
         | 
| 215 | 
            -
                      raise e
         | 
| 216 | 
            -
                    end
         | 
| 207 | 
            +
                    write_asset_file(directory, asset)
         | 
| 217 208 |  | 
| 218 209 | 
             
                    # Store output path of saved file
         | 
| 219 210 | 
             
                    asset.output_path = output_path
         | 
| 220 211 | 
             
                  end
         | 
| 221 212 | 
             
                end
         | 
| 222 213 |  | 
| 214 | 
            +
                # Write asset file to disk
         | 
| 215 | 
            +
                def write_asset_file(directory, asset)
         | 
| 216 | 
            +
                  FileUtils.mkpath(directory) unless File.directory?(directory)
         | 
| 217 | 
            +
                  begin
         | 
| 218 | 
            +
                    # Save file to disk
         | 
| 219 | 
            +
                    File.open(File.join(directory, asset.filename), 'w') do |file|
         | 
| 220 | 
            +
                      file.write(asset.content)
         | 
| 221 | 
            +
                    end
         | 
| 222 | 
            +
                  rescue Exception => e
         | 
| 223 | 
            +
                    puts "Asset Pipeline: Failed to save '#{asset.filename}' to " \
         | 
| 224 | 
            +
                         "disk: #{e.message}"
         | 
| 225 | 
            +
                    raise e
         | 
| 226 | 
            +
                  end
         | 
| 227 | 
            +
                end
         | 
| 228 | 
            +
             | 
| 223 229 | 
             
                # Generate html markup pointing to assets
         | 
| 224 230 | 
             
                def markup
         | 
| 225 231 | 
             
                  # Use display_path if defined, otherwise use output_path in url
         | 
| 226 232 | 
             
                  display_path = @options['display_path'] || @options['output_path']
         | 
| 227 233 |  | 
| 228 234 | 
             
                  @html = @assets.map do |asset|
         | 
| 229 | 
            -
                     | 
| 230 | 
            -
                      t.filetype == File.extname(asset.filename).downcase
         | 
| 231 | 
            -
                    end
         | 
| 232 | 
            -
                    klass = klasses.sort! { |x, y| x.priority <=> y.priority }.last
         | 
| 235 | 
            +
                    klass = JAPR::Template.klass(asset.filename)
         | 
| 233 236 | 
             
                    html = klass.new(display_path, asset.filename).html unless klass.nil?
         | 
| 234 237 |  | 
| 235 238 | 
             
                    html
         | 
    
        data/lib/japr/template.rb
    CHANGED
    
    | @@ -17,6 +17,14 @@ module JAPR | |
| 17 17 | 
             
                  0
         | 
| 18 18 | 
             
                end
         | 
| 19 19 |  | 
| 20 | 
            +
                # Finds a template class based on a filename
         | 
| 21 | 
            +
                def self.klass(filename)
         | 
| 22 | 
            +
                  klasses = JAPR::Template.subclasses.select do |t|
         | 
| 23 | 
            +
                    t.filetype == File.extname(filename).downcase
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                  klasses.sort! { |x, y| x.priority <=> y.priority }.last
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 20 28 | 
             
                # HTML output to return
         | 
| 21 29 | 
             
                #
         | 
| 22 30 | 
             
                # Available instance variables:
         | 
| @@ -1,6 +1,8 @@ | |
| 1 1 | 
             
            module JAPR
         | 
| 2 2 | 
             
              # Default output for CSS assets
         | 
| 3 3 | 
             
              class CssTagTemplate < JAPR::Template
         | 
| 4 | 
            +
                include JAPR::TemplateHelper
         | 
| 5 | 
            +
             | 
| 4 6 | 
             
                def self.filetype
         | 
| 5 7 | 
             
                  '.css'
         | 
| 6 8 | 
             
                end
         | 
| @@ -10,7 +12,8 @@ module JAPR | |
| 10 12 | 
             
                end
         | 
| 11 13 |  | 
| 12 14 | 
             
                def html
         | 
| 13 | 
            -
                  "<link href=' | 
| 15 | 
            +
                  "<link href='#{output_path}/#{@filename}' " \
         | 
| 16 | 
            +
                    "rel='stylesheet' type='text/css' />"
         | 
| 14 17 | 
             
                end
         | 
| 15 18 | 
             
              end
         | 
| 16 19 | 
             
            end
         | 
| @@ -1,6 +1,8 @@ | |
| 1 1 | 
             
            module JAPR
         | 
| 2 2 | 
             
              # Default output for JavaScript assets
         | 
| 3 3 | 
             
              class JavaScriptTagTemplate < JAPR::Template
         | 
| 4 | 
            +
                include JAPR::TemplateHelper
         | 
| 5 | 
            +
             | 
| 4 6 | 
             
                def self.filetype
         | 
| 5 7 | 
             
                  '.js'
         | 
| 6 8 | 
             
                end
         | 
| @@ -10,7 +12,8 @@ module JAPR | |
| 10 12 | 
             
                end
         | 
| 11 13 |  | 
| 12 14 | 
             
                def html
         | 
| 13 | 
            -
                  "<script src=' | 
| 15 | 
            +
                  "<script src='#{output_path}/#{@filename}' " \
         | 
| 16 | 
            +
                    "type='text/javascript'></script>"
         | 
| 14 17 | 
             
                end
         | 
| 15 18 | 
             
              end
         | 
| 16 19 | 
             
            end
         | 
    
        data/lib/japr/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,130 +1,122 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: japr
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 0.4.0
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 7 | 
             
            - Matt Hodan
         | 
| 9 8 | 
             
            autorequire: 
         | 
| 10 9 | 
             
            bindir: bin
         | 
| 11 10 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 11 | 
            +
            date: 2017-12-03 00:00:00.000000000 Z
         | 
| 13 12 | 
             
            dependencies:
         | 
| 14 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 14 | 
             
              name: jekyll
         | 
| 16 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            -
                none: false
         | 
| 18 16 | 
             
                requirements:
         | 
| 19 | 
            -
                - - ~>
         | 
| 17 | 
            +
                - - "~>"
         | 
| 20 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version: ' | 
| 19 | 
            +
                    version: '3.5'
         | 
| 22 20 | 
             
              type: :runtime
         | 
| 23 21 | 
             
              prerelease: false
         | 
| 24 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            -
                none: false
         | 
| 26 23 | 
             
                requirements:
         | 
| 27 | 
            -
                - - ~>
         | 
| 24 | 
            +
                - - "~>"
         | 
| 28 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: ' | 
| 26 | 
            +
                    version: '3.5'
         | 
| 30 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 28 | 
             
              name: liquid
         | 
| 32 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            -
                none: false
         | 
| 34 30 | 
             
                requirements:
         | 
| 35 | 
            -
                - - ~>
         | 
| 31 | 
            +
                - - "~>"
         | 
| 36 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            -
                    version: ' | 
| 33 | 
            +
                    version: '4.0'
         | 
| 38 34 | 
             
              type: :runtime
         | 
| 39 35 | 
             
              prerelease: false
         | 
| 40 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            -
                none: false
         | 
| 42 37 | 
             
                requirements:
         | 
| 43 | 
            -
                - - ~>
         | 
| 38 | 
            +
                - - "~>"
         | 
| 44 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            -
                    version: ' | 
| 40 | 
            +
                    version: '4.0'
         | 
| 46 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            -
              name:  | 
| 42 | 
            +
              name: minitest
         | 
| 48 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            -
                none: false
         | 
| 50 44 | 
             
                requirements:
         | 
| 51 | 
            -
                - - ~>
         | 
| 45 | 
            +
                - - "~>"
         | 
| 52 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            -
                    version: ' | 
| 47 | 
            +
                    version: '5.2'
         | 
| 54 48 | 
             
              type: :development
         | 
| 55 49 | 
             
              prerelease: false
         | 
| 56 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            -
                none: false
         | 
| 58 51 | 
             
                requirements:
         | 
| 59 | 
            -
                - - ~>
         | 
| 52 | 
            +
                - - "~>"
         | 
| 60 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: ' | 
| 54 | 
            +
                    version: '5.2'
         | 
| 62 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            -
              name:  | 
| 56 | 
            +
              name: rake
         | 
| 64 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            -
                none: false
         | 
| 66 58 | 
             
                requirements:
         | 
| 67 | 
            -
                - - ~>
         | 
| 59 | 
            +
                - - "~>"
         | 
| 68 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            -
                    version: ' | 
| 61 | 
            +
                    version: '10.0'
         | 
| 70 62 | 
             
              type: :development
         | 
| 71 63 | 
             
              prerelease: false
         | 
| 72 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            -
                none: false
         | 
| 74 65 | 
             
                requirements:
         | 
| 75 | 
            -
                - - ~>
         | 
| 66 | 
            +
                - - "~>"
         | 
| 76 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            -
                    version: ' | 
| 78 | 
            -
            description:  | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 68 | 
            +
                    version: '10.0'
         | 
| 69 | 
            +
            description: |2
         | 
| 70 | 
            +
                  Jekyll Asset Pipeline reborn adds asset preprocessing (CoffeeScript, Sass,
         | 
| 71 | 
            +
                  Less, ERB, etc.) and asset compression / minification / gzip (Yahoo YUI
         | 
| 72 | 
            +
                  Compressor, Google Closure Compiler, etc.) to Jekyll.'
         | 
| 81 73 | 
             
            email: japr@clicktrackheart.com
         | 
| 82 74 | 
             
            executables: []
         | 
| 83 75 | 
             
            extensions: []
         | 
| 84 76 | 
             
            extra_rdoc_files: []
         | 
| 85 77 | 
             
            files:
         | 
| 78 | 
            +
            - LICENSE
         | 
| 79 | 
            +
            - README.md
         | 
| 80 | 
            +
            - lib/japr.rb
         | 
| 81 | 
            +
            - lib/japr/asset.rb
         | 
| 86 82 | 
             
            - lib/japr/compressor.rb
         | 
| 87 83 | 
             
            - lib/japr/converter.rb
         | 
| 88 | 
            -
            - lib/japr/ | 
| 89 | 
            -
            - lib/japr/ | 
| 90 | 
            -
            - lib/japr/version.rb
         | 
| 91 | 
            -
            - lib/japr/template.rb
         | 
| 92 | 
            -
            - lib/japr/extensions/liquid/asset_tags/javascript_asset_tag.rb
         | 
| 93 | 
            -
            - lib/japr/extensions/liquid/asset_tags/css_asset_tag.rb
         | 
| 84 | 
            +
            - lib/japr/extensions/jekyll/site.rb
         | 
| 85 | 
            +
            - lib/japr/extensions/jekyll/site_extensions.rb
         | 
| 94 86 | 
             
            - lib/japr/extensions/liquid/asset_tag.rb
         | 
| 87 | 
            +
            - lib/japr/extensions/liquid/asset_tags/css_asset_tag.rb
         | 
| 88 | 
            +
            - lib/japr/extensions/liquid/asset_tags/javascript_asset_tag.rb
         | 
| 95 89 | 
             
            - lib/japr/extensions/liquid/liquid_block_extensions.rb
         | 
| 96 | 
            -
            - lib/japr/extensions/jekyll/site_extensions.rb
         | 
| 97 | 
            -
            - lib/japr/extensions/jekyll/site.rb
         | 
| 98 90 | 
             
            - lib/japr/extensions/ruby/subclass_tracking.rb
         | 
| 99 91 | 
             
            - lib/japr/pipeline.rb
         | 
| 100 | 
            -
            - lib/japr/ | 
| 101 | 
            -
            - lib/japr.rb
         | 
| 102 | 
            -
            -  | 
| 103 | 
            -
            -  | 
| 104 | 
            -
             | 
| 92 | 
            +
            - lib/japr/template.rb
         | 
| 93 | 
            +
            - lib/japr/templates/css_tag_template.rb
         | 
| 94 | 
            +
            - lib/japr/templates/javascript_tag_template.rb
         | 
| 95 | 
            +
            - lib/japr/templates/template_helper.rb
         | 
| 96 | 
            +
            - lib/japr/version.rb
         | 
| 97 | 
            +
            homepage: https://github.com/janosrusiczki/japr
         | 
| 105 98 | 
             
            licenses:
         | 
| 106 99 | 
             
            - MIT
         | 
| 100 | 
            +
            metadata: {}
         | 
| 107 101 | 
             
            post_install_message: 
         | 
| 108 102 | 
             
            rdoc_options: []
         | 
| 109 103 | 
             
            require_paths:
         | 
| 110 104 | 
             
            - lib
         | 
| 111 105 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 112 | 
            -
              none: false
         | 
| 113 106 | 
             
              requirements:
         | 
| 114 | 
            -
              - -  | 
| 107 | 
            +
              - - ">="
         | 
| 115 108 | 
             
                - !ruby/object:Gem::Version
         | 
| 116 | 
            -
                  version:  | 
| 109 | 
            +
                  version: 2.2.0
         | 
| 117 110 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 118 | 
            -
              none: false
         | 
| 119 111 | 
             
              requirements:
         | 
| 120 | 
            -
              - -  | 
| 112 | 
            +
              - - ">="
         | 
| 121 113 | 
             
                - !ruby/object:Gem::Version
         | 
| 122 114 | 
             
                  version: '0'
         | 
| 123 115 | 
             
            requirements: []
         | 
| 124 116 | 
             
            rubyforge_project: 
         | 
| 125 | 
            -
            rubygems_version:  | 
| 117 | 
            +
            rubygems_version: 2.6.14
         | 
| 126 118 | 
             
            signing_key: 
         | 
| 127 | 
            -
            specification_version:  | 
| 119 | 
            +
            specification_version: 4
         | 
| 128 120 | 
             
            summary: A powerful asset pipeline for Jekyll that bundles, converts, and minifies
         | 
| 129 121 | 
             
              CSS and JavaScript assets.
         | 
| 130 122 | 
             
            test_files: []
         |