gakubuchi 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -25
- data/lib/gakubuchi.rb +1 -0
- data/lib/gakubuchi/engine.rb +5 -0
- data/lib/gakubuchi/task.rb +2 -2
- data/lib/gakubuchi/template.rb +1 -1
- data/lib/gakubuchi/template_engine.rb +28 -0
- data/lib/gakubuchi/version.rb +1 -1
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 581c86e67d3d350858d9929191d9382656959691
|
4
|
+
data.tar.gz: 5640d23696f5e820da2b4dcaaccf5ac3e942b062
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b34bfcb48634bda49914a78e0d4613921294976977bc60b1186ee87b807b88bb1c177b0c08563b9f7470b49e1763b1ef94c535a756536b3bd357e7f9177684d9
|
7
|
+
data.tar.gz: e592fa46b572100f56648cda5313937010e466e7b2ef0ac876a99b3d2d0338a0b07b5861a5392c8921a76c739cac2468a2999750e5b5294948533eeecd360442
|
data/README.md
CHANGED
@@ -19,20 +19,19 @@ Put this in your Gemfile:
|
|
19
19
|
gem 'gakubuchi'
|
20
20
|
```
|
21
21
|
|
22
|
-
In `app/assets/templates/static_page.html.
|
23
|
-
|
24
|
-
```
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
</html>
|
22
|
+
In `app/assets/templates/static_page.html.slim`:
|
23
|
+
|
24
|
+
```slim
|
25
|
+
doctype html
|
26
|
+
html
|
27
|
+
head
|
28
|
+
title
|
29
|
+
| Sample Static Page
|
30
|
+
= stylesheet_link_tag 'application', media: 'all'
|
31
|
+
= javascript_include_tag 'application'
|
32
|
+
body
|
33
|
+
p
|
34
|
+
| Hello, Gakubuchi!
|
36
35
|
```
|
37
36
|
|
38
37
|
Compile the templeate with:
|
@@ -46,14 +45,14 @@ Then, you can get `public/static_page.html` as follows.
|
|
46
45
|
```html
|
47
46
|
<!DOCTYPE html>
|
48
47
|
<html>
|
49
|
-
<head>
|
50
|
-
|
51
|
-
|
52
|
-
<
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
</body>
|
48
|
+
<head>
|
49
|
+
<title>Sample Static Page</title><link rel="stylesheet" media="all" href="/assets/application-e80e8f2318043e8af94dddc2adad5a4f09739a8ebb323b3ab31cd71d45fd9113.css" /><script src="/assets/application-8f06a73c35179188914ab50e057157639fce1401c1cdca640ac9cec33746fc5b.js"></script>
|
50
|
+
</head>
|
51
|
+
<body>
|
52
|
+
<p>
|
53
|
+
Hello, Gakubuchi!
|
54
|
+
</p>
|
55
|
+
</body>
|
57
56
|
</html>
|
58
57
|
```
|
59
58
|
|
@@ -64,7 +63,8 @@ First, run the installation generator with:
|
|
64
63
|
rails generate gakubuchi:install
|
65
64
|
```
|
66
65
|
|
67
|
-
This will install the initializer into `config/initializers/gakubuchi.rb`.
|
66
|
+
This will install the initializer into `config/initializers/gakubuchi.rb`.
|
67
|
+
|
68
68
|
In the file, you can configure the following values.
|
69
69
|
|
70
70
|
```
|
@@ -74,8 +74,8 @@ template_root # 'app/assets/templates' by default
|
|
74
74
|
|
75
75
|
## Supports
|
76
76
|
* Ruby: `2.0.0` or later
|
77
|
-
* Rails: `4.0.0` or later (supports `3.x` as possible)
|
78
|
-
* Template engines: `ERB
|
77
|
+
* Rails: `4.0.0` or later (supports `3.x` as possible)
|
78
|
+
* Template engines: `ERB`, `Haml` and `Slim`
|
79
79
|
|
80
80
|
## Contributing
|
81
81
|
You should follow the steps below.
|
data/lib/gakubuchi.rb
CHANGED
data/lib/gakubuchi/engine.rb
CHANGED
@@ -5,5 +5,10 @@ module Gakubuchi
|
|
5
5
|
config.generators do |g|
|
6
6
|
g.test_framework :rspec
|
7
7
|
end
|
8
|
+
|
9
|
+
initializer 'gakubuchi.assets.precompile' do |app|
|
10
|
+
TemplateEngine.new('Slim::Template').register!('.slim')
|
11
|
+
TemplateEngine.new('Tilt::HamlTemplate').register!('.haml')
|
12
|
+
end
|
8
13
|
end
|
9
14
|
end
|
data/lib/gakubuchi/task.rb
CHANGED
@@ -20,8 +20,8 @@ module Gakubuchi
|
|
20
20
|
next if src.nil?
|
21
21
|
dest = template.destination_pathname
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
FileUtils.copy_p(src, dest)
|
24
|
+
FileUtils.remove(precompiled_pathnames) if remove_precompiled_templates?
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/gakubuchi/template.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Gakubuchi
|
2
|
+
class TemplateEngine
|
3
|
+
extend ::Forwardable
|
4
|
+
|
5
|
+
attr_reader :klass
|
6
|
+
alias_method :engine, :klass
|
7
|
+
|
8
|
+
def_delegators 'Rails.application', :assets
|
9
|
+
def_delegators 'Sprockets::Utils', :normalize_extension
|
10
|
+
private :assets, :normalize_extension
|
11
|
+
|
12
|
+
def initialize(engine)
|
13
|
+
@klass = engine.to_s.constantize rescue nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def register!(extname)
|
17
|
+
if engine.instance_of?(Class) && !registered?(extname)
|
18
|
+
!!assets.register_engine(extname, engine)
|
19
|
+
else
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def registered?(extname)
|
25
|
+
assets.engines[normalize_extension(extname)] == engine
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/gakubuchi/version.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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yasaichi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -81,7 +81,21 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: appraisal
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.0.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.0.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: haml-rails
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
@@ -95,19 +109,19 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: slim-rails
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - ">="
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
117
|
+
version: '0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
124
|
+
version: '0'
|
111
125
|
description: Gakubuchi enables you to manage static pages with Asset Pipeline
|
112
126
|
email:
|
113
127
|
- yasaichi@users.noreply.github.com
|
@@ -125,6 +139,7 @@ files:
|
|
125
139
|
- lib/gakubuchi/fileutils.rb
|
126
140
|
- lib/gakubuchi/task.rb
|
127
141
|
- lib/gakubuchi/template.rb
|
142
|
+
- lib/gakubuchi/template_engine.rb
|
128
143
|
- lib/gakubuchi/version.rb
|
129
144
|
- lib/generators/gakubuchi/install/install_generator.rb
|
130
145
|
- lib/generators/gakubuchi/install/templates/gakubuchi.rb
|