gakubuchi 1.2.2 → 1.2.3

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: 4a6e8c86354f396e73f8e5ad059c27d18a274ce4
4
- data.tar.gz: d333491a01e13a37f7d5df487d272a54157c4023
3
+ metadata.gz: dfd6e965fec8cad0500f75d122ad38b0fe27e7a1
4
+ data.tar.gz: 78b970cc6498188c45bc09dfbc36db4b3011ef27
5
5
  SHA512:
6
- metadata.gz: c8b1e41ce05eaa3d7396989ee507362052872abf46175f8cbf6aad0a9994283aa780252f96bc09194ba3bd2264aedce3e74eeae99106d0c677b9d0ae945c6a39
7
- data.tar.gz: 4dd28c343135b0b7ff9d01698a61c5cad64a15d2ce54657237953fbe5c65f0b5e291734949b56c5223494dba0fed3022d687edb3be999279e63307ddb4e61411
6
+ metadata.gz: 1a5c9aa9963c4dfbe0178e3f51fed8f3711f799a79ff3ee227ea6596075013e9e62373d1a023ca25c0e6a988ef4539869449d394e96ce01c3ef69463d590dd3c
7
+ data.tar.gz: 0910d6f803aa3af8255bec139329c55373524a61daf42a29f20333a91e70919e8d047043b842d516328d49465e803230051a98390ac699080b8e6369bbbfd67a
data/Rakefile CHANGED
@@ -1,26 +1,26 @@
1
1
  begin
2
- require 'bundler/setup'
2
+ require "bundler/setup"
3
3
  rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
5
  end
6
6
 
7
- require 'rdoc/task'
7
+ require "rdoc/task"
8
8
 
9
9
  RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Gakubuchi'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
10
+ rdoc.rdoc_dir = "rdoc"
11
+ rdoc.title = "Gakubuchi"
12
+ rdoc.options << "--line-numbers"
13
+ rdoc.rdoc_files.include("README.rdoc")
14
+ rdoc.rdoc_files.include("lib/**/*.rb")
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
18
- load 'rails/tasks/engine.rake'
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load "rails/tasks/engine.rake"
19
19
 
20
- load 'rails/tasks/statistics.rake'
20
+ load "rails/tasks/statistics.rake"
21
21
 
22
22
  Bundler::GemHelper.install_tasks
23
23
 
24
- require 'rspec/core/rake_task'
24
+ require "rspec/core/rake_task"
25
25
  RSpec::Core::RakeTask.new(:spec)
26
26
  task default: :spec
data/lib/gakubuchi.rb CHANGED
@@ -1,19 +1,19 @@
1
- require 'fileutils'
2
- require 'forwardable'
3
- require 'logger'
4
- require 'active_support/configurable'
1
+ require "fileutils"
2
+ require "forwardable"
3
+ require "logger"
4
+ require "active_support/configurable"
5
5
 
6
- require 'gakubuchi/configuration'
7
- require 'gakubuchi/error'
8
- require 'gakubuchi/fileutils'
9
- require 'gakubuchi/task'
10
- require 'gakubuchi/version'
6
+ require "gakubuchi/configuration"
7
+ require "gakubuchi/error"
8
+ require "gakubuchi/fileutils"
9
+ require "gakubuchi/task"
10
+ require "gakubuchi/version"
11
11
 
12
12
  if defined?(::Rails::Railtie) && defined?(::Sprockets::Railtie)
13
- require 'pathname'
14
- require 'gakubuchi/engine_registrar'
15
- require 'gakubuchi/template'
16
- require 'gakubuchi/railtie'
13
+ require "pathname"
14
+ require "gakubuchi/engine_registrar"
15
+ require "gakubuchi/template"
16
+ require "gakubuchi/railtie"
17
17
  end
18
18
 
19
19
  module Gakubuchi
@@ -11,7 +11,7 @@ module Gakubuchi
11
11
  end
12
12
 
13
13
  config_accessor :template_directory do
14
- 'templates'
14
+ "templates"
15
15
  end
16
16
  end
17
17
  end
@@ -8,7 +8,10 @@ module Gakubuchi
8
8
  klass = constantize(engine)
9
9
  return false if !klass.instance_of?(::Class) || registered?(target)
10
10
 
11
- @env.register_engine(target, klass)
11
+ args = [target, klass]
12
+ args << { silence_deprecation: true } if Sprockets::VERSION.start_with?("3")
13
+
14
+ @env.register_engine(*args)
12
15
  true
13
16
  end
14
17
 
@@ -3,12 +3,12 @@ module Gakubuchi
3
3
  config.assets.configure do |env|
4
4
  engine_registrar = EngineRegistrar.new(env)
5
5
 
6
- engine_registrar.register(:haml, '::Tilt::HamlTemplate')
7
- engine_registrar.register(:slim, '::Slim::Template')
6
+ engine_registrar.register(:haml, "::Tilt::HamlTemplate")
7
+ engine_registrar.register(:slim, "::Slim::Template")
8
8
  end
9
9
 
10
10
  rake_tasks do
11
- ::Dir.glob(::File.expand_path('../../tasks/*.rake', __FILE__)).each { |path| load path }
11
+ ::Dir.glob(::File.expand_path("../../tasks/*.rake", __FILE__)).each { |path| load path }
12
12
  end
13
13
  end
14
14
  end
@@ -12,11 +12,11 @@ module Gakubuchi
12
12
  end
13
13
 
14
14
  def self.all
15
- ::Dir.glob(root.join('**/*.html*')).map { |source_path| new(source_path) }
15
+ ::Dir.glob(root.join("**/*.html*")).map { |source_path| new(source_path) }
16
16
  end
17
17
 
18
18
  def self.root
19
- ::Rails.root.join('app/assets', ::Gakubuchi.configuration.template_directory)
19
+ ::Rails.root.join("app/assets", ::Gakubuchi.configuration.template_directory)
20
20
  end
21
21
 
22
22
  def initialize(source_path)
@@ -27,9 +27,9 @@ module Gakubuchi
27
27
  @source_path = path.absolute? ? path : root.join(path)
28
28
 
29
29
  case
30
- when !@extname.include?('html')
31
- fail Error::InvalidTemplate, 'source path must refer to a template file'
32
- when !@source_path.fnmatch?(root.join('*').to_s)
30
+ when !@extname.include?("html")
31
+ fail Error::InvalidTemplate, "source path must refer to a template file"
32
+ when !@source_path.fnmatch?(root.join("*").to_s)
33
33
  fail Error::InvalidTemplate, "template must exist in #{root}"
34
34
  end
35
35
  end
@@ -39,10 +39,10 @@ module Gakubuchi
39
39
  end
40
40
 
41
41
  def digest_path
42
- resolved_path = view_context.asset_digest_path(logical_path.to_s)
43
- return if resolved_path.nil?
42
+ asset = assets.find_asset(logical_path)
43
+ return if asset.nil?
44
44
 
45
- ::Pathname.new(::File.join(::Rails.public_path, view_context.assets_prefix, resolved_path))
45
+ ::Pathname.new(::File.join(::Rails.public_path, app.config.assets.prefix, asset.digest_path))
46
46
  end
47
47
 
48
48
  def logical_path
@@ -52,13 +52,23 @@ module Gakubuchi
52
52
 
53
53
  private
54
54
 
55
+ def app
56
+ ::Rails.application
57
+ end
58
+
59
+ # TODO: Cache @assets by Gakubuchi::Task instance because to call #find_asset
60
+ # for the first time takes much time and would cause performance problem.
61
+ def assets
62
+ return @assets if @assets
63
+
64
+ @assets = app.assets || ::Sprockets::Railtie.build_environment(app)
65
+ @assets = @assets.cached if @assets.respond_to?(:cached)
66
+ @assets
67
+ end
68
+
55
69
  def extract_extname(path)
56
70
  extname = path.extname
57
71
  extname.empty? ? extname : "#{extract_extname(path.basename(extname))}#{extname}"
58
72
  end
59
-
60
- def view_context
61
- @view_context ||= ::ActionView::Base.new
62
- end
63
73
  end
64
74
  end
@@ -1,3 +1,3 @@
1
1
  module Gakubuchi
2
- VERSION = '1.2.2'
2
+ VERSION = "1.2.3".freeze
3
3
  end
@@ -3,21 +3,21 @@ module Gakubuchi
3
3
  class InstallGenerator < ::Rails::Generators::Base
4
4
  DEFAULT_DIRECTORY = ::Gakubuchi::Configuration.new.template_directory.freeze
5
5
 
6
- desc 'Create a Gakubuchi initializer.'
7
- source_root ::File.expand_path('../templates', __FILE__)
6
+ desc "Create a Gakubuchi initializer."
7
+ source_root ::File.expand_path("../templates", __FILE__)
8
8
 
9
9
  class_option :directory,
10
10
  type: :string,
11
- aliases: '-d',
11
+ aliases: "-d",
12
12
  default: DEFAULT_DIRECTORY,
13
- desc: 'Name of directory for templates'
13
+ desc: "Name of directory for templates"
14
14
 
15
15
  def copy_initializer_file
16
- template 'gakubuchi.rb.erb', 'config/initializers/gakubuchi.rb'
16
+ template "gakubuchi.rb.erb", "config/initializers/gakubuchi.rb"
17
17
  end
18
18
 
19
19
  def create_template_directory
20
- empty_directory ::Pathname.new('app/assets').join(options.directory)
20
+ empty_directory ::Pathname.new("app/assets").join(options.directory)
21
21
  end
22
22
  end
23
23
  end
@@ -1,4 +1,4 @@
1
- Rake::Task['assets:precompile'].enhance do
1
+ Rake::Task["assets:precompile"].enhance do
2
2
  task = Gakubuchi::Task.new(Gakubuchi::Template.all)
3
3
  task.execute!
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gakubuchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasaichi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties