specific_asset_compiler 0.1.2

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTQ4ZmViZmNlYmFhOGE4NzZhODdmNjkyZjA0OWE4Njk3NjE4NDU1OQ==
5
+ data.tar.gz: !binary |-
6
+ ZTBiNTQ0ODM3YTcwOTI5MDgwNDdhMGU0NTg5YjNkYzFjMzEzMDg0ZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ODM0MzUxNDA2M2Q5NGUyOGQ1YWVkMWQ0NmYwZGMzNGU2YjM5ZDNiMzY5NjM1
10
+ N2NkMzkwNDMwNmQ5NTRlZDFhNTBjNmNlY2FiYjY1Y2MwNjFhNjM4YzE1OWQ5
11
+ OGE3YmJkMjU2MDQzNjc4YWM4MWE3NWE0M2VlNzA3ZTRlN2YwNjU=
12
+ data.tar.gz: !binary |-
13
+ MGJlM2U5M2ZiMTE0MjU5N2UzOWY2ZTdiY2NhOTk5YzI1YWNhNmMzYzQzNzVl
14
+ MTU1YzMwNTNhZDFlZWEwMGEyMjhiMmE2NjAyZDBlZWU2NWVmZjM4Y2NkZTJl
15
+ ZjBlMDAwY2M2MDRlMDEyMTczMDU1Zjc0ZGU5NzliMzYxMzI3OTY=
@@ -0,0 +1,11 @@
1
+ require 'specific_asset_compiler'
2
+ require 'rails'
3
+ module SpecificAssetCompiler
4
+ class Railtie < Rails::Railtie
5
+ railtie_name :specific_asset_compiler
6
+
7
+ rake_tasks do
8
+ load "tasks/specific_asset_compiler.rake"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ require "fileutils"
2
+ require 'action_view'
3
+ require 'sprockets/static_compiler'
4
+
5
+ module Sprockets
6
+ class StaticCompiler
7
+ def compile_specific
8
+ if @manifest && File.exist?("#{@manifest_path}/manifest.yml")
9
+ manifest = YAML.load(File.read("#{@manifest_path}/manifest.yml"))
10
+ else
11
+ manifest = {}
12
+ end
13
+ env.each_logical_path(paths) do |logical_path|
14
+ if asset = env.find_asset(logical_path)
15
+ digest_path = write_asset(asset)
16
+ manifest[asset.logical_path] = digest_path
17
+ manifest[aliased_path_for(asset.logical_path)] = digest_path
18
+ end
19
+ end
20
+ write_manifest(manifest) if @manifest
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ require "fileutils"
2
+ require 'action_view'
3
+ require 'sprockets/static_compiler'
4
+
5
+ module SpecificAssetCompiler
6
+ require 'specific_asset_compiler/railtie' if defined?(Rails)
7
+ end
8
+
9
+ module Sprockets
10
+ class StaticCompiler
11
+ attr_accessor :env, :target, :paths
12
+
13
+ def compile_specific
14
+ if @manifest && File.exist?("#{@manifest_path}/manifest.yml")
15
+ manifest = YAML.load(File.read("#{@manifest_path}/manifest.yml"))
16
+ else
17
+ manifest = {}
18
+ end
19
+ env.each_logical_path(paths) do |logical_path|
20
+ if asset = env.find_asset(logical_path)
21
+ digest_path = write_asset(asset)
22
+ manifest[asset.logical_path] = digest_path
23
+ manifest[aliased_path_for(asset.logical_path)] = digest_path
24
+ end
25
+ end
26
+ write_manifest(manifest) if @manifest
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,66 @@
1
+ require "fileutils"
2
+ require 'action_view'
3
+ require 'sprockets/static_compiler'
4
+
5
+ namespace :assets do
6
+ def ruby_rake_task(task, fork = true)
7
+ env = ENV['RAILS_ENV'] || 'production'
8
+ groups = ENV['RAILS_GROUPS'] || 'assets'
9
+ args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"]
10
+ args << "--trace" if Rake.application.options.trace
11
+ if $0 =~ /rake\.bat\Z/i
12
+ Kernel.exec $0, *args
13
+ else
14
+ fork ? ruby(*args) : Kernel.exec(FileUtils::RUBY, *args)
15
+ end
16
+ end
17
+
18
+ # We are currently running with no explicit bundler group
19
+ # and/or no explicit environment - we have to reinvoke rake to
20
+ # execute this task.
21
+ def invoke_or_reboot_rake_task(task)
22
+ if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?
23
+ ruby_rake_task task
24
+ else
25
+ Rake::Task[task].invoke
26
+ end
27
+ end
28
+
29
+ # execute this task for specific file precompile.
30
+ desc 'Precompile specific rake task'
31
+ task :precompile_specific do
32
+ invoke_or_reboot_rake_task "assets:precompile:specific"
33
+ end
34
+
35
+ namespace :precompile do
36
+ def specific_precompile
37
+ # Ensure that action view is loaded and the appropriate
38
+ # sprockets hooks get executed
39
+ digest = nil
40
+ _ = ActionView::Base
41
+ target_file = (ENV["ASSET_FILES"].gsub("[","").gsub("]","").split(",") rescue [])
42
+ config = Rails.application.config
43
+ config.assets.compile = true
44
+ config.assets.digest = digest unless digest.nil?
45
+ config.assets.digests = {}
46
+ env = Rails.application.assets
47
+ target = File.join(Rails.public_path, config.assets.prefix)
48
+ compiler = Sprockets::StaticCompiler.new(env,
49
+ target,
50
+ [config.assets.precompile[0]]+target_file,
51
+ :manifest_path => config.assets.manifest,
52
+ :digest => config.assets.digest,
53
+ :manifest => digest.nil?)
54
+ compiler.compile_specific
55
+ end
56
+
57
+ task :specific do
58
+ Rake::Task["assets:precompile:specific_internal"].invoke
59
+ end
60
+
61
+ task :specific_internal => ["assets:environment", "tmp:cache:clear"] do
62
+ specific_precompile
63
+ end
64
+
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: specific_asset_compiler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Tanapat Sainak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Specific Asset files to compile
14
+ email: tanapat@computerlogy.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/specific_asset_compiler.rb
20
+ - lib/specific_asset_compiler/railtie.rb
21
+ - lib/specific_asset_compiler/sprockets.rb
22
+ - lib/tasks/specific_asset_compiler.rake
23
+ homepage: http://www.computerlogy.com
24
+ licenses: []
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.3
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Specific Asset files
46
+ test_files: []