gakubuchi 0.0.2 → 0.0.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 +4 -4
- data/lib/gakubuchi/configuration.rb +4 -0
- data/lib/gakubuchi/fileutils.rb +26 -0
- data/lib/gakubuchi/task.rb +10 -27
- data/lib/gakubuchi/template.rb +17 -6
- data/lib/gakubuchi/version.rb +1 -1
- data/lib/gakubuchi.rb +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65b9973f3452444b6bad13a88692fc971ae910d0
|
4
|
+
data.tar.gz: e382605a7813b7b301f979828a28096300bf8935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 331928a87a5c61e1cf47ed78ebe391d44c1d194973b62cd5f2df0022599cb9d265e106731cdf392192d4975c503a1c6d164c3de7ead456f338d635a83419fbb1
|
7
|
+
data.tar.gz: 2ad9268df58198359b39d6f21744cf71c73950fd682f2025992dc4890ab7ad89bf2c37e4c225e51d2041a6355cfc87728a7e30a9dde5f62d9373c7ede677321d
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Gakubuchi
|
4
|
+
module FileUtils
|
5
|
+
extend ::FileUtils
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def copy_p(src, dest)
|
9
|
+
mkdir_p(File.dirname(dest))
|
10
|
+
copy(src, dest)
|
11
|
+
logging("Copied #{src} to #{dest}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def remove(list)
|
15
|
+
super(list)
|
16
|
+
logging("Removed #{list.join(' ')}")
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def logging(message)
|
22
|
+
Logger.new(STDOUT).info(message)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/gakubuchi/task.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fileutils'
|
1
|
+
require 'gakubuchi/fileutils'
|
2
2
|
|
3
3
|
module Gakubuchi
|
4
4
|
class Task
|
@@ -8,42 +8,25 @@ module Gakubuchi
|
|
8
8
|
@templates = Array(templates)
|
9
9
|
end
|
10
10
|
|
11
|
-
def remove_compiled_files?
|
12
|
-
!!Gakubuchi.configuration.remove_compiled_files
|
13
|
-
end
|
14
|
-
|
15
11
|
def execute!
|
16
12
|
templates.each do |template|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
.
|
13
|
+
precompiled_pathnames = template.precompiled_pathnames
|
14
|
+
|
15
|
+
src = precompiled_pathnames
|
16
|
+
.select { |pathname| pathname.extname == '.html' }
|
17
|
+
.sort_by { |pathname| pathname.mtime }
|
21
18
|
.last
|
22
19
|
|
23
20
|
next if src.nil?
|
24
21
|
dest = template.destination_pathname
|
25
22
|
|
26
|
-
|
27
|
-
remove(
|
23
|
+
Gakubuchi::FileUtils.copy_p(src, dest)
|
24
|
+
Gakubuchi::FileUtils.remove(precompiled_pathnames) if remove_precompiled_templates?
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
def copy(src, dest)
|
34
|
-
FileUtils.mkdir_p(File.dirname(dest))
|
35
|
-
FileUtils.cp(src, dest)
|
36
|
-
log("Copied #{src} to #{dest}")
|
37
|
-
end
|
38
|
-
|
39
|
-
def log(message)
|
40
|
-
@logger ||= Logger.new(STDOUT)
|
41
|
-
@logger.info(message)
|
42
|
-
end
|
43
|
-
|
44
|
-
def remove(list)
|
45
|
-
FileUtils.rm(list)
|
46
|
-
log("Removed #{list.join(' ')}")
|
28
|
+
def remove_precompiled_templates?
|
29
|
+
!!Gakubuchi.configuration.remove_precompiled_templates
|
47
30
|
end
|
48
31
|
end
|
49
32
|
end
|
data/lib/gakubuchi/template.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
module Gakubuchi
|
2
2
|
class Template
|
3
|
+
extend ::Forwardable
|
4
|
+
|
3
5
|
attr_reader :pathname
|
6
|
+
def_delegators :@pathname, :hash
|
7
|
+
|
8
|
+
%w(== === eql?).each do |method_name|
|
9
|
+
define_method(method_name) do |other|
|
10
|
+
other.respond_to?(:pathname) &&
|
11
|
+
@pathname.__send__(method_name, other.pathname)
|
12
|
+
end
|
13
|
+
end
|
4
14
|
|
5
15
|
def self.all
|
6
16
|
Dir.glob(root.join('**/*.html*')).map { |path| new(path) }
|
@@ -18,12 +28,6 @@ module Gakubuchi
|
|
18
28
|
pathname.basename.to_s
|
19
29
|
end
|
20
30
|
|
21
|
-
def compiled_pathname
|
22
|
-
dirname = relative_pathname.dirname
|
23
|
-
pattern = "#{relative_pathname.basename(extname)}-*.{html,html.gz}"
|
24
|
-
Rails.public_path.join('assets', dirname, pattern)
|
25
|
-
end
|
26
|
-
|
27
31
|
def destination_pathname
|
28
32
|
dirname = relative_pathname.dirname
|
29
33
|
Rails.public_path.join(dirname, "#{relative_pathname.basename(extname)}.html")
|
@@ -44,6 +48,13 @@ module Gakubuchi
|
|
44
48
|
extnames.join
|
45
49
|
end
|
46
50
|
|
51
|
+
def precompiled_pathnames
|
52
|
+
dirname = relative_pathname.dirname
|
53
|
+
pattern = "#{relative_pathname.basename(extname)}-*.{html,html.gz}"
|
54
|
+
|
55
|
+
Pathname.glob(Rails.public_path.join('assets', dirname, pattern))
|
56
|
+
end
|
57
|
+
|
47
58
|
def relative_pathname
|
48
59
|
pathname.relative_path_from(self.class.root)
|
49
60
|
end
|
data/lib/gakubuchi/version.rb
CHANGED
data/lib/gakubuchi.rb
CHANGED
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: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yasaichi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Gakubuchi enables you to manage static pages with Asset Pipeline
|
84
98
|
email:
|
85
99
|
- yasaichi@users.noreply.github.com
|
@@ -94,6 +108,7 @@ files:
|
|
94
108
|
- lib/gakubuchi.rb
|
95
109
|
- lib/gakubuchi/configuration.rb
|
96
110
|
- lib/gakubuchi/engine.rb
|
111
|
+
- lib/gakubuchi/fileutils.rb
|
97
112
|
- lib/gakubuchi/task.rb
|
98
113
|
- lib/gakubuchi/template.rb
|
99
114
|
- lib/gakubuchi/version.rb
|