specific_asset_compiler 0.1.5 → 0.1.6

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- N2MyMTEyOWJlYmFjYWFmNDIwZDE1MmE0ZGZhYWViYWE2NDZlYTcwMQ==
5
- data.tar.gz: !binary |-
6
- Njg3MjE5YzkxZGNmOGI2M2QyMzUxYzQyZTAyNDdkZDMxODg0Mzk1MA==
2
+ SHA1:
3
+ metadata.gz: 241929ea09c178b88427f3ec16a037a2c34edf07
4
+ data.tar.gz: a89e340c75e4966e12313baf38df0bf299961b33
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDI5ZGUzNTczZWQxNDg3YjhiOGE3YTgzMGNkN2Q4YTgxOTBmZTM2YTI5YzNk
10
- NjVjYWZkODY3NmI2OWZhY2Q3ZjEwNWJiZGRkZDU1NTdkMmVlMDQxZWRmN2Y3
11
- ZTgwMTJlOTc1NmQ2ZDExNTQyZTdlMzZmNzk5MzgzMmVlY2U3ZjI=
12
- data.tar.gz: !binary |-
13
- Yjc4OTA0MzcxNjI5NjViMzZlYzFmOTgxNTExYTU5Mzc0OGI4OGRmNGUwZWFi
14
- ODA3ZDE4YWEyOTBjMTU3NjNhNDIzYzIxZjgxYmMzMDBiNmQ3MDJlZGU0MTEy
15
- ODNjN2ExZGVjMTE5MGYxMDYxOTc0ZjU4NTNkYzI4OTZhMzdhM2M=
6
+ metadata.gz: 664fad5e1bad10d0c0b8cc49c6e5d3db45c062c5f89ca1f87ce64f21d0eb941cd35c4877283f89833040654e6e3a8733dcc3740f92b2171376c678d2e9c567b4
7
+ data.tar.gz: fadc8e582beaba7c8a776426f5e1dccbd6d4135ee351b8f44c67f33c3a98214f924f5c79fdb9da1ab72b853122805936dcbe3d38756f225d7213773a2bf2c741
@@ -38,7 +38,8 @@ namespace :assets do
38
38
  # sprockets hooks get executed
39
39
  digest = nil
40
40
  _ = ActionView::Base
41
- target_file = (ENV["ASSET_FILES"].gsub("[","").gsub("]","").split(",") rescue [])
41
+ target_files = (ENV["ASSET_FILES"].gsub("[","").gsub("]","").split(",") rescue [])
42
+ target_files = target_files.collect{|file| find_parent(file) }.flatten
42
43
  config = Rails.application.config
43
44
  config.assets.compile = true
44
45
  config.assets.digest = digest unless digest.nil?
@@ -47,13 +48,49 @@ namespace :assets do
47
48
  target = File.join(Rails.public_path, config.assets.prefix)
48
49
  compiler = Sprockets::StaticCompiler.new(env,
49
50
  target,
50
- [config.assets.precompile[0]]+target_file,
51
+ [config.assets.precompile[0]]+target_files,
51
52
  :manifest_path => config.assets.manifest,
52
53
  :digest => config.assets.digest,
53
54
  :manifest => digest.nil?)
54
55
  compiler.compile_specific
55
56
  end
56
57
 
58
+ def have_more_parent?(file_path)
59
+ result = []
60
+ file_pure_path = file_path.split(".").first
61
+ file_pure_name = file_path.split("/").last.split(".").first
62
+ all_path = Rails.application.config.assets.paths
63
+ all_found = all_path.collect{|path| %x[ grep -rw '#{path}' -e '#{file_pure_name}' ].split("\n") }.flatten.compact.select{|h| h.split(":").last.split("/").last.include?(file_pure_name) }
64
+ all_found.present?
65
+ end
66
+
67
+ def find_parent(file_path)
68
+ result = []
69
+ file_pure_path = file_path.split(".").first
70
+ file_pure_name = file_path.split("/").last.split(".").first
71
+ all_path = Rails.application.config.assets.paths
72
+ all_found = all_path.collect{|path| %x[ grep -rw '#{path}' -e '#{file_pure_name}' ].split("\n") }.flatten.compact.select{|h| h.split(":").last.split("/").last.include?(file_pure_name) }
73
+ if all_found.present?
74
+ all_found.each do |aff|
75
+ this_file_path = aff.split(":")[0]
76
+ this_only_path = this_file_path.split("/")[0..this_file_path.split("/").count-2].join("/")
77
+ imported_raw_message = aff.split(":")[1]
78
+ imported_raw_path = imported_raw_message.gsub(/\A.* \"/,"").gsub(/\";/,"")
79
+ next unless (this_only_path+"/"+imported_raw_path).match(file_pure_path)
80
+ result << this_file_path.split(/images\/|stylesheets\/|javascripts\//).last
81
+ end
82
+ else
83
+ result << file_path
84
+ end
85
+ result.flatten.uniq.compact.collect{|l|
86
+ if have_more_parent?(l)
87
+ find_parent(l)
88
+ else
89
+ l
90
+ end
91
+ }.flatten.uniq
92
+ end
93
+
57
94
  task :specific do
58
95
  Rake::Task["assets:precompile:specific_internal"].invoke
59
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specific_asset_compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanapat Sainak
@@ -21,7 +21,7 @@ files:
21
21
  - lib/tasks/specific_asset_compiler.rake
22
22
  homepage: http://www.computerlogy.com
23
23
  licenses:
24
- - Tanapat Sainak
24
+ - MIT
25
25
  metadata: {}
26
26
  post_install_message:
27
27
  rdoc_options: []
@@ -29,17 +29,17 @@ require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: 1.9.3
35
35
  required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ! '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
41
  rubyforge_project:
42
- rubygems_version: 2.4.3
42
+ rubygems_version: 2.4.8
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: Specific Asset files