gakubuchi 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +12 -12
- data/lib/gakubuchi.rb +13 -13
- data/lib/gakubuchi/configuration.rb +1 -1
- data/lib/gakubuchi/engine_registrar.rb +4 -1
- data/lib/gakubuchi/railtie.rb +3 -3
- data/lib/gakubuchi/template.rb +22 -12
- data/lib/gakubuchi/version.rb +1 -1
- data/lib/generators/gakubuchi/install/install_generator.rb +6 -6
- data/lib/tasks/after_precompile.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfd6e965fec8cad0500f75d122ad38b0fe27e7a1
|
4
|
+
data.tar.gz: 78b970cc6498188c45bc09dfbc36db4b3011ef27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a5c9aa9963c4dfbe0178e3f51fed8f3711f799a79ff3ee227ea6596075013e9e62373d1a023ca25c0e6a988ef4539869449d394e96ce01c3ef69463d590dd3c
|
7
|
+
data.tar.gz: 0910d6f803aa3af8255bec139329c55373524a61daf42a29f20333a91e70919e8d047043b842d516328d49465e803230051a98390ac699080b8e6369bbbfd67a
|
data/Rakefile
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "bundler/setup"
|
3
3
|
rescue LoadError
|
4
|
-
puts
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
5
5
|
end
|
6
6
|
|
7
|
-
require
|
7
|
+
require "rdoc/task"
|
8
8
|
|
9
9
|
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir =
|
11
|
-
rdoc.title =
|
12
|
-
rdoc.options <<
|
13
|
-
rdoc.rdoc_files.include(
|
14
|
-
rdoc.rdoc_files.include(
|
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(
|
18
|
-
load
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load "rails/tasks/engine.rake"
|
19
19
|
|
20
|
-
load
|
20
|
+
load "rails/tasks/statistics.rake"
|
21
21
|
|
22
22
|
Bundler::GemHelper.install_tasks
|
23
23
|
|
24
|
-
require
|
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
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "fileutils"
|
2
|
+
require "forwardable"
|
3
|
+
require "logger"
|
4
|
+
require "active_support/configurable"
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
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
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
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
|
@@ -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
|
-
|
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
|
|
data/lib/gakubuchi/railtie.rb
CHANGED
@@ -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,
|
7
|
-
engine_registrar.register(:slim,
|
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(
|
11
|
+
::Dir.glob(::File.expand_path("../../tasks/*.rake", __FILE__)).each { |path| load path }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/gakubuchi/template.rb
CHANGED
@@ -12,11 +12,11 @@ module Gakubuchi
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.all
|
15
|
-
::Dir.glob(root.join(
|
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(
|
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?(
|
31
|
-
fail Error::InvalidTemplate,
|
32
|
-
when !@source_path.fnmatch?(root.join(
|
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
|
-
|
43
|
-
return if
|
42
|
+
asset = assets.find_asset(logical_path)
|
43
|
+
return if asset.nil?
|
44
44
|
|
45
|
-
::Pathname.new(::File.join(::Rails.public_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
|
data/lib/gakubuchi/version.rb
CHANGED
@@ -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
|
7
|
-
source_root ::File.expand_path(
|
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:
|
11
|
+
aliases: "-d",
|
12
12
|
default: DEFAULT_DIRECTORY,
|
13
|
-
desc:
|
13
|
+
desc: "Name of directory for templates"
|
14
14
|
|
15
15
|
def copy_initializer_file
|
16
|
-
template
|
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(
|
20
|
+
empty_directory ::Pathname.new("app/assets").join(options.directory)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
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.
|
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-
|
11
|
+
date: 2016-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|