japr 0.2.3 → 0.2.4

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.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # JAPR (Jekyll Asset Pipeline Reborn)
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/japr.png)](http://badge.fury.io/rb/japr) [![Build Status](https://secure.travis-ci.org/kitsched/japr.png)](https://travis-ci.org/kitsched/japr) [![Coverage Status](https://coveralls.io/repos/kitsched/japr/badge.png)](https://coveralls.io/r/kitsched/japr) [![Dependency Status](https://gemnasium.com/kitsched/japr.png)](https://gemnasium.com/kitsched/japr) [![Code Climate](https://codeclimate.com/github/kitsched/japr.png)](https://codeclimate.com/github/kitsched/japr)
3
+ [![Gem Version](https://badge.fury.io/rb/japr.png)](http://badge.fury.io/rb/japr) [![Build Status](https://secure.travis-ci.org/kitsched/japr.png)](https://travis-ci.org/kitsched/japr) [![Coverage Status](https://coveralls.io/repos/kitsched/japr/badge.png?branch=master)](https://coveralls.io/r/kitsched/japr?branch=master) [![Dependency Status](https://gemnasium.com/kitsched/japr.png)](https://gemnasium.com/kitsched/japr) [![Code Climate](https://codeclimate.com/github/kitsched/japr.png)](https://codeclimate.com/github/kitsched/japr)
4
4
 
5
5
  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 site.
6
6
 
@@ -1,10 +1,11 @@
1
1
  module JAPR
2
2
  class Asset
3
- def initialize(content, filename)
3
+ def initialize(content, filename, dirname = '.')
4
4
  @content = content
5
5
  @filename = filename
6
+ @dirname = dirname
6
7
  end
7
8
 
8
- attr_accessor :content, :filename, :output_path
9
+ attr_accessor :content, :filename, :dirname, :output_path
9
10
  end
10
11
  end
@@ -4,7 +4,7 @@ module JAPR
4
4
 
5
5
  def initialize(content)
6
6
  @content = content
7
- @compressed = self.compress
7
+ @compressed = compress
8
8
  end
9
9
 
10
10
  # Returns compressed content
@@ -5,7 +5,8 @@ module JAPR
5
5
  def initialize(asset)
6
6
  @content = asset.content
7
7
  @type = File.extname(asset.filename).downcase
8
- @converted = self.convert
8
+ @converted = convert
9
+ @dirname = asset.dirname
9
10
  end
10
11
 
11
12
  def converted
@@ -8,7 +8,7 @@ module JAPR
8
8
  # Override Jekyll::Site#cleanup
9
9
  define_method(:cleanup) do
10
10
  # Run the Jekyll::Site#cleanup method
11
- original_return_val = old_cleanup_method.bind(self).call()
11
+ original_return_val = old_cleanup_method.bind(self).call
12
12
 
13
13
  # Clear Jekyll Asset Pipeline cache
14
14
  Pipeline.clear_cache
@@ -22,11 +22,11 @@ module JAPR
22
22
  # Override Jekyll::Site#write
23
23
  define_method(:write) do
24
24
  # Run the Jekyll::Site#write method
25
- original_return_value = old_write_method.bind(self).call()
25
+ original_return_value = old_write_method.bind(self).call
26
26
 
27
27
  # Clear Jekyll Asset Pipeline staged assets
28
28
  config = self.config['asset_pipeline'] || {}
29
- Pipeline.remove_staged_assets(self.source, config)
29
+ Pipeline.remove_staged_assets(source, config)
30
30
 
31
31
  original_return_value
32
32
  end
@@ -15,8 +15,10 @@ module JAPR
15
15
  config = site.config['asset_pipeline'] || {}
16
16
 
17
17
  # Run Jekyll Asset Pipeline
18
- pipeline, cached = Pipeline.run(@nodelist.first, @markup.strip, site.source,
19
- site.dest, self.class.tag_name, self.class.output_type, config)
18
+ pipeline, cached = Pipeline.run(@nodelist.first, @markup.strip,
19
+ site.source, site.dest,
20
+ self.class.tag_name,
21
+ self.class.output_type, config)
20
22
 
21
23
  if pipeline.is_a?(Pipeline)
22
24
  # Prevent Jekyll from cleaning up saved assets if new pipeline
@@ -24,7 +26,8 @@ module JAPR
24
26
  config = JAPR::DEFAULTS.merge(config)
25
27
  staging_path = File.expand_path(File.join(site.source, config['staging_path']))
26
28
  site.static_files << Jekyll::StaticFile.new(site, staging_path,
27
- asset.output_path, asset.filename)
29
+ asset.output_path,
30
+ asset.filename)
28
31
  end unless cached
29
32
 
30
33
  # Return HTML tag pointing to asset
@@ -5,7 +5,7 @@ module JAPR
5
5
  def hash(source, manifest, options = {})
6
6
  options = DEFAULTS.merge(options)
7
7
  begin
8
- Digest::MD5.hexdigest(YAML::load(manifest).map! do |path|
8
+ Digest::MD5.hexdigest(YAML.load(manifest).map! do |path|
9
9
  "#{path}#{File.mtime(File.join(source, path)).to_i}"
10
10
  end.join.concat(options.to_s))
11
11
  rescue Exception => e
@@ -20,7 +20,7 @@ module JAPR
20
20
  hash = hash(source, manifest, config)
21
21
 
22
22
  # Check if pipeline has been cached
23
- if cache.has_key?(hash)
23
+ if cache.key?(hash)
24
24
  # Return cached pipeline and cached status
25
25
  return cache[hash], true
26
26
  else
@@ -28,7 +28,7 @@ module JAPR
28
28
  puts "Processing '#{tag}' manifest '#{prefix}'"
29
29
 
30
30
  # Create and process new pipeline
31
- pipeline = self.new(manifest, prefix, source, destination, type, config)
31
+ pipeline = new(manifest, prefix, source, destination, type, config)
32
32
  pipeline.assets.each do |asset|
33
33
  puts "Saved '#{asset.filename}' to '#{destination}/#{asset.output_path}'"
34
34
  end
@@ -60,16 +60,14 @@ module JAPR
60
60
 
61
61
  # Remove staged assets
62
62
  def remove_staged_assets(source, config)
63
- begin
64
- config = DEFAULTS.merge(config)
65
- staging_path = File.join(source, config['staging_path'])
66
- FileUtils.rm_rf(staging_path)
63
+ config = DEFAULTS.merge(config)
64
+ staging_path = File.join(source, config['staging_path'])
65
+ FileUtils.rm_rf(staging_path)
67
66
  rescue Exception => e
68
67
  puts "Failed to remove staged assets."
69
68
 
70
69
  # Re-raise the exception
71
70
  raise e
72
- end
73
71
  end
74
72
 
75
73
  # Add prefix to output
@@ -107,16 +105,15 @@ module JAPR
107
105
 
108
106
  # Collect assets based on manifest
109
107
  def collect
110
- begin
111
- @assets = YAML::load(@manifest).map! do |path|
112
- File.open(File.join(@source, path)) do |file|
113
- JAPR::Asset.new(file.read, File.basename(path))
114
- end
108
+ @assets = YAML.load(@manifest).map! do |path|
109
+ full_path = File.join(@source, path)
110
+ File.open(File.join(@source, path)) do |file|
111
+ JAPR::Asset.new(file.read, File.basename(path), File.dirname(full_path))
115
112
  end
113
+ end
116
114
  rescue Exception => e
117
115
  puts "Asset Pipeline: Failed to load assets from provided manifest."
118
116
  raise e
119
- end
120
117
  end
121
118
 
122
119
  # Convert assets based on the file extension if converter is defined
@@ -186,7 +183,7 @@ module JAPR
186
183
  def gzip
187
184
  @assets.map! do |asset|
188
185
  gzip_content = Zlib::Deflate.deflate(asset.content)
189
- [asset, JAPR::Asset.new(gzip_content, "#{asset.filename}.gz")]
186
+ [asset, JAPR::Asset.new(gzip_content, "#{asset.filename}.gz", asset.dirname)]
190
187
  end.flatten!
191
188
  end
192
189
 
@@ -197,7 +194,7 @@ module JAPR
197
194
 
198
195
  @assets.each do |asset|
199
196
  directory = File.join(@source, staging_path, output_path)
200
- FileUtils::mkpath(directory) unless File.directory?(directory)
197
+ FileUtils.mkpath(directory) unless File.directory?(directory)
201
198
 
202
199
  begin
203
200
  # Save file to disk
@@ -10,7 +10,7 @@ module JAPR
10
10
  end
11
11
 
12
12
  def html
13
- "<link href='/#{@path}/#{@filename}' rel='stylesheet' type='text/css' />\n"
13
+ "<link href='/#{@path}/#{@filename}' rel='stylesheet' type='text/css' />"
14
14
  end
15
15
  end
16
16
  end
@@ -10,7 +10,7 @@ module JAPR
10
10
  end
11
11
 
12
12
  def html
13
- "<script src='/#{@path}/#{@filename}' type='text/javascript'></script>\n"
13
+ "<script src='/#{@path}/#{@filename}' type='text/javascript'></script>"
14
14
  end
15
15
  end
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module JAPR
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: japr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Matt Hodan
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-01-09 00:00:00.000000000 Z
12
+ date: 2014-03-07 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: jekyll
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: liquid
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rake
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: minitest
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,11 +70,12 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
68
77
  version: '5.2'
69
- description: JAPR (Jekyll Asset Pipeline Reborn) adds asset preprocessing (CoffeeScript,
78
+ description: Jekyll Asset Pipeline reborn adds asset preprocessing (CoffeeScript,
70
79
  Sass, Less, ERB, etc.) and asset compression/minification/gzip (Yahoo YUI Compressor,
71
80
  Google Closure Compiler, etc.) to Jekyll.
72
81
  email: japr@clicktrackheart.com
@@ -74,47 +83,48 @@ executables: []
74
83
  extensions: []
75
84
  extra_rdoc_files: []
76
85
  files:
77
- - LICENSE
78
- - README.md
79
- - lib/japr.rb
80
- - lib/japr/asset.rb
81
86
  - lib/japr/compressor.rb
82
87
  - lib/japr/converter.rb
83
- - lib/japr/extensions/jekyll/site.rb
84
- - lib/japr/extensions/jekyll/site_extensions.rb
85
- - lib/japr/extensions/liquid/asset_tag.rb
86
- - lib/japr/extensions/liquid/asset_tags/css_asset_tag.rb
88
+ - lib/japr/templates/javascript_tag_template.rb
89
+ - lib/japr/templates/css_tag_template.rb
90
+ - lib/japr/version.rb
91
+ - lib/japr/template.rb
87
92
  - lib/japr/extensions/liquid/asset_tags/javascript_asset_tag.rb
93
+ - lib/japr/extensions/liquid/asset_tags/css_asset_tag.rb
94
+ - lib/japr/extensions/liquid/asset_tag.rb
88
95
  - lib/japr/extensions/liquid/liquid_block_extensions.rb
96
+ - lib/japr/extensions/jekyll/site_extensions.rb
97
+ - lib/japr/extensions/jekyll/site.rb
89
98
  - lib/japr/extensions/ruby/subclass_tracking.rb
90
99
  - lib/japr/pipeline.rb
91
- - lib/japr/template.rb
92
- - lib/japr/templates/css_tag_template.rb
93
- - lib/japr/templates/javascript_tag_template.rb
94
- - lib/japr/version.rb
100
+ - lib/japr/asset.rb
101
+ - lib/japr.rb
102
+ - LICENSE
103
+ - README.md
95
104
  homepage: https://github.com/kitsched/japr
96
105
  licenses:
97
106
  - MIT
98
- metadata: {}
99
107
  post_install_message:
100
108
  rdoc_options: []
101
109
  require_paths:
102
110
  - lib
103
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
104
113
  requirements:
105
114
  - - ! '>='
106
115
  - !ruby/object:Gem::Version
107
116
  version: 1.9.3
108
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
109
119
  requirements:
110
120
  - - ! '>='
111
121
  - !ruby/object:Gem::Version
112
122
  version: '0'
113
123
  requirements: []
114
124
  rubyforge_project:
115
- rubygems_version: 2.2.1
125
+ rubygems_version: 1.8.24
116
126
  signing_key:
117
- specification_version: 4
127
+ specification_version: 3
118
128
  summary: A powerful asset pipeline for Jekyll that bundles, converts, and minifies
119
129
  CSS and JavaScript assets.
120
130
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MjRiOTE0NjFhNzVmZWUwMzBjYWIyYTVjNWQwZmI4ZjY1YzZmN2JiMQ==
5
- data.tar.gz: !binary |-
6
- OTVlYTQ1MTI0MTA4YTRmNTg0MWI2MmZiNGFiNGZlOWFlOTlhZTllMQ==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- YmFkZmY2ODZmODNkNDJkOWExMzg1NTM3Y2FkZDZmYWI3Yjc4ZDk3MTM3MzU4
10
- MTM1Y2Y3MTIwMTBhNWE2NWE3YTNjNTM5YmI3M2QzMDU2NmNiMTIyNzA2MjY4
11
- OWMxODljYmZiZmIzOTk3ZTg3M2U4OTMwZTJiY2QwZGVhNjYzYjk=
12
- data.tar.gz: !binary |-
13
- NGFlYTU2ZTEyN2JhYjY5Y2M3ZDMwZThhOWVmODgyNjMwYmYzNTE5MDA1ZDUw
14
- YjczOTAwMzliMTVkZGJkZWU4Zjk0MDc0ODI0MzdjNDM2YmNkOTZlYTUzMWM5
15
- ZGM3MWM1YTMzNDU4NzVhYzQ4Mjc3MTlhMjA1NWU1ZTBiNTAzMjM=