webpack-pipeline 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02cd068ca244225d94f556f2440b0bdc6b6a0b17
4
- data.tar.gz: ff97bccebe85372dffe4c3106a460f0c345e4e64
3
+ metadata.gz: 6d9d934bc3b24c9909d1a4c11d581fa0b280cdc7
4
+ data.tar.gz: 409e58f14a152fa0a3ddb299ee424dfd10a6fb96
5
5
  SHA512:
6
- metadata.gz: 443912af6b76161bbc6952109dad10168835fc7d01d90e1aea955bfb21ffa5cd5cc4b291ea5fd9f178a334075e4793f5314eb8d234d572c68eceade5437bbde6
7
- data.tar.gz: dfd6bc6d9a551a5cb5ef302f2881e08cfea9781345f2c8a7869e515d357bc07a98d343088afa84a4e16cd0068017eeba3e1ef8c25c9b07abfec464d7be3c65de
6
+ metadata.gz: 50436240cd6e55635e07ec3b17ab11761053468b85eee577a043644f8e1397f4f634a6c8146caf5d73f4e65bd2f7f9519499fe564a712949cb5b24f99b31863a
7
+ data.tar.gz: 45934c42c1eb1790d157a9c21a646f0b298c5b67a6416cc383350e837b618d51c23e306cfcf8a0dd4d05d5dc0078412cb478b34dbbd2af3ec4d575099ed9e325
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,7 +1,9 @@
1
+
1
2
  module Webpack
2
3
  class Railtie < Rails::Railtie
3
4
  initializer 'load manifest class' do
4
5
  ActiveSupport.on_load :action_view do
6
+ require 'webpack/manifest'
5
7
  require 'webpack/asset_url_helper'
6
8
  include AssetUrlHelper
7
9
  end
@@ -4,9 +4,11 @@ module Webpack
4
4
 
5
5
  included do
6
6
  def compute_asset_path(source, options = {})
7
- webpack.asset_url(source) || super(source, options)
7
+ webpack.asset_url(source) || fail(ArgumentError, "can't find #{source}")
8
8
  end
9
9
 
10
+ protected
11
+
10
12
  def webpack
11
13
  @webpack ||= Manifest.instance
12
14
  end
@@ -3,7 +3,7 @@ module Webpack
3
3
  include ActiveSupport::Configurable
4
4
 
5
5
  config_accessor(:path) {
6
- File.join('public', 'assets', 'manifest.json')
6
+ File.join('config', 'manifest.json')
7
7
  }
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ require 'webpack/configuration'
3
3
  module Webpack
4
4
  class Manifest
5
5
  include Singleton
6
- attr_reader :updated_at
6
+
7
7
  cattr_reader :configuration do
8
8
  @configuration ||= Configuration.new
9
9
  end
@@ -12,14 +12,8 @@ module Webpack
12
12
  yield configuration
13
13
  end
14
14
 
15
- def asset_url(filename)
16
- name = filename.split('.').first
17
- ext = filename.split('.').last
18
- chunk = [*data['assetsByChunkName'][name]]
19
-
20
- asset_name = chunk.find { |asset|
21
- asset.end_with? ext
22
- }
15
+ def asset_url(source)
16
+ asset_name = asset_in_chunks(source) || asset_images(source)
23
17
  "#{host}#{asset_name}" if asset_name
24
18
  end
25
19
 
@@ -29,18 +23,23 @@ module Webpack
29
23
 
30
24
  protected
31
25
 
32
- def data
33
- new_timestamp = File.ctime(configuration.path)
34
- if new_timestamp == @updated_at
35
- @data
36
- else
37
- @updated_at = new_timestamp
38
- @data = JSON.parse(File.read(configuration.path))
39
- end
26
+ def asset_in_chunks(source)
27
+ name = source.split('.').first
28
+ ext = source.split('.').last
29
+ chunk = [*data['assetsByChunkName'][name]]
30
+
31
+ chunk.find { |asset| asset.end_with? ext }
32
+ end
33
+
34
+ def asset_images(source)
35
+ data['assets'][source]
40
36
  end
41
37
 
42
- def chunks
43
- @chunks ||= data['assetsByChunkName'].map(&:first)
38
+ def data
39
+ new_timestamp = File.ctime(configuration.path)
40
+ return @data if new_timestamp == @updated_at
41
+ @updated_at = new_timestamp
42
+ @data = JSON.parse(File.read(configuration.path))
44
43
  end
45
44
  end
46
45
  end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: webpack-pipeline 0.2.0 ruby lib
5
+ # stub: webpack-pipeline 0.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "webpack-pipeline"
9
- s.version = "0.2.0"
9
+ s.version = "0.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Stanislav German"]
14
- s.date = "2015-05-13"
14
+ s.date = "2015-05-19"
15
15
  s.description = "it adds wiew helpers to integrate webpack with rails"
16
16
  s.email = "s.german@rambler-co.ru"
17
17
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpack-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav German
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport